[
  {
    "path": ".editorconfig",
    "content": "# http://editorconfig.org\n\nroot = true\n\n[*]\ncharset = utf-8\nindent_style = space\nindent_size = 2\nend_of_line = lf\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[*.md]\ninsert_final_newline = false\ntrim_trailing_whitespace = false\n"
  },
  {
    "path": ".firebaserc",
    "content": "{\n  \"projects\": {\n    \"default\": \"angularfire2-test\"\n  }\n}\n"
  },
  {
    "path": ".gitattributes",
    "content": "src/**/firebase.ts linguist-generated=true\nsrc/**/rxfire.ts linguist-generated=true\nsrc/compat/**/base.ts linguist-generated=true\nsamples/**/* linguist-generated=true\nyarn.lock linguist-generated=true"
  },
  {
    "path": ".github/workflows/codeql-analysis.yml",
    "content": "# For most projects, this workflow file will not need changing; you simply need\n# to commit it to your repository.\n#\n# You may wish to alter this file to override the set of languages analyzed,\n# or to provide custom queries or build logic.\n#\n# ******** NOTE ********\n# We have attempted to detect the languages in your repository. Please check\n# the `language` matrix defined below to confirm you have the correct set of\n# supported CodeQL languages.\n#\nname: \"CodeQL\"\n\non:\n  push:\n    branches: [ main ]\n  pull_request:\n    # The branches below must be a subset of the branches above\n    branches: [ main ]\n  schedule:\n    - cron: '20 23 * * 3'\n\njobs:\n  analyze:\n    name: Analyze\n    runs-on: ubuntu-latest\n\n    strategy:\n      fail-fast: false\n      matrix:\n        language: [ 'javascript' ]\n        # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]\n        # Learn more:\n        # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed\n\n    steps:\n    - name: Checkout repository\n      uses: actions/checkout@v2\n\n    # Initializes the CodeQL tools for scanning.\n    - name: Initialize CodeQL\n      uses: github/codeql-action/init@v2\n      with:\n        languages: ${{ matrix.language }}\n        # If you wish to specify custom queries, you can do so here or in a config file.\n        # By default, queries listed here will override any specified in a config file.\n        # Prefix the list here with \"+\" to use these queries and those in the config file.\n        # queries: ./path/to/local/query, your-org/your-repo/queries@main\n\n    # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java).\n    # If this step fails, then you should remove it and run the build manually (see below)\n    - name: Autobuild\n      uses: github/codeql-action/autobuild@v2\n\n    # ℹ️ Command-line programs to run using the OS shell.\n    # 📚 https://git.io/JvXDl\n\n    # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines\n    #    and modify them (or add more) to build your code if your project\n    #    uses a compiled language\n\n    #- run: |\n    #   make bootstrap\n    #   make release\n\n    - name: Perform CodeQL Analysis\n      uses: github/codeql-action/analyze@v2\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "name: Test and publish\n\non:\n  push:\n    branches:\n      - main\n    paths-ignore:\n      - \"**/*.md\"\n  pull_request:\n    branches:\n      - \"**\"\n  release:\n    types:\n      - published\n  schedule:\n    - cron: 0 0 * * 1-5\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    name: Build\n    steps:\n      - name: Checkout\n        uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3\n      - name: Setup node\n        uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903\n        with:\n          node-version: '20'\n          check-latest: false\n      - name: angular build cache\n        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830\n        with:\n          path: ./.angular\n          key: angular-cache\n      - name: node_modules cache\n        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830\n        id: node_modules_cache\n        with:\n          path: ./node_modules\n          key: ${{ runner.os }}-20-${{ hashFiles('package-lock.json') }}\n          restore-keys: |\n            ${{ runner.os }}-20-\n      - name: Install deps\n        if: steps.node_modules_cache.outputs.cache-hit != 'true'\n        run: |\n          npm ci\n      - name: Build\n        run: ./tools/build.sh\n      - name: 'Upload Artifact'\n        uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4\n        with:\n          name: angularfire-${{ github.run_id }}\n          path: dist\n          retention-days: 1\n\n  test:\n    runs-on: ${{ matrix.os }}\n    needs: build\n    strategy:\n      matrix:\n        os: [ ubuntu-latest, macos-latest, windows-latest ]\n        node: [\"20\", \"22\", \"24\"]\n      fail-fast: false\n    name: Test Node ${{ matrix.node }} (${{ matrix.os }})\n    steps:\n      - name: Checkout\n        uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3\n      - name: Setup node\n        uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903\n        with:\n          node-version: ${{ matrix.node }}\n          check-latest: true\n      - name: node_modules cache\n        id: node_modules_cache\n        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830\n        with:\n          path: ./node_modules\n          key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }}\n          restore-keys: |\n            ${{ runner.os }}-${{ matrix.node }}-\n      - name: Install deps\n        if: steps.node_modules_cache.outputs.cache-hit != 'true'\n        run: npm ci\n      - name: Download Artifacts\n        uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53\n        with:\n          name: angularfire-${{ github.run_id }}\n          path: dist\n      - name: Test Node\n        run: |\n          npm run build:jasmine\n          npm run test:node\n\n  browser:\n    runs-on: ${{ matrix.os }}\n    needs: build\n    name: Test ${{ matrix.browser }}\n    strategy:\n      matrix:\n        os: [ ubuntu-latest ]\n        browser: [ chrome-headless, firefox-headless ]\n        # TODO(davideast): Figure out why Safari tests timeout only on CI\n        # include:\n        # - os: macos-latest\n        #   browser: safari\n      fail-fast: false\n    steps:\n      - name: Checkout\n        uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3\n      - name: Setup node\n        uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903\n        with:\n          node-version: 20\n          check-latest: false\n      - name: Setup java\n        uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165\n        with:\n          distribution: 'temurin'\n          java-version: '11'\n      - name: node_modules cache\n        id: node_modules_cache\n        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830\n        with:\n          path: ./node_modules\n          key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }}\n          restore-keys: |\n            ${{ runner.os }}-${{ matrix.node }}-\n      - name: Install deps\n        if: steps.node_modules_cache.outputs.cache-hit != 'true'\n        run: npm ci\n      - name: Firebase emulator cache\n        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830\n        with:\n          path: ~/.cache/firebase/emulators\n          key: firebase_emulators\n      - name: Download Artifacts\n        uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53\n        with:\n          name: angularfire-${{ github.run_id }}\n          path: dist\n      - name: Test browser\n        run: npm run test:${{ matrix.browser }}\n\n  contribute:\n    runs-on: ${{ matrix.os }}\n    name: Contribute Node ${{ matrix.node }} (${{ matrix.os }})\n    strategy:\n      matrix:\n        os: [ ubuntu-latest, macos-latest, windows-latest ]\n        node: [\"20\"]\n      fail-fast: false\n    steps:\n      - name: Checkout\n        uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3\n      - name: Setup node\n        uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903\n        with:\n          node-version: ${{ matrix.node }}\n          check-latest: true\n      - name: node_modules cache\n        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830\n        id: node_modules_cache\n        with:\n          path: ./node_modules\n          key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('package-lock.json') }}\n          restore-keys: |\n            ${{ runner.os }}-${{ matrix.node }}-\n      - name: Install deps\n        if: steps.node_modules_cache.outputs.cache-hit != 'true'\n        run: npm ci\n      #- name: Lint\n      #  run: npm run lint\n      - name: Build\n        run: npm run build\n      - name: Test Node\n        run: |\n          npm run build:jasmine\n          npm run test:node\n      - name: Firebase emulator cache\n        uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830\n        with:\n          path: ~/.cache/firebase/emulators\n          key: firebase_emulators\n      - name: Setup java\n        uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165\n        with:\n          distribution: 'temurin'\n          java-version: '11'\n      - name: Test headless\n        run: npm run test:chrome-headless\n        # Tests are flaky on Windows\n        continue-on-error: ${{ matrix.os == 'windows-latest' }}\n\n  # Break the branch protection test into a seperate step, so we can manage the matrix more easily\n  test_and_contribute:\n    runs-on: ubuntu-latest\n    name: Branch protection\n    needs: ['test', 'contribute', 'browser']\n    steps:\n      - run: true\n\n  publish:\n    runs-on: ubuntu-latest\n    name: Publish (NPM)\n    needs: ['build', 'test', 'browser']\n    if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}\n    steps:\n      - name: Setup node\n        uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903\n        with:\n          node-version: '20'\n          registry-url: 'https://registry.npmjs.org'\n          check-latest: false\n      - name: 'Download Artifacts'\n        uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53\n        with:\n          name: angularfire-${{ github.run_id }}\n          path: dist\n      - name: Publish\n        run: |\n          cd ./dist/packages-dist\n          chmod +x publish.sh\n          ./publish.sh\n        env:\n          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules/\ndist/\ndist-test/\ndocs/api/\ntypings/\nnpm-debug.log\n.idea/\n.vscode/settings.json\nangular-fire-*.tgz\nangularfire2-*.tgz\n*.ngfactory.ts\n*.ngsummary.json\n.DS_Store\nyarn-error.log\n*.bak\nyarn.lock\ntest/ng-build/**/yarn.lock\ntools/build.js\ncoverage\n*.log\napi-*.json\nangularfire.tgz\nunpack.sh\npublish.sh\n.firebase\n.angular\n.vscode"
  },
  {
    "path": ".npmignore",
    "content": "*.spec.*\ntest-config.*\npublish.sh\n__ivy_ngcc__/\n*.min.js\n*.min.js.map\n*.__ivy_ngcc_bak"
  },
  {
    "path": ".nvmrc",
    "content": "lts/*"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing to AngularFire\n\nWe would love for you to contribute to AngularFire and help make it even better than it is\ntoday! As a contributor, here are the guidelines we would like you to follow:\n\n - [Code of Conduct](#coc)\n - [Question or Problem?](#question)\n - [Issues and Bugs](#issue)\n - [Feature Requests](#feature)\n - [Initial Setup](#setup)\n - [Submission Guidelines](#submit)\n   - [Submitting an Issue](#submit-issue)\n   - [Submitting a Pull Request](#submit-pr)\n      - [Before you submit](#submit-before)\n      - [How to submit](#submit-how)\n      - [Deploying docs](#submit-docs)\n - Appendix\n   - [Coding Rules][rules] (external link)\n   - [Commit Message Guidelines][commit] (external link)\n   - [Signing the CLA](#cla)\n\n## <a name=\"coc\"></a> Code of Conduct\n\nHelp us keep the Angular and Firebase communities open and inclusive. Please read and follow the Angular [Code of Conduct][coc].\n\n## <a name=\"question\"></a> Got a Question or Problem?\n\nIf you have questions about how to *use* AngularFire, please direct them to the [Angular Google Group][angular-group]\ndiscussion list or [StackOverflow][stackoverflow] (include the `firebase` and `angular` tags!). \nPlease note that the Angular team's capacity to answer usage questions is limited.\nMembers of the Firebase team can be reached on [Slack][slack] and via the [Firebase Google Group][firebase-group].\n\n## <a name=\"issue\"></a> Found an Issue?\n\nIf you find a bug in the source code, you can help us by\n[submitting an issue](#submit-issue) to our [GitHub Repository][github]. Even better, you can\n[submit a Pull Request](#submit-pr) with a fix.\n\n## <a name=\"feature\"></a> Want a Feature?\n\nYou can *request* a new feature by [submitting an issue](#submit-issue) to our [GitHub\nRepository][github]. If you would like to *implement* a new feature, please submit an issue with\na proposal for your work first, to be sure that we can use it.\nPlease consider what kind of change it is:\n\n* For a **Major Feature**, first open an issue and outline your proposal so that it can be\ndiscussed. This will also allow us to better coordinate our efforts, prevent duplication of work,\nand help you to craft the change so that it is successfully accepted into the project.\n* **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).\n\n## <a name=\"setup\"></a> Initial Setup\n\n1) Create a fork of AngularFire (See [Forking a Project][github-fork])\n\n2) Clone your fork, CD into the directory, and install dependencies\n\n```shell\n$ git clone <your fork SSH/HTTPS from GitHub>\n$ cd angularfire\n$ npm i\n$ npm run build\n$ npm run test:all\n```\n\n3) Make your changes in a new git branch:\n\n```shell\ngit checkout -b my-fix-branch master\n```\n\n## <a name=\"submit\"></a> Submission Guidelines\n\n### <a name=\"submit-issue\"></a> Submitting an Issue\nHelp us to maximize the effort we can spend improving the product by not reporting duplicate issues.\nSearch the archives before you submit.\n\nProviding the following information will increase the chances of your issue being dealt with quickly:\n\n* **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps\n* **Angular Version** - what version of Angular, Firebase, and AngularFire are you using?\n* **Motivation for or Use Case** - explain what are you trying to do and why the current behavior is a bug for you\n* **Browsers and Operating System** - is this a problem with all browsers?\n* **Reproduce the Error** - provide a live example (using StackBlitz (https://stackblitz.com/edit/angular-fire-start))\n or a unambiguous set of steps\n* **Related Issues** - has a similar issue been reported before?\n* **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be\n  causing the problem (line of code or commit)\n\nYou can file new issues by providing the above information [here](https://github.com/angular/angularfire2/issues/new).\n\n### <a name=\"submit-pr\"></a> Submitting a Pull Request (PR)\n\n#### <a name=\"submit-before\"></a> Before you submit:\n\n* Ensure proposed changes or problem have already been clearly defined and\n  discussed in the issue tracker. We don't want you to burn time on code\n  that isn't a good fit for the project.\n* Search [GitHub](https://github.com/angular/angularfire2/pulls) for an open or closed PR\n  that relates to your submission. You don't want to duplicate effort.\n* Please sign our [Contributor License Agreement (CLA)](#cla) before sending PRs.\n  We cannot accept code without this.\n* Review our [Coding Rules][rules] (external link)\n* Review our [Commit Message Guidelines][commit] (external link)  \n\n#### <a name=\"submit-how\"></a> How to submit:\n\n* Create your patch, **including appropriate test cases**.\n* Follow the [Angular Coding Rules][rules].\n* Run the full test suite (`yarn test`) and ensure that all tests pass.\n* Commit your changes using a descriptive commit message that follows the\n  [Angular commit message conventions][commit]. Adherence to these conventions\n  is necessary because release notes are automatically generated from these messages.\n\n     ```shell\n     git commit -a\n     ```\n  Note: the optional commit `-a` command line option will automatically \"add\" and \"rm\" edited files.\n\n* Push your branch to GitHub:\n\n    ```shell\n    git push origin my-fix-branch\n    ```\n\n* In GitHub, send a pull request to `angular:master`.\n* If we suggest changes then:\n  * Make the required updates.\n  * Re-run the test suites to ensure tests are still passing.\n  * Rebase your branch and force push to your GitHub repository (this will update your Pull Request):\n\n    ```shell\n    git rebase master -i\n    git push -f\n    ```\n\nThat's it! Thank you for your contribution!\n\n## <a name=\"cla\"></a> Signing the CLA\n\nPlease sign our Contributor License Agreement (CLA) before sending pull requests. For any code\nchanges to be accepted, the CLA must be signed. It's a quick process, we promise!\n\n* For individuals we have a [simple click-through form][individual-cla].\n* For corporations we'll need you to\n  [print, sign and one of scan+email, fax or mail the form][corporate-cla].\n\n\n[slack]: https://firebase-community.appspot.com/\n[coc]: https://github.com/angular/code-of-conduct/blob/main/CODE_OF_CONDUCT.md\n[commit-message-format]: https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#\n[corporate-cla]: https://code.google.com/legal/corporate-cla-v1.0.html\n[individual-cla]: http://code.google.com/legal/individual-cla-v1.0.html\n[js-style-guide]: https://google.github.io/styleguide/javascriptguide.xml\n[jsfiddle]: http://jsfiddle.net\n[plunker]: http://plnkr.co/edit\n[runnable]: http://runnable.com\n[github]: https://github.com/angular/angularfire2\n[stackoverflow]: http://stackoverflow.com/questions/tagged/angularfire\n[rules]: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#rules\n[commit]: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-guidelines\n[angular-group]:  https://groups.google.com/forum/#!forum/angular\n[firebase-group]: https://groups.google.com/forum/#!forum/firebase-talk\n[github-fork]: https://help.github.com/articles/fork-a-repo/\n"
  },
  {
    "path": "ISSUE_TEMPLATE.md",
    "content": "<!--\n\nIMPORTANT! YOU MUST FOLLOW THESE INSTRUCTIONS OR YOUR ISSUE WILL BE CLOSED.\n\nThank you for contributing to the Angular and Firebase communities!\n\nHave a usage question?\n=======================\nWe get lots of those and we love helping you, but GitHub is not the best place for them and they will be closed. Here are some resources to get help:\n\n- Go through the Developer's Guide: https://github.com/angular/angularfire2#developer-guide\n\nIf the official documentation doesn't help, try asking through our officially supported channels:\n\n- Firebase Google Group: https://groups.google.com/forum/#!forum/firebase-talk\n- Stack Overflow: https://stackoverflow.com/questions/tagged/angular (include the firebase and angularfire tags, too!)\n\n*Please avoid double posting across multiple channels!*\n\nThink you found a bug?\n=======================\nYeah, we're definitely not perfect! Please use the bug report template below and include a minimal repro when opening the issue.\n\nHave a feature request?\n========================\nGreat, we love hearing how we can improve our products! Remove the template below and\nprovide an explanation of your feature request. Provide code samples if applicable. Try to\nthink about what it will allow you to do that you can't do today? How will it make current\nworkarounds straightforward? What potential bugs and edge cases does it help to avoid?\n\n-->\n\n\n### Version info\n\n<!-- What versions of the following libraries are you using? Note that your issue may already\nbe fixed in the latest versions. -->\n\n**Angular:**\n\n**Firebase:**\n\n**AngularFire:**\n\n**Other (e.g. Ionic/Cordova, Node, browser, operating system):**\n\n### How to reproduce these conditions\n\n**Failing test unit, Stackblitz demonstrating the problem**\n\n<!-- \nProvide a failing test unit, or create a minimal, complete, and \nverifiable example (http://stackoverflow.com/help/mcve) using \nStackBlitz (https://stackblitz.com/edit/angular-fire-start).\n-->\n\n**Steps to set up and reproduce**\n\n<!-- detailed instructions to run your minimal repro or to recreate the environment -->\n\n**Sample data and security rules**\n\n<!-- include/attach/link to some json sample data (or provide credentials to a sanitized, test Firebase project) -->\n\n### Debug output\n\n** Errors in the JavaScript console **\n\n** Output from `firebase.database().enableLogging(true);` **\n\n** Screenshots **\n\n### Expected behavior\n\n<!-- What is the expected behavior? -->\n\n### Actual behavior\n\n<!-- What is the actual behavior? -->\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License\n\nCopyright (c) 2014-2016 Google, Inc. http://angular.io\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "PULL_REQUEST_TEMPLATE.md",
    "content": "<!--\n\nThank you for contributing to the Firebase community! Please fill out the pull request form below\nand make note of the following:\n\nRun the linter and test suite\n==============================\nMake sure your changes pass our linter and the tests all pass on your local machine. We've hooked\nup this repo with continuous integration to double check those things for you.\n\nAdd tests (if applicable)\n==============================\nMost non-trivial changes should include some extra test coverage. If you aren't sure how to add\ntests, feel free to submit regardless and ask us for some advice.\n\nSign our CLA\n==============================\nPlease sign our Contributor License Agreement (https://cla.developers.google.com/about/google-individual)\nbefore sending PRs. We cannot accept code without this.\n\n-->\n\n### Checklist\n\n   - Issue number for this PR: #nnn (required)\n   - Docs included?: (yes/no; required for all API/functional changes) \n   - Test units included?: (yes/no; required) \n   - In a clean directory, `yarn install`, `yarn test` run successfully? (yes/no; required)\n\n### Description\n\n<!-- Are you fixing a bug? Updating our documentation? Implementing a new feature? Make sure we\nhave the context around your change. Link to other relevant issues or pull requests. -->\n\n### Code sample\n\n<!-- Proposing an API change? Provide code samples showing how the API will be used. -->\n\n"
  },
  {
    "path": "README.md",
    "content": "\n# AngularFire\n\nAngularFire smooths over the rough edges an Angular developer might encounter when implementing the framework-agnostic\n[Firebase JS SDK](https://github.com/firebase/firebase-js-sdk) & aims to provide a more natural developer experience\nby conforming to Angular conventions.\n\n<strong><pre>ng add @angular/fire</pre></strong>\n\n- **Dependency injection** - Provide and Inject Firebase services in your components.\n- **Zone.js wrappers** - Stable zones allow proper functionality of service workers, forms, SSR, and pre-rendering.\n- **Observable based** - Utilize RxJS rather than callbacks for real-time streams.\n- **NgRx friendly API** - Integrate with NgRx using AngularFire's action based APIs.\n- **Lazy-loading** - AngularFire dynamically imports much of Firebase, reducing the time to load your app.\n- **Deploy schematics** - Get your Angular application deployed on Firebase Hosting with a single command.\n- **Google Analytics** - Zero-effort Angular Router awareness in Google Analytics.\n- **Router Guards** - Guard your Angular routes with built-in Firebase Authentication checks.\n\n## Example use\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { getFirestore, provideFirestore } from '@angular/fire/firestore';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideFirestore(() => getFirestore()),\n    ...\n  ],\n  ...\n})\n```\n\n```ts\nimport { AsyncPipe } from '@angular/common';\nimport { inject } from '@angular/core';\nimport { Firestore, collectionData, collection } from '@angular/fire/firestore';\n\ninterface Item {\n  name: string,\n  ...\n};\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <ul>\n    @for (item of (item$ | async); track item) {\n      <li>\n        {{ item.name }}\n      </li>\n    }\n  </ul>\n  `,\n  imports: [AsyncPipe]\n})\nexport class AppComponent {\n  firestore = inject(Firestore);\n  itemCollection = collection(this.firestore, 'items');\n  item$ = collectionData<Item>(itemCollection);\n}\n```\n\n## Resources\n\n[Quickstart](docs/install-and-setup.md) - Get your first application up and running by following our quickstart guide.\n\n[Contributing](CONTRIBUTING.md)\n\n[Stackblitz Template](https://stackblitz.com/edit/angular-fire-start) - Remember to set your Firebase configuration in `app/app.module.ts`.\n\n[Upgrading from v6.0? Check out our guide.](docs/version-7-upgrade.md)\n\n### Sample app\n\nThe [`sample`](sample) folder contains a kitchen sink application that demonstrates use of the \"modular\" API, in a zoneless server-rendered application, with all the bells and whistles.\n\n### Having troubles?\n\nGet help on our [Q&A board](https://github.com/angular/angularfire/discussions?discussions_q=category%3AQ%26A), the official [Firebase Mailing List](https://groups.google.com/forum/#!forum/firebase-talk), the [Firebase Community Slack](https://firebase.community/) (`#angularfire2`), the [Angular Community Discord](http://discord.gg/angular) (`#firebase`), [Gitter](https://gitter.im/angular/angularfire2), the [Firebase subreddit](https://www.reddit.com/r/firebase), or [Stack Overflow](https://stackoverflow.com/questions/tagged/angularfire2).\n\n> **NOTE:** While relatively stable, AngularFire is a [developer preview](https://angular.io/guide/releases#developer-preview) and is subject to change before general availability. Questions on the mailing list and issues filed here are answered on a <strong>best-effort basis</strong> by maintainers and other community members. If you are able to reproduce a problem with Firebase <em>outside of AngularFire's implementation</em>, please [file an issue on the Firebase JS SDK](https://github.com/firebase/firebase-js-sdk/issues) or reach out to the personalized [Firebase support channel](https://firebase.google.com/support/).\n\n## Developer Guide\n\nThis developer guide assumes you're using the new tree-shakable AngularFire API, [if you're looking for the compatibility API you can find the documentation here](docs/compat.md).\n\n[See the v7 upgrade guide for more information on this change.](docs/version-7-upgrade.md).\n\n### Firebase product integrations\n\n<table>\n  <tr>\n    <td>\n\n#### [Analytics](docs/analytics.md#analytics)\n```ts\nimport { } from '@angular/fire/analytics';\n```\n</td>\n    <td>\n\n#### [Authentication](docs/auth.md#authentication)\n```ts\nimport { } from '@angular/fire/auth';\n```\n</td>\n  </tr>\n  <tr>\n    <td>\n\n#### [Cloud Firestore](docs/firestore.md#cloud-firestore)\n```ts\nimport { } from '@angular/fire/firestore';\n```\n</td>\n    <td>\n\n#### [Cloud Functions](docs/functions.md#cloud-functions)\n```ts\nimport { } from '@angular/fire/functions';\n```\n</td>\n  </tr>\n  <tr>\n    <td>\n\n#### [Cloud Messaging](docs/messaging.md#cloud-messaging)\n```ts\nimport { } from '@angular/fire/messaging';\n```\n</td>\n    <td>\n\n#### [Cloud Storage](docs/storage.md#cloud-storage)\n```ts\nimport { } from '@angular/fire/storage';\n```\n</td>\n  </tr>\n  <tr>\n    <td>\n\n#### [Performance Monitoring](docs/performance.md#performance-monitoring)\n```ts\nimport { } from '@angular/fire/performance';\n```\n</td>\n    <td>\n\n#### [Realtime Database](docs/database.md#realtime-database)\n```ts\nimport { } from '@angular/fire/database';\n```\n</td>\n  </tr>\n  <tr>\n    <td>\n\n#### [Remote Config](docs/remote-config.md#remote-config)\n```ts\nimport { } from '@angular/fire/remote-config';\n```\n</td>\n    <td>\n\n#### [App Check](docs/app-check.md#app-check)\n```ts\nimport { } from '@angular/fire/app-check';\n```\n</td>\n  </tr>\n  <tr>\n    <td>\n\n#### [Vertex AI](docs/vertexai.md#vertex-ai)\n```ts\nimport { } from '@angular/fire/vertexai';\n```\n</td>\n\n  </tr>\n</table>\n"
  },
  {
    "path": "SECURITY.md",
    "content": "# Security Policy\n\n## Supported Versions\n\n| Version | Supported          |\n| ------- | ------------------ |\n| 6.0+    | :white_check_mark: |\n| < 6.0   | :x:                |\n\n## Reporting a Vulnerability\n\nPlease contact [Firebase support](https://firebase.google.com/support) and send ticket details to [angularfire-maintainers@google.com](mailto:angularfire-maintainers@google.com?subject=[SECURITY]) with `[SECURITY]` in the subject.\n"
  },
  {
    "path": "angular.json",
    "content": "{\n\t\"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n\t\"version\": 1,\n\t\"newProjectRoot\": \".\",\n\t\"projects\": {\n\t\t\"angularfire\": {\n\t\t\t\"projectType\": \"library\",\n\t\t\t\"root\": \"src\",\n\t\t\t\"sourceRoot\": \"src\",\n\t\t\t\"prefix\": \"angularfire\",\n\t\t\t\"architect\": {\n\t\t\t\t\"build\": {\n\t\t\t\t\t\"builder\": \"@angular-devkit/build-angular:ng-packagr\",\n\t\t\t\t\t\"options\": {\n\t\t\t\t\t\t\"tsConfig\": \"tsconfig.json\",\n\t\t\t\t\t\t\"project\": \"src/ng-package.json\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"test\": {\n\t\t\t\t\t\"builder\": \"@angular-devkit/build-angular:karma\",\n\t\t\t\t\t\"options\": {\n\t\t\t\t\t\t\"polyfills\": [\n\t\t\t\t\t\t\t\"zone.js\",\n\t\t\t\t\t\t\t\"zone.js/testing\"\n\t\t\t\t\t\t],\n\t\t\t\t\t\t\"tsConfig\": \"tsconfig.spec.json\",\n\t\t\t\t\t\t\"karmaConfig\": \"karma.conf.js\"\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t\"lint\": {\n\t\t\t\t\t\"builder\": \"@angular-eslint/builder:lint\",\n\t\t\t\t\t\"options\": {\n\t\t\t\t\t\t\"lintFilePatterns\": [\n\t\t\t\t\t\t\t\"src/**/*.ts\",\n\t\t\t\t\t\t\t\"src/**/*.html\"\n\t\t\t\t\t\t]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\t\"cli\": {\n\t\t\"packageManager\": \"npm\",\n\t\t\"analytics\": \"86795b8f-9036-4a53-929c-a7303453d677\"\n\t}\n}"
  },
  {
    "path": "docs/analytics.md",
    "content": "<img align=\"right\" width=\"30%\" src=\"images/analytics-illo_1x.png\">\n\n<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Analytics\n</small>\n\n# Analytics\n\nGoogle Analytics is an app measurement solution, available at no charge, that provides insight on app usage and user engagement.\n\n[Learn more](https://firebase.google.com/docs/analytics)\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a Analytics instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideAnalytics, getAnalytics } from '@angular/fire/analytics';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideAnalytics(() => getAnalytics()),\n    ...\n  ],\n  ...,\n}\n```\n\nNext inject `Analytics` into your component:\n\n```typescript\nimport { Component, inject } from '@angular/core';\nimport { Analytics } from '@angular/fire/analytics';\n\n@Component({ ... })\nexport class UserProfileComponent {\n    private analytics = inject(Analytics);\n    ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nUpdate the imports from `import { ... } from 'firebase/analytics'` to `import { ... } from '@angular/fire/analytics'` and follow the official documentation.\n\n[Getting Started](https://firebase.google.com/docs/analytics/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/analytics)\n"
  },
  {
    "path": "docs/app-check.md",
    "content": "<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; App Check\n</small>\n\n<img align=\"right\" width=\"30%\" src=\"images/reCAPTCHA-logo@1x.png\">\n\n# App Check\n\nApp Check helps protect your API resources from abuse by preventing unauthorized clients from accessing your backend resources. It works with both Firebase services, Google Cloud services, and your own APIs to keep your resources safe.\n\n[Learn More](https://firebase.google.com/docs/app-check)\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a App Check instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideAppCheck, initializeAppCheck, ReCaptchaV3Provider } from '@angular/fire/app-check';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideAppCheck(() => initializeAppCheck(getApp(), {\n        provider: new ReCaptchaV3Provider(/* configuration */),\n    })),\n    ...\n  ],\n  ...\n})\n```\n\nNext inject `AppCheck` it into your component:\n\n```ts\nimport { Component, inject} from '@angular/core';\nimport { AppCheck } from '@angular/fire/app-check';\n\n@Component({ ... })\nexport class AppCheckComponent {\n  private appCheck = inject(AppCheck);\n  ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nUpdate the imports from `import { ... } from 'firebase/app-check'` to `import { ... } from '@angular/fire/app-check'` and follow the official documentation.\n\n[Getting Started](https://firebase.google.com/docs/app-check/web/recaptcha-enterprise-provider) | [API Reference](https://firebase.google.com/docs/reference/js/app-check)\n"
  },
  {
    "path": "docs/auth.md",
    "content": "<img align=\"right\" width=\"30%\" src=\"images/auth-illo_1x.png\">\n\n<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Authentication\n</small>\n\n# Authentication\n\nMost apps need to know the identity of a user. Knowing a user's identity allows an app to securely save user data in the cloud and provide the same personalized experience across all of the user's devices.\nFirebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.\n\nFirebase Authentication integrates tightly with other Firebase services, and it leverages industry standards like OAuth 2.0 and OpenID Connect, so it can be easily integrated with your custom backend.\n\n[Learn more about Firebase Authentication](https://firebase.google.com/docs/auth)\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a Auth instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideAuth, getAuth } from '@angular/fire/auth';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideAuth(() => getAuth()),\n    ...\n  ],\n  ...\n})\n```\n\nNext inject `Auth` into your component:\n\n```ts\nimport { Component, inject} from '@angular/core';\nimport { Auth } from '@angular/fire/auth';\n\n@Component({ ... })\nexport class LoginComponent {\n  private auth = inject(Auth);\n  ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nUpdate the imports from `import { ... } from 'firebase/auth'` to `import { ... } from '@angular/fire/auth'` and follow the official documentation.\n\n[Getting Started](https://firebase.google.com/docs/auth/web/start) | [API Reference](https://firebase.google.com/docs/reference/js/auth)\n\n## Server-side Rendering\n\nTo support Auth context in server-side rendering, you can provide `FirebaseServerApp`:\n\n```ts\nimport { ApplicationConfig, PLATFORM_ID, inject } from '@angular/core';\nimport { isPlatformBrowser } from '@angular/common';\nimport { provideFirebaseApp, initializeApp, initializeServeApp, initializeServerApp } from '@angular/fire/app';\nimport { provideAuth, getAuth } from '@angular/fire/auth';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => {\n      if (isPlatformBrowser(inject(PLATFORM_ID))) {\n        return initializeApp(firebaseConfig);\n      }\n      // Optional, since it's null in dev-mode and SSG\n      const request = inject(REQUEST, { optional: true });\n      const authIdToken = request?.headers.authorization?.split(\"Bearer \")[1];\n      return initializeServerApp(firebaseConfig, {\n        authIdToken,\n        releaseOnDeref: request || undefined\n      });\n    }),\n    provideAuth(() => getAuth(inject(FirebaseApp)),\n    ...\n  ],\n  ...\n})\n```\n\nFollow Firebase's [ Session Management with Service Workers documentation](https://firebase.google.com/docs/auth/web/service-worker-sessions) to learn how to pass the `idToken` to the server. __Note: this will not currently work in dev-mode as Angular SSR does not provide a method to get the Request headers.__\n\n## Convenience observables\n\nAngularFire provides observables to allow convenient use of the Firebase Authentication with RXJS.\n\n### user\n\nThe `user` observable streams events triggered by sign-in, sign-out, and token refresh events.\n\nExample code:\n\n```ts\nimport { Auth, User, user } from '@angular/fire/auth';\n...\n\nexport class UserComponent implements OnDestroy {\n  private auth: Auth = inject(Auth);\n  user$ = user(auth);\n  userSubscription: Subscription;\n  ...\n\n  constructor() {\n    this.userSubscription = this.user$.subscribe((aUser: User | null) => {\n        //handle user state changes here. Note, that user will be null if there is no currently logged in user.\n     console.log(aUser);\n    })\n  }\n\n  ngOnDestroy() {\n    // when manually subscribing to an observable remember to unsubscribe in ngOnDestroy\n    this.userSubscription.unsubscribe();\n  }\n}\n\n```\n\n### authState\n\nThe `authState` observable streams events triggered by sign-in and sign-out events.\n\nExample code:\n```ts\nimport { Auth, authState } from '@angular/fire/auth';\n...\n\nexport class UserComponent implements OnDestroy {\n  private auth: Auth = inject(Auth);\n  authState$ = authState(auth);\n  authStateSubscription: Subscription;\n  ...\n\n  constructor() {\n    this.authStateSubscription = this.authState$.subscribe((aUser: User | null) => {\n        //handle auth state changes here. Note, that user will be null if there is no currently logged in user.\n     console.log(aUser);\n    })\n  }\n\n  ngOnDestroy() {\n    // when manually subscribing to an observable remember to unsubscribe in ngOnDestroy\n    this.authStateSubscription.unsubscribe();\n  }\n}\n```\n\n### idToken\n\nThe `idToken` observable streams events triggered by sign-in, sign-out and token refresh events.\n\nExample code:\n```ts\nimport { Auth, idToken } from '@angular/fire/auth';\n...\n\nexport class UserComponent implements OnDestroy {\n  private auth: Auth = inject(Auth);\n  idToken$ = idToken(auth);\n  idTokenSubscription: Subscription;\n  ...\n\n  constructor() {\n    this.idTokenSubscription = this.idToken$.subscribe((token: string | null) => {\n        //handle idToken changes here. Note, that user will be null if there is no currently logged in user.\n     console.log(string);\n    })\n  }\n\n  ngOnDestroy() {\n    // when manually subscribing to an observable remember to unsubscribe in ngOnDestroy\n    this.idTokenSubscription.unsubscribe();\n  }\n}\n```\n\n## Connecting the emulator suite\n\n```ts\nimport { connectAuthEmulator, getAuth, provideAuth } from '@angular/fire/auth';\n\n@NgModule({\n  imports: [\n    provideAuth(() => {\n      const auth = getAuth();\n      connectAuthEmulator(auth, 'http://localhost:9099', { disableWarnings: true });\n      return auth;\n    }),\n  ]\n})\n```\n"
  },
  {
    "path": "docs/compat/analytics/getting-started.md",
    "content": "# Getting started with Google Analytics\n\n`AngularFireAnalytics` dynamically imports the `firebase/analytics` library and provides a promisified version of the [Firebase Analytics SDK (`firebase.analytics.Analytics`)](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html).\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n### API:\n\n```ts\nclass AngularFireAnalytics {\n  updateConfig(options: {[key:string]: any}): Promise<void>;\n\n  // from firebase.analytics() proxy:\n  logEvent(eventName: string, eventParams?: {[key: string]: any}, options?: analytics.AnalyticsCallOptions): Promise<void>;\n  setCurrentScreen(screenName: string, options?: analytics.AnalyticsCallOptions): Promise<void>;\n  setUserId(id: string, options?: analytics.AnalyticsCallOptions): Promise<void>;\n  setUserProperties(properties: analytics.CustomParams, options?: analytics.AnalyticsCallOptions): Promise<void>;\n  setAnalyticsCollectionEnabled(enabled: boolean): Promise<void>;\n  app: Promise<app.App>;\n}\n\nCOLLECTION_ENABLED = InjectionToken<boolean>;\nAPP_VERSION = InjectionToken<string>;\nAPP_NAME = InjectionToken<string>;\nDEBUG_MODE = InjectionToken<boolean>;\nCONFIG = InjectionToken<Config>;\n```\n\n### Usage:\n\n```ts\nimport { AngularFireAnalyticsModule } from '@angular/fire/compat/analytics';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireAnalyticsModule\n  ]\n})\nexport class AppModule { }\n```\n\n`AngularFireAnalyticsModule` will dynamically import and configure `firebase/analytics`. A `page_view` event will automatically be logged (see `CONFIG` below if you wish to disable this behavior.)\n\nIn your component you can then dependency inject `AngularFireAnalytics` and make calls against the SDK:\n\n```ts\nimport { AngularFireAnalytics } from '@angular/fire/compat/analytics';\n\nconstructor(analytics: AngularFireAnalytics) {\n  analytics.logEvent('custom_event', { ... });\n}\n```\n\n## Tracking Screen Views\n\nYou can log [`screen_view` events](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html#parameters_10) yourself of course, but AngularFire provides the `ScreenTrackingService` which automatically integrates with the Angular Router to provide Firebase with screen view tracking. You simply can integrate like so:\n\n```ts\nimport { AngularFireAnalyticsModule, ScreenTrackingService } from '@angular/fire/compat/analytics';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireAnalyticsModule\n  ],\n  providers: [\n    ScreenTrackingService\n  ]\n})\nexport class AppModule { }\n```\n\n`AngularFireAnalyticsModule` will initialize `ScreenTrackingService` if it is provided.\n\n## Tracking User Identifiers\n\nTo enrich your Analytics data you can track the currently signed in user by setting [`setuserid`](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html#setuserid) and [`setUserProperties`](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html#set-user-properties). AngularFire provides a `UserTrackingService` which will dynamically import `firebase/auth`, monitor for changes in the logged in user, and call `setuserid` for you automatically.\n\n\n```ts\nimport { AngularFireAnalyticsModule, UserTrackingService } from '@angular/fire/compat/analytics';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireAnalyticsModule\n  ],\n  providers: [\n    UserTrackingService\n  ]\n})\nexport class AppModule { }\n```\n\n`AngularFireAnalyticsModule` will initialize `UserTrackingService` if it is provided.\n\n## Configuration with Dependency Injection\n\n### Configure Google Analtyics with `CONFIG`\n\nUsing the `CONFIG` DI Token (*default: {}*) will allow you to configure Google Analytics. E.g, you could skip sending the initial `page_view` event, anonymize IP addresses, and disallow ads personalization signals for all events like so:\n\n```ts\nimport { AngularFireAnalyticsModule, CONFIG } from '@angular/fire/compat/analytics';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireAnalyticsModule\n  ],\n  providers: [\n    { provide: CONFIG, useValue: {\n      send_page_view: false,\n      allow_ad_personalization_signals: false,\n      anonymize_ip: true\n    } }\n  ]\n})\nexport class AppModule { }\n```\n\nSee the gtag.js documentation to learn of the different configuration options at your disposal.\n\n### Use DebugView `DEBUG_MODE`\n\nTo use [DebugView in Analytics](https://console.firebase.google.com/project/_/analytics/debugview) set `DEBUG_MODE` to `true` (*default: false*).\n\n### Track deployments with `APP_NAME` and `APP_VERSION`\n\nIf you provide `APP_NAME` and `APP_VERSION` (*default: undefined*) you will be able to [track version adoption](https://console.firebase.google.com/project/_/analytics/latestrelease) of your PWA.\n\n### Disable analytics collection via `COLLECTION_ENABLED`\n\nIf you set `COLLECTION_ENABLED` (*default: true*) to `false` then analytics collection will be disabled for this app on this device. To opt back in to analytics collection you could then call `setAnalyticsCollectionEnabled(true)`.\n\nPutting these APIs to use with cookies would allow you to create a flexible analytics collection scheme that would respect your user's desire for privacy.\n"
  },
  {
    "path": "docs/compat/auth/getting-started.md",
    "content": "# 5. Getting started with Firebase Authentication\n\n`AngularFireAuth.user` provides you an `Observable<User|null>` to monitor your application's authentication State.\n\n`AngularFireAuth` promise proxies an initialized\n`firebase.auth.Auth` instance, allowing you to log users in, out, etc. [See\nthe Firebase docs for more information on what methods are available.](https://firebase.google.com/docs/reference/js/auth.auth)\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n**Example app:**\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireAuth } from '@angular/fire/compat/auth';\nimport firebase from 'firebase/compat/app';\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <div *ngIf=\"auth.user | async as user; else showLogin\">\n      <h1>Hello {{ user.displayName }}!</h1>\n      <button (click)=\"logout()\">Logout</button>\n    </div>\n    <ng-template #showLogin>\n      <p>Please login.</p>\n      <button (click)=\"login()\">Login with Google</button>\n    </ng-template>\n  `,\n})\nexport class AppComponent {\n  constructor(public auth: AngularFireAuth) {\n  }\n  login() {\n    this.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());\n  }\n  logout() {\n    this.auth.signOut();\n  }\n}\n```\n\n## Configuration with Dependency Injection\n\nThe AngularFireAuth Module provides several DI tokens to further configure your\nauthentication process.\n\n### Configure \n\nUsing the `SETTINGS` DI Token (*default: null*), we can set the current Auth\ninstance's settings. This is used to edit/read configuration related options\nlike app verification mode for phone authentication, which is useful for\n[testing](https://cloud.google.com/identity-platform/docs/test-phone-numbers).\n\n```ts\nimport { SETTINGS as AUTH_SETTINGS } from '@angular/fire/compat/auth';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    // ... Existing Providers\n    { provide: AUTH_SETTINGS, useValue: { appVerificationDisabledForTesting: true } },\n  ]\n})\nexport class AppModule { }\n```\n\nRead more at [Firebase Auth Settings](https://firebase.google.com/docs/reference/js/auth.authsettings).\n\n### Use Current Browser Language\n\nUsing the `USE_DEVICE_LANGUAGE` DI Token (*default: null*), which is a boolean\nthat allow you to set the current language to the default device/browser\npreference. This allows to localize emails but be aware that this only applies\nif you use the standard template provided by Firebase. \n\n```ts\nimport { USE_DEVICE_LANGUAGE } from '@angular/fire/compat/auth';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    // ... Existing Providers\n    { provide: USE_DEVICE_LANGUAGE, useValue: true },\n  ]\n})\nexport class AppModule { }\n```\n\nIf you want to set a different language, you can use `LANGUAGE_CODE` DI Token\n(*default: null*).\n\nMore info at the [firebase auth docs](https://firebase.google.com/docs/reference/js/auth.auth#authlanguagecode).\n\n```ts\nimport { LANGUAGE_CODE } from '@angular/fire/compat/auth';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    // ... Existing Providers\n    { provide: LANGUAGE_CODE, useValue: 'fr' },\n  ]\n})\nexport class AppModule { }\n```\n\n### Persistence\n\nFirebase Auth default behavior is to persist a user's session even after the\nuser closes the browser. To change the current type of persistence on the\ncurrent Auth instance for the currently saved Auth session and apply this type\nof persistence for future sign-in requests, including sign-in with redirect\nrequests, you can use the `PERSISTENCE` DI Token (*default: null*).\n\nThe possible types are `'local'`, `'session'` or `'none'`. Read more at \n[authentication state persistence](https://firebase.google.com/docs/auth/web/auth-state-persistence).\n\n```ts\nimport { PERSISTENCE } from '@angular/fire/compat/auth';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    // ... Existing Providers\n    { provide: PERSISTENCE, useValue: 'session' },\n  ]\n})\nexport class AppModule { }\n```\n\n### Tenant\n\nIf you need to use multi-tenancy, you can set the current Auth instance's tenant\nID using `TENANT_ID` DI Token (*default: null*).\n\nMore tutorials regarding this topic are _coming soon_.\n\n```ts\nimport { TENANT_ID } from '@angular/fire/compat/auth';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    // ... Existing Providers\n    { provide: TENANT_ID, useValue: 'tenant-id-app-one' },\n  ]\n})\nexport class AppModule { }\n```\n\n- [Multi-Tenancy Authentication](https://cloud.google.com/identity-platform/docs/multi-tenancy-authentication)\n- [Firebase Auth Tenant](https://firebase.google.com/docs/reference/js/auth.auth#tenantid)\n\n## UI Libraries\n\n- Material Design : [ngx-auth-firebaseui](https://github.com/AnthonyNahas/ngx-auth-firebaseui)\n- Bootstrap : [@firebaseui/ng-bootstrap](https://github.com/firebaseui/ng-bootstrap)\n\n## Cordova\n\nLearn how to [setup Firebase Authentication with Cordova](https://firebase.google.com/docs/auth/web/cordova) in the Firebase Guides.\n"
  },
  {
    "path": "docs/compat/auth/router-guards.md",
    "content": "# Route users with AngularFire guards\n\n`AngularFireAuthGuard` provides a prebuilt [`canActivate` Router Guard](https://angular.io/api/router/CanActivate) using `AngularFireAuth`. By default unauthenticated users are not permitted to navigate to protected routes:\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n```ts\nimport { AngularFireAuthGuard } from '@angular/fire/compat/auth-guard';\n\nexport const routes: Routes = [\n    { path: '',      component: AppComponent },\n    { path: 'items', component: ItemListComponent, canActivate: [AngularFireAuthGuard] },\n]\n```\n\n## Customizing the behavior of `AngularFireAuthGuard`\n\nTo customize the behavior of `AngularFireAuthGuard`, you can pass an RXJS pipe through the route data's `authGuardPipe` key.\n\nThe `auth-guard` module provides the following pre-built pipes:\n\n| Exported pipe                      | Functionality |\n|-|-|\n| `loggedIn`                         | The default pipe, rejects if the user is not authenticated. |\n| `isNotAnonymous`                   | Rejects if the user is anonymous |\n| `emailVerified`                    | Rejects if the user's email is not verified |\n| `hasCustomClaim(claim)`            | Rejects if the user does not have the specified claim |\n| `redirectUnauthorizedTo(redirect)` | Redirect unauthenticated users to a different route  |\n| `redirectLoggedInTo(redirect)`     | Redirect authenticated users to a different route |\n\nExample use:\n\n```ts\nimport { AngularFireAuthGuard, hasCustomClaim, redirectUnauthorizedTo, redirectLoggedInTo } from '@angular/fire/compat/auth-guard';\n\nconst adminOnly = () => hasCustomClaim('admin');\nconst redirectUnauthorizedToLogin = () => redirectUnauthorizedTo(['login']);\nconst redirectLoggedInToItems = () => redirectLoggedInTo(['items']);\nconst belongsToAccount = (next) => hasCustomClaim(`account-${next.params.id}`);\n\nexport const routes: Routes = [\n    { path: '',      component: AppComponent },\n    { path: 'login', component: LoginComponent,        canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectLoggedInToItems }},\n    { path: 'items', component: ItemListComponent,     canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectUnauthorizedToLogin }},\n    { path: 'admin', component: AdminComponent,        canActivate: [AngularFireAuthGuard], data: { authGuardPipe: adminOnly }},\n    { path: 'accounts/:id', component: AdminComponent, canActivate: [AngularFireAuthGuard], data: { authGuardPipe: belongsToAccount }}\n];\n```\n\nUse the provided `canActivate` helper and spread syntax to make your routes more readable:\n\n```ts\nimport { canActivate } from '@angular/fire/compat/auth-guard';\n\nexport const routes: Routes = [\n    { path: '',             component: AppComponent },\n    { path: 'login',        component: LoginComponent,    ...canActivate(redirectLoggedInToItems) },\n    { path: 'items',        component: ItemListComponent, ...canActivate(redirectUnauthorizedToLogin) },\n    { path: 'admin',        component: AdminComponent,    ...canActivate(adminOnly) },\n    { path: 'accounts/:id', component: AdminComponent,    ...canActivate(belongsToAccount) }\n];\n```\n\n### Compose your own pipes\n\n`AngularFireAuthGuard` pipes are RXJS operators which transform an optional User to a boolean or Array (for redirects). You can easily build your own to customize behavior further:\n\n```ts\nimport { map } from 'rxjs/operators';\n\n// This pipe redirects a user to their \"profile edit\" page or the \"login page\" if they're unauthenticated\n// { path: 'profile', ...canActivate(redirectToProfileEditOrLogin) }\nconst redirectToProfileEditOrLogin = () => map(user => user ? ['profiles', user.uid, 'edit'] : ['login']);\n```\n\nThe `auth-guard` modules provides a `customClaims` operator to reduce boiler plate when checking a user's claims:\n\n```ts\nimport { pipe } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { customClaims } from '@angular/fire/compat/auth-guard';\n\n// This pipe will only allow users with the editor role to access the route\n// { path: 'articles/:id/edit', component: ArticleEditComponent, ...canActivate(editorOnly) }\nconst editorOnly = () => pipe(customClaims, map(claims => claims.role === 'editor'));\n```\n\n### Using router state\n\n`AngularFireAuthGuard` will also accept `AuthPipeGenerator`s which generate `AuthPipe`s given the router state:\n\n```ts\nimport { pipe } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { customClaims } from '@angular/fire/compat/auth-guard';\n\n// Only allow navigation to the route if :userId matches the authenticated user's uid\n// { path: 'user/:userId/edit', component: ProfileEditComponent, ...canActivate(onlyAllowSelf) }\nconst onlyAllowSelf = (next) => map(user => !!user && next.params.userId === user.uid);\n\n// Only allow navigation to the route if the user has a custom claim matching  :accountId\n// { path: 'accounts/:accountId/billing', component: BillingDetailsComponent, ...canActivate(accountAdmin) }\nconst accountAdmin = (next) => pipe(customClaims, map(claims => claims[`account-${next.params.accountId}-role`] === 'admin'));\n```\n"
  },
  {
    "path": "docs/compat/emulators/emulators.md",
    "content": "# Connect your app and start prototyping\n\nIn this guide, we'll look at how to use `@angular/fire` to connect an Angular application with Firebase Emulator Suite to start prototyping your apps.\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\nThere are four supported emulators, all of them available at the Firebase suite workflow:\n\n- [Authentication Emulator](https://firebase.google.com/docs/emulator-suite/connect_auth)\n- [Realtime Database Emulator](https://firebase.google.com/docs/emulator-suite/connect_rtdb)\n- [Cloud Firestore Emulator](https://firebase.google.com/docs/emulator-suite/connect_firestore)\n- [Cloud Functions Emulator](https://firebase.google.com/docs/emulator-suite/connect_functions)\n\n**The Auth Emulator only works with Firebase v8 and above, which is supported by `@angular/fire` 6.1.0 or higher**.\n\nBefore configuring these emulators at the Angular App, be sure to install the ones you need by following the [Install, configure and integrate Local Emulator Suite](https://firebase.google.com/docs/emulator-suite/install_and_configure) documentation.\n\n_**TL;DR**_\n\nInitialize firebase to your project (if you haven't) by running:\n\n```shell\nfirebase init\n```\n\nThen launch the emulator setup wizard by running:\n\n```shell\nfirebase init emulators\n```\n\nFollow the instructions to download whatever emulator you want to use then checkout that the `firebase.json` file got updated with the default ports per emulator, something like this:\n\n```jsonc\n{\n  // Existing firebase configuration ...\n  // Optional emulator configuration. Default\n  // values are used if absent.\n  \"emulators\": {\n    \"firestore\": {\n      \"port\": \"8080\"\n    },\n    \"ui\": {\n      \"enabled\": true, // Default is `true`\n      \"port\": 4000     // If unspecified, see CLI log for selected port\n    },\n    \"auth\": {\n      \"port\": \"9099\"\n    },\n    \"functions\": {\n      \"port\": \"5001\"\n    },\n    \"database\": {\n      \"port\": \"9000\"\n    },\n    \"pubsub\": {\n      \"port\": \"8085\"\n    }\n  }\n}\n```\n\nThen launch the emulators by running\n\n```shell\nfirebase emulators:start\n```\n\nThen you can visit \n\n```shell\n┌─────────────────────────────────────────────────────────────┐\n│ ✔  All emulators ready! It is now safe to connect your app. │\n│ i  View Emulator UI at http://127.0.0.1:4000/               │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Import the DI Tokens at your AppModule\n\nConfiguring your app to connect to local emulators is easily done by using dependency injection tokens provided by the library. However, there are slighty changes between 6.0.0 and 6.1.0 in the way it was done.\n\n### 6.1.0 Method\n\nEach module (database, firestore, auth, function) provides `USE_EMULATOR` token to configure the emulator `host` and `port` by passing a tuple of `[string, number]` values, which are set by default to `localhost` and the asigned port from your `firebase.json` file.\n\nUpdate your `environment.ts` file:\n\n```ts\nexport const environment = {\n  production: false,\n  useEmulators: true,\n  ...\n}\n\n```\n\nImport these tokens at your `app.module.ts` as follow:\n\n```ts\nimport { USE_EMULATOR as USE_AUTH_EMULATOR } from '@angular/fire/compat/auth';\nimport { USE_EMULATOR as USE_DATABASE_EMULATOR } from '@angular/fire/compat/database';\nimport { USE_EMULATOR as USE_FIRESTORE_EMULATOR } from '@angular/fire/compat/firestore';\nimport { USE_EMULATOR as USE_FUNCTIONS_EMULATOR } from '@angular/fire/compat/functions';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    // ... Existing Providers\n    { provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['http://localhost', 9099] : undefined },\n    { provide: USE_DATABASE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9000] : undefined },\n    { provide: USE_FIRESTORE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 8080] : undefined },\n    { provide: USE_FUNCTIONS_EMULATOR, useValue: environment.useEmulators ? ['localhost', 5001] : undefined },\n  ]\n})\nexport class AppModule { }\n```\n\nThe environment `useEmulators` flag is used to control whenever the app should connect to the emulators, which is usually done in non-production environments.\n\nAlso you can opt-in the new way of setting the Cloud Functions [origin](https://firebase.google.com/docs/functions/locations) in Firebase v8 by using the `NEW_ORIGIN_BEHAVIOR` token in conjuction with the already present `ORIGIN` token.\n\n```ts\nimport { isDevMode, NgModule } from '@angular/core';\nimport { ORIGIN as FUNCTIONS_ORIGIN, NEW_ORIGIN_BEHAVIOR } from '@angular/fire/compat/functions';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    // ... Existing Providers\n    { provide: NEW_ORIGIN_BEHAVIOR, useValue: true },\n    { provide: FUNCTIONS_ORIGIN, useFactory: () => isDevMode() ? undefined : location.origin },\n  ]\n})\nexport class AppModule { }\n```\n\n### 6.0.0 Method\n\nWith the exception of the Auth Emulator, the old way of setting the `host` and `port` for each emulator was done using a different set of tokens by passing the entire url path as string.\n\n```ts\nimport { URL as DATABASE_URL } from '@angular/fire/compat/database';\nimport { ORIGIN as FUNCTIONS_ORIGIN } from '@angular/fire/compat/functions';\nimport { SETTINGS as FIRESTORE_SETTINGS } from '@angular/fire/compat/firestore';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    {\n      provide: DATABASE_URL,\n      useValue: environment.useEmulators ? `http://localhost:9000?ns=${environment.firebase.projectId}` : undefined\n    },\n    { provide: FIRESTORE_SETTINGS, useValue: environment.useEmulators ? { host: 'localhost:8080', ssl: false } : {} },\n    { provide: FUNCTIONS_ORIGIN, useFactory: environment.useEmulators ? 'http://localhost:5001' : undefined },\n  ]\n})\nexport class AppModule { }\n```\n\nFor older versions, please upgrade your app to latest version to get the advantages of these new features :rocket: \n"
  },
  {
    "path": "docs/compat/firestore/collections.md",
    "content": "# 3. Collections in AngularFirestore\n\n> Cloud Firestore is a NoSQL, document-oriented database. Unlike a SQL database, there are no tables or rows. Instead, you store data in *documents*, which are organized into *collections*.\nEach *document* contains a set of key-value pairs. Cloud Firestore is optimized for storing large collections of small documents.\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n## Using `AngularFirestoreCollection`\n\nThe `AngularFirestoreCollection` service is a wrapper around the native Firestore SDK's [`CollectionReference`](https://firebase.google.com/docs/reference/js/v8/firebase.firestore.CollectionReference) and [`Query`](https://firebase.google.com/docs/reference/js/v8/firebase.firestore.Query) types. It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/compat/firestore';\nimport { Observable } from 'rxjs';\n\nexport interface Item { name: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <ul>\n      <li *ngFor=\"let item of items | async\">\n        {{ item.name }}\n      </li>\n    </ul>\n  `\n})\nexport class AppComponent {\n  private itemsCollection: AngularFirestoreCollection<Item>;\n  items: Observable<Item[]>;\n  constructor(private afs: AngularFirestore) {\n    this.itemsCollection = afs.collection<Item>('items');\n    this.items = this.itemsCollection.valueChanges();\n  }\n  addItem(item: Item) {\n    this.itemsCollection.add(item);\n  }\n}\n```\n\nThe `AngularFirestoreCollection` is a service you use to create streams of the collection and perform data operations on the underyling collection.\n\n### The `DocumentChangeAction` type\n\nWith the exception of the `valueChanges()`, each streaming method returns an Observable of `DocumentChangeAction[]`.\n\nA `DocumentChangeAction` gives you the `type` and `payload` properties. The `type` tells when what `DocumentChangeType` operation occured (`added`, `modified`, `removed`). The `payload` property is a `DocumentChange` which provides you important metadata about the change and a `doc` property which is the `DocumentSnapshot`.\n\n```ts\ninterface DocumentChangeAction {\n  //'added' | 'modified' | 'removed';\n  type: DocumentChangeType;\n  payload: DocumentChange;\n}\n\ninterface DocumentChange {\n  type: DocumentChangeType;\n  doc: DocumentSnapshot;\n  oldIndex: number;\n  newIndex: number;\n}\n\ninterface DocumentSnapshot {\n  exists: boolean;\n  ref: DocumentReference;\n  id: string;\n  metadata: SnapshotMetadata;\n  data(): DocumentData;\n  get(fieldPath: string): any;\n}\n```\n\n## Streaming collection data\n\nThere are multiple ways of streaming collection data from Firestore. \n\n### `valueChanges({ idField?: string })`\n\n**What is it?** - The current state of your collection. Returns an Observable of data as a synchronized array of JSON objects. All Snapshot metadata is stripped and just the document data is included. Optionally, you can pass an options object with an `idField` key containing a string. If provided, the returned JSON objects will include their document ID mapped to a property with the name provided by `idField`.  \n\n**Why would you use it?** - When you just need a list of data. No document metadata is attached to the resulting array which makes it simple to render to a view.\n\n**When would you not use it?** - When you need a more complex data structure than an array.\n\n**Best practices** - Use this method to display data on a page. It's simple but effective. Use `.snapshotChanges()` once your needs become more complex.\n\n#### Example of persisting a Document Id\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/compat/firestore';\nimport { Observable } from 'rxjs';\n\nexport interface Item { id: string; name: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <ul>\n      <li *ngFor=\"let item of items | async\">\n        {{ item.name }}\n      </li>\n    </ul>\n  `\n})\nexport class AppComponent {\n  private itemsCollection: AngularFirestoreCollection<Item>;\n  items: Observable<Item[]>;\n  constructor(private readonly afs: AngularFirestore) {\n    this.itemsCollection = afs.collection<Item>('items');\n    this.items = this.itemsCollection.valueChanges({ idField: 'customID' });\n  }\n  addItem(name: string) {\n    // Persist a document id\n    const id = this.afs.createId();\n    const item: Item = { id, name };\n    this.itemsCollection.doc(id).set(item);\n  }\n}\n```\n\n### `snapshotChanges()`\n\n**What is it?** - The current state of your collection. Returns an Observable of data as a synchronized array of `DocumentChangeAction[]`. \n\n**Why would you use it?** - When you need a list of data but also want to keep around metadata. Metadata provides you the underyling `DocumentReference`, document id, and array index of the single document. Having the document's id around makes it easier to use data manipulation methods. This method gives you more horsepower with other Angular integrations such as ngrx, forms, and animations due to the `type` property. The `type` property on each `DocumentChangeAction` is useful for ngrx reducers, form states, and animation states.\n\n**When would you not use it?** - When you need a more complex data structure than an array or if you need to process changes as they occur. This array is synchronized with the remote and local changes in Firestore.\n\n**Best practices** - Use an observable operator to transform your data from `.snapshotChanges()`. Don't return the `DocumentChangeAction[]` to the template. See the example below.\n\n#### Example\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/compat/firestore';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nexport interface Shirt { name: string; price: number; }\nexport interface ShirtId extends Shirt { id: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <ul>\n      <li *ngFor=\"let shirt of shirts | async\">\n        {{ shirt.name }} is {{ shirt.price }}\n      </li>\n    </ul>\n  `\n})\nexport class AppComponent {\n  private shirtCollection: AngularFirestoreCollection<Shirt>;\n  shirts: Observable<ShirtId[]>;\n  constructor(private readonly afs: AngularFirestore) {\n    this.shirtCollection = afs.collection<Shirt>('shirts');\n    // .snapshotChanges() returns a DocumentChangeAction[], which contains\n    // a lot of information about \"what happened\" with each change. If you want to\n    // get the data and the id use the map operator.\n    this.shirts = this.shirtCollection.snapshotChanges().pipe(\n      map(actions => actions.map(a => {\n        const data = a.payload.doc.data() as Shirt;\n        const id = a.payload.doc.id;\n        return { id, ...data };\n      }))\n    );\n  }\n}\n```\n\n### `stateChanges()`\n\n**What is it?** - Returns an Observable of the most recent changes as a `DocumentChangeAction[]`. \n\n**Why would you use it?** - The above methods return a synchronized array sorted in query order. `stateChanges()` emits changes as they occur rather than syncing the query order. This works well for ngrx integrations as you can build your own data structure in your reducer methods.\n\n**When would you not use it?** - When you just need a list of data. This is a more advanced usage of AngularFirestore.\n\n#### Example\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/compat/firestore';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nexport interface AccountDeposit { description: string; amount: number; }\nexport interface AccountDepositId extends AccountDeposit { id: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <ul>\n      <li *ngFor=\"let deposit of deposits | async\">\n        {{ deposit.description }} for {{ deposit.amount }}\n      </li>\n    </ul>\n  `\n})\nexport class AppComponent {\n  private depositCollection: AngularFirestoreCollection<AccountDeposit>;\n  deposits: Observable<AccountDepositId[]>;\n  constructor(private readonly afs: AngularFirestore) {\n    this.depositCollection = afs.collection<AccountDeposit>('deposits');\n    this.deposits = this.depositCollection.stateChanges(['added']).pipe(\n      map(actions => actions.map(a => {\n        const data = a.payload.doc.data() as AccountDeposit;\n        const id = a.payload.doc.id;\n        return { id, ...data };\n      }))\n    );\n  }\n}\n```\n\n### `auditTrail()`\n\n**What is it?** - Returns an Observable of `DocumentChangeAction[]` as they occur. Similar to `stateChanges()`, but instead it keeps around the trail of events as an array.\n\n**Why would you use it?** - This method is like `stateChanges()` except it is not ephemeral. It collects each change in an array as they occur. This is useful for ngrx integrations where you need to replay the entire state of an application. This also works as a great debugging tool for all applications. You can simply write `afs.collection('items').auditTrail().subscribe(console.log)` and check the events in the console as they occur.\n\n**When would you not use it?** - When you just need a list of data. This is a more advanced usage of AngularFirestore. \n\n#### Example\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/compat/firestore';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nexport interface AccountLogItem { description: string; amount: number; }\nexport interface AccountLogItemId extends AccountLogItem { id: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <ul>\n      <li *ngFor=\"let log of accountLogs | async\">\n        {{ log.description }} for {{ log.amount }}\n      </li>\n    </ul>\n  `\n})\nexport class AppComponent {\n  private accountLogCollection: AngularFirestoreCollection<AccountLogItem>;\n  accountLogs: Observable<AccountLogItemId[]>;\n  constructor(private readonly afs: AngularFirestore) {\n    this.accountLogCollection = afs.collection<AccountLogItem>('accountLog');\n    this.accountLogs = this.accountLogCollection.auditTrail().pipe(\n      map(actions => actions.map(a => {\n        const data = a.payload.doc.data() as AccountLogItem;\n        const id = a.payload.doc.id;\n        return { id, ...data };\n      }))\n    );\n  }\n}\n```\n\n### Limiting events\n\nThere are three `DocumentChangeType`s in Firestore: `added`, `removed`, and `modified`. Each streaming method listens to all three by default. However, you may only be interested in one of these events. You can specify which events you'd like to use through the first parameter of each method:\n\n#### Basic example\n\n```ts\n  constructor(private afs: AngularFirestore): {\n    this.itemsCollection = afs.collection<Item>('items');\n    this.items = this.itemsCollection.snapshotChanges(['added', 'removed']);\n  }\n```\n\n#### Component example\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/compat/firestore';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <ul>\n      <li *ngFor=\"let item of items | async\">\n        {{ item.name }}\n      </li>\n    </ul>\n  `\n})\nexport class AppComponent {\n  private itemsCollection: AngularFirestoreCollection<Item>;\n  items: Observable<Item[]>;\n  constructor(private afs: AngularFirestore) {\n    this.itemsCollection = afs.collection<Item>('items');\n    this.items = this.itemsCollection.valueChanges(['added', 'removed']);\n  }\n}\n```\n\n## State based vs. action based\n\nEach one of these methods falls into two categories: state based and action based. State based methods return the state of your collection \"as-is\". Whereas action based methods return \"what happened\" in your collection.\n\nFor example, a user updates the third item in a list. In a state based method like `.valueChanges()` will update the third item in the collection and return an array of JSON data. This is how your state looks.\n\n## Adding documents to a collection\n\nTo add a new document to a collection with a generated id use the `add()` method. This method uses the type provided by the generic class to validate it's type structure.\n\n#### Basic example\n\n```ts\n  constructor(private afs: AngularFirestore): {\n    const shirtsCollection = afs.collection<Item>('tshirts');\n    shirtsCollection.add({ name: 'item', price: 10 });\n  }\n```\n\n## Manipulating individual documents\n\nTo retrieve, update, or delete an individual document you can use the `doc()` method. This method returns an `AngularFirestoreDocument`, which provides methods for streaming, updating, and deleting. [See Using Documents with AngularFirestore for more information on how to use documents](documents.md).\n\n### [Next Step: Querying Collections in AngularFirestore](querying-collections.md)\n"
  },
  {
    "path": "docs/compat/firestore/documents.md",
    "content": "# 2. Documents in AngularFirestore\n\n> Cloud Firestore is a NoSQL, document-oriented database. Unlike a SQL database, there are no tables or rows. Instead, you store data in *documents*, which are organized into *collections*.\nEach *document* contains a set of key-value pairs. Cloud Firestore is optimized for storing large collections of small documents.\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n## Using `AngularFirestoreDocument`\n\nThe `AngularFirestoreDocument` service is a wrapper around the native Firestore SDK's [`DocumentReference` type](https://firebase.google.com/docs/reference/js/firebase.firestore.DocumentReference). It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreDocument } from '@angular/fire/compat/firestore';\nimport { Observable } from 'rxjs';\n\nexport interface Item { name: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <div>\n      {{ (item | async)?.name }}\n    </div>\n  `\n})\nexport class AppComponent {\n  private itemDoc: AngularFirestoreDocument<Item>;\n  item: Observable<Item>;\n  constructor(private afs: AngularFirestore) {\n    this.itemDoc = afs.doc<Item>('items/1');\n    this.item = this.itemDoc.valueChanges();\n  }\n  update(item: Item) {\n    this.itemDoc.update(item);\n  }\n}\n```\n\n### The `DocumentChangeAction` type\n\nWith the exception of the `valueChanges()`, each streaming method returns an Observable of `DocumentChangeAction[]`.\n\nA `DocumentChangeAction` gives you the `type` and `payload` properties. The `type` tells when what `DocumentChangeType` operation occured (`added`, `modified`, `removed`). The `payload` property is a `DocumentChange` which provides you important metadata about the change and a `doc` property which is the `DocumentSnapshot`.\n\n```ts\ninterface DocumentChangeAction {\n  //'added' | 'modified' | 'removed';\n  type: DocumentChangeType;\n  payload: DocumentSnapshot;\n}\n\ninterface DocumentChange {\n  type: DocumentChangeType;\n  doc: DocumentSnapshot;\n  oldIndex: number;\n  newIndex: number;\n}\n\ninterface DocumentSnapshot {\n  exists: boolean;\n  ref: DocumentReference;\n  id: string;\n  metadata: SnapshotMetadata;\n  data(): DocumentData;\n  get(fieldPath: string): any;\n}\n```\n\n## Streaming document data\n\nThere are multiple ways of streaming collection data from Firestore.\n\n### `valueChanges({ idField?: string })`\n\n**What is it?** - Returns an Observable of document data. All Snapshot metadata is stripped. This method provides only the data. Optionally, you can pass an options object with an `idField` key containing a string. If provided, the returned object will include its document ID mapped to a property with the name provided by `idField`.\n\n**Why would you use it?** - When you just need the object data. No document metadata is attached which makes it simple to render to a view.\n\n**When would you not use it?** - When you need document metadata.\n\n### `snapshotChanges()`\n\n**What is it?** - Returns an Observable of data as a `DocumentChangeAction`. \n\n**Why would you use it?** - When you need the document data but also want to keep around metadata. This metadata provides you the underyling `DocumentReference` and document id. Having the document's id around makes it easier to use data manipulation methods. This method gives you more horsepower with other Angular integrations such as ngrx, forms, and animations due to the `type` property. The `type` property on each `DocumentChangeAction` is useful for ngrx reducers, form states, and animation states.\n\n**When would you not use it?** - When you simply need to render data to a view and don't want to do any extra processing.\n\n## Manipulating documents\n\nAngularFirestore provides methods for setting, updating, and deleting document data.\n\n- `set(data: T)` - Destructively updates a document's data.\n- `update(data: T)` - Non-destructively updates a document's data.\n- `delete()` - Deletes an entire document. Does not delete any nested collections.\n\n## Querying?\n\nQuerying has no effect on documents. Documents are a single object and querying effects a range of multiple documents. If you are looking for querying then you want to use a collection.\n\n## Retrieving nested collections\n\nNesting collections is a great way to structure your data. This allows you to group related data structures together. If you are creating a \"Task List\" site, you can group \"tasks\" under a user: `user/<uid>/tasks`. \n\nTo retrieve a nested collection use the `collection(path: string)` method.\n\n```ts\n  constructor(private afs: AngularFirestore) {\n    this.userDoc = afs.doc<Item>('user/david');\n    this.tasks = this.userDoc.collection<Task>('tasks').valueChanges();\n  }\n```\n\n### [Next Step: Collections in AngularFirestore](collections.md)\n"
  },
  {
    "path": "docs/compat/firestore/offline-data.md",
    "content": "# Offline Data in Firestore\n\n> Cloud Firestore supports offline data persistence. This feature caches a copy of the Cloud Firestore data that your app is actively using, so your app can access the data when the device is offline. You can write, read, listen to, and query the cached data. When the device comes back online, Cloud Firestore synchronizes any local changes made by your app to the data stored remotely in Cloud Firestore.\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n**Offline persistence is an experimental feature that is supported only by the Chrome, Safari, and Firefox web browsers.** If a user opens multiple browser tabs that point to the same Cloud Firestore database, and offline persistence is enabled, Cloud Firestore will work correctly only in the first tab.\n\n## Enable Offline Data in AngularFirestore\n\nTo enable offline persistence in your AngularFire application, call `enablePersistence()` when you are importing `AngularFirestoreModule` into your `@NgModule`:\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFirestoreModule } from '@angular/fire/compat/firestore';\nimport { AngularFireAuthModule } from '@angular/fire/compat/auth';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFirestoreModule.enablePersistence(),\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n\n```\n\nWhile offline your listeners will receive listen events when the locally cached data changes. You can use to Documents and Collections normally.\n\nTo check whether you're receiving data from the server or the cache, use the `fromCache` property on the `SnapshotMetadata` in your snapshot event. If `fromCache` is true, the data came from the cache and might be stale or incomplete. If `fromCache` is false, the data is complete and current with the latest updates on the server.\n\n[To learn more about Offline Persistence in Firestore, check out the Firebase documentation](https://firebase.google.com/docs/firestore/enable-offline)."
  },
  {
    "path": "docs/compat/firestore/querying-collections.md",
    "content": "# 4. Querying Collections in AngularFirestore\n\n> Firestore has [powerful querying syntax](https://firebase.google.com/docs/firestore/query-data/queries) and the `AngularFirestoreCollection` provides a thin wrapper around it. This keeps you from having to learn two query syntax systems.\nIf you know the [Firestore query API](https://firebase.google.com/docs/reference/js/v8/firebase.firestore.Query) then you know how to query in AngularFirestore.\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n## Creating a query with primitive/scalar values\n\nQueries are created by building on the [`firebase.firestore.CollectionReference`](https://firebase.google.com/docs/reference/js/v8/firebase.firestore.CollectionReference).\n\n```ts\nafs.collection('items', ref => ref.where('size', '==', 'large'))\n```\n\n### Query options\n\n| method   | purpose            |\n| ---------|--------------------|\n| `where` | Create a new query. *Can be chained to form complex queries.* |\n| `orderBy` | Sort by the specified field, in descending or ascending order. |\n| `limit` | Sets the maximum number of items to return. |\n| `startAt` | Results start at the provided document (inclusive). |\n| `startAfter` | Results start after the provided document (exclusive). |\n| `endAt` | Results end at the provided document (inclusive). |\n| `endBefore` | Results end before the provided document (exclusive). |\n\n[To learn more about querying and sorting in Firestore, check out the Firebase documentation](https://firebase.google.com/docs/firestore/query-data/queries).\n\n## Invalid query combinations\n\nRange filters can only be specified on a single field:\n\n```ts\n// WARNING: Do not copy and paste. This will not work!\nref.where('state', '>=', 'CA')\n   .where('population', '>', 100000)\n```\n\nRange filter and orderBy cannot be on different fields:\n\n```ts\n// WARNING: Do not copy and paste. This will not work!\nref.where('population', '>', 100000).orderBy('country')\n```\n\nRange filters / orderBy cannot be used in conjuction with user-defined data, they require composite indexes be defined on the specific fields.\n\n```ts\n// WARNING: Do not copy and paste. This will not work!\nref.where('tags.awesome', '==', true).orderBy('population')\n```\n\n## Dynamic querying\n\nTo enable dynamic queries one should lean on RxJS Operators like `switchMap`.\n\nAn RxJS Subject is imported below. A Subject is like an Observable, but can multicast to many Observers. Subjects are like EventEmitters: they maintain a registry of many listeners. See, [What is a Subject](http://reactivex.io/rxjs/manual/overview.html#subject) for more information.\n\nWhen we call [`switchMap` on the Subject](https://www.learnrxjs.io/operators/transformation/switchmap.html), we can map each value to a new Observable; in this case a database query.\n\n```ts\nconst size$ = new Subject<string>();\nconst queryObservable = size$.pipe(\n  switchMap(size => \n    afs.collection('items', ref => ref.where('size', '==', size)).valueChanges()\n  )\n);\n\n// subscribe to changes\nqueryObservable.subscribe(queriedItems => {\n  console.log(queriedItems);  \n});\n\n// trigger the query\nsize$.next('large');\n\n// re-trigger the query!!!\nsize$.next('small');\n```\n\n### Example app\n \n[See this example in action on StackBlitz](https://stackblitz.com/edit/angularfire-db-api-fbad9p).\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore } from '@angular/fire/compat/firestore';\nimport { Observable, BehaviorSubject, combineLatest } from 'rxjs';\nimport { switchMap } from 'rxjs/operators';\n\nexport interface Item {\n  text: string;\n  color: string;\n  size: string;\n}\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <div *ngIf=\"items$ | async; let items; else loading\">\n    <ul>\n      <li *ngFor=\"let item of items\">\n        {{ item.text }}\n      </li>\n    </ul>\n    <div *ngIf=\"items.length === 0\">No results, try clearing filters</div>\n  </div>\n  <ng-template #loading>Loading&hellip;</ng-template>\n  <div>\n    <h4>Filter by size</h4>\n    <button (click)=\"filterBySize('small')\">Small</button>\n    <button (click)=\"filterBySize('medium')\">Medium</button>\n    <button (click)=\"filterBySize('large')\">Large</button>\n    <button (click)=\"filterBySize(null)\" *ngIf=\"this.sizeFilter$.getValue()\">\n      <em>clear filter</em>\n    </button>\n  </div>\n  <div>\n    <h4>Filter by color</h4>\n    <button (click)=\"filterByColor('red')\">Red</button>\n    <button (click)=\"filterByColor('green')\">Blue</button>\n    <button (click)=\"filterByColor('blue')\">Green</button>\n    <button (click)=\"filterByColor(null)\" *ngIf=\"this.colorFilter$.getValue()\">\n      <em>clear filter</em>\n    </button>\n  </div>\n  `,\n})\nexport class AppComponent {\n  items$: Observable<Item[]>;\n  sizeFilter$: BehaviorSubject<string|null>;\n  colorFilter$: BehaviorSubject<string|null>;\n  \n  constructor(afs: AngularFirestore) {\n    this.sizeFilter$ = new BehaviorSubject(null);\n    this.colorFilter$ = new BehaviorSubject(null);\n    this.items$ = combineLatest(\n      this.sizeFilter$,\n      this.colorFilter$\n    ).pipe(\n      switchMap(([size, color]) => \n        afs.collection('items', ref => {\n          let query : firebase.firestore.CollectionReference | firebase.firestore.Query = ref;\n          if (size) { query = query.where('size', '==', size) };\n          if (color) { query = query.where('color', '==', color) };\n          return query;\n        }).valueChanges()\n      )\n    );\n  }\n  filterBySize(size: string|null) {\n    this.sizeFilter$.next(size); \n  }\n  filterByColor(color: string|null) {\n    this.colorFilter$.next(color); \n  }\n}\n```\n\n**To run the above example as is, you need to have sample data in your Firebase database with the following structure:**\n\n```json\n{\n  \"items\": {\n    \"a\" : {\n      \"size\"  : \"small\",\n      \"text\"  : \"small thing\",\n      \"color\" : \"red\"\n    },\n    \"b\" : {\n      \"size\"  : \"medium\",\n      \"text\"  : \"medium sample\",\n      \"color\" : \"red\"\n    },\n    \"c\" : {\n      \"size\"  : \"large\",\n      \"text\"  : \"large widget\",\n      \"color\" : \"green\"\n    }\n  }\n}\n```\n\n## Collection Group Queries\n\nTo query across collections and sub-collections with the same name anywhere in Firestore, you can use collection group queries.\n\nCollection Group Queries allow you to have a more nested data-structure without sacrificing performance. For example, we could easily query all comments a user posted; even if the comments were stored as a sub-collection under `Articles/**` or even nested deeply (`Articles/**/Comments/**/Comments/**/...`):\n\n```ts\nconstructor(private afs: AngularFirestore) { }\n\nngOnInit() {\n  ...\n  // Get all the user's comments, no matter how deeply nested\n  this.comments$ = afs.collectionGroup('Comments', ref => ref.where('user', '==', userId))\n                      .valueChanges({ idField: 'docId' });\n}\n```\n\n`collectionGroup` returns an `AngularFirestoreCollectionGroup` which is similar to `AngularFirestoreCollection`. The main difference is that `AngularFirestoreCollectionGroup` has no data operation methods such as `add` because it doesn't have a concrete reference.\n\n### [Next Step: Getting started with Firebase Authentication](../auth/getting-started.md)\n"
  },
  {
    "path": "docs/compat/functions/functions.md",
    "content": "# AngularFireFunctions\n\n> The Cloud Functions for Firebase client SDKs let you call functions directly from a Firebase app. To call a function from your app in this way, write and deploy an HTTPS Callable function in Cloud Functions, and then add client logic to call the function from your app.\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n### Import the `NgModule`\n\nCloud Functions for AngularFire is contained in the `@angular/fire/functions` module namespace. Import the `AngularFireFunctionsModule` in your `NgModule`. This sets up the `AngularFireFunction` service for dependency injection.\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireFunctionsModule } from '@angular/fire/compat/functions';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireFunctionsModule\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\n### Injecting the AngularFireFunctions service\n\nOnce the `AngularFireFunctionsModule` is registered you can inject the `AngularFireFunctions` service.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireFunctions } from '@angular/fire/compat/functions';\n\n@Component({\n  selector: 'app-component',\n  template: ``\n})\nexport class AppComponent {\n  constructor(private fns: AngularFireFunctions) { }\n}\n```\n\n### Creating a callable function\n\nAngularFireFunctions is super easy. You create a function on the server side and then \"call\" it by its name with the client library. \n\n| method   |                    |\n| ---------|--------------------|\n| `httpCallable(name: string): (data: T) ` | Creates a callable function based on a function name. Returns a function that can create the observable of the http call. |\n```ts\n\nimport { Component } from '@angular/core';\nimport { AngularFireFunctions } from '@angular/fire/compat/functions';\n\n@Component({\n  selector: 'app-root',\n  template: `{ data$  | async }`\n})\nexport class AppComponent {\n  constructor(private fns: AngularFireFunctions) { \n    const callable = fns.httpsCallable('my-fn-name');\n    this.data$ = callable({ name: 'some-data' });\n  }\n}\n```\n\nNotice that calling `httpsCallable()` does not initiate the request. It creates a function, which when called creates an Observable, subscribe or convert it to a Promise to initiate the request.\n\n## Configuration via Dependency Injection\n\n### Functions Region\n\nAllow configuration of the Function's region by adding `REGION` to the `providers` section of your `NgModule`. The default is `us-central1`.\n\n```ts\nimport { NgModule } from '@angular/core';\nimport { AngularFireFunctionsModule, REGION } from '@angular/fire/compat/functions';\n\n@NgModule({\n  imports: [\n    ...\n    AngularFireFunctionsModule,\n    ...\n  ],\n  ...\n  providers: [\n   { provide: REGION, useValue: 'asia-northeast1' }\n  ]\n})\nexport class AppModule {}\n\n```\n\n### Cloud Functions emulator\n\nPoint callable Functions to the Cloud Function emulator by adding `USE_EMULATOR` to the `providers` section of your `NgModule`.\n\n```ts\nimport { NgModule } from '@angular/core';\nimport { AngularFireFunctionsModule, USE_EMULATOR } from '@angular/fire/compat/functions';\n\n@NgModule({\n  imports: [\n    ...\n    AngularFireFunctionsModule,\n    ...\n  ],\n  ...\n  providers: [\n   { provide: USE_EMULATOR, useValue: ['localhost', 5001] }\n  ]\n})\nexport class AppModule {}\n\n```\n\n[Learn more about integration with the Firebase Emulator suite on our dedicated guide here](../emulators/emulators.md).\n\n### Firebase Hosting integration\n\nIf you serve your app using [Firebase Hosting](https://firebase.google.com/docs/hosting/), you can configure Functions to be served from the same domain as your app. This will avoid an extra round-trip per function call due to [CORS preflight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). This only applies to sites hosted via firebase on `us-central1`.\n\nTo set this up, you first need to update your `hosting` section in `firebase.json` and add one `rewrite` rule per function:\n\n```json\n  \"hosting\": {\n    \"rewrites\": [\n      {\n        \"source\": \"/someFunction\",\n        \"function\": \"someFunction\"\n      },\n      {\n        \"source\": \"/anotherFunction\",\n        \"function\": \"anotherFunction\"\n      },\n      ...\n    ]\n  }\n```\n\nDeploy your hosting project to the new settings go into effect, finally configure functions origin to point at your app domain:\n\n```ts\nimport { NgModule } from '@angular/core';\nimport { AngularFireFunctionsModule, ORIGIN, NEW_ORIGIN_BEHAVIOR } from '@angular/fire/compat/functions';\n\n@NgModule({\n  imports: [\n    ...\n    AngularFireFunctionsModule,\n    ...\n  ],\n  ...\n  providers: [\n   { provide: NEW_ORIGIN_BEHAVIOR, useValue: true },\n   { provide: ORIGIN, useValue: 'https://project-name.web.app' }\n  ]\n})\nexport class AppModule {}\n\n```\n"
  },
  {
    "path": "docs/compat/messaging/messaging.md",
    "content": "# AngularFireMessaging\n\n> The FCM JavaScript API lets you receive notification messages in web apps running in browsers that support the Push API.\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n### AngularFireMessaging is not out-of-the-box compatible with the Angular Service Worker\n\nIf you are using the Angular Service Worker, you are not currently able to use AngularFireMessaging out-of-the-box.\nIf you'd like this feature please add your 👍 to [this issue](https://github.com/angular/angular/issues/34352).\n\nYour alternatives are to use\n- [WorkboxJS](https://developers.google.com/web/tools/workbox/)\n- Follow the discussion in [this issue](https://github.com/angular/angular/issues/34352) and [here](https://github.com/angular/angularfire/discussions/1923), manually registering the Angular Service Worker\n- The Firebase Messaging Service Worker, which is detailed below\n\n### Import the `NgModule`\n\nPush Notifications for AngularFire are contained in the `@angular/fire/messaging` module namespace. Import the `AngularFireMessagingModule` in your `NgModule`. This sets up the `AngularFireMessaging` service for dependency injection.\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireMessagingModule } from '@angular/fire/compat/messaging';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireMessagingModule\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\n### Setting up the Firebase Messaging Service Worker\n\nThere are two parts to Firebase Messaging, a Service Worker and the DOM API. AngularFireMessaging allows you to request permission, get tokens, delete tokens, and subscribe to messages on the DOM side. To register to receive notifications you need to set up the Service Worker. [The official Firebase documentation for setting up the details exactly how to do that](https://firebase.google.com/docs/cloud-messaging/js/client). \n\nYou can either use the `firebase-messaging-sw.js` file provided in the docs or you can set your own Service Worker to import that script. Make sure to set up your `angular.json` file to copy over the Service Worker file:\n\n```json\n  \"assets\": [\n    \"assets\",\n    \"favicon.ico\",\n    \"firebase-messaging-sw.js\",\n    \"manifest.json\"\n  ],\n```\n\n[Warning] Remember update the `firebase-messaging-sw.js` everytime you update the `firebase` in package.json. The missmatch version could lead to unable to receive notification in `foreground`, you can create your `firebase-messaging-sw.js` like this:\n\n```js\n// Give the service worker access to Firebase Messaging.\n// Note that you can only use Firebase Messaging here, other Firebase libraries\n// are not available in the service worker.\nimportScripts('https://www.gstatic.com/firebasejs/[the number of version matching with firebase in package.json]/firebase-app.js');\nimportScripts('https://www.gstatic.com/firebasejs/[for example: 7.16.1]/firebase-messaging.js');\n\n// Initialize the Firebase app in the service worker by passing in the\n// messagingSenderId.\n\nfirebase.initializeApp({\n    apiKey: '<your-key>',\n    authDomain: '<your-project-authdomain>',\n    databaseURL: '<your-database-URL>',\n    projectId: '<your-project-id>',\n    storageBucket: '<your-storage-bucket>',\n    messagingSenderId: '<your-messaging-sender-id>'\n});\n\n// Retrieve an instance of Firebase Messaging so that it can handle background\n// messages.\nconst messaging = firebase.messaging();\n\n\n```\n\n### Requesting permission\n\nOnce you have the Firebase Messaging Service Worker set up and installed, you need to request permission to send a user notifications. While the browser will popup a UI for you, it is highly recommend to ask the user for permission with a custom UI and only ask when it makes sense. If you blindly ask for permission, you have an extremely high chance of getting denied or blocked.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/compat/messaging';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"requestPermission()\">\n    Hello this is a chat app. You should let us send you notifications for this reason.\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  requestPermission() {\n    this.afMessaging.requestPermission\n      .subscribe(\n        () => { console.log('Permission granted!'); },\n        (error) => { console.error(error); },  \n      );\n  }\n}\n```\n\nOnce you have the permission of the user, you need their token. You can do this with the `getToken` observable or the `tokenChanges` observable. The `tokenChanges` observable listens for token refreshes whereas the `getToken` observable is a one-time call.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/compat/messaging';\nimport { mergeMapTo } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"requestPermission()\">\n    Hello this is a chat app. You should let us send you notifications for this reason.\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  requestPermission() {\n    this.afMessaging.requestPermission\n      .pipe(mergeMapTo(this.afMessaging.tokenChanges))\n      .subscribe(\n        (token) => { console.log('Permission granted! Save to the server!', token); },\n        (error) => { console.error(error); },  \n      );\n  }\n}\n```\n\nOnce you have a user's token, you need to save it to the server in order to send them notifications in response to events. Let's say you want to send a push each time a user sends a chat message. Once a user grants permission, you can send the token to the Realtime Database or Cloud Firestore and associate it with a unique id, like a Firebase Auth UID. You can then create a Cloud Function trigger that looks up the user's token when a chat message is created.\n\n### Shortcutting token requests\n\nAn easier way of requesting permission and getting tokens is with the `requestToken` observable. It combines the two steps above into one observable.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/compat/messaging';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"requestPermission()\">\n    Hello this is a chat app. You should let us send you notifications for this reason.\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  requestPermission() {\n    this.afMessaging.requestToken\n      .subscribe(\n        (token) => { console.log('Permission granted! Save to the server!', token); },\n        (error) => { console.error(error); },  \n      );\n  }\n}\n```\n\nThe `requestToken` observable uses the `tokenChanges` observable to listen to refreshes.\n\n### Deleting tokens\n\nNeed to delete a user's token? Not a problem.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/compat/messaging';\nimport { mergeMap } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"deleteToken()\">\n    Delete my token\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  deleteToken() {\n    this.afMessaging.getToken\n      .pipe(mergeMap(token => this.afMessaging.deleteToken(token)))\n      .subscribe(\n        (token) => { console.log('Token deleted!'); },\n      );\n  }\n}\n```\n\nThe code above requests the current user's token and passes it to the `deleteToken()` observable.\n\n### Subscribing to foreground messages\n\nOnce you have a user's token and they are subscribed, you can listen to messages in the foreground. The Firebase Messaging Service Worker handles background push notifications.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/compat/messaging';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"listen()\">\n    Get notified!\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  listen() {\n    this.afMessaging.messages\n      .subscribe((message) => { console.log(message); });\n  }\n}\n```\n\n### Sending notifications\n\n[Sending a notification](https://firebase.google.com/docs/cloud-messaging/js/first-message) requires a call to a server. You can do this directly with an HTTP call or you can even build a Cloud Function to do this in response to an event. A Cloud Function trigger is ideal because you have trusted access to the database and can securely look up tokens to send to the right user. If you want to send push notifications via HTTP requests you'll need to secure the API call. This is usually done with a Firebase Auth UID. On the server you can verify the UID with the Firebase Admin SDK and allow access to get a user's push id.\n\nThe [Firebase Admin SDK has helper functions for sending notifications](https://firebase.google.com/docs/cloud-messaging/admin/send-messages) to the user and subscribing them to topics, which [simplifies sending grouped messages](https://firebase.google.com/docs/cloud-messaging/admin/manage-topic-subscriptions).\n"
  },
  {
    "path": "docs/compat/performance/getting-started.md",
    "content": "# Getting started with Performance Monitoring\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n## Automatic page load tracing\n\nUnderstand your Angular application's real-world performance with [Firebase Performance Monitoring](https://firebase.google.com/docs/perf-mon). Performance Monitoring automatically provides a trace for **page load** when you add `AngularFirePerformanceModule` into your App Module's imports.\n\n```ts\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFirePerformanceModule, PerformanceMonitoringService } from '@angular/fire/compat/performance';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFirePerformanceModule,\n    ...\n  ],\n  providers: [\n    PerformanceMonitoringService\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\nThe page load trace breaks down into the following default metrics:\n\n* [first paint traces](https://firebase.google.com/docs/perf-mon/automatic-web#first-paint) — measure the time between when the user navigates to a page and when any visual change happens\n* [first contentful paint traces](https://firebase.google.com/docs/perf-mon/automatic-web#contentful-paint) — measure the time between when a user navigates to a page and when meaningful content displays, like an image or text\n* [domInteractive traces](https://firebase.google.com/docs/perf-mon/automatic-web#domInteractive) — measure the time between when the user navigates to a page and when the page is considered interactive for the user\n* [domContentLoadedEventEnd traces](https://firebase.google.com/docs/perf-mon/automatic-web#domContentLoaded) — measure the time between when the user navigates to a page and when the initial HTML document is completely loaded and parsed\n* [loadEventEnd traces](https://firebase.google.com/docs/perf-mon/automatic-web#loadEventEnd) — measure the time between when the user navigates to the page and when the current document's load event completes\n* [first input delay traces](https://firebase.google.com/docs/perf-mon/automatic-web#input-delay) — measure the time between when the user interacts with a page and when the browser is able to respond to that input\n* **Angular specific traces** - `PerformanceMonitoringService` will measure the time needed for `ApplicationRef.isStable` to be true, an important metric to track if you're concerned about solving Zone.js issues for proper functionality of NGSW and Server Side Rendering\n\n### Measuring First Input Delay\n\n> First Input Delay (FID) measures the time from when a user first interacts with your site (i.e. when they click a link, tap on a button, or use a custom, JavaScript-powered control) to the time when the browser is actually able to respond to that interaction. [See the article on the Google Developer's Blog for more information on FID.](https://developers.google.com/web/updates/2018/05/first-input-delay)\n\nIn order to track first input delay, you'll want to [polyfill the browser performance API](https://github.com/GoogleChromeLabs/first-input-delay):\n\n`npm install --save-dev first-input-delay`\n\nThen add `import 'first-input-delay';` to your `src/polyfills.ts`.\n\n## Manual traces\n\nYou can inject `AngularFirePerformance` to perform manual traces.\n\n```ts\nconstructor(private performance: AngularFirePerformance) {}\n\n...\n\nconst trace = await this.performance.trace('some-trace');\ntrace.start();\n...\ntrace.stop();\n```\n\n## RXJS operators\n\nAngularFire provides a number of RXJS operators which wrap the User Timing API. These are picked up by performance monitoring tools such as Chrome Inspector and Firebase Performance Monitoring.\n\n```ts\nimport { trace } from '@angular/fire/compat/performance';\n\n...\n\nconstructor(private performance: AngularFirePerformance, private afs: AngularFirestore) {}\n\nngOnInit() {\n  this.articles = afs.collection('articles')\n      .collection('articles', ref => ref.orderBy('publishedAt', 'desc'))\n      .snapshotChanges()\n      .pipe(\n        // measure the amount of time between the Observable being subscribed to and first emission (or completion)\n        trace('getArticles'),\n        map(articles => ...)\n      );\n}\n```\n\n### `trace(name: string)`\n\nThe most basic operator, `trace` will measure the amount of time it takes for your observable to either complete or emit its first value. Beyond the basic trace there are several other operators:\n\n<h3>\n<pre>\ntraceUntil(\n  name: string,\n  test: (T) => Boolean,\n  options?: { orComplete?: true }\n)\n</pre>\n</h3>\n\nTrace the observable until the first emission that passes the provided test.\n\nIf the `orComplete` option is passed it will complete the trace when the observable completes, even if an emission never passed the provided test.\n\n<h3>\n<pre>\ntraceWhile(\n  name: string,\n  test: (T) => Boolean,\n  options?: { orComplete?: true }\n)\n</pre>\n</h3>\n\nStarting with an emission that passes the provided test, trace until an emission fails the test.\n\nIf the `orComplete` option is passed it will complete any existing trace when the observable completes.\n\n### `traceUntilLast(name: string)`\n\nTrace the observable until completion.\n\n### `traceUntilFirst(name: string)`\n\nTraces the observable until the first emission.\n\n## Advanced usage\n\n### Configuration via Dependency Injection\n\nSet `INSTRUMENTATION_ENABLED` or `DATA_COLLECTION_ENABLED` to false disable all automatic and custom traces respectively."
  },
  {
    "path": "docs/compat/remote-config/getting-started.md",
    "content": "<h1>Getting started with Remote Config <em><abbr title=\"beta\">β<abbr></em></h1>\n\n`AngularFireRemoteConfig` dynamically imports the `firebase/remote-config` library on demand, provides convenience observables, pipes, and a promisified version of the [Firebase Remote Config SDK (`firebase.remoteConfig.RemoteConfig`)](https://firebase.google.com/docs/reference/js/firebase.remoteconfig.RemoteConfig).\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n### API:\n\n```ts\nclass AngularFireRemoteConfigModule { }\n\ninterface ConfigTemplate {[key:string]: string|number|boolean}\n\ntype Parameter extends remoteConfig.Value {\n  key: string,\n  fetchTimeMillis: number\n}\n\nclass AngularFireRemoteConfig {\n  changes:    Observable<Parameter>;\n  parameters: Observable<Parameter[]>;\n  numbers:    Observable<{[key:string]: number|undefined}>  & {[key:string]: Observable<number>};\n  booleans:   Observable<{[key:string]: boolean|undefined}> & {[key:string]: Observable<boolean>};\n  strings:    Observable<{[key:string]: string|undefined}>  & {[key:string]: Observable<string|undefined>};\n  \n  // from firebase.remoteConfig() proxy:\n  activate: () => Promise<boolean>;\n  ensureInitialized: () => Promise<void>;\n  fetch: () => Promise<void>;\n  fetchAndActivate: () => Promise<boolean>;\n  getAll: () => Promise<{[key:string]: remoteConfig.Value}>;\n  getBoolean: (key:string) => Promise<boolean>;\n  getNumber: (key:string) => Promise<number>;\n  getString: (key:string) => Promise<string>;\n  getValue: (key:string) => Promise<remoteConfig.Value>;\n  setLogLevel: (logLevel: remoteConfig.LogLevel) => Promise<void>;\n  settings: Promise<remoteConfig.Settings>;\n  defaultConfig: Promise<{[key: string]: string | number | boolean}>;\n  fetchTimeMillis: Promise<number>;\n  lastFetchStatus: Promise<remoteConfig.FetchStatus>;\n}\n\n// Pipes for working with .changes and .parameters\nfilterRemote: () => MonoTypeOperatorFunction<Parameter | Parameter[]>\nfilterFresh: (interval: number) => MonoTypeOperatorFunction<Parameter | Parameter[]>\nbudget: <T>(interval: number) => MonoTypeOperatorFunction<T>\n\n// scanToObject is for use with .changes\nscanToObject: () => OperatorFunction<Parameter, {[key: string]: string|undefined}>\n\n// mapToObject is the same behavior as scanToObject but for use with .parameters\nmapToObject: () => OperatorFunction<Parameter[], {[key: string]: string|undefined}>\n\nSETTINGS = InjectionToken<remoteConfig.Settings>;\nDEFAULTS = InjectionToken<ConfigTemplate>;\n```\n\n## Configuration with Dependency Injection\n\n### Configure Remote Config with `SETTINGS`\n\nUsing the `SETTINGS` DI Token (*default: {}*) will allow you to [configure Firebase Remote Config](https://firebase.google.com/docs/reference/js/firebase.remoteconfig.Settings.html).\n\n### Configure default values with  `DEFAULTS`\n\nProviding `DEFAULTS ({[key: string]: string | number | boolean})` tells `AngularFireRemoteConfig` to emit the provided defaults first. This allows you to count on Remote Config when the user is offline or in environments that the Remote Config service does not handle (i.e. Server Side Rendering).\n\n## Putting it all together\n\n```ts\nimport { AngularFireRemoteConfigModule, DEFAULTS, SETTINGS } from '@angular/fire/compat/remote-config';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireRemoteConfigModule\n  ],\n  providers: [\n    { provide: DEFAULTS, useValue: { enableAwesome: true } },\n    {\n      provide: SETTINGS,\n      useFactory: () => isDevMode() ? { minimumFetchIntervalMillis: 10_000 } : {}\n    }\n  ]\n})\nexport class AppModule { }\n\n...\n\nconstructor(remoteConfig: AngularFireRemoteConfig) {\n  remoteConfig.changes.pipe(\n    filterFresh(172_800_000), // ensure we have values from at least 48 hours ago\n    first(),\n    // scanToObject when used this way is similar to defaults\n    // but most importantly smart-casts remote config values and adds type safety\n    scanToObject({\n      enableAwesome: true,\n      titleBackgroundColor: 'blue',\n      titleFontSize: 12\n    })\n  ).subscribe(…);\n\n  // all remote config values cast as strings\n  remoteConfig.strings.subscribe(...)\n  remoteConfig.booleans.subscribe(...); // as booleans\n  remoteConfig.numbers.subscribe(...); // as numbers\n\n  // convenience for observing a single string\n  remoteConfig.strings.titleBackgroundColor.subscribe(...);\n  remoteConfig.booleans.enableAwesome.subscribe(...); // boolean\n  remoteConfig.numbers.titleBackgroundColor.subscribe(...); // number\n\n  // however those may emit more than once as the remote config cache fires and gets fresh values\n  // from the server. You can filter it out of .changes for more control:\n  remoteConfig.changes.pipe(\n    filter(param => param.key === 'titleBackgroundColor'),\n    map(param => param.asString())\n    // budget at most 800ms and return the freshest value possible in that time\n    // our budget pipe is similar to timeout but won't error or abort the pending server fetch\n    // (it won't emit it, if the deadline is exceeded, but it will have been fetched so can use the\n    // freshest values on next subscription)\n    budget(800),\n    last()\n  ).subscribe(...)\n\n  // just like .changes, but scanned into an array\n  remoteConfig.parameters.subscribe(all => ...);\n\n  // or make promisified firebase().remoteConfig() calls direct off AngularFireRemoteConfig\n  // using our proxy\n  remoteConfig.getAll().then(all => ...);\n  remoteConfig.lastFetchStatus.then(status => ...);\n}\n```\n"
  },
  {
    "path": "docs/compat/rtdb/lists.md",
    "content": "# 3. Retrieving data as lists\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n> AngularFire synchronizes data as lists using the `AngularFireList` service.\n\nThe `AngularFireList` service is not created by itself, but through the `AngularFireDatabase` service. \n\nThe guide below demonstrates how to retrieve, save, and remove data as lists.\n\n## Injecting the `AngularFireDatabase` service\n\n**Make sure you have bootstrapped your application for AngularFire. See the Installation guide for bootstrap setup.**\n\nAngularFireDatabase is a service which can be injected through the constructor of your Angular component or `@Injectable()` service.\nIn the previous step, we modified the `/src/app/app.component.ts` to retrieve data as an object. In this step, let's start with a clean slate.\n\nReplace your  `/src/app/app.component.ts` from previous step to look like below.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase } from '@angular/fire/compat/database';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: 'app.component.html',\n  styleUrls: ['app.component.css']\n})\nexport class AppComponent {\n  constructor(db: AngularFireDatabase) { }\n}\n```\n\nIn this section, we're going to modify the `/src/app/app.component.ts`  to retrieve data as list, but before that let's look at ways around how to bind to a list.\n\n## Create a list binding\n\nData is retrieved through the `AngularFireDatabase` service. The service is also generic. Provide the singular type and not the array type.\n\n```ts\nconst listRef = db.list('items');\nconst shirtsRef = db.list<Shirt>('shirts');\n```\n\n### Retrieve data\n\nTo get the list in realtime, create a list binding as a property of your component or service.\n\nThen in your template, you can use the `async` pipe to unwrap the binding.\n\nUpdate `/src/app/app.component.ts` to import `AngularFireList` from `@angular/fire` and iterate through the list once data is retrieved. Also note the change in attribute `templateUrl` to inline `template` below.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase } from '@angular/fire/compat/database';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <ul>\n    <li *ngFor=\"let item of items | async\">\n       {{ item | json }}\n    </li>\n  </ul>\n  `,\n})\nexport class AppComponent {\n  items: Observable<any[]>;\n  constructor(db: AngularFireDatabase) {\n    this.items = db.list('items').valueChanges();\n  }\n}\n```\n\n## `AngularFireAction` - Action based API\n\nAngularFire provides methods that stream data back as redux compatible actions. This gives you extra horsepower when using libraries like Animations, ngrx, and ReactiveForms. \n\n### `valueChanges()`\n\n**What is it?** - Returns an Observable of data as a synchronized array of JSON objects. All Snapshot metadata is stripped and just the method provides only the data.\n\n**Why would you use it?** - When you just need a list of data. No snapshot metadata is attached to the resulting array which makes it simple to render to a view.\n\n**When would you not use it?** - When you need a more complex data structure than an array or you need the `key` of each snapshot for data manipulation methods. This method assumes you either are saving the `key` for the snapshot data or using a \"readonly\" approach.\n\n### `snapshotChanges()`\n\n**What is it?** - Returns an Observable of data as a synchronized array of `AngularFireAction<DatabaseSnapshot>[]`.\n\n**Why would you use it?** - When you need a list of data but also want to keep around metadata. Metadata provides you the underyling `DatabaseReference` and snapshot key. Having the snapshot's `key` around makes it easier to use data manipulation methods. This method gives you more horsepower with other Angular integrations such as ngrx, forms, and animations due to the `type` property. The `type` property on each `AngularFireAction` is useful for ngrx reducers, form states, and animation states.\n\n**When would you not use it?** - When you need a more complex data structure than an array or if you need to process changes as they occur. This array is synchronized with the remote and local changes in the Firebase Database.\n\n### `stateChanges()`\n\n**What is it?** - Returns an Observable of the most recent change as an `AngularFireAction`.\n\n**Why would you use it?** - The above methods return a singular `AngularFireAction` from each child event that occurs. `stateChanges()` emits changes as they occur rather than syncing the query order. This works well for ngrx integrations as you can build your own data structure in your reducer methods.\n\n**When would you not use it?** - When you just need a list of data. This is a more advanced usage of `AngularFireDatabase`.\n\n### `auditTrail()`\n\n**What is it?** - Returns an Observable of `AngularFireAction[]` as they occur. Similar to `stateChanges()`, but instead it keeps around the trail of events as an array.\n\n**Why would you use it?** - This method is like `stateChanges()` except it is not ephemeral. It collects each change in an array as they occur. This is useful for ngrx integrations where you need to replay the entire state of an application. This also works as a great debugging tool for all applications. You can simple write `db.list('items').auditTrail().subscribe(console.log)` and check the events in the console as they occur.\n\n**When would you not use it?** - When you just need a list of data. This is a more advanced usage of AngularFireDatabase.\n\n### Limiting events\n\nThere are four child events: `\"child_added\"`, `\"child_changed\"`, `\"child_removed\"`, and `\"child_moved\"`. Each streaming method listens to all four by default. However, your site may only be intrested in one of these events. You can specify which events you'd like to use through the first parameter of each method:\n\n```ts\nthis.itemsRef = db.list('items');\nthis.itemsRef.snapshotChanges(['child_added'])\n  .subscribe(actions => {\n    actions.forEach(action => {\n      console.log(action.type);\n      console.log(action.key);\n      console.log(action.payload.val());\n    });\n  });\n```\n\n## Saving data\n\n### API Summary\n\nThe table below highlights some of the common methods on the `AngularFireList`.\n\n| method   |                    | \n| ---------|--------------------| \n| `push(value: T)` | Creates a new record on the list, using the Realtime Database's push-ids. | \n| `update(keyRefOrSnap: string, value: T)` | Firebase | AFUnwrappedSnapshot, value: Object) | Updates an existing item in the array. Accepts a key, database reference, or an unwrapped snapshot. |\n| `remove(key: string?)` | Deletes the item by key. If no parameter is provided, the entire list will be deleted. |\n\n## Returning promises\n\nEach data operation method in the table above returns a promise. However,\nyou should rarely need to use the completion promise to indicate success, \nbecause the realtime database keeps the list in sync. \n\nThe promise can be useful to chain multiple operations, catching possible errors\nfrom security rules denials, or for debugging.\n\n```ts\nconst promise = db.list('items').remove();\npromise\n  .then(_ => console.log('success'))\n  .catch(err => console.log(err, 'You do not have access!'));\n```\n\n### Adding new items\n\nUse the `push()` method to add new items on the list.\n\n```ts\nconst itemsRef = db.list('items');\nitemsRef.push({ name: newName });\n```\n\n### Replacing items in the list using `set`\n\nUse the `set()` method to update existing items.\n\n```ts\nconst itemsRef = db.list('items');\n// to get a key, check the Example app below\nitemsRef.set('key-of-some-data', { size: newSize });\n```\n\nReplaces the current value in the database with the new value specified as the parameter. This is called a destructive update, because it deletes everything currently in place and saves the new value.\n\n### Updating items in the list using `update`\n\nUse the `update()` method to update existing items.\n\n```ts\nconst itemsRef = db.list('items');\n// to get a key, check the Example app below\nitemsRef.update('key-of-some-data', { size: newSize });\n```\n\nNote that this updates the current value with in the database with the new value specified as the parameter. This is called a non-destructive update, because it only updates the values specified.\n\n### Removing items from the list\nUse the `remove()` method to remove data at the list item's location.\n\n```ts\nconst itemsRef = db.list('items');\n// to get a key, check the Example app below\nitemsRef.remove('key-of-some-data');\n```\n\n## Deleting the entire list\n\nIf you omit the `key` parameter from `.remove()` it deletes the entire list.\n\n```ts\nconst itemsRef = db.list('items');\nitemsRef.remove();\n```\n\n### Example\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase, AngularFireList } from '@angular/fire/compat/database';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <ul>\n    <li *ngFor=\"let item of items | async\">\n      <input type=\"text\" #updatetext [value]=\"item.text\" />\n      <button (click)=\"updateItem(item.key, updatetext.value)\">Update</button>\n      <button (click)=\"deleteItem(item.key)\">Delete</button>\n    </li>\n  </ul>\n  <input type=\"text\" #newitem />\n  <button (click)=\"addItem(newitem.value)\">Add</button>\n  <button (click)=\"deleteEverything()\">Delete All</button>\n  `,\n})\nexport class AppComponent {\n  itemsRef: AngularFireList<any>;\n  items: Observable<any[]>;\n  constructor(db: AngularFireDatabase) {\n    this.itemsRef = db.list('messages');\n    // Use snapshotChanges().map() to store the key\n    this.items = this.itemsRef.snapshotChanges().pipe(\n      map(changes => \n        changes.map(c => ({ key: c.payload.key, ...c.payload.val() }))\n      )\n    );\n  }\n  addItem(newName: string) {\n    this.itemsRef.push({ text: newName });\n  }\n  updateItem(key: string, newText: string) {\n    this.itemsRef.update(key, { text: newText });\n  }\n  deleteItem(key: string) {\n    this.itemsRef.remove(key);\n  }\n  deleteEverything() {\n    this.itemsRef.remove();\n  }\n}\n```\n\n### [Next Step: Querying lists](querying-lists.md)\n"
  },
  {
    "path": "docs/compat/rtdb/objects.md",
    "content": "# 2. Retrieving data as objects\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n> The `AngularFireObject` is a service for manipulating and streaming object data.\n\nThe `AngularFireObject` service is not created by itself, but through the `AngularFireDatabase` service.\n\nThe guide below demonstrates how to retrieve, save, and remove data as objects.\n\n## Injecting the `AngularFireDatabase` service\n\n**Make sure you have bootstrapped your application for AngularFire. See the Installation guide for bootstrap setup.**\n\n`AngularFireDatabase` is a service which can be injected through the constructor of your Angular component or `@Injectable()` service.\n\nIf you've followed the earlier step \"Installation and Setup\"  your `/src/app/app.component.ts` should look like below. \n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase } from '@angular/fire/compat/database';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: 'app.component.html',\n  styleUrls: ['app.component.css']\n})\nexport class AppComponent {\n  items: Observable<any[]>;\n  constructor(db: AngularFireDatabase) {\n    this.items = db.list('items').valueChanges();\n  }\n}\n```\n\nIn this section, we're going to modify the `/src/app/app.component.ts`  to retrieve data as object.\n\n## Create an object binding\n\n```ts\nconst relative = db.object('item').valueChanges();\n```\n\n### Retrieve data\n\nTo get the object in realtime, create an object binding as a property of your component or service.\n\nThen in your template, you can use the `async` pipe to unwrap the binding.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase } from '@angular/fire/compat/database';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <h1>{{ (item | async)?.name }}</h1>\n  `,\n})\nexport class AppComponent {\n  item: Observable<any>;\n  constructor(db: AngularFireDatabase) {\n    this.item = db.object('item').valueChanges();\n  }\n}\n```\n\n## Saving data\n\n### API Summary\n\nThe table below highlights some of the common methods on the `AngularFireObject`.\n\n| method   |                    | \n| ---------|--------------------| \n| `set(value: T)`      | Replaces the current value in the database with the new value specified as the parameter. This is called a **destructive** update, because it deletes everything currently in place and saves the new value. | \n| `update(value: T)`   | Updates the current value with in the database with the new value specified as the parameter. This is called a **non-destructive** update, because it only updates the values specified. |\n| `remove()`   | Deletes all data present at that location. Same as calling `set(null)`. |\n\n## Returning promises\n\nEach data operation method in the table above returns a promise. However,\nyou should rarely need to use the completion promise to indicate success, \nbecause the realtime database keeps the object in sync. \n\nThe promise can be useful to chain multiple operations, catching possible errors from security rules denials, or for debugging.\n\n```ts\nconst promise = db.object('item').remove();\npromise\n  .then(_ => console.log('success'))\n  .catch(err => console.log(err, 'You dont have access!'));\n```\n\n### Saving data\n\nUse the `set()` method for **destructive updates**.\n\n```ts\nconst itemRef = db.object('item');\nitemRef.set({ name: 'new name!'});\n```\n\n### Updating data\n\nUse the `update()` method for **non-destructive updates**.\n\n```ts\nconst itemRef = db.object('item');\nitemRef.update({ age: newAge });\n```\n\n**Only objects are allowed for updates, not primitives**. This is because\nusing an update with a primitive is the exact same as doing a `.set()` with a primitive.\n\n### Deleting data\n\nUse the `remove()` method to remove data at the object's location.\n\n```ts\nconst itemRef = db.object('item');\nitemRef.remove();\n```\n\n**Example app**: \n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase, AngularFireObject } from '@angular/fire/compat/database';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <h1>{{ item | async | json }}</h1>\n  <input type=\"text\" #newname placeholder=\"Name\" />\n  <input type=\"text\" #newsize placeholder=\"Size\" />\n  <br />\n  <button (click)=\"save(newname.value)\">Set Name</button>\n  <button (click)=\"update(newsize.value)\">Update Size</button>\n  <button (click)=\"delete()\">Delete</button>\n  `,\n})\nexport class AppComponent {\n  itemRef: AngularFireObject<any>;\n  item: Observable<any>;\n  constructor(db: AngularFireDatabase) {\n    this.itemRef = db.object('item');\n    this.item = this.itemRef.valueChanges();\n  }\n  save(newName: string) {\n    this.itemRef.set({ name: newName });\n  }\n  update(newSize: string) {\n    this.itemRef.update({ size: newSize });\n  }\n  delete() {\n    this.itemRef.remove();\n  }\n}\n```\n\n## Retrieving the snapshot\n\nAngularFire `valueChanges()` unwraps the Firebase DataSnapshot by default, but you can get the data as the original snapshot by using the `snapshotChanges()` option.\n\n```ts\nthis.itemRef = db.object('item');\nthis.itemRef.snapshotChanges().subscribe(action => {\n  console.log(action.type);\n  console.log(action.key)\n  console.log(action.payload.val())\n});\n```\n\n## Querying?\n\nBecause `AngularFireObject` synchronizes objects from the realtime database, sorting will have no effect for queries that are not also limited by a range. For example, when paginating you would provide a query with a sort and filter. Both the sort operation and the filter operation affect which subset of the data is returned by the query; however, because the resulting object is simply json, the sort order will not be preseved locally. Hence, for operations that require sorting, you are probably looking for a [list](lists.md)\n\n### [Next Step: Retrieving data as lists](lists.md)\n"
  },
  {
    "path": "docs/compat/rtdb/querying-lists.md",
    "content": "# 4. Querying lists\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n## Creating a query with primitive/scalar values\n\nQueries are created by building on the [`firebase.database.Reference`](https://firebase.google.com/docs/reference/js/firebase.database.Reference).\n\n```ts\ndb.list('/items', ref => ref.orderByChild('size').equalTo('large'))\n```\n\n### Query options\n\n| Method   | Purpose            |\n| ---------|--------------------|\n| `orderByChild` | Specify a child to order by. |\n| `orderByKey` | Boolean to order by Firebase Database keys. |\n| `orderByValue` | Specify a value to order by. |\n| ~~`orderByPriority`~~<sup>1</sup> | Boolean to order by Firebase Database priority.|\n| `equalTo`<sup>2</sup> | Limit list to items that contain certain value. |\n| `limitToFirst` | Sets the maximum number of items to return from the beginning of the ordered list of results. |\n| `limitToLast` | Sets the maximum number of items to return from the end of the ordered list of results. |\n| `startAt`<sup>2</sup> | Return items greater than or equal to the specified key or value, depending on the order-by method chosen. |\n| `endAt`<sup>2</sup> | Return items less than or equal to the specified key or value, depending on the order-by method chosen. |\n\n<sup>1</sup> [This is the old way of doing things and is no longer recommended for use](https://youtu.be/3WTQZV5-roY?t=3m). Anything you can achieve with `orderByPriority` you should be doing with `orderByChild`.\n\n<sup>2</sup> The Firebase SDK supports an optional `key` parameter for [`startAt`](https://firebase.google.com/docs/reference/js/firebase.database.Reference#startAt), [`endAt`](https://firebase.google.com/docs/reference/js/firebase.database.Reference#endAt), and [`equalTo`](https://firebase.google.com/docs/reference/js/firebase.database.Reference#equalTo) when ordering by child, value, or priority. You can specify the `key` parameter using an object literal that contains the `value` and the `key`. For example: `startAt: { value: 'some-value', key: 'some-key' }`.\n\nTo learn more about how sorting and ordering data works in Firebase, check out the Firebase documentation on [working with lists of data](https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data).\n\n## Invalid query combinations\n\n**Queries can only be ordered by one method.** This means you can only specify\n`orderByChild`, `orderByKey`, `orderByPriority`, or `orderByValue`.\n\n```ts\n// WARNING: Do not copy and paste. This will not work!\nref.orderByChild('size').equalTo('large').orderByKey(true)\n```\n\nYou can only use `limitToFirst` or `limitToLast`, but not both in combination.\n\n```ts\n// WARNING: Do not copy and paste. This will not work!\nref.limitToFirst(10).limitToLast(100)\n```\n\n## Dynamic querying\n\nTo enable dynamic queries one should lean on RxJS Operators like `switchMap`.\n\nAn RxJS Subject is imported below. A Subject is like an Observable, but can multicast to many Observers. Subjects are like EventEmitters: they maintain a registry of many listeners. See, [What is a Subject](http://reactivex.io/rxjs/manual/overview.html#subject) for more information.\n\nWhen we call [`switchMap` on the Subject](https://www.learnrxjs.io/operators/transformation/switchmap.html), we can map each value to a new Observable; in this case a database query.\n\n```ts\nconst size$ = new Subject<string>();\nconst queryObservable = size$.pipe(\n  switchMap(size => \n    db.list('/items', ref => ref.orderByChild('size').equalTo(size)).valueChanges()\n  )\n);\n\n// subscribe to changes\nqueryObservable.subscribe(queriedItems => {\n  console.log(queriedItems);  \n});\n\n// trigger the query\nsize$.next('large');\n\n// re-trigger the query!!!\nsize$.next('small');\n```\n\n**Example app:**\n \n[See this example in action on StackBlitz](https://stackblitz.com/edit/angularfire-db-api-s8ip7m).\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase, AngularFireAction } from '@angular/fire/compat/database';\nimport { Observable, Subscription, BehaviorSubject } from 'rxjs';\nimport { switchMap } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <h1>Firebase widgets!</h1>\n  <div *ngIf=\"items$ | async; let items; else loading\">\n    <ul>\n      <li *ngFor=\"let item of items\">\n        {{ item.payload.val().text }}\n        <code>{{ item.payload.key }}</code>\n      </li>\n    </ul>\n    <div *ngIf=\"items.length === 0\">No results, try clearing filters</div>\n  </div>\n  <ng-template #loading>Loading&hellip;</ng-template>\n  <div>\n    <h4>Filter by size</h4>\n    <button (click)=\"filterBy('small')\">Small</button>\n    <button (click)=\"filterBy('medium')\">Medium</button>\n    <button (click)=\"filterBy('large')\">Large</button>\n    <button (click)=\"filterBy('x-large')\">Extra Large</button>\n    <button (click)=\"filterBy(null)\" *ngIf=\"this.size$.getValue()\">\n      <em>clear filter</em>\n    </button>\n  </div>\n  `,\n})\nexport class AppComponent {\n  items$: Observable<AngularFireAction<firebase.database.DataSnapshot>[]>;\n  size$: BehaviorSubject<string|null>;\n  \n  constructor(db: AngularFireDatabase) {\n    this.size$ = new BehaviorSubject(null);\n    this.items$ = this.size$.pipe(\n      switchMap(size => \n        db.list('/items', ref =>\n          size ? ref.orderByChild('size').equalTo(size) : ref\n        ).snapshotChanges()\n      )\n    );\n  }\n  filterBy(size: string|null) {\n    this.size$.next(size);\n  }\n}\n```\n\n**To run the above example as is, you need to have sample data in you firebase database with the following structure:**\n \n ```json\n{\n  \"items\": {\n    \"a\" : {\n      \"size\" : \"small\",\n      \"text\" : \"small thing\"\n    },\n    \"b\" : {\n      \"size\" : \"medium\",\n      \"text\" : \"medium sample\"\n    },\n    \"c\" : {\n      \"size\" : \"large\",\n      \"text\" : \"large widget\"\n    }\n  }\n}\n ```\n\n### [Next Step: Getting started with Firebase Authentication](../auth/getting-started.md)\n"
  },
  {
    "path": "docs/compat/storage/storage.md",
    "content": "# AngularFireStorage\n\n> Cloud Storage is designed to help you quickly and easily store and serve user-generated content, such as photos and videos.\n\n> **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).\n\n### Import the `NgModule`\n\nCloud Storage for AngularFire is contained in the `@angular/fire/storage` module namespace. Import the `AngularFireStorageModule` in your `NgModule`. This sets up the `AngularFireStorage` service for dependency injection.\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireStorageModule } from '@angular/fire/compat/storage';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireStorageModule\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\nThe `BUCKET` injection token can be used to customise the storage bucket.\n\n```ts\nimport {AngularFireStorageModule, BUCKET } from '@angular/fire/compat/storage';\n\n@NgModule({\n  providers: [\n    { provide: BUCKET, useValue: 'my-bucket-name' }\n  ],\n  ...\n})\nexport class AppModule {}\n```\n\n### Injecting the AngularFireStorage service\n\nOnce the `AngularFireStorageModule` is registered you can inject the `AngularFireStorage` service.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/compat/storage';\n\n@Component({\n  selector: 'app-component',\n  template: ``\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) { }\n}\n```\n\n### Uploading blobs\n\nThere are three options for uploading files.\n\n\n| method   |                    |\n| ---------|--------------------|\n| `put(data: Blob, metadata?: storage.UploadMetadata): AngularFireUploadTask` | Starts the upload of the blob to the storage reference's path. Returns an `AngularFireUploadTask` for upload monitoring. |\n| `putString(data: string, format?: StringFormat, metadata?: UploadMetadata): AngularFireUploadTask` | Updates an existing item in the array. Accepts a key, database reference, or an unwrapped snapshot. |\n| `upload(path: string, data: StringFormat, metadata?: UploadMetadata): AngularFireUploadTask` | Upload or update a new file to the storage reference's path. Returns an `AngularFireUploadTask` for upload monitoring. |\n\n### Examples\n\n#### Uploading blobs with put\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/compat/storage';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <input type=\"file\" (change)=\"uploadFile($event)\">\n  `\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) { }\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const ref = this.storage.ref(filePath);\n    const task = ref.put(file);\n  }\n}\n```\n\n#### Uploading blobs with putString\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/compat/storage';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <input type=\"file\" (change)=\"uploadFile($event)\">\n  `\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) { }\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const ref = this.storage.ref(filePath);\n    const task = ref.putString(file);\n  }\n}\n```\n\n#### Uploading files with upload\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/compat/storage';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <input type=\"file\" (change)=\"uploadFile($event)\">\n  `\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) { }\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const task = this.storage.upload(filePath, file);\n  }\n}\n```\n\n### Monitoring upload percentage\n\nAn `AngularFireUploadTask` has methods for observing upload percentage as well as the final download URL.\n\n| method   |                    |\n| ---------|--------------------|\n| `snapshotChanges(): Observable<FirebaseStorage.UploadTaskSnapshot>` | Emits the raw `UploadTaskSnapshot` as the file upload progresses. |\n| `percentageChanges(): Observable<number>` | Emits the upload completion percentage. |\n| `getDownloadURL(): Observable<any>` | Emits the download url when available |\n\n#### Example Usage\n\nThe method `getDownloadURL()` doesn't rely on the task anymore, hence, in order to get the url we should use the finalize method from RxJS on top of the storage ref.\n\n```ts\nimport { finalize } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <input type=\"file\" (change)=\"uploadFile($event)\" />\n    <div>{{ uploadPercent | async }}</div>\n    <a [href]=\"downloadURL | async\">{{ downloadURL | async }}</a>\n `\n})\nexport class AppComponent {\n  uploadPercent: Observable<number>;\n  downloadURL: Observable<string>;\n  constructor(private storage: AngularFireStorage) {}\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const fileRef = this.storage.ref(filePath);\n    const task = this.storage.upload(filePath, file);\n\n    // observe percentage changes\n    this.uploadPercent = task.percentageChanges();\n    // get notified when the download URL is available\n    task.snapshotChanges().pipe(\n        finalize(() => this.downloadURL = fileRef.getDownloadURL() )\n     )\n    .subscribe()\n  }\n}\n```\n\n### Downloading Files\n\nA convenient pipe exists for simple in page references.\n\n```ts\n@Component({\n  selector: 'app-root',\n  template: `<img [src]=\"'users/davideast.jpg' | getDownloadURL\" />`\n})\nexport class AppComponent {}\n```\n\nTo download a file you'll need to create a reference and call the `getDownloadURL()` method on an `AngularFireStorageReference`.\n\n```ts\n@Component({\n  selector: 'app-root',\n  template: `<img [src]=\"profileUrl | async\" />`\n})\nexport class AppComponent {\n  profileUrl: Observable<string | null>;\n  constructor(private storage: AngularFireStorage) {\n     const ref = this.storage.ref('users/davideast.jpg');\n     this.profileUrl = ref.getDownloadURL();\n  }\n}\n```\n\n### Managing Metadata\n\nCloud Storage for Firebase allows you to upload and download metadata associated with files. This is useful because you can store important metadata and download it without needing to download the entire file.\n\n### Examples\n\n#### Downloading metadata\n\n```ts\n@Component({\n  selector: 'app-root',\n  template: `<pre><code>{{ meta | async }}</code></pre>`\n})\nexport class AppComponent {\n  meta: Observable<any>;\n  constructor(private storage: AngularFireStorage) {\n     const ref = this.storage.ref('users/davideast.jpg');\n     this.meta = ref.getMetadata();\n  }\n}\n```\n\n#### Uploading metadata with files\n\n```ts\n@Component({\n  selector: 'app-root',\n  template: `\n    <input type=\"file\" (change)=\"uploadFile($event)\" />\n `\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) {}\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const ref = this.storage.ref(filePath);\n    const task = ref.put(file, { customMetadata: { blah: 'blah' } });\n  }\n}\n```\n"
  },
  {
    "path": "docs/compat.md",
    "content": "# AngularFire\nThe official [Angular](https://angular.io/) library for [Firebase](https://firebase.google.com/).\n\n<strong><pre>ng add @angular/fire</pre></strong>\n\n## Compatibility Developer Guide\n\nAngularFire has a new tree-shakable API, you're looking at the documentation for the compatability version of the library. [Find the new developer guide here](../README.md#developer-guide).\n\n[See the v7 upgrade guide for more information on this change.](version-7-upgrade.md).\n\n### Monitor usage of your application in production\n\n> `AngularFireAnalytics` provides a convenient method of interacting with Google Analytics in your Angular application. The provided `ScreenTrackingService` and `UserTrackingService` automatically log events when you're using the Angular Router or Firebase Authentication respectively. [Learn more about Google Analytics](https://firebase.google.com/docs/analytics).\n\n- [Getting started with Google Analytics](compat/analytics/getting-started.md)\n\n### Interacting with your database(s)\n\nFirebase offers two cloud-based, client-accessible database solutions that support realtime data syncing. [Learn about the differences between them in the Firebase Documentation](https://firebase.google.com/docs/firestore/rtdb-vs-firestore).\n\n#### Cloud Firestore\n\n> `AngularFirestore` allows you to work with Cloud Firestore, the new flagship database for mobile app development. It improves on the successes of Realtime Database with a new, more intuitive data model. Cloud Firestore also features richer, faster queries and scales better than Realtime Database.\n\n- [Documents](compat/firestore/documents.md)\n- [Collections](compat/firestore/collections.md)\n- [Querying Collections](compat/firestore/querying-collections.md)\n- [Offline data](compat/firestore/offline-data.md)\n\n#### Realtime Database\n\n> `AngularFireDatabase` allows you to work with the Realtime Database, Firebase's original database. It's an efficient, low-latency solution for mobile apps that require synced states across clients in realtime.\n\n- [Objects](compat/rtdb/objects.md)\n- [Lists](compat/rtdb/lists.md)\n- [Querying lists](compat/rtdb/querying-lists.md)\n\n### Authenticate users\n\n- [Getting started with Firebase Authentication](compat/auth/getting-started.md)\n- [Route users with AngularFire guards](compat/auth/router-guards.md)\n\n### Local Emulator Suite\n\n- [Getting started with Firebase Emulator Suite](compat/emulators/emulators.md)\n\n### Upload files\n\n- [Getting started with Cloud Storage](compat/storage/storage.md)\n\n### Receive push notifications\n\n- [Getting started with Firebase Messaging](compat/messaging/messaging.md)\n\n### **BETA:** Change behavior and appearance of your application without deploying\n\n> Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update. [Learn more about Remote Config](https://firebase.google.com/docs/remote-config).\n\n- [Getting started with Remote Config](compat/remote-config/getting-started.md)\n\n### Monitor your application performance in production\n\n> Firebase Performance Monitoring is a service that helps you to gain insight into the performance characteristics of your iOS, Android, and web apps. [Learn more about Performance Monitoring](https://firebase.google.com/docs/perf-mon).\n\n- [Getting started with Performance Monitoring](compat/performance/getting-started.md)\n\n### Directly call Cloud Functions\n\n- [Getting started with Callable Functions](compat/functions/functions.md)\n"
  },
  {
    "path": "docs/database.md",
    "content": "<img align=\"right\" width=\"30%\" src=\"images/database-illo_1x.png\">\n\n<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Realtime Database\n</small>\n\n# Realtime Database\n\nStore and sync data with our NoSQL cloud database. Data is synced across all clients in realtime, and remains available when your app goes offline.\n\nThe Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. When you build cross-platform apps with our iOS, Android, and JavaScript SDKs, all of your clients share one Realtime Database instance and automatically receive updates with the newest data. [Learn more about the Realtime Database](https://firebase.google.com/docs/database).\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a Database instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideDatabase, getDatabase } from '@angular/fire/database';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideDatabase(() => getDatabase()),\n    ...\n  ],\n  ...\n})\n```\n\nNext inject `Database` into your component:\n\n```ts\nimport { Component, inject } from '@angular/core';\nimport { Database } from '@angular/fire/database';\n\n@Component({...})\nexport class DepartmentComponent {\n  private database = inject(Database);\n  ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nJust change your imports from `import { ... } from 'firebase/database'` to `import { ... } from '@angular/fire/database'` and follow the official documentation.\n\n[Getting Started](https://firebase.google.com/docs/database/web/start) | [API Reference](https://firebase.google.com/docs/reference/js/database)\n\n## Convenience observables\n\nAngularFire provides observables to allow convenient use of the Realtime Database with RXJS.\n\n### `object`\n\nThe `object()` function creates an observable that emits object changes.\n\n|                 |                                          |\n|-----------------|------------------------------------------|\n| **function**    | `object(ref)`                               |\n| **params**      | ref: `Reference`  |\n| **return**      | `Observable<QueryChange>`                |\n\n### `objectVal`\n\nThe `objectVal` function creates an observable that emits an array of object values, optionally with a mapped key.\n\n|                 |                                                       |\n|-----------------|-------------------------------------------------------|\n| **function**    | `objectVal(query, options?)`                                              |\n| **params**      | query: `Reference\\|Query`, options?: { keyField?: `string` } |\n| **return**      | `Observable<T>`                           |\n\n### `list`\n\nThe `list()` function creates an observable that emits a sorted array for each child event change. The optional `events` parameter will filter which child events populate the array.\n\n|                 |                                                       |\n|-----------------|-------------------------------------------------------|\n| **function**    | `list(ref, options?)`                                              |\n| **params**      | ref: `Reference\\|Query`, options?: { events?: `ListenEvent[]` } |\n| **return**      | `Observable<QueryChange[]>`                           |\n\n### `listVal`\n\nThe `listVal()` function creates an observable that emits an object mapped to its value, and optionally its key.\n\n|                 |                                                       |\n|-----------------|-------------------------------------------------------|\n| **function**    | `listVal(query, options?)`                            |\n| **params**      | ref: `Reference\\|Query`, options?: { keyField?: `string` } |\n| **return**      | `Observable<T \\| null>`                                            |\n\n### `stateChanges`\n\nThe `stateChanges()` function creates an observable that emits each time a change occurs at the reference or query passed. This is useful for tracking the changes in your list. The optional `events` parameter will filter which child events populate the array.\n\n|                 |                                                      |\n|-----------------|------------------------------------------------------|\n| **function**    | `stateChanges(ref, options?)`                                     |\n| **params**      | ref: `Reference\\|Query`, options:? { events?: `ListenEvent[]` } |\n| **return**      | `Observable<QueryChange>`                          |\n\n### `auditTrail`\n\nThe `auditTrail()` function creates an observable that emits the entire state trail. This is useful for debugging or replaying the state of a list in your app. The optional `events` parameter will filter which child events populate the array.\n\n|                 |                                                      |\n|-----------------|------------------------------------------------------|\n| **function**    | `auditTrail(ref, options?)`                                       |\n| **params**      | ref: `Reference\\|Query`, options?: { events?: `ListenEvent[]` } |\n| **return**      | `Observable<QueryChange[]>`                          |\n\n### `fromRef`\n\nThe `fromRef()` function creates an observable that emits reference changes.\n\n|                 |                                          |\n|-----------------|------------------------------------------|\n| **function**    | `fromRef(ref, event)`                              |\n| **params**      | ref: `Reference\\|Query`, event: `ListenEvent` |\n| **return**      | `Observable<QueryChange>`                |\n\n## Connecting to the emulator suite\n\n```ts\nimport { connectDatabaseEmulator, getDatabase, provideDatabase } from '@angular/fire/database';\n\n@NgModule({\n  imports: [\n    provideDatabase(() => {\n      const database = getDatabase();\n      connectDatabaseEmulator(database, 'localhost', 9000);\n      return database;\n    }),\n  ]\n})\n```\n\n## Working with multiple instances\n\n```ts\nimport { provideFirebaseApp, FirebaseApp, initializeApp } from '@angular/fire/app';\nimport { getDatabase, provideDatabase } from '@angular/fire/database';\n\nconst DATABASE_SHARD_URLS = [\n  'https://FOO.firebaseio.com',\n  'https://BAR.firebaseio.com',\n  'https://BAZ.firebaseio.com',\n];\n\n@NgModule({\n  imports: [\n    provideFirebaseApp(() => initializeApp(environment.firebase)),\n    provideDatabase((app: FirebaseApp) => getDatabase(app, DATABASE_SHARD_URLS[0])),\n    provideDatabase((app: FirebaseApp) => getDatabase(app, DATABASE_SHARD_URLS[1])),\n    provideDatabase((app: FirebaseApp) => getDatabase(app, DATABASE_SHARD_URLS[2])),\n  ]\n})\n```\n\n```ts\nimport { DatabaseInstances } from '@angular/fire/database';\n\nconstructor(databases: DatabaseInstances) {\n // databases => Database[]\n}\n```\n"
  },
  {
    "path": "docs/deploy/getting-started.md",
    "content": "# Deploy your application on Firebase Hosting & Functions\n\nIn this guide, we'll look at how to use `@angular/fire` to automatically deploy an Angular application to Firebase hosting or functions by using the Angular CLI.\n\n`@angular/fire` uses Firebase functions to deploy your Angular universal projects, with server-side rendering enabled.\n\n**Angular Universal deployments work with `@nguniversal/*` version 9.0.0 and above**.\n\n## Step 1: add `@angular/fire` to your project\n\nFirst, you need to add the `@angular/fire` package to your project. In your Angular CLI project run:\n\n```shell\nng add @angular/fire\n```\n\n*Note that the command above assumes you have global Angular CLI installed. To install Angular CLI globally run `npm i -g @angular/cli`.*\n\nFirst, the command above will check if you have an Angular universal project. It'll do so by looking at your `angular.json` project, looking for a `server` target for the specified project. If it finds one, it'll ask you if you want to deploy the project in a firebase function.\n\nAfter that it will trigger the `@angular/fire` `ng-add` schematics. The schematics will open a web browser and guide you through the Firebase authentication flow (if you're not signed in already). After you authenticate, you'll see a prompt to select a Firebase hosting project.\n\nThe schematics will do the following:\n\n- Add `@angular/fire` to your list of dependencies\n- Create `firebase.json`, `.firebaserc` files in the root of your workspace. You can use them to configure your firebase hosting deployment. Find more about them [here](https://firebase.google.com/docs/hosting/full-config)\n- Update your workspace file (`angular.json`) by inserting the `deploy` builder\n\nIn the end, your `angular.json` project will look like below:\n\n```json5\n{\n  \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n  \"version\": 1,\n  \"newProjectRoot\": \"projects\",\n  \"projects\": {\n    \"sample-app\": {\n      // ...\n      \"deploy\": {\n        \"builder\": \"@angular/fire:deploy\",\n        \"options\": {} // Here you may find an \"ssr\": true option if you've\n                      // selected that you want to deploy your Angular universal project\n                      // as a firebase function.\n        }\n      }\n  },\n    // ...\n  \"defaultProject\": \"sample-app\"\n  \n}\n```\n\nIf you want to add deployment capabilities to a different project in your workspace, you can run:\n\n```\nng add @angular/fire --project=[PROJECT_NAME]\n```\n\n## Step 2: deploying the project\n\nAs the second step, to deploy your project run:\n\n```\nng deploy --project=[PROJECT_NAME]\n```\n\n*The `--project` option is optional. Learn more [here](https://angular.io/cli/deploy).*\n\nThe command above will trigger:\n\n1. Production build of your application\n2. Deployment of the produced assets to the firebase hosting project you selected during `ng add`\n\nIf you've specified that you want a server-side rendering enabled deployment in a firebase function, the command will also:\n\n1. Create a firebase function in `dist`, which directly consumes `main.js` from your server output directory.\n2. Create `package.json` for the firebase function with the required dependencies.\n3. Deploy the static assets to firebase hosting and your universal server as a Firebase function.\n\nIf you want to preview your Angular Universal project before we deploy it as a Firebase Function you can run:\n\n```\nng deploy --preview\n```\n\nWe'll create the function and a `package.json` in your project output directory. This way, you can later run `firebase serve` in your project root so you can test everything before deploying.\n\n## Step 3: customization\n\nTo customize the deployment flow, you can use the configuration files you're already familiar with from `firebase-tools`. You can find more in the [firebase documentation](https://firebase.google.com/docs/hosting/full-config).\n\n### Configuring Cloud Functions\n\nSetting `functionsNodeVersion` and `functionsRuntimeOptions` in your `angular.json` allow you to customize the version of Node.js Cloud Functions is running and run-time settings like timeout, VPC connectors, and memory.\n\n```json\n\"deploy\": {\n    \"builder\": \"@angular/fire:deploy\",\n    \"options\": {\n        \"functionsNodeVersion\": 12,\n        \"functionsRuntimeOptions\": {\n          \"memory\": \"2GB\",\n          \"timeoutSeconds\": 10,\n          \"vpcConnector\": \"my-vpc-connector\",\n          \"vpcConnectorEgressSettings\": \"PRIVATE_RANGES_ONLY\"\n        }\n    }\n}\n```\n\n### Working with multiple Firebase Projects\n\nIf you have multiple build targets and deploy targets, it is possible to specify them in your `angular.json` or `workspace.json`.\n\nIt is possible to use either your project name or project alias in `firebaseProject`. The setting provided here is equivalent to passing a project name or alias to `firebase deploy --project projectNameOrAlias`.\n\nThe `buildTarget` simply points to an existing build configuration for your project. Most projects have a default configuration and a production configuration (commonly activated by using the `--prod` flag) but it is possible to specify as many build configurations as needed.\n\nYou may specify a `buildTarget` and `firebaseProject` in your `options` as follows:\n\n```json\n\"deploy\": {\n    \"builder\": \"@angular/fire:deploy\",\n    \"options\": {\n        \"buildTarget\": \"projectName:build\",\n        \"firebaseProject\": \"developmentProject\"\n    },\n    \"configurations\": {\n        \"production\": {\n            \"buildTarget\": \"projectName:build:production\",\n            \"firebaseProject\": \"productionProject\"\n        }\n    }\n}\n```\n\nThe above configuration specifies the following:\n\n1. `ng deploy` will deploy the default project with default configuration.\n2. `ng deploy projectName` will deploy the specified project with default configuration.\n3. `ng deploy projectName --prod` or `ng deploy projectName --configuration='production'` will deploy `projectName` with production build settings to your production environment.\n\nAll of the options are optional. If you do not specify a `buildTarget`, it defaults to a production build (`projectName:build:production`). If you do not specify a `firebaseProject`, it defaults to the first matching deploy target found in your `.firebaserc` (where your projectName is the same as your Firebase deploy target name). The `configurations` section is also optional.\n\n### Working with multiple project sites\n\nFor example, if you have muti sites config in firebase.json like this:\n```\n{\n  \"hosting\": [\n    {\n      \"target\": \"custom-site\",\n      \"public\": \"public/my-custom-site\",\n      \"ignore\": [\n        \"firebase.json\",\n        \"**/.*\",\n        \"**/node_modules/**\"\n      ],\n      \"rewrites\": [\n        {\n          \"source\": \"**\",\n          \"destination\": \"/index.html\"\n        }\n      ]\n    }\n  ],\n```\n\nIf you have multiple build targets and deploy targets, it is possible to specify them in your `angular.json` or `workspace.json`.\n\nIt is possible to use either your project name or project alias in `siteTarget`.\n\nYou may specify a `siteTarget` in your `options` as follows:\n\n```json\n\"deploy\": {\n    \"builder\": \"@angular/fire:deploy\",\n    \"options\": {\n        \"buildTarget\": \"projectName:build\",\n        \"firebaseProject\": \"developmentProject\",\n        \"siteTarget\": \"yourDefaultSiteTarget\"\n    },\n    \"configurations\": {\n        \"production\": {\n            \"buildTarget\": \"projectName:build:production\",\n            \"firebaseProject\": \"productionProject\",\n            \"siteTarget\": \"yourProdSiteTarget\"\n        },\n        \"storybook\": {\n            \"buildTarget\": \"projectName:build-storybook\",\n            \"firebaseProject\": \"developmentProject\",\n            \"siteTarget\": \"yourStorybookSiteTarget\"\n        }\n    }\n}\n```\n\nThe above configuration specifies the following:\n\n1. `ng deploy` will deploy the default project with default configuration.\n2. `ng deploy projectName` will deploy the specified project with default configuration.\n3. `ng deploy projectName --configuration=storybook --siteTarget=mySiteTarget` will deploy `projectName` to `mySiteTarget` with configuration`storybook`.\n\nAll of the options are optional\n"
  },
  {
    "path": "docs/firebase.json",
    "content": "{\n  \"firebase\": \"angular-fire-2\",\n  \"public\": \".\",\n  \"redirects\": [\n    {\n      \"source\": \"/\",\n      \"destination\": \"/api\",\n      \"type\": 302\n    }\n  ],\n  \"ignore\": [\n    \"firebase.json\",\n    \"**/.*\",\n    \"**/node_modules/**\"\n  ]\n}\n"
  },
  {
    "path": "docs/firestore.md",
    "content": "<img align=\"right\" width=\"30%\" src=\"images/firestore-illo_1x.png\">\n\n<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Cloud Firestore\n</small>\n\n# Cloud Firestore\n\nCloud Firestore is a flexible, scalable NoSQL database for mobile, web, and server development from Firebase and Google Cloud. It keeps your data in sync across client apps through realtime listeners and offers offline support for mobile and web so you can build responsive apps that work regardless of network latency or Internet connectivity. \n\n[Learn more](https://firebase.google.com/docs/firestore)\n\nCloud Firestore is the API that gives your application access to your database in the cloud or locally in your [emulator](https://firebase.google.com/docs/emulator-suite).\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\nProvide a Firestore instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideFirestore, getFirestore } from '@angular/fire/firestore';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideFirestore(() => getFirestore()),\n    ...\n  ],\n  ...\n}\n```\n\nNext inject `Firestore` into your component:\n\n```typescript\nimport { Component, inject } from '@angular/core';\nimport { Firestore } from '@angular/fire/firestore';\n\n@Component({ ... })\nexport class UserProfileComponent {\n    private firestore = inject(Firestore);\n    ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nUpdate the imports from `import { ... } from 'firebase/firestore'` to `import { ... } from '@angular/fire/firestore'` and follow the official documentation.\n\n[Getting Started](https://firebase.google.com/docs/firestore/quickstart#web-modular-api) | [API Reference](https://firebase.google.com/docs/reference/js/firestore)\n\n### Reading data\n\nIn Cloud Firestore data is stored in `documents` and `documents` are stored in `collections`. The path to data follows `<collection_name>/<document_id>` and continues if there are subcollections. For example, `\"users/ABC12345/posts/XYZ6789\"` represents:\n* `users` collection\n* document id `ABC12345`\n* `posts` collection\n* document id `XYZ6789`\n\n\nLet's explore reading data in Angular using the `collection` and `collectionData` functions.\n\nIn `user-profile.component.ts`:\n\n```typescript\nimport { Firestore, collection, collectionData} from '@angular/fire/firestore';\nimport { Component, inject } from '@angular/core';\n\n@Component ({\n    selector: 'app-user-profile',\n    standalone: true,\n    ...\n})\nexport class UserProfileComponent {\n    private firestore: Firestore = inject(Firestore); // inject Cloud Firestore\n    users$: Observable<UserProfile[]>;\n\n    constructor() {\n        // get a reference to the user-profile collection\n        const userProfileCollection = collection(this.firestore, 'users');\n\n        // get documents (data) from the collection using collectionData\n        this.users$ = collectionData(userProfileCollection) as Observable<UserProfile[]>;\n    }\n}\nexport Interface UserProfile {\n    username: string;\n}\n```\n`collectionData` returns an `observable` that can we can use to display the data in the template. In `user-profile.component.html`:\n\n```html\n    <section>\n        <h1>User Profiles</h1>\n        <ul>\n            <li *ngFor=\"let user of users$ | async\">\n                {{user.username}}\n            </li>\n        </ul>\n    </section>\n```\n\nThe `async` pipe handles unsubscribing from observables.\n\n### Writing data\n\nTo write to Cloud Firestore use the `addDoc` function. It will create a new document at the path specified by the collection. In `user-profile.component.ts`, we'll update the code to add a new document on a `<button>` click.\n\n\n```typescript\nimport { Firestore, collection, collectionData, addDoc} from '@angular/fire/firestore';\nimport { Component, inject } from '@angular/core';\n\n@Component ({\n    selector: 'app-user-profile',\n    standalone: true,\n    ...\n})\nexport class UserProfileComponent {\n    private firestore: Firestore = inject(Firestore); // inject Cloud Firestore\n    users$: Observable<UserProfile[]>;\n    usersCollection: CollectionReference;\n    \n    constructor() {...}\n\n    addUserProfile(username: string) {\n        if (!username) return;\n\n        addDoc(this.usersCollection, <UserProfile> { username }).then((documentReference: DocumentReference) => {\n            // the documentReference provides access to the newly created document\n        });\n    }\n}\nexport Interface UserProfile {\n    username: string;\n}\n```\nIn the `addUserProfile` method we use a reference to the `this.usersCollection` and provide `UserProfile` data to the the `addDoc` function. `addDoc` returns a promise that can be used to respond to the successful addition of the data. Errors can also be caught here.\n\n## Learn More\nMore information on API methods and other functions can be found on the [Firebase Official Docs](https://firebase.google.com/docs/reference/js/firestore_)\n"
  },
  {
    "path": "docs/functions.md",
    "content": "<img align=\"right\" width=\"30%\" src=\"images/functions-illo_1x.png\">\n\n<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Cloud Functions\n</small>\n\n# Cloud Functions\n\nThe Cloud Functions for Firebase client SDKs let you call functions directly from a Firebase app. To call a function from your app in this way, write and deploy an HTTPS Callable function in Cloud Functions, and then add client logic to call the function from your app.\n\n[Learn More](https://firebase.google.com/docs/functions/get-started)\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a Cloud Functions instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideFunctions, getFunctions } from '@angular/fire/functions';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideFunctions(() => getFunctions()),\n    ...\n  ],\n  ...\n})\n```\n\nNext inject `Functions` into your component:\n\n```ts\nimport { Component, inject} from '@angular/core';\nimport { Functions } from '@angular/fire/functions';\n\n@Component({ ... })\nexport class AppComponent {\n  private functions = inject(Functions);\n  ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nUpdate the imports from `import { ... } from 'firebase/functions'` to `import { ... } from '@angular/fire/functions'` and follow the official documentation.\n\n[Call functions from your app](https://firebase.google.com/docs/functions/callable?gen=2nd#web-modular-api) | [API Reference](https://firebase.google.com/docs/reference/js/functions)\n"
  },
  {
    "path": "docs/install-and-setup.md",
    "content": "# AngularFire Quickstart\n\n### 1. Create a new project\n\n```bash\n# Using yarn create\nyarn create @angular <project-name>\ncd <project-name>\n```\nor \n\n```bash\n# Using npm create\nnpm create @angular <project-name>\ncd <project-name>\n```\n\noptionally installing the tooling directly:\n```bash\n# Installing the tooling directly\nnpm install -g @angular/cli\nng new <project-name>\ncd <project-name>\n```\n\nThe Angular CLI's `new` command will set up the latest Angular build in a new project structure.\n\n### 2. Install AngularFire and Firebase\n\n```bash\nng add @angular/fire\n```\n\nNow that you have a new project setup, install AngularFire and Firebase from npm. This will complete the following tasks:\n\n1. Add Firebase config to environments variables\n2. Configure `@NgModule` for the `AngularFireModule`\n\n### 3. Inject `Firestore`\n\nOpen `/src/app/app.component.ts`, and make the following changes to :\n\n```ts\nimport { Component, inject } from '@angular/core';\nimport { AsyncPipe } from '@angular/common';\nimport { Firestore } from '@angular/fire/firestore';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: 'app.component.html',\n  styleUrls: ['app.component.css'],\n  imports: [AsyncPipe],\n})\nexport class AppComponent {\n  firestore: Firestore = inject(Firestore);\n\n  constructor() {\n\n  }\n}\n```\n\n### 4. Bind a Firestore collection to a list\n\nIn `/src/app/app.component.ts`:\n\n```ts\nimport { Component, inject } from '@angular/core';\nimport { AsyncPipe } from '@angular/common';\nimport { Observable } from 'rxjs';\nimport { Firestore, collection, collectionData } from '@angular/fire/firestore';\n\n@Component({\n  selector: 'app-root',\n  standalone: true,\n  imports: [AsyncPipe],\n  templateUrl: 'app.component.html',\n  styleUrls: ['app.component.css']\n})\nexport class AppComponent {\n  firestore: Firestore = inject(Firestore);\n  items$: Observable<any[]>;\n\n  constructor() {\n    const aCollection = collection(this.firestore, 'items')\n    this.items$ = collectionData(aCollection);\n  }\n}\n```\n\nOpen `/src/app/app.component.html`:\n\n```html\n<ul>\n  @for (item of items$ | async; track item) {\n    <li>{{ item.name }}</li>\n  }\n</ul>\n```\n\n### 5. Run your app locally\n\n```bash\nng serve\n```\n\nYour Angular app will compile and serve locally, visit it we should find an empty list.\n\nIn another tab [start adding data to an `items` collection in Firestore](https://firebase.google.com/docs/firestore/manage-data/add-data). *As we're not authenticating users yet, be sure to start Firestore in **test mode** or allow reading from the `items` collection in Security Rules (`allow read: if true`).*\n\nOnce you've created a `items` collection and are inserting documents, you should find data streaming into your Angular application and being rendered in your browser.\n\n### 6. Deploy your app\n\nFinally, we can deploy the application to Firebase hosting:\n\n```bash\nng deploy\n```\n"
  },
  {
    "path": "docs/install-angular-cli-windows10.md",
    "content": "# Installing Angular CLI on Windows 10\n\n> There had been installation issues of `@angular/cli` on Windows 10 system. Most of the time these errors are related to Python dependencies and node-gyp.\n\nSomething as below :\n\n```bash\nexecSync@1.0.2 install C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\angu\nlar-cli\\node_modules\\angular2-template-loader\\node_modules\\codecov\\node_modules\\\nexecSync\n node install.js\n\n[execsync v1.0.2] Attempting to compile native extensions.\n{ [Error: spawn node-gyp ENOENT]\n  code: 'ENOENT',\n  errno: 'ENOENT',\n  syscall: 'spawn node-gyp',\n  path: 'node-gyp',\n  spawnargs: [ 'rebuild' ] }\n[execSync v1.0.2]\n    Native code compile failed!!\n    Will try to use win32 extension.\nnpm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie h\nttps://nodesecurity.io/advisories/130\nnpm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher\nto avoid a RegExp DoS issue\nnpm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher\n to avoid a RegExp DoS issue\n\n node-zopfli@2.0.1 install C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\a\nngular-cli\\node_modules\\compression-webpack-plugin\\node_modules\\node-zopfli\n node-pre-gyp install --fallback-to-build\n.......................\n```\n\nTo resolve this issue, make sure you've upgraded to the latest version of **NPM** and try installing `@angular/cli` again. This seems to have worked on certain scenarios.\n\nIf the above doesn't work then the below steps should help. Please ensure all the commands are executed as an **Administrator**.\n\n## Steps:\n\n### 1) Install `node-gyp` from [here](https://github.com/nodejs/node-gyp) using NPM\n\n```bash\nnpm install -g node-gyp\n```\n\n### 2) Install Windows build tools from [here](https://github.com/felixrieseberg/windows-build-tools) using NPM\n\n```bash\nnpm install --global windows-build-tools\n```\n\n*This will also install Python\n\n### 3) Install Angular CLI\n\n```bash\nnpm install -g @angular/cli\n```\n\nThis should install `@angular/cli` without errors.\n\n#### Post this installation, follow the installation [guide](https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md) to install AngularFire and everything should work as expected.\n\n\n### Note:\n\nWhen you start your app using `ng serve` in the console, you might still see the below errors. Despite these errors, the application should work as expected and should be able to talk to Firebase.\n\n```bash\nERROR in [default] C:\\angularFire2Test\\node_modules\\angularfire2\\interfaces.d.ts:12:34\nCannot find namespace 'firebase'.\n\nERROR in [default] C:\\angularFire2Test\\src\\typings.d.ts:6:12\nSubsequent variable declarations must have the same type.  Variable 'require' must be of type 'NodeRequire',\nbut here has type 'any'.\n\nERROR in [default] C:\\angularFire2Test\\src\\typings.d.ts:7:12\nSubsequent variable declarations must have the same type.  Variable 'module' must be of type 'NodeModule',\nbut here has type 'any'.\n```\n"
  },
  {
    "path": "docs/install-firebase-tools.md",
    "content": "# Firebase Tools Install and Setup\n\n### 1. Install package\n\n```bash\nnpm install -g firebase-tools\n```\n\nor with `yarn`\n\n```bash\nyarn global add firebase-tools\n```\n\nYou can also choose to install it as a dependency for your project rather than globally\n\n```bash\nnpm install --save-dev firebase-tools\n```\n\nor with `yarn`\n\n```bash\nyarn add -D firebase-tools\n```\n\n### 2. Configure Firebase Tools\n\nIn your projects root directory run:\n\n```bash\nfirebase init\n```\n\nor if your installed it within your project rather than globally\n\n```bash\nnpx firebase init\n```\n\nor with `yarn`\n\n```bash\nyarn firebase init\n```\n\nThis will ask you to login if you are not logged in already, the process will take you through a browser\nredirect to log you into Firebase.\n\n### 3. Choose what Firebase features\n\n`firebase-tools` displays Firebase features you want to configure.\n\n```bash\n? Which Firebase features do you want to set up for this directory? Press Space \nto select features, then Enter to confirm your choices. (Press <space> to select\n, <a> to toggle all, <i> to invert selection, and <enter> to proceed)\n ◯ Realtime Database: Configure a security rules file for Realtime Database and \n(optionally) provision default instance\n ◯ Firestore: Configure security rules and indexes files for Firestore\n ◯ Functions: Configure a Cloud Functions directory and its files\n ◯ Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub \nAction deploys\n ◯ Hosting: Set up GitHub Action deploys\n(Move up and down to reveal more choices)\n```\n\n### 4. Connect your repo to a Firebase project\n\nThe CLI will then walk you through making sure your repo is configured with a Firebase project.\n\n```bash\n? Please select an option: \n  ◯ Use an existing project \n  ◯ Create a new project \n  ◯ Add Firebase to an existing Google Cloud Platform project \n  ◯ Don't set up a default project\n  ```"
  },
  {
    "path": "docs/messaging.md",
    "content": "<img align=\"right\" width=\"30%\" src=\"images/cloud-messaging-illo_1x.png\">\n\n<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Cloud Messaging\n</small>\n\n# Cloud Messaging\n\nFirebase FCM allows you to register devices with unique FCM tokens, that you can later programtically send notifications to using Firebase Cloud Functions. It is up to the application to update these tokens in Firebase if you want to use them in other layers of your application, i.e send a notification to all administrators, etc. In that case, you would likely want to store your fcm tokens on your user collection, or a sub collection or another collection with different permissions.\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a Cloud Messaging instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideMessaging, getMessaging } from '@angular/fire/messaging';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideMessaging(() => getMessaging()),\n    ...\n  ],\n  ...\n})\n```\n\nNext inject `Messaging` into your component:\n\n```ts\nimport { Component, inject} from '@angular/core';\nimport { Messaging } from '@angular/fire/messaging';\n\n@Component({ ... })\nexport class AppComponent {\n  private messaging = inject(Messaging);\n  ...\n}\n```\n\n# Create a Firebase Messaging Service Worker \n\nThere are two parts to Firebase Messaging, a Service Worker and the DOM API. Angular Fire Messaging allows you to request permission, get tokens, delete tokens, and subscribe to messages on the DOM side. To register to receive notifications you need to set up the Service Worker. [The official Firebase documentation for setting up the details exactly how to do that](https://firebase.google.com/docs/cloud-messaging/js/client).\n\n#### Create your firebase-messaging-sw.js file in your src/assets folder\n\n*Note: When copying the below file, make sure your firebase version in your installation matches the version your are importing from below*\n\nIt may be wise to use file replacements or environments here for different environments\n\n```\n// This sample application is using 9.22, make sure you are importing the same version\n\nimport { initializeApp } from \"https://www.gstatic.com/firebasejs/9.22.0/firebase-app.js\";\nimport { getMessaging } from \"https://www.gstatic.com/firebasejs/9.22.0/firebase-messaging-sw.js\";\n\nconst firebaseApp = initializeApp({\n  apiKey: \"\",\n  authDomain: \"\",\n  projectId: \"\",\n  storageBucket: \"\",\n  messagingSenderId: \"\",\n  appId: \"\",\n});\n\nconst messaging = getMessaging(firebaseApp);\n```\n\n# Example messaging service\n\n```\nimport { Injectable } from \"@angular/core\";\nimport { Messaging, getToken, onMessage, deleteToken } from \"@angular/fire/messaging\";\nimport { Observable, tap } from \"rxjs\";\n\n@Injectable({\n  providedIn: \"root\",\n})\nexport class FcmService {\n  constructor(private msg: Messaging){\n    Notification.requestPermission().then(\n    (notificationPermissions: NotificationPermission) => {\n      if (notificationPermissions === \"granted\") {\n        console.log(\"Granted\");\n      }\n      if (notificationPermissions === \"denied\") {\n        console.log(\"Denied\");\n      }\n    });\n    navigator.serviceWorker\n      .register(\"/assets/firebase-messaging-sw.js\", {\n        type: \"module\",\n      })\n      .then((serviceWorkerRegistration) => {\n        getToken(this.msg, {\n          vapidKey: `an optional key generated on Firebase for your fcm tokens`,\n          serviceWorkerRegistration: serviceWorkerRegistration,\n        }).then((x) => {\n          console.log('my fcm token', x);\n          // This is a good place to then store it on your database for each user\n        });\n\t});  \n    }\n    this.message$ = new Observable((sub) => onMessage(this.msg, (msg) =>     \n      sub.next(msg))).pipe(\n\t    tap((msg) => {\n\t      console.log(\"My Firebase Cloud Message\", msg);\n\t    })\n    );\n    }\n  deleteToken(){\n    // We can also delete fcm tokens, make sure to also update this on your firestore db if you are storing them as well\n    await deleteToken(this.msg);\n  }\n```\n\n# Testing and Sending Notifications\n\nFirebase will allow you to send a test notification under Engage > Messaging > New Campaign > Notifications. Here you can click send a test message. Additionally, you can send them programmatically through Firebase cloud functions. \n\nHere is a barebones Node example:\n\n```\nexport const sendTestMessage = onRequest(async (_, res) => {\n  try {\n    const message = {\n      notification: {\n        title: \"Test Title\",\n        body: \"Test Body\",\n      },\n      token: \"your token here, you can store these and retreive as you please\",\n    };\n    await admin.messaging().send(message);\n    res.sendStatus(200);\n  } catch (error) {\n    console.error(error);\n    res.sendStatus(500);\n  }\n});\n```\n\nHere is a Node example that listens for a new comment on a collection, then sends a notification, and also adds it to a cache on Firebase so users can click through them.\n\n```\nexports.onPostReply =\n  onDocumentCreated(\"comments/{commentId}\", async (event) => {\n    if (!event) throw new Error(\"No event found for document creation\");\n    const snapshot = event.data;\n    if (!snapshot) {\n      throw new Error(\"No data associated with the event\");\n    }\n    const data = snapshot.data();\n    if (!data.postId) {\n      throw new Error(\"No post ID found\");\n    }\n    const postRef = await firestore.collection(\"posts\").doc(data.postId).get();\n    const postData = postRef.data();\n    if (!postData) {\n      throw new Error(\"No postData found\");\n    }\n    // userUid will be the post author's id.\n    const {userUid} = postData;\n    if (!userUid) {\n      throw new Error(\n        \"Could not find the userUid for the post author for post reply\"\n      );\n    }\n    const messageForNotification = {\n      title: \"You have a new reply on your post\",\n      body: \"\",\n    };\n    await createNotificationAndCache(messageForNotification, userUid);\n  });\n\n  // If you want to cache notifications a number of times, abstracting this\n  // to a function can bring a lot of value.\n  \ninterface NotificationProps {\n  title: string;\n  body: string;\n}\n\nasync function createNotificationAndCache(\n  notificationProps: NotificationProps, userAuthUid: string) {\n  const userRef = await firestore.collection(\"users\").where(\"authUid\", \"==\",\n    userAuthUid).get();\n  const userData = userRef.docs[0].data();\n\n  const promises: Promise<any>[] = [];\n  // This sample application has seperate fcm tokens for web and mobile\n  if (userData.mobileToken) {\n    const message = {\n      notification: notificationProps,\n      token: userData.mobileToken,\n    };\n    const promise = admin.messaging().send(message);\n    promises.push(promise);\n  }\n  if (userData.webToken) {\n    const message = {\n      notification: notificationProps,\n      token: userData.webToken,\n    };\n    const promise = admin.messaging().send(message);\n    promises.push(promise);\n  }\n\n  const notificationCacheValue = {\n    userAuthUid: userAuthUid,\n    tokenTitle: notificationProps.title,\n    tokenBody: notificationProps.body,\n    isActive: true, // This determines whether a notification has been seen\n  };\n\n  promises.push(\n    firestore.collection(\"notificationCache\").add(notificationCacheValue));\n\n  await Promise.all(promises);\n}  ```\n"
  },
  {
    "path": "docs/performance.md",
    "content": "<img align=\"right\" width=\"30%\" src=\"images/performance-illo_1x.png\">\n\n<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Performance Monitoring\n</small>\n\n# Performance Monitoring\n\nFirebase Performance Monitoring is a service that helps you to gain insight into the performance characteristics of your Apple, Android, and web apps.\n\n[Learn More](https://firebase.google.com/docs/perf-mon)\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a Performance instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { providePerformance, getPerformance } from '@angular/fire/performance';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    providePerformance(() => getPerformance()),\n    ...\n  ],\n  ...\n})\n```\n\nNext inject `Performance` into your component:\n\n```ts\nimport { Component, inject} from '@angular/core';\nimport { Performance } from '@angular/fire/performance';\n\n@Component({ ... })\nexport class PerformanceComponent {\n  private performance = inject(Performance);\n  ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nUpdate the imports from `import { ... } from 'firebase/performance'` to `import { ... } from '@angular/fire/performance'` and follow the official documentation.\n\n[Getting Started](https://firebase.google.com/docs/perf-mon/get-started-web) | [API Reference](https://firebase.google.com/docs/reference/js/performance)\n"
  },
  {
    "path": "docs/remote-config.md",
    "content": "<img align=\"right\" width=\"30%\" src=\"images/remote-config-illo_1x.png\">\n\n<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Remote Config\n</small>\n\n# Remote Config\n\nFirebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update.\n\n[Learn More](https://firebase.google.com/docs/remote-config/)\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a Remote Config instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideRemoteConfig, getRemoteConfig } from '@angular/fire/remote-config';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideRemoteConfig(() => getRemoteConfig()),\n    ...\n  ],\n  ...\n})\n```\n\nNext inject `RemoteConfig` into your component:\n\n```ts\nimport { Component, inject} from '@angular/core';\nimport { RemoteConfig } from '@angular/fire/remote-config';\n\n@Component({ ... })\nexport class RemoteConfigComponent {\n  private remoteConfig = inject(RemoteConfig);\n  ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nUpdate the imports from `import { ... } from 'firebase/remote-config'` to `import { ... } from '@angular/fire/remote-config'` and follow the official documentation.\n\n[Getting Started](https://firebase.google.com/docs/remote-config/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/remote-config)\n"
  },
  {
    "path": "docs/storage.md",
    "content": "<img align=\"right\" width=\"30%\" src=\"images/storage-illo_1x.png\">\n\n<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Cloud Storage\n</small>\n\n# Cloud Storage\n\nCloud Storage allows developers to upload and share user generated content such as images, video and more. Data is stored in Google Cloud Storage. \n\n[Learn more](https://firebase.google.com/docs/storage)\n\n## Dependency Injection\n\nAngularFire allows you to work with Firebase Storage via Angular's Dependency Injection.\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a Cloud Storage instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideStorage, getStorage } from '@angular/fire/storage';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideStorage(() => getStorage()),\n    ...\n  ],\n  ...\n})\n```\n\nNext inject `Storage` into your component:\n\n```ts\nimport { Component, inject} from '@angular/core';\nimport { Storage } from '@angular/fire/storage';\n\n@Component({ ... })\nexport class StorageComponent {\n  private storage = inject(Storage);\n  ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nUpdate the imports from `import { ... } from 'firebase/storage'` to `import { ... } from '@angular/fire/storage'` and follow the official documentation.\n\n[Getting Started](https://firebase.google.com/docs/storage/web/start) | [API Reference](https://firebase.google.com/docs/reference/js/storage)\n\n## File Upload Example\n\n```ts\nimport { Component, inject } from '@angular/core';\nimport { Storage, ref, uploadBytesResumable } from '@angular/fire/storage';\n\n@Component({\n    selector: 'app-storage',\n    template: `\n        <h1>Storage</h1>\n        <label for=\"fileUpload\">Choose a File</label>\n        <input id=\"fileUpload\" type=\"file\" #upload>\n        <button (click)=\"uploadFile(upload)\">Upload</button>\n    `,\n})\nexport class StorageComponent {\n    private readonly storage: Storage = inject(Storage);\n\n    uploadFile(input: HTMLInputElement) {\n        if (!input.files) return\n\n        const files: FileList = input.files;\n\n        for (let i = 0; i < files.length; i++) {\n            const file = files.item(i);\n            if (file) {\n                const storageRef = ref(this.storage, file.name);\n                uploadBytesResumable(storageRef, file);\n            }\n        }\n    }\n}\n```"
  },
  {
    "path": "docs/universal/cloud-functions.md",
    "content": "# Deploying your Universal application on Cloud Functions for Firebase\n\nAfter [setting up your application with Angular Universal as outlined in Getting Started](getting-started.md), you're now ready to build your application for Firebase Hosting & Cloud Functions.\n\n> Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers. [Learn more about Cloud Functions for Firebase](https://firebase.google.com/docs/functions/).\n\nIf you don't already have the Firebase CLI installed, do so:\n\n```bash\nnpm i -g firebase-tools\nfirebase login\n```\n\nThen inside your project root, setup your Firebase CLI project:\n\n```bash\nfirebase init\n```\n\nConfigure whichever features you'd want to manage but make sure to select at least `functions` and `hosting`. Choose Typescript for Cloud Functions and use the default `public` directory for Hosting.\n\nAfter you're configured, you should now see a `firebase.json` file in your project root. Let's add the following `rewrites` directive to it:\n\n```js\n{\n  // ...\n  \"hosting\": {\n    // ...\n    \"rewrites\": [\n      { \"source\": \"**\", \"function\": \"universal\" }\n    ]\n  }\n}\n```\n\nThis will inform Firebase Hosting that it should proxy all requests to Cloud Functions, if a file isn't already present in the hosting directory.\n\nLet's go ahead and modify your `package.json` to build for Cloud Functions:\n\n```js\n\"scripts\": {\n  // ... omitted\n  \"build\": \"ng build && npm run build:ssr && npm run copy:hosting && npm run build:functions\",\n  \"copy:hosting\": \"cp -r ./dist/YOUR_PROJECT_NAME/* ./public && rm -f ./public/index.html\",\n  \"build:functions\": \"npm run --prefix functions build\"\n},\n```\n\nChange the build script in your `functions/package.json` to the following:\n\n```js\n\"scripts\": {\n    // ... omitted\n    \"build\": \"rm -rf ./dist && cp -r ../dist . && tsc\",\n}\n```\n\nYou will either need to install the dependencies from the `functions/package.json` or add them to your root `package.json`.\n\nFinally, add the following to your `functions/src/index.ts`:\n\n```ts\nexport const universal = functions.https.onRequest((request, response) => {\n  require(`${process.cwd()}/dist/YOUR_PROJECT_NAME/server/main`).app()(request, response);\n});\n```\n\nIn the `server.ts` file generated by the Angular CLI ensure that the `index.html` is being read from the correct place.\n\nAs of writing the Angular CLI generates:\n\n```typescript\nconst indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index.html';\n```\n\nthis needs to be changed to:\n\n```typescript\nconst indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : join(distFolder, 'index.html');\n```\n\nSo that the `index.html` is read from the correct `dist` folder.\n\nYou should now be able to run `npm run build` to build your project for Firebase Hosting and Cloud Functions.\n\nTo test, spin up the emulator with `firebase serve`. Once you've confirmed its working go ahead and `firebase deploy`.\n\n_Note: Universal will now SSR your application and serve it, depending on how you have your deployment setup some assets may fail to \nserve because the Cloud Function is at a different route than the `APP_BASE_REF` configured._\n\n### [Next Step: Prerendering your Universal application](prerendering.md)\n\n## Additional Resources\n\n- [Universal Starter Template](https://github.com/angular/universal-starter)\n- [FireShip: Angular Universal SSR with Firebase](https://fireship.io/lessons/angular-universal-firebase/)\n"
  },
  {
    "path": "docs/universal/getting-started.md",
    "content": "# Getting started with AngularFire and Universal\n\nServer-side rendering (SSR) is the process of converting a JavaScript app to plain HTML at request-time, allowing search engine crawlers and linkbots to understand page content reliably. \n\n## 0. Prerequisites\n\n- @angular/cli >= v6.0\n- @angular/fire >= v5.0.0\n\n## 1. Add Angular Universal to your project\n\nFollow the steps from the [Angular Universal Tutorial](https://angular.io/guide/universal) to add Universal to your\nproject.\n\n```\nng add @nguniversal/express-engine\n```\n\nThis will create all the files you need and setup all the configurations for Universal rendering for your application.\n\n## 2. Next Steps\n\nTest your app locally by running `npm run dev:ssr`.\n\n_Note: `dev:ssr` is a command that was added to your `package.json` by the `ng add` command that will run the dev server\nfor your Angular with Universal._ \n\n### [Next Step: Deploying your Universal application on Cloud Functions for Firebase](cloud-functions.md)\n"
  },
  {
    "path": "docs/universal/prerendering.md",
    "content": "# Prerendering your Universal application\n\nPrerendering a Universal application allows us to generate the HTML before the user requests it; increasing performance and decreasing cost. Let's configure your application to prerender and staticly serve it's most commonly accessed routes on Firebase Hosting.\n\nFirst create a `static.paths.js` in your project root, which lists the URLs you'd want to prerender:\n\n```js\nexport default [\n    '/',\n    '/another_path',\n    '/yet_another_path'\n];\n```\n\nLet's install `mkdir-recursive` to make the next step a little easier:\n\n```bash\nnpm i --save-dev mkdir-recursive\n```\n\nNow replace the listener in your `server.ts` with the following:\n\n```ts\nimport { readFileSync, writeFileSync, existsSync } from 'fs';\nimport { renderModuleFactory } from '@angular/platform-server';\nimport { mkdirSync } from 'mkdir-recursive';\n\nif (process.env.PRERENDER) {\n\n    const routes = require('./static.paths').default;\n    Promise.all(\n        routes.map(route =>\n            renderModuleFactory(AppServerModuleNgFactory, {\n                document: template,\n                url: route,\n                extraProviders: [\n                    provideModuleMap(LAZY_MODULE_MAP)\n                ]\n            }).then(html => [route, html])\n        )\n    ).then(results => {\n        results.forEach(([route, html]) => {\n            const fullPath = join('./public', route);\n            if (!existsSync(fullPath)) { mkdirSync(fullPath); }\n            writeFileSync(join(fullPath, 'index.html'), html);\n        });\n        process.exit();\n    });\n\n} else if (!process.env.FUNCTION_NAME) {\n\n    // If we're not in the Cloud Functions environment, spin up a Node server\n    const PORT = process.env.PORT || 4000;\n    app.listen(PORT, () => {\n        console.log(`Node server listening on http://localhost:${PORT}`);\n    });\n}\n```\n\nNow if the `PRERENDER` environment variable is passed any value, instead of serving your application it will iterate over the paths in `static.paths.js`, render them, and write them to your `public` directory.  *You could always make this a seperate script.*\n\nFinally make some modifications to your `package.json`, to prerender your content when you build:\n\n```js\n\"scripts\": {\n  // ... omitted\n  \"build\": \"ng build && npm run copy:hosting && npm run build:functions && npm run prerender:ssr\",\n  \"prerender:ssr\": \"PRERENDER=1 node dist/YOUR_PROJECT_NAME-webpack/server.js\",\n},\n```\n\nNow when you run `npm run build` the prerendered content should be available in your `/public` directory, ready for deployment on Firebase Hosting.\n"
  },
  {
    "path": "docs/version-4-upgrade.md",
    "content": "# Upgrading to AngularFire2 4.0\n\nAngularFire2 4.0 is a refactor of the AngularFire2 package which implements\n@NgModule, simplifies authentication, and better supports Angular 4.\n\n### Removing `AngularFire` for Modularity\n\nPrior to 4.0, AngularFire2 did not take advantage of the Firebase SDK's modularity for tree shaking. The `AngularFire` service has now been removed and the library is broken up into smaller `@NgModule`s:\n\n* `AngularFireModule`\n* `AngularFireDatabaseModule`\n* `AngularFireAuthModule`\n\nWhen upgrading, replace calls to `AngularFire.database` and `AngularFire.auth` with `AngularFireDatabase` and `AngularFireAuth` respectively.\n\n```typescript\nconstructor(af: AngularFire) {\n  af.database.list('foo');\n  af.auth;\n}\n```\nShould now be:\n\n```typescript\nconstructor(db: AngularFireDatabase, afAuth: AngularFireAuth) {\n  db.list('foo');\n  afAuth.authState;\n}\n```\n\n### Simplified Authentication API\n\nIn 4.0 we've reduced the complexity of the auth module by providing only [`firebase.User`](https://firebase.google.com/docs/reference/js/firebase.User) observers (`AngularFireAuth.authState`, `AngularFireAuth.idToken`) and cutting the methods that were wrapping the Firebase SDK.\n\n\n```typescript\nimport { AngularFireAuth } from 'angularfire2/auth';\n// Do not import from 'firebase' as you'd lose the tree shaking benefits\nimport firebase from 'firebase/app';\n...\n\nuser: Observable<firebase.User>;\nconstructor(afAuth: AngularFireAuth) {\n  this.user = afAuth.authState; // only triggered on sign-in/out (for old behavior use .idToken)\n}\n```\n\nAngularFire2 exposes the raw Firebase Auth object via `AngularFireAuth.auth`. For actions like login, logout, user creation, etc. you should use the [methods available to `firebase.auth.Auth`](https://firebase.google.com/docs/reference/js/firebase.auth.Auth).\n\nWhile convenient, the pre-configured login feature added unneeded complexity. `AngularFireModule.initializeApp` no longer takes a default sign in method. Sign in should be done with the Firebase SDK via `firebase.auth.Auth`:\n\n```typescript\nlogin() {\n  this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());\n}\nlogout() {\n  this.afAuth.auth.signOut();\n}\n```\n\n### FirebaseListFactory and FirebaseObjectFactory API Changes\n\nIf you directly use `FirebaseListFactory` or `FirebaseObjectFactory` you will no longer be able to pass in a string, it will instead expect a Firebase database reference.\n\n## Putting this all together\n\nHere's an example of what AngularFire2 4.0 looks like:\n\n```typescript\nimport { NgModule, Component } from '@angular/core';\nimport { Observable } from 'rxjs/Observable';\nimport { AngularFireModule } from 'angularfire2';\nimport { AngularFireDatabaseModule, AngularFireDatabase, FirebaseListObservable } from 'angularfire2/database';\nimport { AngularFireAuthModule, AngularFireAuth } from 'angularfire2/auth';\nimport { environment } from '../environments/environment';\n\n// Do not import from 'firebase' as you'd lose the tree shaking benefits\nimport firebase from 'firebase/app';\n\n\n@NgModule({\n  declarations: [ App ],\n  exports: [ App ],\n  imports: [ \n    AngularFireModule.initializeApp(environment.firebase, 'my-app'),\n    AngularFireDatabaseModule,\n    AngularFireAuthModule\n  ],\n  bootstrap: [ App ]\n})\nexport class MyModule { }\n\n```\n\n```typescript\n@Component({\n  selector: 'my-app',\n  template: `\n    <div> {{ (items | async)? | json }} </div>\n    <div> {{ (user | async)? | json }} </div>\n    <button (click)=\"login()\">Login</button>\n    <button (click)=\"logout()\">Logout</button>\n  `\n})\nexport class App {\n  user: Observable<firebase.User>;\n  items: FirebaseListObservable<any[]>;\n  constructor(afAuth: AngularFireAuth, db: AngularFireDatabase) {\n    this.user = afAuth.authState;\n    this.items = db.list('items');\n  }\n  login() {\n    this.afAuth.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());\n  }\n  logout() {\n     this.afAuth.auth.signOut();\n  }\n}\n```\n"
  },
  {
    "path": "docs/version-5-upgrade.md",
    "content": "# Upgrading to AngularFire 5.0\n\nAngularFire 5.0 is a refactor of the `AngularFireDatabase` module. It removes the `FirebaseListObservable` and `FirebaseObjectObservable` in favor of a generic based service API.\n\n## Updating `FirebaseListObservable` to `AngularFireList<T>`\n\nRather than `.list()` returning a `FirebaseListObservable`, it now returns an `AngularFireList<T>`. This service contains methods that allow you to manipulate and stream data.\n\nIn the case of streaming back data, you now call one of the observable methods on `AngularFireList`.\n\n### 4.0\n\n```ts\nconstructor(afDb: AngularFireDatabase) {\n  afDb.list('items').subscribe(console.log);\n}\n```\n\n### 5.0\n\n```ts\nconstructor(afDb: AngularFireDatabase) {\n  afDb.list<Item>('items').valueChanges().subscribe(console.log);\n}\n```\n\nThe same concepts apply to `FirebaseObjectObservable` to `AngularFireObject`.\n\n## Moving away from `$key` and `$value`\n\nIn AngularFireDatabase 4.0 the snapshot was automatically unwrapped for you and metadata was placed in `$` property. The Firebase Database rejects any keys with `$` in them so this mechanism allowed us to provide you with important metadata alongside your actual data. However, persisting the object could be a pain in some cases as the SDK would reject any `$` based properties. In 5.0 we have moved away from `$` properties and we provide multiple observable methods for receiving the data.\n\nCalling `.valueChanges()` returns an Observable without any metadata. If you are already persisting the key as a property then you are fine. However, if you are relying on `$key`, then you need to use `.snapshotChanges()` and transform the data with an observable `.map()`.\n\n### 4.0\n\n```ts\nconstructor(afDb: AngularFireDatabase) {\n  afDb.list('items').subscribe(items => { \n    const allKeys = items.map(item => item.$key);\n  });\n}\n```\n\n### 5.0\n\n```ts\nconstructor(afDb: AngularFireDatabase) {\n  afDb.list('items').snapshotChanges().pipe(\n    map(actions => \n      actions.map(a => ({ key: a.key, ...a.payload.val() }))\n    )\n  ).subscribe(items => {\n    return items.map(item => item.key);\n  });\n}\n```\n\n## Data manipulation methods\n\nAngularFire 5.0 removes all custom observables which means their custom operators are gone as well. Instead of using custom operators on either a `FirebaseListObservable` or a `FirebaseObjectObservable`, use the methods on the service based APIs: `AngularFireList` and `AngularFireObject`. There is no resulting code change, but it worth pointing out.\n\n### 4.0\n\n```ts\nconstructor(afDb: AngularFireDatabase) {\n  const listObservable = afDb.list('items');\n  listObservable.push({ name: 'item' });\n  listObservable.subscribe();\n}\n```\n\n### 5.0\n\n```ts\nconstructor(afDb: AngularFireDatabase) {\n  const afList = afDb.list('items');\n  afList.push({ name: 'item' });\n  const listObservable = afList.snapshotChanges();\n  listObservable.subscribe();\n}\n```\n"
  },
  {
    "path": "docs/version-6-upgrade.md",
    "content": "# Upgrading to AngularFire 6.0\n\nIntended to be run with Angular 9; version 6 of AngularFire drops support for Angular version 8 and below, older versions of typescript, Firebase, drops `firebase-node`, `database-deprecated`, and more.\n\n## Breaking changes:\n\n* Support for Angular versions less than 9 has been dropped\n* Support for Firebase JS SDK versions less than 7.13.1 has been dropped\n* Support for `firebase-tools` less than 8.0 has been dropped\n* The `angularfire2` NPM library will no longer be updated\n* Dropped `@angular/fire/firebase-node` and `@angular/fire/database-depreciated`\n* We make use of Proxy in more modules, you'll need to polyfill if you want to support IE 11\n* We've standardized our DI Token naming conventions across all modules\n* `AngularFireAuth` has dropped the `auth` property and instead Promise Proxies the underlying Firebase `auth.Auth` instance; allowing your development experience to more closely mirror the JS SDK. Similar changes have been made to `AngularFireFunctions`, `AngularFireMessaging`, and `AngularFirePerformance`.\n* `AngularFireAuthGuard` and `canActivate` have dropped support for raw pipes, this was never working correctly in AOT\n* `AngularFirePerformance` has been simplified, the RXJS pipes are now exported as pure-functions outside the class. Automatic tracking of `isStable` timing has now been moved into `PerformanceMonitoringService` and we've dropped the `AUTOMATICALLY_TRACE_CORE_NG_METRICS` DI token."
  },
  {
    "path": "docs/version-7-upgrade.md",
    "content": "# Upgrading to AngularFire 7.0\n\nIntended to be run with Angular 12, AngularFire 7.0 allows you to take full advantage of the new tree-shakable Firebase JS SDK (v9) while also providing a compatible experience with the prior API.\n\n`ng update @angular/fire`\n\n## Breaking changes\n\n* Angular 12 is required\n* AngularFire now only works in Ivy applications\n* Firebase JS SDK v9 is required\n* The existing AngularFire v6 API surface has moved from `@angular/fire/*` to `@angular/fire/compat/*` (see compatibility mode)\n* **compat/auth:** `USE_EMULATOR` DI token is now in the form of `['http://localhost:9099']`\n\n## Compatibility mode\n\nAngularFire v7.0 has a compatibility layer that supports the AngularFire v6.0 API. Just change your imports from `@angular/fire/*` to `@angular/fire/compat/*` and `firebase/*` to `firebase/compat/*`.\n\nWhile not as tree-shakable as the new modular SDK, this allows you to upgrade and take advantage of the benefits of the new SDK ASAP.\n\n**Most developers can stop here for now as the new API isn't feature complete.**\n\n## **NEW** Modular SDK\n\n### Initialization\n\nIn order to better support the tree-shakability introduced in Firebase v9 & to reduce the maintence required when the JS SDK adds new configuration flags, AngularFire providers now take a factory for a fully instantiated instance of the SDK you'd like to inject.\n\n**Before:**\n```ts\n@NgModule({\n    imports: [\n        AngularFireModule.initializeApp(config),\n        AngularFirestoreModule.enablePersistence(),\n        AngularFireStorageModule,\n    ],\n    providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', 8080] },\n    ],\n})\n```\n\n**Modular SDK:**\n```ts\n@NgModule({\n    imports: [\n        provideFirebaseApp(() => initializeApp(config)),\n        provideFirestore(() => {\n            const firestore = getFirestore();\n            connectFirestoreEmulator(firestore, 'localhost', 8080);\n            enableIndexedDbPersistence(firestore);\n            return firestore;\n        }),\n        provideStorage(() => getStorage()),\n    ],\n})\n```\n\n### Injecting services\n\nBefore when you injected Firebase JS SDK services into AngularFire they would be lazy-loaded and a promise-proxy would be returned to you. In AngularFire v7 you get the intiated service directly. We no longer lazy load for you.\n\n```ts\nimport { Firestore, doc, onSnapshot, DocumentReference, docSnapshots } from '@angular/fire/firestore';\n\n@Component({})\nexport class Foo {\n    doc: DocumentReference;\n    constructor(\n        firestore: Firestore, // Injects the instantiated Firestore instance\n    ) {\n        // You can directly operate on the instance with JS SDK methods which we've\n        // reexported in AngularFire\n        this.doc = doc(firestore, 'foo/1');\n        onSnapshot(doc, snap => {\n            // ...\n        });\n        // or use the convenience observables\n        docSnapshots(doc).subscribe(...);\n    }\n    async update() {\n        await updateDoc(this.doc, { ... });\n        ...\n    }\n}\n```\n\n### Working with multiple apps / instances\n\nIn AngularFire v7 working with multiple instances was difficult, in the new SDK we have new DI tokens that make working with them much more straight forward.\n\n```ts\n@NgModule({\n    imports: [\n        provideFirebaseApp(() => initializeApp(config)),\n        provideFirebaseApp(() => initializeApp(config2, 'anotherApp')),\n        provideStorage(() => getStorage()),\n        provideStorage(() => getStorage(getApp(), 'anotherBucket')),\n        provideStorage(() => getStorage(getApp('anotherApp'))),\n    ],\n})\n```\n\n```ts\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { Storage, StorageInstances } from '@angular/fire/storage';\n\nexport class Foo {\n    constructor(\n        defaultApp: FirebaseApp,       // Injects the default FirebaseApp\n        allFirebaseApps: FirebaseApps, // Injects an array of all initialized Firebase Apps\n        storage: Storage,                      // Injects the default storage instance\n        allStorageInstances: StorageInstances, // Injects an array of all the intialized storage instances\n    ) { }\n}\n```\nHow the main injection tokens (i.e, `FirebaseApp`, `Storage`) function have changed from v7 but it should provide a much more powerful and intuitive API.\n\n### API\n\nBeyond Depdency Injection AngularFire is sporting an entirely new API:\n\n1) We no longer handle lazy-loading the Firebase JS SDK modules for you\n1) We no longer provide classes beyond Depedency Injection\n1) No more Proxy / Promise-Proxy\n1) We reexport and Zone-wrap all Firebase and RxFire APIs\n\nSo developing with the new AngularFire is easy, you can use it just like the vanilla Firebase JS SDK. Just change all your `firebase/app` imports to `@angular/fire/app`, `firebase/firestore` to `@angular/fire/firestore`, `firebase/database` to `@angular/fire/database`, etc. Then if you're feeling comfortable with RXJS and would like to use some of our convenience operators you can just dip into that toolbox.\n\n#### Alternatives to v6 APIs\n\n<table>\n    <thead>\n        <tr>\n            <th colspan=\"2\">v6 / Compat</th>\n            <th>v7 Modular</th>\n        </tr>\n    </thead>\n    <tbody>\n        <tr>\n            <th rowspan=\"3\">AngularFirestore</th>\n            <td>doc</td>\n            <td>\n\n```ts\nimport { doc } from '@angular/fire/firestore';\ndoc<T>(firestore, 'foo/bar') // DocumentReference<T>\n```\n</td>\n        </tr>\n        <tr>\n            <td>collection</td>\n            <td>\n\n```ts\nimport { collection } from '@angular/fire/firestore';\ncollection<T>(firestore, 'foo') // CollectionReference<T>\n```\n</td>\n        </tr>\n        <tr>\n            <td>collectionGroup</td>\n            <td>\n\n```ts\nimport { collectionGroup } from '@angular/fire/firestore';\ncollectionGroup<T>(firestore, 'foo') // Query<T>\n```\n</td>\n        </tr>\n        <tr>\n            <th rowspan=\"7\">AngularFirestoreDocument</th>\n            <td>set</td>\n            <td>\n\n```ts\nimport { setDoc } from '@angular/fire/firestore';\nsetDoc(docRef, { ... }) // Promise<void>\n```\n</td>\n\n</td>\n        </tr>\n        <tr>\n            <td>update</td>\n            <td>\n\n```ts\nimport { updateDoc } from '@angular/fire/firestore';\nupdateDoc(docRef, { ... }) // Promise<void>\n```\n</td>\n        </tr>\n        <tr>\n            <td>delete</td>\n            <td>\n\n```ts\nimport { deleteDoc } from '@angular/fire/firestore';\ndeleteDoc(docRef) // Promise<void>\n```\n</td>\n        </tr>\n        <tr>\n            <td>collection</td>\n            <td>\n\n```ts\nimport { collection } from '@angular/fire/firestore';\ncollection<T>(docRef, 'bar') // CollectionReference<T>\n```\n</td>\n        </tr>\n        <tr>\n            <td>snapshotChanges</td>\n            <td>\n\n```ts\nimport { docSnapshots } from '@angular/fire/firestore';\ndocSnapshots<T>(docRef) // Observable<DocumentSnapshot<T>>\n```\n</td>\n\n</td>\n        </tr>\n        <tr>\n            <td>valueChanges</td>\n            <td>\n\n```ts\nimport { docData } from '@angular/fire/firestore';\ndocData<T>(docRef) // Observable<T>\n```\n</td>\n        </tr>\n        <tr>\n            <td>get</td>\n            <td>\n\n```ts\nimport { getDoc } from '@angular/fire/firestore';\ngetDoc<T>(docRef) // Promise<DocumentSnapshot<T>>\n```\n\n</td>\n        </tr>\n    </tbody>\n</table>\n\n### Code splitting and lazy-loading\n\nAngularFire does not lazy-load services any longer. We have provided a helper observable for detecting when a new service instance is instantiated. In this example we'll code split out of all the Firestore related code and lazy-load\n\n```ts\n// firestore_operations.ts\nimport {\n    collectionData,\n    firestoreInstance$,\n    collection,\n    getFirestore\n} from '@angular/fire/firestore';\nimport { first } from 'rxjs/operators';\nimport { IFoo } from '../interfaces';\n\nexport { getFirestore };\n\nexport const fooData = firestoreInstance$.pipe(\n    first(),\n    concatMap(firestore => collectionData<IFoo>(collection(firestore, 'foo'))),\n);\n```\n\n```ts\nexport class AuthService {\n    constructor() {\n        getRedirectResult().then(result => {\n            // Initialize Firestore only after a user logs in\n            if (result.user) {\n                const { getFirestore } = await import('./firestore_operations');\n                getFirestore();\n            }\n        });\n    }\n}\n```\n\n```ts\n@Component({})\nexport class Foo {\n    data: Observable<IFoo[]>;\n    constructor() {\n        this.data = of(undefined).pipe(\n            concatMap(() => import('./firestore_operations')),\n            concatMap(it => it.fooData)\n        );\n    }\n}\n```\n"
  },
  {
    "path": "docs/vertexai.md",
    "content": "<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Vertex AI\n</small>\n\n# Vertex AI (preview)\n\nThe Vertex AI Gemini API gives you access to the latest generative AI models from Google: the Gemini models.\n\n[Learn more](https://firebase.google.com/docs/vertex-ai)\n\n## Dependency Injection\n\nAs a prerequisite, ensure that `AngularFire` has been added to your project via\n```bash\nng add @angular/fire\n```\n\nProvide a Vertex AI instance in the application's `app.config.ts`:\n\n```ts\nimport { provideFirebaseApp, initializeApp } from '@angular/fire/app';\nimport { provideVertexAI, getVertexAI } from '@angular/fire/vertexai-preview';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp({ ... })),\n    provideVertexAI(() => getVertexAI()),\n    ...\n  ],\n  ...,\n}\n```\n\nNext inject `VertexAI` into your component:\n\n```typescript\nimport { Component, inject } from '@angular/core';\nimport { VertexAI } from '@angular/fire/vertexai';\n\n@Component({ ... })\nexport class MyComponent {\n    private vertexAI = inject(VertexAI);\n    ...\n}\n```\n\n## Firebase API\n\nAngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.\n\nUpdate the imports from `import { ... } from 'firebase/vertexai'` to `import { ... } from '@angular/fire/vertexai'` and follow the official documentation.\n\n[Getting Started](https://firebase.google.com/docs/vertex-ai/get-started?platform=web) | [API Reference](https://firebase.google.com/docs/reference/js/vertexai)\n"
  },
  {
    "path": "docs/zones.md",
    "content": "<small>\n<a href=\"https://github.com/angular/angularfire\">AngularFire</a> &#10097; <a href=\"../README.md#developer-guide\">Developer Guide</a> &#10097; Zone Wrappers\n</small>\n\n# Zone Wrappers\n\nAngularFire wraps the [framework agnostic Firebase JS SDK](https://github.com/firebase/firebase-js-sdk) and [RxFire](https://github.com/firebaseextended/rxfire) to ensure proper functionality in Zone and Zoneless applications alike.\n\nThese wrappers ensure Firebase APIs are called outside of the Angular zone. This isolates side-effects such as timers so that they do not destabilize your application. \n\nObservables, Promise-based APIs, and those with callbacks will purposely destabilize your application until a initial value is returned, this ensures that server-side rendering (SSR) and static site generation (SSG/pre-rendering) wait for data before rendering the page's HTML.\n\n## Consequences of not Zone wrapping\n\nWhen using a Firebase or RxFire API without importing from AngularFire or if AngularFire APIs are used outside of an injection context you _may_ experience instability.\n\nWhen an application is unstable change-detection, two-way binding, and rehydration may not work as expected—leading to both subtle and non-subtle bugs in your application. Further, server-side rendering (SSR) and static site generation (SSG/pre-rendering) may timeout or render a blank page.\n\nThere are a number of situations where AngularFire's Zone wrapping is inconsequential such adding/deleting/updating a document in response to user-input, signing a user in, calling a Cloud Function, etc. So long as no long-lived side-effects are kicked off, your application should be ok. Most Promise based APIs are fairly safe without zone wrapping. \n\n## Logging\n\nYou may see a log warning, `Calling Firebase APIs outside of an Injection context may destabilize your application leading to subtle change-detection and hydration bugs. Find more at https://github.com/angular/angularfire/blob/main/docs/zones.md` when developing your application.\n\nInstability can be difficult to track down. To help with debugging, AngularFire emits warnings when it is unable to Zone wrap an API while in dev-mode. **Often these messages can be safely ignored** but we'd rather be verbose.\n\nThere are three logging levels in AngularFire:\n\n* **Silent**: when the logging level is set to silent only the above banner is displayed when AngularFire APIs are called outside of an injection context, this is the default when using Zoneless change-detection.\n* **Warn**: when the logging level is set to warn, only blocking reads, long-lived tasks, and APIs with high risk of destabilizing your application are called, this is the default when using ZoneJS.\n* **Verbose**: when the logging level is set to verbose, all AngularFire APIs called outside of an injection context are logged—helping you track down APIs that may be destabilizing your application\n\nYou can change the log-level like so:\n\n```ts\nimport { setLogLevel, LogLevel } from \"@angular/fire\";\n\nsetLogLevel(LogLevel.VERBOSE);\n```"
  },
  {
    "path": "eslint.config.js",
    "content": "const tsParser = require('@typescript-eslint/parser');\nconst js = require('@eslint/js');\nconst globals = require('globals');\nconst ts = require('@typescript-eslint/eslint-plugin');\nconst ng = require('@angular-eslint/eslint-plugin');\nconst esImport = require('eslint-plugin-import');\n\nmodule.exports = [\n  {\n    files: ['**/*.ts'],\n    plugins: {\n      '@typescript-eslint': ts,\n      '@angular-eslint': ng,\n      import: esImport,\n    },\n    languageOptions: {\n      parser: tsParser,\n      globals: {\n        ...globals.browser,\n      },\n      parserOptions: {\n        project: ['tsconfig.build.json', 'tsconfig.json', 'tsconfig.spec.json'],\n      },\n    },\n    rules: {\n      ...js.configs.recommended.rules,\n      ...ts.configs['recommended-requiring-type-checking'].rules,\n      ...ts.configs['stylistic-type-checked'].rules,\n      ...ng.configs.recommended.rules,\n      ...esImport.configs.errors.rules,\n      // eslint/js rules\n      'no-undef': 'off',\n      'no-redeclare': 'off',\n      'prefer-arrow-callback': 'error',\n      'curly': 'error',\n      'no-dupe-class-members': 'off',\n      \"no-restricted-imports\": [\"error\", \"rxjs/Rx\"],\n      \"no-console\": [\"error\", {allow: ['log', 'error', 'warn']}],\n      'sort-imports': [\n        'error',\n        {\n          ignoreDeclarationSort: true,\n        },\n      ],\n      // @typescript-eslint rules\n      '@typescript-eslint/prefer-nullish-coalescing': 'off', // require `strictNullChecks`\n      '@typescript-eslint/no-explicit-any': 'off',\n      '@typescript-eslint/no-unsafe-assignment': 'off',\n      '@typescript-eslint/no-unsafe-member-access': 'off',\n      '@typescript-eslint/no-unsafe-call': 'off',\n      '@typescript-eslint/no-unsafe-return': 'off',\n      '@typescript-eslint/no-unsafe-declaration-merging': 'off',\n      '@typescript-eslint/no-unsafe-argument': 'off',\n      '@typescript-eslint/no-floating-promises': 'off',\n      '@typescript-eslint/no-unnecessary-type-assertion': 'off',\n      '@typescript-eslint/no-redundant-type-constituents': 'off', // causing pipeline error in src/compat/firestore/utils.spec.ts\n      '@typescript-eslint/no-non-null-assertion': 'error',\n      \"@typescript-eslint/member-ordering\": [\"error\", {\n        \"default\": [\n          \"static-field\",\n          \"instance-field\",\n          \"static-method\",\n          \"instance-method\"\n        ]\n      }],\n      '@typescript-eslint/no-unused-vars': [\n        'error', {args: \"after-used\", \"argsIgnorePattern\": \"^_\"}\n      ],\n      // @angular-eslint rules\n      '@angular-eslint/directive-selector': [\n        'error',\n        {\n          type: 'attribute',\n          prefix: 'app',\n          style: 'camelCase',\n        },\n      ],\n      '@angular-eslint/component-selector': [\n        'error',\n        {\n          type: 'element',\n          prefix: 'app',\n          style: 'kebab-case',\n        },\n      ],\n      // import rules\n      'import/no-unresolved': 'off',\n      'import/namespace': 'off',\n      'import/default': 'off',\n      'import/export': 'off',\n      'import/newline-after-import': 'error',\n      'import/order': [\n        'error',\n        {\n          alphabetize: {order: 'asc'},\n          \"newlines-between\": \"never\"\n        },\n      ],\n      '@angular-eslint/prefer-inject': 'off',\n      '@typescript-eslint/no-empty-object-type': 'off',\n      'import/named': 'off',\n      \"@typescript-eslint/no-unused-vars\": [\n        \"error\",\n        {\n          \"argsIgnorePattern\": \"^_\",\n          \"varsIgnorePattern\": \"^_\",\n          \"caughtErrorsIgnorePattern\": \"^_\",\n          \"ignoreRestSiblings\": true\n        }\n      ],\n      \"@typescript-eslint/prefer-promise-reject-errors\": \"off\",\n      \"@typescript-eslint/no-require-imports\": \"off\",\n      \"@typescript-eslint/ban-ts-comment\": \"warn\",\n    },\n  },\n  {\n    files: ['**/*.spec.ts'],\n    languageOptions: {\n      globals: {\n        ...globals.jasmine,\n      },\n    },\n  },\n];\n"
  },
  {
    "path": "firebase.json",
    "content": "{\n  \"database\": {\n    \"rules\": \"test/database.rules.json\"\n  },\n  \"firestore\": {\n    \"rules\": \"test/firestore.rules\",\n    \"indexes\": \"test/firestore.indexes.json\"\n  },\n  \"storage\": {\n    \"rules\": \"test/storage.rules\"\n  },\n  \"emulators\": {\n    \"auth\": {\n      \"port\": 9098\n    },\n    \"functions\": {\n      \"port\": 5001\n    },\n    \"firestore\": {\n      \"port\": 8089\n    },\n    \"database\": {\n      \"port\": 9002\n    },\n    \"storage\": {\n      \"port\": 9199\n    },\n    \"ui\": {\n      \"enabled\": false\n    }\n  },\n  \"functions\": [\n    {\n      \"source\": \"test/functions\",\n      \"codebase\": \"default\",\n      \"ignore\": [\n        \"node_modules\",\n        \".git\",\n        \"firebase-debug.log\",\n        \"firebase-debug.*.log\",\n        \"*.local\"\n      ],\n      \"predeploy\": [\n        \"npm --prefix \\\"$RESOURCE_DIR\\\" run build\"\n      ]\n    }\n  ]\n}\n"
  },
  {
    "path": "karma.conf.js",
    "content": "const dns = require('node:dns');\n\n// The emulator suite fails in CI, only on Node 18.\n// This apparently fixes it.\n// https://github.com/firebase/firebase-tools/issues/5755#issuecomment-1535445383\ndns.setDefaultResultOrder('ipv4first');\n\nlet firestoreEmulatorPort, storageEmulatorPort, authEmulatorPort, databaseEmulatorPort, functionsEmulatorPort;\nif (process.env.FIRESTORE_EMULATOR_HOST &&\n    process.env.STORAGE_EMULATOR_HOST &&\n    process.env.FIREBASE_AUTH_EMULATOR_HOST &&\n    process.env.FIREBASE_DATABASE_EMULATOR_HOST) {\n      firestoreEmulatorPort = parseInt(process.env.FIRESTORE_EMULATOR_HOST.split(\":\")[1], 10); // '127.0.0.1:9098'\n      storageEmulatorPort = parseInt(process.env.STORAGE_EMULATOR_HOST.split(\":\")[2], 10); // 'http://127.0.0.1:9199'\n      authEmulatorPort = parseInt(process.env.FIREBASE_AUTH_EMULATOR_HOST.split(\":\")[1], 10); // '127.0.0.1:9098'\n      databaseEmulatorPort = parseInt(process.env.FIREBASE_DATABASE_EMULATOR_HOST.split(\":\")[1], 10); // '127.0.0.1:9002'\n      functionsEmulatorPort = 5001; // TODO figure out why this env variable isn't present\n} else {\n  console.error(\"Missing emulator environments variables\");\n  process.exit(1);\n}\n\n// Karma configuration file, see link for more information\n// https://karma-runner.github.io/1.0/config/configuration-file.html\nmodule.exports = function (config) {\n  config.set({\n    basePath: '',\n    frameworks: ['jasmine', '@angular-devkit/build-angular'],\n    plugins: [\n      require('karma-jasmine'),\n      require('karma-chrome-launcher'),\n      require('karma-safarinative-launcher'),\n      require('karma-firefox-launcher'),\n      require('karma-jasmine-html-reporter'),\n      require('karma-coverage-istanbul-reporter'),\n      require('@angular-devkit/build-angular/plugins/karma')\n    ],\n    client: {\n      clearContext: false, // leave Jasmine Spec Runner output visible in browser\n      args: [\n        [\"FIRESTORE_EMULATOR_PORT\", firestoreEmulatorPort],\n        [\"DATABASE_EMULATOR_PORT\", databaseEmulatorPort],\n        [\"STORAGE_EMULATOR_PORT\", storageEmulatorPort],\n        [\"AUTH_EMULATOR_PORT\", authEmulatorPort],\n        [\"FUNCTIONS_EMULATOR_PORT\", functionsEmulatorPort],\n      ],\n    },\n    coverageIstanbulReporter: {\n      dir: `${process.cwd()}/coverage`,\n      reports: ['html', 'lcovonly'],\n      fixWebpackSourcePaths: true\n    },\n    reporters: ['progress', 'kjhtml'],\n    port: 9876,\n    colors: true,\n    logLevel: config.LOG_INFO,\n    autoWatch: true,\n    browsers: ['Chrome', 'ChromeHeadless', 'SafariNative', 'Firefox', 'FirefoxHeadless'],\n    singleRun: false,\n    restartOnFileChange: true,\n    customLaunchers: {\n      FirefoxHeadless: {\n        base: 'Firefox',\n        flags: [\n          '-headless',\n        ],\n      }\n    },\n  });\n};\n"
  },
  {
    "path": "mise.toml",
    "content": "[tools]\nnode = \"latest\"\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"@angular/fire\",\n  \"version\": \"21.0.0-rc.0\",\n  \"description\": \"Angular + Firebase = ❤️\",\n  \"private\": true,\n  \"scripts\": {\n    \"test\": \"npm run build:jasmine && npm run test:node-esm && npm run test:chrome-headless\",\n    \"test:watch\": \"npx --yes firebase-tools@latest emulators:exec --project=demo-123 \\\"ng test --watch=true --browsers=Chrome\\\"\",\n    \"test:chrome\": \"npx --yes firebase-tools@latest emulators:exec --project=demo-123 \\\"ng test --watch=false --browsers=Chrome\\\"\",\n    \"test:firefox\": \"npx --yes firebase-tools@latest emulators:exec --project=demo-123 \\\"ng test --watch=false --browsers=Firefox\\\"\",\n    \"test:safari\": \"npx --yes firebase-tools@latest emulators:exec --project=demo-123 \\\"ng test --watch=false --browsers=SafariNative\\\"\",\n    \"test:chrome-headless\": \"npx --yes firebase-tools@latest emulators:exec --project=demo-123 \\\"ng test --watch=false --browsers=ChromeHeadless\\\"\",\n    \"test:firefox-headless\": \"npx --yes firebase-tools@latest emulators:exec --project=demo-123 \\\"ng test --watch=false --browsers=FirefoxHeadless\\\"\",\n    \"lint\": \"ng lint\",\n    \"lint:fix\": \"ng lint --fix\",\n    \"test:node\": \"node -r tsconfig-paths/register ./dist/out-tsc/jasmine/tools/jasmine.mjs --input-type=commonjs\",\n    \"test:node-esm\": \"node -r tsconfig-paths/register ./dist/out-tsc/jasmine/tools/jasmine.mjs\",\n    \"test:typings\": \"node ./tools/run-typings-test.js\",\n    \"test:build\": \"bash ./test/ng-build/build.sh\",\n    \"test:all\": \"npm run test:node-esm && npm run test:chrome-headless && npm run test:typings && npm run test:build\",\n    \"build\": \"rimraf dist && tspc -p tsconfig.build.json && node --trace-warnings ./tools/build.js && npm pack ./dist/packages-dist\",\n    \"buildd\": \"tsc -p tsconfig.build.json && node --trace-warnings ./tools/build.js && npm pack ./dist/packages-dist\",\n    \"build:jasmine\": \"npx tsc -p tsconfig.jasmine.json --module es2015 && cp ./dist/out-tsc/jasmine/tools/jasmine.js ./dist/out-tsc/jasmine/tools/jasmine.mjs && npx tsc -p tsconfig.jasmine.json && cp ./dist/packages-dist/schematics/versions.json ./dist/out-tsc/jasmine/src/schematics\",\n    \"changelog\": \"conventional-changelog -p angular -i CHANGELOG.md -s -r 1\"\n  },\n  \"husky\": {\n    \"hooks\": {\n      \"pre-commit\": \"npm run lint\"\n    }\n  },\n  \"schematics\": \"./dist/packages-dist/collection.json\",\n  \"builders\": \"./dist/packages-dist/builders.json\",\n  \"keywords\": [\n    \"angular\",\n    \"firebase\",\n    \"rxjs\"\n  ],\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/angular/angularfire.git\"\n  },\n  \"author\": \"davideast\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/angular/angularfire/issues\"\n  },\n  \"homepage\": \"https://github.com/angular/angularfire#readme\",\n  \"dependencies\": {\n    \"@angular-devkit/architect\": \"~0.2100.0\",\n    \"@angular-devkit/core\": \"^21.0.0\",\n    \"@angular-devkit/schematics\": \"^21.0.0\",\n    \"@angular/common\": \"^21.0.0\",\n    \"@angular/compiler\": \"^21.0.0\",\n    \"@angular/core\": \"^21.0.0\",\n    \"@angular/platform-browser\": \"^21.0.0\",\n    \"@angular/platform-browser-dynamic\": \"^21.0.0\",\n    \"@angular/router\": \"^21.0.0\",\n    \"@schematics/angular\": \"^21.0.0\",\n    \"esbuild\": \"^0.24.0\",\n    \"firebase\": \"^12.4.0\",\n    \"firebase-functions\": \"^6.1.0\",\n    \"fs-extra\": \"^8.0.1\",\n    \"fuzzy\": \"^0.1.3\",\n    \"husky\": \"^4.2.5\",\n    \"inquirer-autocomplete-prompt\": \"^1.0.1\",\n    \"jsonc-parser\": \"^3.0.0\",\n    \"open\": \"^7.0.3 || ^8.0.0\",\n    \"ora\": \"^5.3.0\",\n    \"rxfire\": \"^6.1.0\",\n    \"rxjs\": \"~7.8.0\",\n    \"semver\": \"^7.1.3\",\n    \"triple-beam\": \"^1.3.0\",\n    \"tslib\": \"^2.3.0\",\n    \"winston\": \"^3.0.0\",\n    \"zone.js\": \"~0.15.0\"\n  },\n  \"devDependencies\": {\n    \"@angular-devkit/build-angular\": \"^21.0.0\",\n    \"@angular-eslint/builder\": \"^21.0.0\",\n    \"@angular-eslint/eslint-plugin\": \"^21.0.0\",\n    \"@angular/animations\": \"^21.0.0\",\n    \"@angular/cli\": \"^21.0.0\",\n    \"@angular/compiler-cli\": \"^21.0.0\",\n    \"@angular/platform-server\": \"^21.0.0\",\n    \"@types/fs-extra\": \"^7.0.0\",\n    \"@types/gzip-size\": \"^5.1.1\",\n    \"@types/inquirer\": \"^0.0.44\",\n    \"@types/jasmine\": \"^4.3.4\",\n    \"@types/lodash.isequal\": \"^4.5.5\",\n    \"@types/node\": \"^12.6.2 < 12.12.42\",\n    \"@types/request\": \"0.0.30\",\n    \"@types/semver\": \"^7.1.0\",\n    \"@types/triple-beam\": \"^1.3.0\",\n    \"@types/winston\": \"^2.4.4\",\n    \"@typescript-eslint/eslint-plugin\": \"^8.33.0\",\n    \"@typescript-eslint/parser\": \"^8.33.0\",\n    \"conventional-changelog-cli\": \"^1.2.0\",\n    \"cross-spawn\": \"^7.0.3\",\n    \"eslint\": \"^9.27.0\",\n    \"eslint-plugin-import\": \"^2.31.0\",\n    \"globals\": \"^13.21.0\",\n    \"globalthis\": \"^1.0.1\",\n    \"jasmine\": \"^5.0.0\",\n    \"jasmine-core\": \"~5.0.0\",\n    \"karma\": \"~6.4.0\",\n    \"karma-chrome-launcher\": \"~3.1.0\",\n    \"karma-coverage-istanbul-reporter\": \"~3.0.2\",\n    \"karma-firefox-launcher\": \"^2.1.0\",\n    \"karma-jasmine\": \"~5.1.0\",\n    \"karma-jasmine-html-reporter\": \"^2.1.0\",\n    \"karma-safarinative-launcher\": \"^1.1.0\",\n    \"ng-packagr\": \"^21.0.0\",\n    \"reflect-metadata\": \"^0.1.2\",\n    \"replace-in-file\": \"^5.0.2\",\n    \"rimraf\": \"^2.5.4\",\n    \"shelljs\": \"^0.8.0\",\n    \"ts-patch\": \"^3.2.1\",\n    \"ts-transformer-keys\": \"^0.4.4\",\n    \"tslint\": \"~6.1.0\",\n    \"typescript\": \">=5.9 <6.0\",\n    \"yaml\": \"^2.7.0\"\n  },\n  \"overrides\": {\n    \"rxfire\": {\n      \"firebase\": \"^12.4.0\"\n    }\n  },\n  \"typings\": \"index.d.ts\"\n}\n"
  },
  {
    "path": "sample/.editorconfig",
    "content": "# Editor configuration, see https://editorconfig.org\nroot = true\n\n[*]\ncharset = utf-8\nindent_style = space\nindent_size = 2\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[*.ts]\nquote_type = single\nij_typescript_use_double_quotes = false\n\n[*.md]\nmax_line_length = off\ntrim_trailing_whitespace = false\n"
  },
  {
    "path": "sample/.firebaserc",
    "content": "{\n  \"projects\": {\n    \"default\": \"angularfire2-test\"\n  }\n}\n"
  },
  {
    "path": "sample/.gitignore",
    "content": "# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.\n\n# Compiled output\n/dist\n/tmp\n/out-tsc\n/bazel-out\n\n# Node\n/node_modules\nnpm-debug.log\nyarn-error.log\n\n# IDEs and editors\n.idea/\n.project\n.classpath\n.c9/\n*.launch\n.settings/\n*.sublime-workspace\n\n# Visual Studio Code\n.vscode/*\n!.vscode/settings.json\n!.vscode/tasks.json\n!.vscode/launch.json\n!.vscode/extensions.json\n.history/*\n\n# Miscellaneous\n/.angular/cache\n.sass-cache/\n/connect.lock\n/coverage\n/libpeerconnection.log\ntestem.log\n/typings\n\n# System files\n.DS_Store\nThumbs.db\n\n# Firebase\n.firebase\n*-debug.log\n.runtimeconfig.json\n"
  },
  {
    "path": "sample/README.md",
    "content": "# Ng19Test\n\nThis project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.0.0.\n\n## Development server\n\nTo start a local development server, run:\n\n```bash\nng serve\n```\n\nOnce the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files.\n\n## Code scaffolding\n\nAngular CLI includes powerful code scaffolding tools. To generate a new component, run:\n\n```bash\nng generate component component-name\n```\n\nFor a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:\n\n```bash\nng generate --help\n```\n\n## Building\n\nTo build the project run:\n\n```bash\nng build\n```\n\nThis will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed.\n\n## Running unit tests\n\nTo execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:\n\n```bash\nng test\n```\n\n## Running end-to-end tests\n\nFor end-to-end (e2e) testing, run:\n\n```bash\nng e2e\n```\n\nAngular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.\n\n## Additional Resources\n\nFor more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.\n"
  },
  {
    "path": "sample/angular.json",
    "content": "{\n  \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n  \"version\": 1,\n  \"newProjectRoot\": \"projects\",\n  \"projects\": {\n    \"ng19-test\": {\n      \"projectType\": \"application\",\n      \"schematics\": {},\n      \"root\": \"\",\n      \"sourceRoot\": \"src\",\n      \"prefix\": \"app\",\n      \"architect\": {\n        \"build\": {\n          \"builder\": \"@angular-devkit/build-angular:application\",\n          \"options\": {\n            \"outputPath\": \"dist/ng19-test\",\n            \"index\": \"src/index.html\",\n            \"browser\": \"src/main.ts\",\n            \"polyfills\": [],\n            \"tsConfig\": \"tsconfig.app.json\",\n            \"assets\": [\n              {\n                \"glob\": \"**/*\",\n                \"input\": \"public\"\n              }\n            ],\n            \"styles\": [\n              \"src/styles.css\"\n            ],\n            \"scripts\": [],\n            \"server\": \"src/main.server.ts\",\n            \"outputMode\": \"server\",\n            \"ssr\": {\n              \"entry\": \"src/server.ts\"\n            },\n            \"externalDependencies\": [\"firebase-admin\", \"cookie-store\"]\n          },\n          \"configurations\": {\n            \"production\": {\n              \"budgets\": [\n                {\n                  \"type\": \"initial\",\n                  \"maximumWarning\": \"500kB\",\n                  \"maximumError\": \"1MB\"\n                },\n                {\n                  \"type\": \"anyComponentStyle\",\n                  \"maximumWarning\": \"4kB\",\n                  \"maximumError\": \"8kB\"\n                }\n              ],\n              \"outputHashing\": \"all\"\n            },\n            \"development\": {\n              \"optimization\": false,\n              \"extractLicenses\": false,\n              \"sourceMap\": true\n            }\n          },\n          \"defaultConfiguration\": \"production\"\n        },\n        \"serve\": {\n          \"builder\": \"@angular-devkit/build-angular:dev-server\",\n          \"configurations\": {\n            \"production\": {\n              \"buildTarget\": \"ng19-test:build:production\"\n            },\n            \"development\": {\n              \"buildTarget\": \"ng19-test:build:development\"\n            }\n          },\n          \"defaultConfiguration\": \"development\"\n        },\n        \"extract-i18n\": {\n          \"builder\": \"@angular-devkit/build-angular:extract-i18n\"\n        },\n        \"test\": {\n          \"builder\": \"@angular-devkit/build-angular:karma\",\n          \"options\": {\n            \"polyfills\": [],\n            \"tsConfig\": \"tsconfig.spec.json\",\n            \"assets\": [\n              {\n                \"glob\": \"**/*\",\n                \"input\": \"public\"\n              }\n            ],\n            \"styles\": [\n              \"src/styles.css\"\n            ],\n            \"scripts\": []\n          }\n        }\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "sample/database.rules.json",
    "content": "{\n  /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */\n  \"rules\": {\n    \".read\": true,\n    \".write\": false\n  }\n}"
  },
  {
    "path": "sample/firebase.json",
    "content": "{\n  \"database\": {\n    \"rules\": \"database.rules.json\"\n  },\n  \"firestore\": {\n    \"rules\": \"firestore.rules\",\n    \"indexes\": \"firestore.indexes.json\"\n  },\n  \"storage\": {\n    \"rules\": \"storage.rules\"\n  },\n  \"functions\": [\n    {\n      \"source\": \"functions\",\n      \"codebase\": \"default\",\n      \"ignore\": [\n        \"node_modules\",\n        \".git\",\n        \"firebase-debug.log\",\n        \"firebase-debug.*.log\"\n      ],\n      \"predeploy\": [\n        \"npm --prefix \\\"$RESOURCE_DIR\\\" run build\"\n      ]\n    }\n  ],\n  \"emulators\": {\n    \"auth\": {\n      \"port\": 9099\n    },\n    \"functions\": {\n      \"port\": 5001\n    },\n    \"firestore\": {\n      \"port\": 8080\n    },\n    \"database\": {\n      \"port\": 9000\n    },\n    \"storage\": {\n      \"port\": 9199\n    },\n    \"ui\": {\n      \"enabled\": true\n    }\n  }\n}\n"
  },
  {
    "path": "sample/firestore.indexes.json",
    "content": "{\n  \"indexes\": [\n    {\n      \"collectionGroup\": \"animals\",\n      \"queryScope\": \"COLLECTION\",\n      \"fields\": [\n        {\n          \"fieldPath\": \"upboats\",\n          \"order\": \"DESCENDING\"\n        },\n        {\n          \"fieldPath\": \"updatedAt\",\n          \"order\": \"DESCENDING\"\n        }\n      ]\n    }\n  ],\n  \"fieldOverrides\": []\n}\n"
  },
  {
    "path": "sample/firestore.rules",
    "content": "service cloud.firestore {\n  match /databases/{database}/documents {\n    match /{document=**} {\n      allow read;\n      allow write: if false;\n    }\n    match /animals/{document=**} {\n    \tallow read;\n      allow write: if request.auth != null;\n    }\n    match /dreams/{document=**} {\n    \tallow read;\n      allow write;\n    }\n  }\n}"
  },
  {
    "path": "sample/functions/.gitignore",
    "content": "# Compiled JavaScript files\n**/*.js\n**/*.js.map\n\n# Except the ESLint config file\n!.eslintrc.js\n\n# TypeScript v1 declaration files\ntypings/\n\n# Node.js dependency directory\nnode_modules/\nlib/\n"
  },
  {
    "path": "sample/functions/package.json",
    "content": "{\n  \"name\": \"functions\",\n  \"scripts\": {\n    \"build\": \"tsc\",\n    \"serve\": \"npm run build && firebase emulators:start --only functions\",\n    \"shell\": \"npm run build && firebase functions:shell\",\n    \"start\": \"npm run shell\",\n    \"deploy\": \"firebase deploy --only functions\",\n    \"logs\": \"firebase functions:log\"\n  },\n  \"engines\": {\n    \"node\": \"20\"\n  },\n  \"main\": \"lib/index.js\",\n  \"dependencies\": {\n    \"firebase-admin\": \"^13.0.1\",\n    \"firebase-functions\": \"^6.1.2\"\n  },\n  \"devDependencies\": {\n    \"typescript\": \"^5.7.2\"\n  },\n  \"private\": true\n}\n"
  },
  {
    "path": "sample/functions/src/index.ts",
    "content": "import { onCall } from \"firebase-functions/https\";\n\nexport const yada = onCall(() => {\n    return { time: new Date().getTime() };\n});\n"
  },
  {
    "path": "sample/functions/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"noImplicitReturns\": true,\n    \"noUnusedLocals\": true,\n    \"outDir\": \"lib\",\n    \"sourceMap\": true,\n    \"strict\": true,\n    \"target\": \"es2020\"\n  },\n  \"compileOnSave\": true,\n  \"include\": [\n    \"src\"\n  ]\n}\n"
  },
  {
    "path": "sample/package.json",
    "content": "{\n  \"name\": \"ng19-test\",\n  \"version\": \"0.0.0\",\n  \"scripts\": {\n    \"ng\": \"ng\",\n    \"start\": \"firebase emulators:exec --import seed \\\"ng serve\\\"\",\n    \"build\": \"ng build\",\n    \"watch\": \"ng build --watch --configuration development\",\n    \"test\": \"ng test\",\n    \"serve:ssr:ng19-test\": \"node dist/ng19-test/server/server.mjs\"\n  },\n  \"private\": true,\n  \"dependencies\": {\n    \"@angular/animations\": \"^19.0.0\",\n    \"@angular/common\": \"^19.0.0\",\n    \"@angular/compiler\": \"^19.0.0\",\n    \"@angular/core\": \"^19.0.0\",\n    \"@angular/fire\": \"file:../angular-fire-19.0.0.tgz\",\n    \"@angular/forms\": \"^19.0.0\",\n    \"@angular/platform-browser\": \"^19.0.0\",\n    \"@angular/platform-browser-dynamic\": \"^19.0.0\",\n    \"@angular/platform-server\": \"^19.0.0\",\n    \"@angular/router\": \"^19.0.0\",\n    \"@angular/ssr\": \"^19.0.0\",\n    \"cookie-parser\": \"^1.4.7\",\n    \"cookie-store\": \"^4.0.0-next.4\",\n    \"express\": \"^4.18.2\",\n    \"firebase-admin\": \"^13.0.1\",\n    \"js-cookie\": \"^3.0.5\",\n    \"rxjs\": \"~7.8.0\",\n    \"tslib\": \"^2.3.0\",\n    \"zone.js\": \"~0.15.0\"\n  },\n  \"devDependencies\": {\n    \"@angular-devkit/build-angular\": \"^19.0.0\",\n    \"@angular/cli\": \"^19.0.0\",\n    \"@angular/compiler-cli\": \"^19.0.0\",\n    \"@types/cookie-parser\": \"^1.4.8\",\n    \"@types/express\": \"^4.17.17\",\n    \"@types/jasmine\": \"~5.1.0\",\n    \"@types/js-cookie\": \"^3.0.6\",\n    \"@types/node\": \"^18.18.0\",\n    \"jasmine-core\": \"~5.4.0\",\n    \"karma\": \"~6.4.0\",\n    \"karma-chrome-launcher\": \"~3.2.0\",\n    \"karma-coverage\": \"~2.2.0\",\n    \"karma-jasmine\": \"~5.1.0\",\n    \"karma-jasmine-html-reporter\": \"~2.1.0\",\n    \"typescript\": \"~5.6.2\"\n  }\n}\n"
  },
  {
    "path": "sample/seed/auth_export/accounts.json",
    "content": "{\"kind\":\"identitytoolkit#DownloadAccountResponse\",\"users\":[]}"
  },
  {
    "path": "sample/seed/auth_export/config.json",
    "content": "{\"signIn\":{\"allowDuplicateEmails\":false}}"
  },
  {
    "path": "sample/seed/database_export/angularfire2-test.json",
    "content": "{\"test\":{\"foo\":\"bar\"}}"
  },
  {
    "path": "sample/seed/firebase-export-metadata.json",
    "content": "{\n  \"version\": \"9.18.0\",\n  \"firestore\": {\n    \"version\": \"1.13.1\",\n    \"path\": \"firestore_export\",\n    \"metadata_file\": \"firestore_export/firestore_export.overall_export_metadata\"\n  },\n  \"database\": {\n    \"version\": \"4.7.2\",\n    \"path\": \"database_export\"\n  },\n  \"auth\": {\n    \"version\": \"9.18.0\",\n    \"path\": \"auth_export\"\n  },\n  \"storage\": {\n    \"version\": \"9.18.0\",\n    \"path\": \"storage_export\"\n  }\n}"
  },
  {
    "path": "sample/seed/storage_export/buckets.json",
    "content": "{\n  \"buckets\": [\n    {\n      \"id\": \"default-bucket\"\n    },\n    {\n      \"id\": \"angularfire2-test.appspot.com\"\n    }\n  ]\n}\n"
  },
  {
    "path": "sample/seed/storage_export/metadata/angularfire2-test.appspot.com/google-g.png.json",
    "content": "{\n  \"name\": \"google-g.png\",\n  \"bucket\": \"angularfire2-test.appspot.com\",\n  \"contentType\": \"image/png\",\n  \"metageneration\": 1,\n  \"generation\": 1631220526565,\n  \"storageClass\": \"STANDARD\",\n  \"etag\": \"someETag\",\n  \"contentDisposition\": \"inline\",\n  \"contentEncoding\": \"identity\",\n  \"downloadTokens\": [\n    \"7553ce27-5bd0-409d-843b-25ff4d792740\"\n  ],\n  \"timeCreated\": \"2021-09-09T20:48:46.564Z\",\n  \"updated\": \"2021-09-09T20:48:46.567Z\",\n  \"size\": 9916,\n  \"md5Hash\": \"3NH+6XyxOMx2hUhq9d4hxQ==\",\n  \"crc32c\": \"2188947963\"\n}\n"
  },
  {
    "path": "sample/src/app/app.component.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AppComponent } from './app.component';\n\ndescribe('AppComponent', () => {\n  beforeEach(async () => {\n    await TestBed.configureTestingModule({\n      imports: [AppComponent],\n    }).compileComponents();\n  });\n\n  it('should create the app', () => {\n    const fixture = TestBed.createComponent(AppComponent);\n    const app = fixture.componentInstance;\n    expect(app).toBeTruthy();\n  });\n\n  it(`should have the 'ng19-test' title`, () => {\n    const fixture = TestBed.createComponent(AppComponent);\n    const app = fixture.componentInstance;\n    expect(app.title).toEqual('ng19-test');\n  });\n\n  it('should render title', () => {\n    const fixture = TestBed.createComponent(AppComponent);\n    fixture.detectChanges();\n    const compiled = fixture.nativeElement as HTMLElement;\n    expect(compiled.querySelector('h1')?.textContent).toContain('Hello, ng19-test');\n  });\n});\n"
  },
  {
    "path": "sample/src/app/app.component.ts",
    "content": "import { Component } from '@angular/core';\nimport { RouterOutlet } from '@angular/router';\nimport { AuthComponent } from './auth/auth.component';\nimport { DatabaseComponent } from './database/database.component';\nimport { FirestoreComponent } from './firestore/firestore.component';\nimport { FunctionsComponent } from './functions/functions.component';\nimport { MessagingComponent } from './messaging/messaging.component';\nimport { RemoteConfigComponent } from './remote-config/remote-config.component';\nimport { StorageComponent } from './storage/storage.component';\nimport { UpboatsComponent } from './upboats/upboats.component';\n\n@Component({\n  selector: 'app-root',\n  imports: [\n    RouterOutlet,\n    AuthComponent,\n    DatabaseComponent,\n    FirestoreComponent,\n    FunctionsComponent,\n    MessagingComponent,\n    RemoteConfigComponent,\n    StorageComponent,\n    UpboatsComponent\n  ],\n  template: `\n    Hello World!\n    <app-auth />\n    @defer (hydrate on idle) { <app-database /> } @placeholder { Database! &hellip; }\n    @defer (hydrate on idle) { <app-firestore /> } @placeholder { Firestore! &hellip; }\n    @defer (hydrate on idle) { <app-functions /> } @placeholder { Functions! &hellip; }\n    @defer (hydrate on idle) { <app-messaging /> } @placeholder { Messaging! &hellip; }\n    @defer (hydrate on idle) { <app-remote-config /> } @placeholder { Remote Config! &hellip; }\n    @defer (hydrate never) { <app-storage /> } @placeholder { Storage! &hellip; }\n    @defer (hydrate on idle) { <app-upboats /> } @placeholder { &hellip; }\n    <router-outlet />\n  `,\n})\nexport class AppComponent {\n  title = 'ng19-test';\n}\n"
  },
  {
    "path": "sample/src/app/app.config.client.ts",
    "content": "import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';\nimport { initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { getAnalytics, provideAnalytics, ScreenTrackingService, UserTrackingService } from '@angular/fire/analytics';\nimport { getMessaging, provideMessaging } from '@angular/fire/messaging';\nimport { getPerformance, providePerformance } from '@angular/fire/performance';\n\nimport { appConfig } from './app.config';\n\nimport { environment } from '../environments/environment';\n\nconst clientConfig: ApplicationConfig = {\n  providers: [\n    provideFirebaseApp(() => initializeApp(environment.firebase)),\n    provideAnalytics(() => getAnalytics()),\n    ScreenTrackingService,\n    UserTrackingService,\n    provideMessaging(() => getMessaging()),\n    providePerformance(() => getPerformance()),\n  ]\n};\n\nexport const config = mergeApplicationConfig(appConfig, clientConfig);\n"
  },
  {
    "path": "sample/src/app/app.config.server.ts",
    "content": "import { mergeApplicationConfig, ApplicationConfig, inject, REQUEST_CONTEXT } from '@angular/core';\nimport { initializeServerApp, provideFirebaseApp } from '@angular/fire/app';\nimport { provideServerRendering } from '@angular/platform-server';\nimport { provideServerRoutesConfig } from '@angular/ssr';\n\nimport { appConfig } from './app.config';\nimport { serverRoutes } from './app.routes.server';\nimport { environment } from '../environments/environment';\n\nconst serverConfig: ApplicationConfig = {\n  providers: [\n    provideServerRendering(),\n    provideServerRoutesConfig(serverRoutes),\n    provideFirebaseApp(() => {\n      // TODO migrate to REQUEST once that's working\n      const requestContext = inject(REQUEST_CONTEXT, { optional: true }) as {\n        authIdToken: string,\n      } | undefined;\n      const authIdToken = requestContext?.authIdToken;\n      return initializeServerApp(environment.firebase, { authIdToken });\n    }),\n  ]\n};\n\nexport const config = mergeApplicationConfig(appConfig, serverConfig);\n"
  },
  {
    "path": "sample/src/app/app.config.ts",
    "content": "import { ApplicationConfig, inject, provideExperimentalZonelessChangeDetection } from '@angular/core';\nimport { connectAuthEmulator, getAuth, provideAuth } from '@angular/fire/auth';\nimport { provideClientHydration, withIncrementalHydration } from '@angular/platform-browser';\nimport { provideRouter } from '@angular/router';\n\nimport { routes } from './app.routes';\nimport { FirebaseApp } from '@angular/fire/app';\nimport { environment } from '../environments/environment';\n\nexport const appConfig: ApplicationConfig = {\n  providers: [\n    provideExperimentalZonelessChangeDetection(),\n    provideRouter(routes),\n    provideClientHydration(withIncrementalHydration()),\n    provideAuth(() => {\n      const auth = getAuth(inject(FirebaseApp));\n      if ((auth as any)._canInitEmulator && environment.emulatorPorts?.auth) {\n        connectAuthEmulator(auth, `http://localhost:${environment.emulatorPorts.auth}`, { disableWarnings: true });\n      }\n      return auth;\n    }),\n  ],\n};\n"
  },
  {
    "path": "sample/src/app/app.routes.server.ts",
    "content": "import { RenderMode, ServerRoute } from '@angular/ssr';\n\nexport const serverRoutes: ServerRoute[] = [\n  {\n    path: '**',\n    renderMode: RenderMode.Server\n  }\n];\n"
  },
  {
    "path": "sample/src/app/app.routes.ts",
    "content": "import { Routes } from '@angular/router';\n\nexport const routes: Routes = [];\n"
  },
  {
    "path": "sample/src/app/auth/auth.component.ts",
    "content": "import { Component, inject, makeStateKey, OnDestroy, PLATFORM_ID, TransferState } from '@angular/core';\nimport { Auth, signInAnonymously, signOut, User } from '@angular/fire/auth';\nimport { map, startWith, switchMap, tap } from 'rxjs/operators';\nimport { AsyncPipe, isPlatformBrowser, isPlatformServer } from '@angular/common';\nimport cookies from 'js-cookie';\nimport { from, Observable } from 'rxjs';\nimport { GoogleAuthProvider, onAuthStateChanged, signInWithPopup, beforeAuthStateChanged, onIdTokenChanged } from \"firebase/auth\";\nimport { ɵzoneWrap } from \"@angular/fire\";\n\n// TODO bring this to RxFire\nfunction _authState(auth: Auth): Observable<User|null> {\n  return from(auth.authStateReady()).pipe(\n    switchMap(() => new Observable<User|null>((subscriber) => {\n      const unsubscribe = onAuthStateChanged(\n          auth,\n          subscriber.next.bind(subscriber),\n          subscriber.error.bind(subscriber),\n          subscriber.complete.bind(subscriber),\n      );\n      return {unsubscribe};\n    }))\n  );\n}\n\nexport const authState = ɵzoneWrap(_authState, true);\n\n@Component({\n    selector: 'app-auth',\n    template: `\n    <p>\n      Auth!\n      <code>{{ uid | async }}</code>\n      @if (showLoginButton | async) {\n        <button (click)=\"loginAnonymously()\">Log in anonymously</button>\n        <button (click)=\"loginWithGoogle()\">Log in with Google</button>\n      }\n      @if (showLogoutButton | async) {\n        <button (click)=\"logout()\">Log out</button>\n      }\n    </p>\n  `,\n    imports: [AsyncPipe]\n})\nexport class AuthComponent implements OnDestroy {\n\n  private readonly auth = inject(Auth);\n  protected readonly authState = authState(this.auth);\n\n  private readonly transferState = inject(TransferState);\n  private readonly transferStateKey = makeStateKey<string|undefined>(\"auth:uid\");\n  protected readonly uid = this.authState.pipe(map(u => u?.uid)).pipe(\n    isPlatformServer(inject(PLATFORM_ID)) ?\n        tap(it => this.transferState.set(this.transferStateKey, it)) :\n        this.transferState.hasKey(this.transferStateKey) ?\n          startWith(this.transferState.get(this.transferStateKey, undefined)) :\n          tap()\n);\n\n  protected readonly showLoginButton = this.uid.pipe(map(it => !it));\n  protected readonly showLogoutButton = this.uid.pipe(map(it => !!it));\n\n  private readonly unsubscribeFromOnIdTokenChanged: (() => void) | undefined;\n  private readonly unsubscribeFromBeforeAuthStateChanged: (() => void) | undefined;\n\n  constructor() {\n    if (isPlatformBrowser(inject(PLATFORM_ID))) {\n\n      this.unsubscribeFromOnIdTokenChanged = onIdTokenChanged(this.auth, async (user) => {\n          if (user) {\n              const idToken = await user.getIdToken();\n              cookies.set(\"__session\", idToken);\n          } else {\n              cookies.remove(\"__session\");\n          }\n      });\n  \n      let priorCookieValue: string|undefined;\n      this.unsubscribeFromBeforeAuthStateChanged = beforeAuthStateChanged(this.auth, async (user) => {\n          priorCookieValue = cookies.get(\"__session\");\n          const idToken = await user?.getIdToken();\n          if (idToken) {\n              cookies.set(\"__session\", idToken);\n          } else {\n              cookies.remove(\"__session\");\n          }\n      }, async () => {\n          // If another beforeAuthStateChanged rejects, revert the cookie (best-effort)\n          if (priorCookieValue) {\n              cookies.set(\"__session\", priorCookieValue);\n          } else {\n              cookies.remove(\"__session\");\n          }\n      });\n    }\n  }\n\n  ngOnDestroy(): void {\n      this.unsubscribeFromBeforeAuthStateChanged?.();\n      this.unsubscribeFromOnIdTokenChanged?.();\n  }\n\n  async logout() {\n    return await signOut(this.auth);\n  }\n\n  async loginAnonymously() {\n    return await signInAnonymously(this.auth);\n  }\n\n  async loginWithGoogle() {\n    return await signInWithPopup(this.auth, new GoogleAuthProvider());\n  }\n\n}\n"
  },
  {
    "path": "sample/src/app/database/database.component.ts",
    "content": "import { Component, inject, makeStateKey, PLATFORM_ID, TransferState } from '@angular/core';\nimport { startWith, tap } from 'rxjs';\nimport { connectDatabaseEmulator, getDatabase, objectVal, ref } from '@angular/fire/database';\nimport { AsyncPipe, isPlatformServer, JsonPipe } from '@angular/common';\nimport { FirebaseApp } from '@angular/fire/app';\nimport { environment } from '../../environments/environment';\n\n@Component({\n  selector: 'app-database',\n  template: `\n    <p>\n      Database!\n      <code>{{ testObjectValue$ | async | json }}</code>\n    </p>\n  `,\n  imports: [AsyncPipe, JsonPipe]\n})\nexport class DatabaseComponent {\n\n  private readonly database;\n\n  private readonly transferState = inject(TransferState);\n  private readonly transferStateKey = makeStateKey<unknown|undefined>(\"database:test\");\n  protected readonly testObjectValue$;\n\n  constructor() {\n    this.database = getDatabase(inject(FirebaseApp));\n    if (!(this.database as any)._instanceStarted && environment.emulatorPorts?.database) {\n      connectDatabaseEmulator(this.database, \"localhost\", environment.emulatorPorts.database);\n    }\n\n    this.testObjectValue$ = objectVal(ref(this.database, \"test\")).pipe(\n      isPlatformServer(inject(PLATFORM_ID)) ?\n          tap(it => this.transferState.set(this.transferStateKey, it)) :\n          this.transferState.hasKey(this.transferStateKey) ?\n            startWith(this.transferState.get(this.transferStateKey, undefined)) :\n            tap()\n    );\n  }\n}\n"
  },
  {
    "path": "sample/src/app/firestore/firestore.component.ts",
    "content": "import { Component, inject, makeStateKey, PLATFORM_ID, signal, TransferState } from '@angular/core';\nimport { traceUntilFirst } from '@angular/fire/performance';\nimport { doc, docData, getFirestore, connectFirestoreEmulator } from '@angular/fire/firestore';\nimport { startWith, tap } from 'rxjs';\nimport { AsyncPipe, isPlatformServer, JsonPipe } from '@angular/common';\nimport { FirebaseApp } from '@angular/fire/app';\nimport { environment } from '../../environments/environment';\n\n@Component({\n  selector: 'app-firestore',\n  template: `<p>\n    Firestore!\n    <code>{{ testDocValue | async | json }}</code>\n  </p>`,\n  imports: [ AsyncPipe, JsonPipe ]\n})\nexport class FirestoreComponent {\n\n  private readonly firestore;\n\n  private readonly transferState = inject(TransferState);\n  private readonly transferStateKey = makeStateKey<unknown|undefined>(\"firestore:test/1\");\n  public readonly testDocValue;\n\n  protected readonly className = signal(\"is-deferred\");\n\n  constructor() {\n    this.firestore = getFirestore(inject(FirebaseApp));\n    if (!(this.firestore as any)._settingsFrozen && environment.emulatorPorts?.firestore) {\n      connectFirestoreEmulator(this.firestore, \"localhost\", environment.emulatorPorts.firestore);\n    }\n\n    this.testDocValue = docData(doc(this.firestore, 'test/1')).pipe(\n      traceUntilFirst('firestore'),\n      isPlatformServer(inject(PLATFORM_ID)) ?\n          tap(it => this.transferState.set(this.transferStateKey, it)) :\n          this.transferState.hasKey(this.transferStateKey) ?\n            startWith(this.transferState.get(this.transferStateKey, undefined)) :\n            tap()\n    );\n  }\n\n}\n"
  },
  {
    "path": "sample/src/app/functions/functions.component.ts",
    "content": "import { JsonPipe } from '@angular/common';\nimport { afterNextRender, Component, inject, signal } from '@angular/core';\nimport { FirebaseApp } from '@angular/fire/app';\nimport { connectFunctionsEmulator, getFunctions, httpsCallableData } from '@angular/fire/functions';\nimport { environment } from '../../environments/environment';\n\n@Component({\n  selector: 'app-functions',\n  template: `\n    <p>\n      Functions!\n      <code>{{ response() | json }}</code>\n      <button (click)=\"request()\">Call!</button>\n    </p>\n  `,\n  imports: [JsonPipe]\n})\nexport class FunctionsComponent {\n\n  private readonly functions = getFunctions(inject(FirebaseApp));\n\n  protected readonly response = signal<unknown>(undefined);\n  private readonly yadaFunction = httpsCallableData(this.functions, 'yada', { timeout: 3_000 });\n\n  async request() {\n    this.yadaFunction({}).subscribe({\n      next: (next) => this.response.set(next),\n      error: (error) => this.response.set(error),\n    });\n  }\n\n  protected readonly className = signal(\"is-deferred\");\n\n  constructor() {\n    if (environment.emulatorPorts?.functions) {\n      connectFunctionsEmulator(this.functions, \"localhost\", environment.emulatorPorts.functions);\n    }\n\n    afterNextRender(() => {\n      if (this.className) this.className.set(\"\");\n    });\n  }\n\n}\n"
  },
  {
    "path": "sample/src/app/messaging/messaging.component.ts",
    "content": "import { AsyncPipe, JsonPipe, SlicePipe } from '@angular/common';\nimport { Component, inject, signal } from '@angular/core';\nimport { Messaging } from '@angular/fire/messaging';\nimport { EMPTY } from 'rxjs';\n\n@Component({\n  selector: 'app-messaging',\n  template: `\n    <p>\n      Messaging!\n      <code>{{ token$ | async | slice:0:12 }} @if (token$ | async) { &hellip; }</code>\n      &nbsp;<code>{{ message$ | async | json }}</code>\n      @if (showRequest()) {\n        <button (click)=\"request()\">Request FCM token</button>\n      }\n    </p>\n  `,\n  imports: [AsyncPipe, SlicePipe, JsonPipe]\n})\nexport class MessagingComponent {\n\n  private readonly messaging = inject(Messaging, { optional: true });\n  protected readonly token$ = EMPTY;\n  protected readonly message$ = EMPTY;\n\n  protected readonly showRequest = signal(false);\n\n  async request() {\n    await Notification.requestPermission();\n  }\n\n}\n"
  },
  {
    "path": "sample/src/app/remote-config/remote-config.component.ts",
    "content": "import { Component, inject, PLATFORM_ID } from '@angular/core';\nimport { getAllChanges, getRemoteConfig } from '@angular/fire/remote-config';\nimport { traceUntilFirst } from '@angular/fire/performance';\nimport { EMPTY } from 'rxjs';\nimport { AsyncPipe, isPlatformServer, JsonPipe } from '@angular/common';\nimport { FirebaseApp } from '@angular/fire/app';\n\n@Component({\n  selector: 'app-remote-config',\n  template: `<p>Remote Config! <code>{{ config$ | async | json }}</code></p>`,\n  imports: [AsyncPipe, JsonPipe],\n})\nexport class RemoteConfigComponent {\n\n  private readonly remoteConfig = isPlatformServer(inject(PLATFORM_ID)) ? undefined : getRemoteConfig(inject(FirebaseApp));\n  protected readonly config$ = this.remoteConfig ?\n    getAllChanges(this.remoteConfig).pipe(\n      traceUntilFirst('remote-config'),\n    ) :\n    EMPTY;\n\n}\n"
  },
  {
    "path": "sample/src/app/storage/storage.component.ts",
    "content": "import { Component, inject, makeStateKey, PLATFORM_ID, TransferState } from '@angular/core';\nimport { from, startWith, tap } from 'rxjs';\nimport { traceUntilFirst } from '@angular/fire/performance';\nimport { connectStorageEmulator, getDownloadURL, getStorage, ref } from '@angular/fire/storage';\nimport { AsyncPipe, isPlatformServer } from '@angular/common';\nimport { FirebaseApp } from '@angular/fire/app';\nimport { environment } from '../../environments/environment';\n\nconst TRANSPARENT_PNG\n  = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';\n\n@Component({\n  selector: 'app-storage',\n  template: `\n    <p>\n      Storage!\n      <img [src]=\"downloadUrl$ | async\" width=\"64\" height=\"64\" />\n    </p>\n  `,\n  imports: [AsyncPipe]\n})\nexport class StorageComponent {\n\n  private readonly storage = getStorage(inject(FirebaseApp));\n\n  private readonly transferState = inject(TransferState);\n  private readonly transferStateKey = makeStateKey<string|undefined>(\"storage:google-g.png\");\n  \n  private readonly icon = ref(this.storage, 'google-g.png');\n\n  protected readonly downloadUrl$ = from(getDownloadURL(this.icon)).pipe(\n    traceUntilFirst('storage'),\n    isPlatformServer(inject(PLATFORM_ID)) ?\n        tap(it => this.transferState.set(this.transferStateKey, it)) :\n        startWith(this.transferState.get(this.transferStateKey, TRANSPARENT_PNG))\n  );\n\n  constructor() {\n    if (environment.emulatorPorts?.storage) {\n      connectStorageEmulator(this.storage, \"localhost\", environment.emulatorPorts.storage);\n    }\n  }\n\n}\n"
  },
  {
    "path": "sample/src/app/upboats/upboats.component.ts",
    "content": "import { Component, inject, makeStateKey, OnInit, PLATFORM_ID, TransferState } from '@angular/core';\nimport { Observable } from 'rxjs';\nimport { map, startWith, tap } from 'rxjs/operators';\nimport { traceUntilFirst } from '@angular/fire/performance';\nimport { Auth } from '@angular/fire/auth';\nimport { addDoc, collection, collectionData, connectFirestoreEmulator, doc, getFirestore, increment, orderBy, query, serverTimestamp, updateDoc } from '@angular/fire/firestore';\nimport { AsyncPipe, isPlatformServer } from '@angular/common';\nimport { authState } from '../auth/auth.component';\nimport { FirebaseApp } from '@angular/fire/app';\nimport { environment } from '../../environments/environment';\n\nexport type Animal = {\n  name: string,\n  upboats: number,\n  id: string,\n  hasPendingWrites: boolean,\n};\n\n@Component({\n  selector: 'app-upboats',\n  template: `\n  <div>\n    <ul>\n      @for (animal of (animals | async); track animal.id) {\n        <li>\n          {{ animal.name }}\n          <button (click)=\"upboat(animal.id)\" [disabled]=\"(this.disableInputs | async)\">👍</button>\n          {{ animal.upboats }}\n          <button (click)=\"downboat(animal.id)\" [disabled]=\"(this.disableInputs | async)\">👎</button>\n          @if (animal.hasPendingWrites) { 🕒 }\n        </li>\n      }\n    </ul>\n    <button (click)=\"newAnimal()\" [disabled]=\"(this.disableInputs | async)\">New animal</button>\n  </div>\n  `,\n  styles: [\"div.is-deferred { opacity: 0.5; }\"],\n  imports: [AsyncPipe],\n})\nexport class UpboatsComponent implements OnInit {\n\n  private readonly transferState = inject(TransferState);\n  private readonly transferStateKeys = {\n    disableInputs: makeStateKey<boolean>(\"upboats:disableInputs\"),\n    animals: makeStateKey<Animal[]>(\"upboats:animals\"),\n  } as const;\n\n  protected readonly disableInputs = authState(inject(Auth)).pipe(\n    map(it => !it),\n    isPlatformServer(inject(PLATFORM_ID)) ?\n        tap(it => this.transferState.set(this.transferStateKeys.disableInputs, it)) :\n        startWith(this.transferState.get(this.transferStateKeys.disableInputs, true))\n  );\n\n  public readonly animals: Observable<Animal[]>;\n\n  private readonly firestore;\n\n  constructor() {\n    this.firestore = getFirestore(inject(FirebaseApp));;\n    if (!(this.firestore as any)._settingsFrozen && environment.emulatorPorts?.firestore) {\n      connectFirestoreEmulator(this.firestore, \"localhost\", environment.emulatorPorts.firestore);\n    }\n\n    const animalsCollection = collection(this.firestore, 'animals').withConverter<Animal>({\n      fromFirestore: snapshot => {\n        const { name, upboats } = snapshot.data();\n        const { id } = snapshot;\n        const { hasPendingWrites } = snapshot.metadata;\n        return { id, name, upboats, hasPendingWrites };\n      },\n      toFirestore: (it: any) => it,\n    });\n    const animalsQuery = query(animalsCollection, orderBy('upboats', 'desc'), orderBy('updatedAt', 'desc'));\n\n    this.animals = collectionData(animalsQuery).pipe(\n      traceUntilFirst('animals'),\n      isPlatformServer(inject(PLATFORM_ID)) ?\n        tap(it => this.transferState.set(this.transferStateKeys.animals, it)) :\n        this.transferState.hasKey(this.transferStateKeys.animals) ?\n          startWith(this.transferState.get(this.transferStateKeys.animals, [])) :\n          tap()\n    );\n  }\n\n  ngOnInit(): void {\n  }\n\n  async upboat(id: string) {\n    return await updateDoc(doc(this.firestore, `animals/${id}`), {\n        upboats: increment(1),\n        updatedAt: serverTimestamp(),\n    });\n  }\n\n  async downboat(id: string) {\n    return await updateDoc(doc(this.firestore, `animals/${id}`), {\n      upboats: increment(-1),\n      updatedAt: serverTimestamp(),\n    });\n  }\n\n  async newAnimal() {\n    return await addDoc(collection(this.firestore, 'animals'), {\n      name: prompt('Can haz name?'),\n      upboats: 1,\n      updatedAt: serverTimestamp(),\n    });\n  }\n\n}\n"
  },
  {
    "path": "sample/src/environments/environment.ts",
    "content": "export const environment = {\n    firebase: {\n        apiKey: \"AIzaSyBVSy3YpkVGiKXbbxeK0qBnu3-MNZ9UIjA\",\n        authDomain: \"angularfire2-test.firebaseapp.com\",\n        databaseURL: \"https://angularfire2-test.firebaseio.com\",\n        projectId: \"angularfire2-test\",\n        storageBucket: \"angularfire2-test.appspot.com\",\n        messagingSenderId: \"920323787688\",\n        appId: \"1:920323787688:web:2253a0e5eb5b9a8b\",\n        measurementId: \"G-W20QDV5CZP\"\n    },\n    emulatorPorts: {\n        auth: 9099,\n        functions: 5001,\n        firestore: 8080,\n        database: 9000,\n        storage: 9199,\n    },\n    vapidKey: 'BObYLml9CWDGcaj2xQTv6MwjS-R5mRyTlCbfTpflWy3iGHEMTyIhhd0FN6VIFszPoVzwEL_gm7o9ISxpotwKHfE',\n    recaptcha3SiteKey: '6LchwAoqAAAAAMfT_hY2nwI1WXJcBE20DGA_k-A3',\n};\n"
  },
  {
    "path": "sample/src/index.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n<head>\n  <meta charset=\"utf-8\">\n  <title>Ng19Test</title>\n  <base href=\"/\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n  <link rel=\"icon\" type=\"image/x-icon\" href=\"favicon.ico\">\n</head>\n<body>\n  <app-root></app-root>\n</body>\n</html>\n"
  },
  {
    "path": "sample/src/main.server.ts",
    "content": "import { bootstrapApplication } from '@angular/platform-browser';\nimport { AppComponent } from './app/app.component';\nimport { config } from './app/app.config.server';\n\nconst bootstrap = () => bootstrapApplication(AppComponent, config);\n\nexport default bootstrap;\n"
  },
  {
    "path": "sample/src/main.ts",
    "content": "import { bootstrapApplication } from '@angular/platform-browser';\nimport { config } from './app/app.config.client';\nimport { AppComponent } from './app/app.component';\n\nbootstrapApplication(AppComponent, config)\n  .catch((err) => console.error(err));\n"
  },
  {
    "path": "sample/src/server.ts",
    "content": "import {\n  AngularNodeAppEngine,\n  createNodeRequestHandler,\n  isMainModule,\n  writeResponseToNodeResponse,\n} from '@angular/ssr/node';\nimport express from 'express';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport cookieParser from \"cookie-parser\";\n\nconst serverDistFolder = dirname(fileURLToPath(import.meta.url));\nconst browserDistFolder = resolve(serverDistFolder, '../browser');\n\nconst app = express();\nconst angularApp = new AngularNodeAppEngine();\n\napp.use(\n  express.static(browserDistFolder, {\n    maxAge: '1y',\n    index: false,\n    redirect: false,\n  }),\n);\n\napp.use(cookieParser());\n\napp.use('/**', (req, res, next) => {\n  angularApp\n    .handle(req, { authIdToken: req.cookies?.__session })\n    .then((response) =>\n      response ? writeResponseToNodeResponse(response, res) : next(),\n    )\n    .catch(next);\n});\n\nif (isMainModule(import.meta.url)) {\n  const port = process.env['PORT'] || 4000;\n  app.listen(port, () => {\n    console.log(`Node Express server listening on http://localhost:${port}`);\n  });\n}\n\nexport const reqHandler = createNodeRequestHandler(app);\n"
  },
  {
    "path": "sample/src/styles.css",
    "content": "/* You can add global styles to this file, and also import other style files */\n"
  },
  {
    "path": "sample/storage.rules",
    "content": "rules_version = '2';\nservice firebase.storage {\n  match /b/{bucket}/o {\n    match /{allPaths=**} {\n      allow read;\n      allow write: if request.auth!=null;\n    }\n  }\n}\n"
  },
  {
    "path": "sample/tsconfig.app.json",
    "content": "/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */\n/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */\n{\n  \"extends\": \"./tsconfig.json\",\n  \"compilerOptions\": {\n    \"outDir\": \"./out-tsc/app\",\n    \"types\": [\n      \"node\"\n    ]\n  },\n  \"files\": [\n    \"src/main.ts\",\n    \"src/main.server.ts\",\n    \"src/server.ts\"\n  ],\n  \"include\": [\n    \"src/**/*.d.ts\"\n  ]\n}\n"
  },
  {
    "path": "sample/tsconfig.json",
    "content": "/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */\n/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */\n{\n  \"compileOnSave\": false,\n  \"compilerOptions\": {\n    \"outDir\": \"./dist/out-tsc\",\n    \"strict\": true,\n    \"noImplicitOverride\": true,\n    \"noPropertyAccessFromIndexSignature\": true,\n    \"noImplicitReturns\": true,\n    \"noFallthroughCasesInSwitch\": true,\n    \"skipLibCheck\": true,\n    \"isolatedModules\": true,\n    \"esModuleInterop\": true,\n    \"experimentalDecorators\": true,\n    \"moduleResolution\": \"bundler\",\n    \"importHelpers\": true,\n    \"target\": \"ES2022\",\n    \"module\": \"ES2022\"\n  },\n  \"angularCompilerOptions\": {\n    \"enableI18nLegacyMessageIdFormat\": false,\n    \"strictInjectionParameters\": true,\n    \"strictInputAccessModifiers\": true,\n    \"strictTemplates\": true\n  }\n}\n"
  },
  {
    "path": "sample/tsconfig.spec.json",
    "content": "/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */\n/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */\n{\n  \"extends\": \"./tsconfig.json\",\n  \"compilerOptions\": {\n    \"outDir\": \"./out-tsc/spec\",\n    \"types\": [\n      \"jasmine\"\n    ]\n  },\n  \"include\": [\n    \"src/**/*.spec.ts\",\n    \"src/**/*.d.ts\"\n  ]\n}\n"
  },
  {
    "path": "site/.eleventy.js",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst eleventyNavigationPlugin = require(\"@11ty/eleventy-navigation\");\nconst prism = require('markdown-it-prism');\n\nmodule.exports = eleventyConfig => {\n  eleventyConfig.setUseGitIgnore(false);\n  eleventyConfig.addPlugin(eleventyNavigationPlugin);\n\n  eleventyConfig.addWatchTarget(\"./_tmp/style.css\");\n  eleventyConfig.addPassthroughCopy({ \"./src/styles/prism.css\": \"./prism.css\"});\n  eleventyConfig.addPassthroughCopy({ \"./src/js/**/*.js\": \"./js\"});\n  eleventyConfig.addPassthroughCopy({ \"./_tmp/style.css\": \"./style.css\" });\n  eleventyConfig.setLibrary(\"md\", configureMarkdownIt());\n\n  registerShortcodes(eleventyConfig);\n\n  return {\n    dir: {\n      input: \"src\",\n      output: \"public\"\n    },\n    templateFormats: [\n      \"md\",\n      \"njk\",\n      \"html\",\n      \"svg\",\n      \"woff2\",\n      \"ico\",\n    ],\n    markdownTemplateEngine: \"njk\",\n    htmlTemplateEngine: \"njk\",\n    dataTemplateEngine: \"njk\",\n  };\n};\n\nfunction configureMarkdownIt() {\n  return require(\"markdown-it\")({\n    html: true,\n    linkify: true,\n    replaceLink: function rewriteRelativeLinks (link, env) {\n      // TODO(davideast): Create readable expressions or matches\n      // for this if statement tree.\n      if (link.indexOf('./') !== -1) {\n        link = link.replace('./', '/reference/');\n        if (link === '/reference/index') {\n          link = '/reference';\n        }\n        if (link === '/reference/firestore') {\n          link = '/reference/firestore_';\n        }\n      }\n      return link;\n    }\n  }).use(require('markdown-it-attrs'))\n    // https://github.com/markdown-it/markdown-it-container/issues/23\n    .use(require('markdown-it-container'), 'dynamic', {\n      validate: function () { return true; },\n      render: function (tokens, idx) {\n        const token = tokens[idx];\n        if (token.nesting === 1) {\n          return '<div class=\"' + token.info.trim() + '\">';\n        } else {\n          return '</div>';\n        }\n      },\n    })\n    .use(require('markdown-it-replace-link'))\n    .use(prism);\n}\n\nfunction registerShortcodes(eleventyConfig) {\n  const { shortcodes } = require('./src/shortcodes');\n  shortcodes.forEach(shortcode => {\n    console.log(`Creating shortcode: ${shortcode.name} as ${shortcode.type}`);\n    eleventyConfig[shortcode.type](shortcode.name, shortcode.create);\n  });\n}\n"
  },
  {
    "path": "site/.firebaserc",
    "content": "{\n  \"projects\": {\n    \"default\": \"afdocsite\"\n  }\n}\n"
  },
  {
    "path": "site/.gitignore",
    "content": "_site\npublic\n_tmp\n"
  },
  {
    "path": "site/firebase.json",
    "content": "{\n  \"hosting\": {\n    \"public\": \"public\",\n    \"cleanUrls\": true,\n    \"redirects\": [\n      {\n        \"source\": \"/get-started\",\n        \"destination\": \"/get-started/quick-start\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/analytics\",\n        \"destination\": \"/analytics/getting-started\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/auth\",\n        \"destination\": \"/auth/getting-started\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/firestore\",\n        \"destination\": \"/firestore/documents\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/functions\",\n        \"destination\": \"/functions/getting-started\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/ionic\",\n        \"destination\": \"/ionic/getting-started\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/messaging\",\n        \"destination\": \"/messaging/getting-started\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/performance\",\n        \"destination\": \"/performance/getting-started\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/remote-config\",\n        \"destination\": \"/remote-config/getting-started\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/rtdb\",\n        \"destination\": \"/rtdb/getting-started\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/storage\",\n        \"destination\": \"/storage/getting-started\",\n        \"type\": 301\n      },\n      {\n        \"source\": \"/universal\",\n        \"destination\": \"/universal/getting-started\",\n        \"type\": 301\n      }\n    ],\n    \"ignore\": [\n      \"firebase.json\",\n      \"**/.*\",\n      \"**/node_modules/**\"\n    ]\n  }\n}\n"
  },
  {
    "path": "site/package.json",
    "content": "{\n  \"name\": \"angularfire-guide\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"private\": true,\n  \"scripts\": {\n    \"start\": \"eleventy --serve & postcss ./src/styles/tailwind.css --o _tmp/style.css --watch\",\n    \"quiet\": \"eleventy --quiet --serve & postcss ./src/styles/tailwind.css --o _tmp/style.css --watch\",\n    \"just_a_comment_explaining_below\": \"The build scripts are read by scripts/build.js and executed in their number order (_0_, _1_, etc...), hence the weird naming system.\",\n    \"build:_0_clean\": \"rm -rf _site\",\n    \"build:_1_css\": \"NODE_ENV=production postcss ./src/styles/tailwind.css --o _site/style.css\",\n    \"build:_2_eleventy\": \"ELEVENTY_PRODUCTION=true eleventy\",\n    \"build\": \"node scripts/build.js\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"devDependencies\": {\n    \"@11ty/eleventy\": \"^0.11.1\",\n    \"@11ty/eleventy-navigation\": \"^0.1.6\",\n    \"firebase-tools\": \"^9.3.0\",\n    \"markdown-it\": \"^12.0.4\",\n    \"markdown-it-attrs\": \"^3.0.3\",\n    \"markdown-it-container\": \"^3.0.0\",\n    \"markdown-it-prism\": \"^2.1.3\",\n    \"markdown-it-replace-link\": \"^1.1.0\",\n    \"nunjucks\": \"^3.2.2\",\n    \"postcss-cli\": \"^8.3.1\",\n    \"postcss-import\": \"^14.0.0\",\n    \"shelljs\": \"^0.8.4\",\n    \"tailwindcss\": \"^2.0.2\"\n  },\n  \"dependencies\": {}\n}\n"
  },
  {
    "path": "site/postcss.config.js",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nmodule.exports = {\n  plugins: [\n    require(`tailwindcss`)(`./src/styles/tailwind.config.js`),\n  ],\n};\n"
  },
  {
    "path": "site/scripts/build.js",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst { exec, echo } = require('shelljs');\nconst pkg = require('../package.json');\n\nfunction runExec(command) {\n  if (exec(command).code !== 0) {\n    echo(`${command} failed`);\n  }\n}\n\nconst buildScripts = Object.keys(pkg.scripts)\n  .filter(k => k.startsWith('build:'));\n\nfor(let script of buildScripts) {\n  console.log(`Running npm run ${script}`);\n  runExec(`npm run ${script}`);\n}\n"
  },
  {
    "path": "site/src/_data/nextprev.json",
    "content": "{\n  \"Get started\": { \n    \"key\": \"Get Started\", \n    \"url\": \"/get-started\", \n    \"children\": [\n      { \"key\": \"Quick start\", \"url\": \"/get-started\" },\n      { \"key\": \"Deploying\", \"url\": \"/get-started/deploying\" },\n      { \"key\": \"Local development\", \"url\": \"/get-started/local-development\" }\n    ]\n  },\n  \"Firestore\": {\n    \"key\": \"Firestore\", \n    \"url\": \"/firestore\", \n    \"children\": [\n      { \"key\": \"Documents\", \"url\": \"/firestore/documents\" },\n      { \"key\": \"Collections\", \"url\": \"/firestore/collections\" }\n    ]    \n  },\n  \"Auth\": {\n    \"key\": \"Auth\", \n    \"url\": \"/auth\", \n    \"children\": [\n      { \"key\": \"Getting started\", \"url\": \"/auth\" },\n      { \"key\": \"Route guards\", \"url\": \"/auth/route-gards\" }\n    ]    \n  },\n  \"RTDB\": {\n    \"key\": \"RTDB\", \n    \"url\": \"/rtdb\", \n    \"children\": [\n      { \"key\": \"Objects\", \"url\": \"/rtdb/objects\" },\n      { \"key\": \"Lists\", \"url\": \"/rtdb/lists\" },\n      { \"key\": \"Querying\", \"url\": \"/rtdb/querying\" }\n    ]    \n  },\n  \"Analytics\": {\n    \"key\": \"Analytics\", \n    \"url\": \"/analytics\", \n    \"children\": [\n      { \"key\": \"Getting started\", \"url\": \"/analytics\" }\n    ]    \n  },\n  \"Storage\": {\n    \"key\": \"Storage\", \n    \"url\": \"/storage\", \n    \"children\": [\n      { \"key\": \"Getting started\", \"url\": \"/storage\" }\n    ]\n  },\n  \"Functions\": {\n    \"key\": \"Functions\", \n    \"url\": \"/functions\", \n    \"children\": [\n      { \"key\": \"Getting started\", \"url\": \"/functions\" }\n    ]\n  },\n  \"Messaging\": {\n    \"key\": \"Messaging\", \n    \"url\": \"/messaging\", \n    \"children\": [\n      { \"key\": \"Getting started\", \"url\": \"/messaging\" }\n    ]\n  },\n  \"Remote Config\": {\n    \"key\": \"Remote Config\", \n    \"url\": \"/remote-config\", \n    \"children\": [\n      { \"key\": \"Getting started\", \"url\": \"/remote-config\" }\n    ]\n  },\n  \"Performance\": {\n    \"key\": \"Performance\", \n    \"url\": \"/performance\", \n    \"children\": [\n      { \"key\": \"Getting started\", \"url\": \"/performance\" }\n    ]\n  },\n  \"Universal\": {\n    \"key\": \"Universal\", \n    \"url\": \"/universal\", \n    \"children\": [\n      { \"key\": \"Getting started\", \"url\": \"/universal\" },\n      { \"key\": \"Cloud Functions\", \"url\": \"/universal/cloud-functions\" },\n      { \"key\": \"Prerendering\", \"url\": \"/universal/prerendering\" }\n    ]\n  },\n  \"Ionic\": {\n    \"key\": \"Ionic\", \n    \"url\": \"/ionic\", \n    \"children\": [\n      { \"key\": \"Getting started\", \"url\": \"/ionic/getting-started\" },\n      { \"key\": \"Authentication\", \"url\": \"/ionic/authentication\" }\n    ]\n  }\n}\n"
  },
  {
    "path": "site/src/_includes/default.njk",
    "content": "{% import \"side-nav.njk\" as nav %}\n\n<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <title>\n      {% block title %}AngularFire Guide{% endblock %}\n    </title>\n    <meta charset=\"utf-8\" />\n    {% if description %}\n      <meta name=\"description\" content=\"{{description}}\"/>\n    {% endif%}\n    <meta http-equiv=\"x-ua-compatible\" content=\"ie=edge\"/>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover\"/>\n    <link rel=\"stylesheet\" href=\"/style.css?v={% version %}\"/>\n    <link rel=\"stylesheet\" href=\"/prism.css?v={% version %}\"/>\n    <script type=\"module\" src=\"/js/click-card.js?v={% version %}\"></script>\n    <script type=\"module\" src=\"/js/menu-button.js?v={% version %}\"></script>\n  </head>\n  <body class=\"text-lg font-body docs-content\">\n\n    <main class=\"relative py-18\">\n        \n      <aside id=\"sideNav\" class=\"sticky top-0 bg-gray-100\">\n        <header class=\"py-16\">\n          <section class=\"flex items-center\">\n\n            <div class=\"mr-2\">\n              <img src=\"/assets/firebase-logo.svg\" class=\"w-10 h-10\" />\n            </div>\n\n            <div class=\"\">\n              <div class=\"text-sm\">\n                <a href=\"/\" class=\"font-bold text-black font-display hover:underline\">\n                  AngularFire\n                </a>\n              </div>\n              <div class=\"text-sm font-mono text-grey-300\">\n                @angular/fire\n              </div>\n            </div>\n\n          </section>\n        </header>\n        <section class=\"sticky overflow-y-scroll top-16\">\n          <nav>\n\n            {%- for section in collections.all | eleventyNavigation | mergeNavigation %}\n              {{ nav.navsection(section, page) }}\n            {%- endfor %}\n\n          </nav>\n        </section>\n      </aside>\n\n      <article>\n        <section class=\"container py-16 mt-24\">\n        {% block content%}\n          {{ content | safe }}\n        {% endblock %}\n        <section>\n      </article>\n      \n      <eap-menu-button data-menu-id=\"sideNav\"></eap-menu-button>\n\n    </main>\n\n  </body>\n</html>\n"
  },
  {
    "path": "site/src/_includes/guide.njk",
    "content": "{% extends \"default.njk\" %}\n{% import \"next-prev.njk\" as nextprev with context %}\n\n{% block content %}\n\n  <h1>{{ title }}</h1>\n  \n  {{ content | safe }}\n  {{ nextprev.contextgrid(\"guides\") }}\n\n{% endblock %}\n"
  },
  {
    "path": "site/src/_includes/next-prev.njk",
    "content": "\n{% macro item(direction, title, url) %}\n  {% set justifyDirection = 'justify-center lg:justify-start xl:justify-start' %}\n  {% set textDirection = 'text-center lg:text-left xl:text-left' %}\n\n  {% if direction === 'Next' %}\n    {% set justifyDirection = 'justify-center lg:justify-end xl:justify-end' %}\n    {% set textDirection = 'text-center lg:text-right xl:text-right' %}\n  {% endif%}\n\n  <eap-click-card class=\"flex items-center h-32 px-8 py-6 bg-gray-100 rounded-md shadow-md {{ textDirection }} {{ justifyDirection }}\">\n    <div>\n      <h5 class=\"text-xl font-bold tracking-wider text-black uppercase font-display\">\n        {{ direction }}\n      </h5>\n      <a class=\"underline text-blue\" href=\"{{ url }}\">\n        {{ title }}\n      </a>\n    </div>\n  </eap-click-card>\n{% endmacro %}\n\n{% macro grid(prevRecord, nextRecord) %}\n  \n  <section class=\"py-8 next-prev\">\n\n    <nav>\n      <ul class=\"prevnext-grid grid grid-cols-2 gap-x-4 lg:gap-x-16 xl:gap-x-16 list-none p-0 m-0\">\n\n      {% if prevRecord %}\n      <li class=\"border-b-4 border-solid border-blue\">\n        {{ item(\"Previous\", prevRecord.key, prevRecord.url) }}\n      </li>\n      {% else %}\n      <div></div>\n      {% endif %}\n\n      {% if nextRecord %}\n      <li class=\"border-b-4 border-solid border-blue\">\n        {{ item(\"Next\", nextRecord.key, nextRecord.url) }}  \n      </li>\n      {% else %}\n      <div></div>\n      {% endif %}\n\n      </ul>\n    </nav>\n\n  </section>\n\n{% endmacro %}\n\n{% macro contextgrid(tag) %}\n  {# Get the current page index from eleventyNavigation and then get the next and previous pages #}\n  \n  {% if eleventyNavigation.parent %}\n    {% set children = nextprev[eleventyNavigation.parent].children %}\n    {% set prevRecord = children | findPreviousEntry(eleventyNavigation) %}\n    {% set nextRecord = children | findNextEntry(eleventyNavigation) %}\n\n    {{ grid(prevRecord, nextRecord) }}\n\n  {% endif%}\n\n{% endmacro %}\n"
  },
  {
    "path": "site/src/_includes/side-nav.njk",
    "content": "{# \nType of sectionEntry\n[{\n    \"key\": \"Mammals\",\n    \"url\": \"/mammals/\",\n    \"title\": \"Mammals\",\n    \"children\": [{\n        \"key\": \"Humans\",\n        \"parentKey\": \"Mammals\",\n        \"url\": \"/humans/\",\n        \"title\": \"Humans\"\n      },\n      {\n        \"key\": \"Dogs\",\n        \"parentKey\": \"Mammals\",\n        \"url\": \"/dogs/\",\n        \"title\": \"Dogs\"\n      }]\n  }] \n#}\n\n{% macro navsection(sectionEntry, page) %}\n<ul class=\"pb-4\">\n\n  <li class=\"font-bold font-display\">\n\n    <a href=\"{{sectionEntry.url}}\" {% if page.url == sectionEntry.url %} aria-current=\"page\"{% endif %}>\n      {{sectionEntry.key}}\n    </a>\n\n    <ul class=\"mt-2 ml-6 text-sm font-normal font-body text-grey-300\">\n\n    {%- for pageEntry in sectionEntry.children %}\n      <li class=\"py-1\">\n        <a href=\"{{pageEntry.url}}\" {% if page.url == pageEntry.url %} aria-current=\"page\" class=\"text-blue\"{% endif %}>\n          {{pageEntry.key}}\n        </a>\n      </li>\n    {% endfor %}\n    </ul>\n\n  </li>\n\n</ul>\n{% endmacro %}\n"
  },
  {
    "path": "site/src/analytics/analytics.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/analytics/getting-started.md",
    "content": "---\ntitle: Getting started\neleventyNavigation:\n  key: Getting started\n  parent: Analytics\n---\n\n## Google Analytics\n\n`AngularFireAnalytics` dynamically imports the `firebase/analytics` library and provides a promisified version of the [Firebase Analytics SDK (`firebase.analytics.Analytics`)](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html).\n\n## API Summary\n\n```ts\nclass AngularFireAnalytics {\n  updateConfig(options: {[key:string]: any}): Promise<void>;\n\n  // from firebase.analytics() proxy:\n  logEvent(eventName: string, eventParams?: {[key: string]: any}, options?: analytics.AnalyticsCallOptions): Promise<void>;\n  setCurrentScreen(screenName: string, options?: analytics.AnalyticsCallOptions): Promise<void>;\n  setUserId(id: string, options?: analytics.AnalyticsCallOptions): Promise<void>;\n  setUserProperties(properties: analytics.CustomParams, options?: analytics.AnalyticsCallOptions): Promise<void>;\n  setAnalyticsCollectionEnabled(enabled: boolean): Promise<void>;\n  app: Promise<app.App>;\n}\n\nCOLLECTION_ENABLED = InjectionToken<boolean>;\nAPP_VERSION = InjectionToken<string>;\nAPP_NAME = InjectionToken<string>;\nDEBUG_MODE = InjectionToken<boolean>;\nCONFIG = InjectionToken<Config>;\n```\n\n## Usage\n\n```ts\nimport { AngularFireAnalyticsModule } from '@angular/fire/analytics';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireAnalyticsModule\n  ]\n})\nexport class AppModule { }\n```\n\n`AngularFireAnalyticsModule` will dynamically import and configure `firebase/analytics`. A `page_view` event will automatically be logged (see `CONFIG` below if you wish to disable this behavior.)\n\nIn your component you can then dependency inject `AngularFireAnalytics` and make calls against the SDK:\n\n```ts\nimport { AngularFireAnalytics } from '@angular/fire/analytics';\n\nconstructor(analytics: AngularFireAnalytics) {\n  analytics.logEvent('custom_event', { ... });\n}\n```\n\n## Tracking Screen Views\n\nYou can log [`screen_view` events](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html#parameters_10) yourself of course, but AngularFire provides the `ScreenTrackingService` which automatically integrates with the Angular Router to provide Firebase with screen view tracking. You simply can integrate like so:\n\n```ts\nimport { AngularFireAnalyticsModule, ScreenTrackingService } from '@angular/fire/analytics';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireAnalyticsModule\n  ],\n  providers: [\n    ScreenTrackingService\n  ]\n})\nexport class AppModule { }\n```\n\n`AngularFireAnalyticsModule` will initialize `ScreenTrackingService` if it is provided.\n\n## Tracking User Identifiers\n\nTo enrich your Analytics data you can track the currently signed in user by setting [`setuserid`](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html#setuserid) and [`setUserProperties`](https://firebase.google.com/docs/reference/js/firebase.analytics.Analytics.html#set-user-properties). AngularFire provides a `UserTrackingService` which will dynamically import `firebase/auth`, monitor for changes in the logged in user, and call `setuserid` for you automatically.\n\n\n```ts\nimport { AngularFireAnalyticsModule, UserTrackingService } from '@angular/fire/analytics';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireAnalyticsModule\n  ],\n  providers: [\n    UserTrackingService\n  ]\n})\nexport class AppModule { }\n```\n\n`AngularFireAnalyticsModule` will initialize `UserTrackingService` if it is provided.\n\n## Configuration with Dependency Injection\n\nUsing the `CONFIG` DI Token (*default: {}*) will allow you to configure Google Analytics. E.g, you could skip sending the initial `page_view` event, anonymize IP addresses, and disallow ads personalization signals for all events like so:\n\n```ts\nimport { AngularFireAnalyticsModule, CONFIG } from '@angular/fire/analytics';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireAnalyticsModule\n  ],\n  providers: [\n    { provide: CONFIG, useValue: {\n      send_page_view: false,\n      allow_ad_personalization_signals: false,\n      anonymize_ip: true\n    } }\n  ]\n})\nexport class AppModule { }\n```\n\nSee the gtag.js documentation to learn of the different configuration options at your disposal.\n\n## Use DebugView\n\nTo use [DebugView in Analytics](https://console.firebase.google.com/project/_/analytics/debugview) set `DEBUG_MODE` to `true` (*default: false*).\n\n## Track deployments\n\nIf you provide `APP_NAME` and `APP_VERSION` (*default: undefined*) you will be able to [track version adoption](https://console.firebase.google.com/project/_/analytics/latestrelease) of your PWA.\n\n## Disable collection\n\nIf you set `COLLECTION_ENABLED` (*default: true*) to `false` then analytics collection will be disabled for this app on this device. To opt back in to analytics collection you could then call `setAnalyticsCollectionEnabled(true)`.\n\nPutting these APIs to use with cookies would allow you to create a flexible analytics collection scheme that would respect your user's preferences and data collection policies.\n"
  },
  {
    "path": "site/src/analytics/index.md",
    "content": "---\neleventyNavigation:\n  key: Analytics\n  order: 5\n---\n\n"
  },
  {
    "path": "site/src/auth/auth.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/auth/getting-started.md",
    "content": "---\ntitle: Getting started\neleventyNavigation:\n  key: Getting started\n  parent: Auth\n---\n\n## Using AngularFireAuth\n\n`AngularFireAuth.user` provides you an `Observable<User|null>` to monitor your application's authentication State.\n\n`AngularFireAuth` promise proxies an initialized\n`firebase.auth.Auth` instance, allowing you to log users in, out, etc. [See\nthe Firebase docs for more information on what methods are available.](https://firebase.google.com/docs/reference/js/firebase.auth.Auth)\n\n**Example app:**\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireAuth } from '@angular/fire/auth';\nimport firebase from 'firebase/app';\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n    <div *ngIf=\"auth.user | async as user; else showLogin\">\n      <h1>Hello {{ user.displayName }}!</h1>\n      <button (click)=\"logout()\">Logout</button>\n    </div>\n    <ng-template #showLogin>\n      <p>Please login.</p>\n      <button (click)=\"login()\">Login with Google</button>\n    </ng-template>\n  {%endraw%}`,\n})\nexport class AppComponent {\n  constructor(public auth: AngularFireAuth) {\n  }\n  login() {\n    this.auth.signInWithPopup(new firebase.auth.GoogleAuthProvider());\n  }\n  logout() {\n    this.auth.signOut();\n  }\n}\n```\n\n## UI Libraries\n\n- Material Design : [ngx-auth-firebaseui](https://github.com/AnthonyNahas/ngx-auth-firebaseui)\n- Bootstrap : [@firebaseui/ng-bootstrap](https://github.com/firebaseui/ng-bootstrap)\n\n## Cordova\n\nLearn how to [setup Firebase Authentication with Cordova](https://firebase.google.com/docs/auth/web/cordova) in the Firebase Guides.\n"
  },
  {
    "path": "site/src/auth/index.md",
    "content": "---\neleventyNavigation:\n  key: Auth\n  order: 3\n---\n"
  },
  {
    "path": "site/src/auth/route-guards.md",
    "content": "---\ntitle: Route guards\neleventyNavigation:\n  key: Route guards\n  parent: Auth\n---\n\n## Route users with AngularFire guards\n\n`AngularFireAuthGuard` provides a prebuilt [`canActivate` Router Guard](https://angular.io/api/router/CanActivate) using `AngularFireAuth`. By default unauthenticated users are not permitted to navigate to protected routes:\n\n```ts\nimport { AngularFireAuthGuard } from '@angular/fire/auth-guard';\n\nexport const routes: Routes = [\n    { path: '',      component: AppComponent },\n    { path: 'items', component: ItemListComponent, canActivate: [AngularFireAuthGuard] },\n]\n```\n\n## Customizing the behavior\n\nTo customize the behavior of `AngularFireAuthGuard`, you can pass an RXJS pipe through the route data's `authGuardPipe` key.\n\nThe `auth-guard` module provides the following pre-built pipes:\n\n| Exported pipe                      | Functionality |\n|-|-|\n| `loggedIn`                         | The default pipe, rejects if the user is not authenticated. |\n| `isNotAnonymous`                   | Rejects if the user is anonymous |\n| `emailVerified`                    | Rejects if the user's email is not verified |\n| `hasCustomClaim(claim)`            | Rejects if the user does not have the specified claim |\n| `redirectUnauthorizedTo(redirect)` | Redirect unauthenticated users to a different route  |\n| `redirectLoggedInTo(redirect)`     | Redirect authenticated users to a different route |\n\nExample use:\n\n```ts\nimport { AngularFireAuthGuard, hasCustomClaim, redirectUnauthorizedTo, redirectLoggedInTo } from '@angular/fire/auth-guard';\n\nconst adminOnly = () => hasCustomClaim('admin');\nconst redirectUnauthorizedToLogin = () => redirectUnauthorizedTo(['login']);\nconst redirectLoggedInToItems = () => redirectLoggedInTo(['items']);\nconst belongsToAccount = (next) => hasCustomClaim(`account-${next.params.id}`);\n\nexport const routes: Routes = [\n    { path: '',      component: AppComponent },\n    { path: 'login', component: LoginComponent,        canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectLoggedInToItems }},\n    { path: 'items', component: ItemListComponent,     canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectUnauthorizedToLogin }},\n    { path: 'admin', component: AdminComponent,        canActivate: [AngularFireAuthGuard], data: { authGuardPipe: adminOnly }},\n    { path: 'accounts/:id', component: AdminComponent, canActivate: [AngularFireAuthGuard], data: { authGuardPipe: belongsToAccount }}\n];\n```\n\nUse the provided `canActivate` helper and spread syntax to make your routes more readable:\n\n```ts\nimport { canActivate } from '@angular/fire/auth-guard';\n\nexport const routes: Routes = [\n    { path: '',             component: AppComponent },\n    { path: 'login',        component: LoginComponent,    ...canActivate(redirectLoggedInToItems) },\n    { path: 'items',        component: ItemListComponent, ...canActivate(redirectUnauthorizedToLogin) },\n    { path: 'admin',        component: AdminComponent,    ...canActivate(adminOnly) },\n    { path: 'accounts/:id', component: AdminComponent,    ...canActivate(belongsToAccount) }\n];\n```\n\n## Compose your own pipes\n\n`AngularFireAuthGuard` pipes are RXJS operators which transform an optional User to a boolean or Array (for redirects). You can easily build your own to customize behavior further:\n\n```ts\nimport { map } from 'rxjs/operators';\n\n// This pipe redirects a user to their \"profile edit\" page or the \"login page\" if they're unauthenticated\n// { path: 'profile', ...canActivate(redirectToProfileEditOrLogin) }\nconst redirectToProfileEditOrLogin = () => map(user => user ? ['profiles', user.uid, 'edit'] : ['login']);\n```\n\nThe `auth-guard` modules provides a `customClaims` operator to reduce boiler plate when checking a user's claims:\n\n```ts\nimport { pipe } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { customClaims } from '@angular/fire/auth-guard';\n\n// This pipe will only allow users with the editor role to access the route\n// { path: 'articles/:id/edit', component: ArticleEditComponent, ...canActivate(editorOnly) }\nconst editorOnly = () => pipe(customClaims, map(claims => claims.role === 'editor'));\n```\n\n## Using router state\n\n`AngularFireAuthGuard` will also accept `AuthPipeGenerator`s which generate `AuthPipe`s given the router state:\n\n```ts\nimport { pipe } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { customClaims } from '@angular/fire/auth-guard';\n\n// Only allow navigation to the route if :userId matches the authenticated user's uid\n// { path: 'user/:userId/edit', component: ProfileEditComponent, ...canActivate(onlyAllowSelf) }\nconst onlyAllowSelf = (next) => map(user => !!user && next.params.userId === user.uid);\n\n// Only allow navigation to the route if the user has a custom claim matching  :accountId\n// { path: 'accounts/:accountId/billing', component: BillingDetailsComponent, ...canActivate(accountAdmin) }\nconst accountAdmin = (next) => pipe(customClaims, map(claims => claims[`account-${next.params.accountId}-role`] === 'admin'));\n```\n"
  },
  {
    "path": "site/src/firestore/collections.md",
    "content": "---\ntitle: Collections\neleventyNavigation:\n  key: Collections\n  parent: Firestore\n---\n\n## Documents in AngularFirestore\n\nCloud Firestore is a NoSQL, document-oriented database. Unlike a SQL database, there are no tables or rows. Instead, you store data in *documents*, which are organized into *collections*.\nEach *document* contains a set of key-value pairs. Cloud Firestore is optimized for storing large collections of small documents.\n\n## Using `AngularFirestoreCollection`\n\nThe `AngularFirestoreCollection` service is a wrapper around the native Firestore SDK's [`CollectionReference`](https://firebase.google.com/docs/reference/js/v8/firebase.firestore.CollectionReference) and [`Query`](hhttps://firebase.google.com/docs/reference/js/v8/firebase.firestore.Query) types. It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';\nimport { Observable } from 'rxjs';\n\nexport interface Item { name: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `\n    <ul>\n      <li *ngFor=\"let item of items | async\">\n        {{ item.name }}\n      </li>\n    </ul>\n  `\n})\nexport class AppComponent {\n  private itemsCollection: AngularFirestoreCollection<Item>;\n  items: Observable<Item[]>;\n  constructor(private afs: AngularFirestore) {\n    this.itemsCollection = afs.collection<Item>('items');\n    this.items = this.itemsCollection.valueChanges();\n  }\n  addItem(item: Item) {\n    this.itemsCollection.add(item);\n  }\n}\n```\n\nThe `AngularFirestoreCollection` is a service you use to create streams of the collection and perform data operations on the underyling collection.\n\n## The `DocumentChangeAction` type\n\nWith the exception of the `valueChanges()`, each streaming method returns an Observable of `DocumentChangeAction[]`.\n\nA `DocumentChangeAction` gives you the `type` and `payload` properties. The `type` tells when what `DocumentChangeType` operation occured (`added`, `modified`, `removed`). The `payload` property is a `DocumentChange` which provides you important metadata about the change and a `doc` property which is the `DocumentSnapshot`.\n\n```ts\ninterface DocumentChangeAction {\n  //'added' | 'modified' | 'removed';\n  type: DocumentChangeType;\n  payload: DocumentChange;\n}\n\ninterface DocumentChange {\n  type: DocumentChangeType;\n  doc: DocumentSnapshot;\n  oldIndex: number;\n  newIndex: number;\n}\n\ninterface DocumentSnapshot {\n  exists: boolean;\n  ref: DocumentReference;\n  id: string;\n  metadata: SnapshotMetadata;\n  data(): DocumentData;\n  get(fieldPath: string): any;\n}\n```\n\n## Streaming collection data\n\nThere are multiple ways of streaming collection data from Firestore. \n\n## `valueChanges({ idField?: string })`\n\n*What is it?* - The current state of your collection. Returns an Observable of data as a synchronized array of JSON objects. All Snapshot metadata is stripped and just the document data is included. Optionally, you can pass an options object with an `idField` key containing a string. If provided, the returned JSON objects will include their document ID mapped to a property with the name provided by `idField`.  \n\n*Why would you use it?* - When you just need a list of data. No document metadata is attached to the resulting array which makes it simple to render to a view.\n\n*When would you not use it?* - When you need a more complex data structure than an array.\n\n*Best practices* - Use this method to display data on a page. It's simple but effective. Use `.snapshotChanges()` once your needs become more complex.\n\n#### Example of persisting a Document Id\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';\nimport { Observable } from 'rxjs';\n\nexport interface Item { id: string; name: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n    <ul>\n      <li *ngFor=\"let item of items | async\">\n        {{ item.name }}\n      </li>\n    </ul>\n  {%endraw%}`\n})\nexport class AppComponent {\n  private itemsCollection: AngularFirestoreCollection<Item>;\n  items: Observable<Item[]>;\n  constructor(private readonly afs: AngularFirestore) {\n    this.itemsCollection = afs.collection<Item>('items');\n    this.items = this.itemsCollection.valueChanges({ idField: 'customID' });\n  }\n  addItem(name: string) {\n    // Persist a document id\n    const id = this.afs.createId();\n    const item: Item = { id, name };\n    this.itemsCollection.doc(id).set(item);\n  }\n}\n```\n\n### `snapshotChanges()`\n\n*What is it?* - The current state of your collection. Returns an Observable of data as a synchronized array of `DocumentChangeAction[]`. \n\n*Why would you use it?* - When you need a list of data but also want to keep around metadata. Metadata provides you the underyling `DocumentReference`, document id, and array index of the single document. Having the document's id around makes it easier to use data manipulation methods. This method gives you more horsepower with other Angular integrations such as ngrx, forms, and animations due to the `type` property. The `type` property on each `DocumentChangeAction` is useful for ngrx reducers, form states, and animation states.\n\n*When would you not use it?* - When you need a more complex data structure than an array or if you need to process changes as they occur. This array is synchronized with the remote and local changes in Firestore.\n\n*Best practices* - Use an observable operator to transform your data from `.snapshotChanges()`. Don't return the `DocumentChangeAction[]` to the template. See the example below.\n\n#### Example\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nexport interface Shirt { name: string; price: number; }\nexport interface ShirtId extends Shirt { id: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n    <ul>\n      <li *ngFor=\"let shirt of shirts | async\">\n        {{ shirt.name }} is {{ shirt.price }}\n      </li>\n    </ul>\n  {%endraw%}`\n})\nexport class AppComponent {\n  private shirtCollection: AngularFirestoreCollection<Shirt>;\n  shirts: Observable<ShirtId[]>;\n  constructor(private readonly afs: AngularFirestore) {\n    this.shirtCollection = afs.collection<Shirt>('shirts');\n    // .snapshotChanges() returns a DocumentChangeAction[], which contains\n    // a lot of information about \"what happened\" with each change. If you want to\n    // get the data and the id use the map operator.\n    this.shirts = this.shirtCollection.snapshotChanges().pipe(\n      map(actions => actions.map(a => {\n        const data = a.payload.doc.data() as Shirt;\n        const id = a.payload.doc.id;\n        return { id, ...data };\n      }))\n    );\n  }\n}\n```\n\n### `stateChanges()`\n\n*What is it?* - Returns an Observable of the most recent changes as a `DocumentChangeAction[]`. \n\n*Why would you use it?* - The above methods return a synchronized array sorted in query order. `stateChanges()` emits changes as they occur rather than syncing the query order. This works well for ngrx integrations as you can build your own data structure in your reducer methods.\n\n*When would you not use it?* - When you just need a list of data. This is a more advanced usage of AngularFirestore.\n\n#### Example\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nexport interface AccountDeposit { description: string; amount: number; }\nexport interface AccountDepositId extends AccountDeposit { id: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n    <ul>\n      <li *ngFor=\"let deposit of deposits | async\">\n        {{ deposit.description }} for {{ deposit.amount }}\n      </li>\n    </ul>\n  {%endraw%}`\n})\nexport class AppComponent {\n  private depositCollection: AngularFirestoreCollection<AccountDeposit>;\n  deposits: Observable<AccountDepositId[]>;\n  constructor(private readonly afs: AngularFirestore) {\n    this.depositCollection = afs.collection<AccountDeposit>('deposits');\n    this.deposits = this.depositCollection.stateChanges(['added']).pipe(\n      map(actions => actions.map(a => {\n        const data = a.payload.doc.data() as AccountDeposit;\n        const id = a.payload.doc.id;\n        return { id, ...data };\n      }))\n    );\n  }\n}\n```\n\n### `auditTrail()`\n\n*What is it?* - Returns an Observable of `DocumentChangeAction[]` as they occur. Similar to `stateChanges()`, but instead it keeps around the trail of events as an array.\n\n*Why would you use it?* - This method is like `stateChanges()` except it is not ephemeral. It collects each change in an array as they occur. This is useful for ngrx integrations where you need to replay the entire state of an application. This also works as a great debugging tool for all applications. You can simply write `afs.collection('items').auditTrail().subscribe(console.log)` and check the events in the console as they occur.\n\n*When would you not use it?* - When you just need a list of data. This is a more advanced usage of AngularFirestore. \n\n#### Example\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\nexport interface AccountLogItem { description: string; amount: number; }\nexport interface AccountLogItemId extends AccountLogItem { id: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n    <ul>\n      <li *ngFor=\"let log of accountLogs | async\">\n        {{ log.description }} for {{ log.amount }}\n      </li>\n    </ul>\n  {%endraw%}`\n})\nexport class AppComponent {\n  private accountLogCollection: AngularFirestoreCollection<AccountLogItem>;\n  accountLogs: Observable<AccountLogItemId[]>;\n  constructor(private readonly afs: AngularFirestore) {\n    this.accountLogCollection = afs.collection<AccountLogItem>('accountLog');\n    this.accountLogs = this.accountLogCollection.auditTrail().pipe(\n      map(actions => actions.map(a => {\n        const data = a.payload.doc.data() as AccountLogItem;\n        const id = a.payload.doc.id;\n        return { id, ...data };\n      }))\n    );\n  }\n}\n```\n\n### Limiting events\n\nThere are three `DocumentChangeType`s in Firestore: `added`, `removed`, and `modified`. Each streaming method listens to all three by default. However, you may only be intrested in one of these events. You can specify which events you'd like to use through the first parameter of each method:\n\n#### Basic example\n\n```ts\nconstructor(private afs: AngularFirestore): {\n  this.itemsCollection = afs.collection<Item>('items');\n  this.items = this.itemsCollection.snapshotChanges(['added', 'removed']);\n}\n```\n\n#### Component example\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n    <ul>\n      <li *ngFor=\"let item of items | async\">\n        {{ item.name }}\n      </li>\n    </ul>\n  {%endraw%}`\n})\nexport class AppComponent {\n  private itemsCollection: AngularFirestoreCollection<Item>;\n  items: Observable<Item[]>;\n  constructor(private afs: AngularFirestore) {\n    this.itemsCollection = afs.collection<Item>('items');\n    this.items = this.itemsCollection.valueChanges(['added', 'removed']);\n  }\n}\n```\n\n## State based vs. action based\n\nEach one of these methods falls into two categories: state based and action based. State based methods return the state of your collection \"as-is\". Whereas action based methods return \"what happened\" in your collection.\n\nFor example, a user updates the third item in a list. In a state based method like `.valueChanges()` will update the third item in the collection and return an array of JSON data. This is how your state looks.\n\n## Adding documents to a collection\n\nTo add a new document to a collection with a generated id use the `add()` method. This method uses the type provided by the generic class to validate it's type structure.\n\n#### Basic example\n\n```ts\nconstructor(private afs: AngularFirestore): {\n  const shirtsCollection = afs.collection<Item>('tshirts');\n  shirtsCollection.add({ name: 'item', price: 10 });\n}\n```\n\n## Manipulating individual documents\n\nTo retrieve, update, or delete an individual document you can use the `doc()` method. This method returns an `AngularFirestoreDocument`, which provides methods for streaming, updating, and deleting. [See Using Documents with AngularFirestore for more information on how to use documents](/firestore/documents).\n\n"
  },
  {
    "path": "site/src/firestore/documents.md",
    "content": "---\ntitle: Documents\neleventyNavigation:\n  key: Documents\n  parent: Firestore\n---\n\n## Documents in AngularFirestore\n\nCloud Firestore is a NoSQL, document-oriented database. Unlike a SQL database, there are no tables or rows. Instead, you store data in *documents*, which are organized into *collections*.\nEach *document* contains a set of key-value pairs. Cloud Firestore is optimized for storing large collections of small documents.\n\n## Using `AngularFirestoreDocument`\n\nThe `AngularFirestoreDocument` service is a wrapper around the native Firestore SDK's [`DocumentReference` type](https://firebase.google.com/docs/reference/js/firebase.firestore.DocumentReference). It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.\n\n\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFirestore, AngularFirestoreDocument } from '@angular/fire/firestore';\nimport { Observable } from 'rxjs';\n\nexport interface Item { name: string; }\n\n@Component({\n  selector: 'app-root',\n  template: `{% raw %}\n    <div>\n      {{ (item | async)?.name }}\n    </div>\n  {% endraw %}`\n})\nexport class AppComponent {\n  private itemDoc: AngularFirestoreDocument<Item>;\n  item: Observable<Item>;\n  constructor(private afs: AngularFirestore) {\n    this.itemDoc = afs.doc<Item>('items/1');\n    this.item = this.itemDoc.valueChanges();\n  }\n  update(item: Item) {\n    this.itemDoc.update(item);\n  }\n}\n```\n\n## The `DocumentChangeAction` type\n\nWith the exception of the `valueChanges()`, each streaming method returns an Observable of `DocumentChangeAction[]`.\n\nA `DocumentChangeAction` gives you the `type` and `payload` properties. The `type` tells when what `DocumentChangeType` operation occured (`added`, `modified`, `removed`). The `payload` property is a `DocumentChange` which provides you important metadata about the change and a `doc` property which is the `DocumentSnapshot`.\n\n```ts\ninterface DocumentChangeAction {\n  //'added' | 'modified' | 'removed';\n  type: DocumentChangeType;\n  payload: DocumentChange;\n}\n\ninterface DocumentChange {\n  type: DocumentChangeType;\n  doc: DocumentSnapshot;\n  oldIndex: number;\n  newIndex: number;\n}\n\ninterface DocumentSnapshot {\n  exists: boolean;\n  ref: DocumentReference;\n  id: string;\n  metadata: SnapshotMetadata;\n  data(): DocumentData;\n  get(fieldPath: string): any;\n}\n```\n\n## Streaming document data\n\nThere are multiple ways of streaming collection data from Firestore.\n\n## `valueChanges({ idField?: string })`\n\n*What is it?* - Returns an Observable of document data. All Snapshot metadata is stripped. This method provides only the data. Optionally, you can pass an options object with an `idField` key containing a string. If provided, the returned object will include its document ID mapped to a property with the name provided by `idField`.\n\n*Why would you use it?* - When you just need the object data. No document metadata is attached which makes it simple to render to a view.\n\n*When would you not use it?* - When you need document metadata.\n\n## `snapshotChanges()`\n\n*What is it?* - Returns an Observable of data as a `DocumentChangeAction`. \n\n*Why would you use it?* - When you need the document data but also want to keep around metadata. This metadata provides you the underyling `DocumentReference` and document id. Having the document's id around makes it easier to use data manipulation methods. This method gives you more horsepower with other Angular integrations such as ngrx, forms, and animations due to the `type` property. The `type` property on each `DocumentChangeAction` is useful for ngrx reducers, form states, and animation states.\n\n*When would you not use it?* - When you simply need to render data to a view and don't want to do any extra processing.\n\n## Manipulating documents\n\nAngularFirestore provides methods for setting, updating, and deleting document data.\n\n- `set(data: T)` - Destructively updates a document's data.\n- `update(data: T)` - Non-destructively updates a document's data.\n- `delete()` - Deletes an entire document. Does not delete any nested collections.\n\n## Querying?\n\nQuerying has no effect on documents. Documents are a single object and querying effects a range of multiple documents. If you are looking for querying then you want to use a collection.\n\n## Retrieving nested collections\n\nNesting collections is a great way to structure your data. This allows you to group related data structures together. If you are creating a \"Task List\" site, you can group \"tasks\" under a user: `user/<uid>/tasks`. \n\nTo retrieve a nested collection use the `collection(path: string)` method.\n\n```ts\nconstructor(private afs: AngularFirestore) {\n  this.userDoc = afs.doc<Item>('user/david');\n  this.tasks = this.userDoc.collection<Task>('tasks').valueChanges();\n}\n```\n"
  },
  {
    "path": "site/src/firestore/firestore.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/firestore/index.md",
    "content": "---\neleventyNavigation:\n  key: Firestore\n  order: 2\n---"
  },
  {
    "path": "site/src/functions/functions.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/functions/getting-started.md",
    "content": "---\ntitle: Getting started\neleventyNavigation:\n  key: Getting started\n  parent: Functions\n---\n\n## Using AngularFireFunctions\n\nThe Cloud Functions for Firebase client SDKs let you call functions directly from a Firebase app. To call a function from your app in this way, write and deploy an HTTPS Callable function in Cloud Functions, and then add client logic to call the function from your app.\n\n## Import the `NgModule`\n\nCloud Functions for AngularFire is contained in the `@angular/fire/functions` module namespace. Import the `AngularFireFunctionsModule` in your `NgModule`. This sets up the `AngularFireFunction` service for dependency injection.\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { AngularFireModule } from '@angular/fire';\nimport { AngularFireFunctionsModule } from '@angular/fire/functions';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireFunctionsModule\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\n## Injecting the `AngularFireFunctions` service\n\nOnce the `AngularFireFunctionsModule` is registered you can inject the `AngularFireFunctions` service.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireFunctions } from '@angular/fire/functions';\n\n@Component({\n  selector: 'app-component',\n  template: ``\n})\nexport class AppComponent {\n  constructor(private fns: AngularFireFunctions) { }\n}\n```\n\n## Creating a callable function\n\nAngularFireFunctions is super easy. You create a function on the server side and then \"call\" it by its name with the client library. \n\n| method   |                    |\n| ---------|--------------------|\n| `httpCallable(name: string): (data: T) ` | Creates a callable function based on a function name. Returns a function that can create the observable of the http call. |\n```ts\n\nimport { Component } from '@angular/core';\nimport { AngularFireFunctions } from '@angular/fire/functions';\n\n@Component({\n  selector: 'app-root',\n  template: `{ data$  | async }`\n})\nexport class AppComponent {\n  constructor(private fns: AngularFireFunctions) { \n    const callable = fns.httpsCallable('my-fn-name');\n    this.data$ = callable({ name: 'some-data' });\n  }\n}\n```\n\nNotice that calling `httpsCallable()` does not initiate the request. It creates a function, which when called creates an Observable, subscribe or convert it to a Promise to initiate the request.\n\n## Configuration via Dependency Injection\n\n### Functions Region\n\nAllow configuration of the Function's region by adding `REGION` to the `providers` section of your `NgModule`. The default is `us-central1`.\n\n```ts\nimport { NgModule } from '@angular/core';\nimport { AngularFireFunctionsModule, REGION } from '@angular/fire/functions';\n\n@NgModule({\n  imports: [\n    ...\n    AngularFireFunctionsModule,\n    ...\n  ],\n  ...\n  providers: [\n   { provide: REGION, useValue: 'asia-northeast1' }\n  ]\n})\nexport class AppModule {}\n\n```\n\n### Cloud Functions emulator\n\nPoint callable Functions to the Cloud Function emulator by adding `USE_EMULATOR` to the `providers` section of your `NgModule`.\n\n```ts\nimport { NgModule } from '@angular/core';\nimport { AngularFireFunctionsModule, USE_EMULATOR } from '@angular/fire/functions';\n\n@NgModule({\n  imports: [\n    ...\n    AngularFireFunctionsModule,\n    ...\n  ],\n  ...\n  providers: [\n   { provide: USE_EMULATOR, useValue: ['localhost', 5001] }\n  ]\n})\nexport class AppModule {}\n\n```\n\n[Learn more about integration with the Firebase Emulator suite on our dedicated guide here](../emulators/emulators.md).\n\n## Firebase Hosting integration\n\nIf you serve your app using [Firebase Hosting](https://firebase.google.com/docs/hosting/), you can configure Functions to be served from the same domain as your app. This will avoid an extra round-trip per function call due to [CORS preflight request](https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request). This only applies to sites hosted via firebase on `us-central1`.\n\nTo set this up, you first need to update your `hosting` section in `firebase.json` and add one `rewrite` rule per function:\n\n```json\n  \"hosting\": {\n    \"rewrites\": [\n      {\n        \"source\": \"/someFunction\",\n        \"function\": \"someFunction\"\n      },\n      {\n        \"source\": \"/anotherFunction\",\n        \"function\": \"anotherFunction\"\n      },\n      ...\n    ]\n  }\n```\n\nDeploy your hosting project to the new settings go into effect, finally configure functions origin to point at your app domain:\n\n```ts\nimport { NgModule } from '@angular/core';\nimport { AngularFireFunctionsModule, ORIGIN, NEW_ORIGIN_BEHAVIOR } from '@angular/fire/functions';\n\n@NgModule({\n  imports: [\n    ...\n    AngularFireFunctionsModule,\n    ...\n  ],\n  ...\n  providers: [\n   { provide: NEW_ORIGIN_BEHAVIOR, useValue: true },\n   { provide: ORIGIN, useValue: 'https://project-name.web.app' }\n  ]\n})\nexport class AppModule {}\n```\n"
  },
  {
    "path": "site/src/functions/index.md",
    "content": "---\neleventyNavigation:\n  key: Functions\n  order: 7\n---\n"
  },
  {
    "path": "site/src/get-started/deploying.md",
    "content": "---\ntitle: Deploying\neleventyNavigation:\n  key: Deploying\n  parent: Get started\n---\n\n## Static or Server-side rendered\n\nIn this guide, we'll look at how to use `@angular/fire` to automatically deploy an Angular application to Firebase Hosting or Cloud Functions by using the Angular CLI.\n\n`@angular/fire` uses Firebase functions to deploy your Angular Universal projects, with server-side rendering enabled.\n\n**Angular Universal deployments work with `@nguniversal/*` version 9.0.0 and above**.\n\n## Add `@angular/fire` to your project\n\nFirst, you need to add the `@angular/fire` package to your project. In your Angular CLI project run:\n\n```shell\nng add @angular/fire\n```\n\n*Note that the command above assumes you have global Angular CLI installed. To install Angular CLI globally run `npm i -g @angular/cli`.*\n\nFirst, the command above will check if you have an Angular universal project. It'll do so by looking at your `angular.json` project, looking for a `server` target for the specified project. If it finds one, it'll ask you if you want to deploy the project in a firebase function.\n\nAfter that it will trigger the `@angular/fire` `ng-add` schematics. The schematics will open a web browser and guide you through the Firebase authentication flow (if you're not signed in already). After you authenticate, you'll see a prompt to select a Firebase hosting project.\n\nThe schematics will do the following:\n\n1. Add `@angular/fire` to your list of dependencies\n2. Create `firebase.json`, `.firebaserc` files in the root of your workspace. You can use them to configure your firebase hosting deployment. Find more about them [here](https://firebase.google.com/docs/hosting/full-config)\n3. Update your workspace file (`angular.json`) by inserting the `deploy` builder\n\nIn the end, your `angular.json` project will look like below:\n\n```json5\n{\n  \"$schema\": \"./node_modules/@angular/cli/lib/config/schema.json\",\n  \"version\": 1,\n  \"newProjectRoot\": \"projects\",\n  \"projects\": {\n    \"sample-app\": {\n      // ...\n      \"deploy\": {\n        \"builder\": \"@angular/fire:deploy\",\n        \"options\": {} // Here you may find an \"ssr\": true option if you've\n                      // selected that you want to deploy your Angular universal project\n                      // as a firebase function.\n        }\n      }\n  },\n    // ...\n  \"defaultProject\": \"sample-app\"\n  \n}\n```\n\nIf you want to add deployment capabilities to a different project in your workspace, you can run:\n\n```bash\nng add @angular/fire --project=[PROJECT_NAME]\n```\n\n## Deploying the project\n\nAs the second step, to deploy your project run:\n\n```bash\nng deploy --project=[PROJECT_NAME]\n```\n\n*The `--project` option is optional. Learn more [here](https://angular.io/cli/deploy).*\n\nThe command above will trigger:\n\n1. Production build of your application\n2. Deployment of the produced assets to the firebase hosting project you selected during `ng add`\n\nIf you've specified that you want a server-side rendering enabled deployment in a firebase function, the command will also:\n\n1. Create a firebase function in `dist`, which directly consumes `main.js` from your server output directory.\n2. Create `package.json` for the firebase function with the required dependencies.\n3. Deploy the static assets to firebase hosting and your universal server as a Firebase function.\n\nIf you want to preview your Angular Universal project before we deploy it as a Firebase Function you can run:\n\n```\nng deploy --preview\n```\n\nWe'll create the function and a `package.json` in your project output directory. This way, you can later run `firebase serve` in your project root so you can test everything before deploying.\n\n## Customization\n\nTo customize the deployment flow, you can use the configuration files you're already familiar with from `firebase-tools`. You can find more in the [firebase documentation](https://firebase.google.com/docs/hosting/full-config).\n\n### Configuring Cloud Functions\n\nSetting `functionsNodeVersion` and `functionsRuntimeOptions` in your `angular.json` allow you to custimze the version of Node.js Cloud Functions is running and run-time settings like timeout, VPC connectors, and memory.\n\n```json\n\"deploy\": {\n    \"builder\": \"@angular/fire:deploy\",\n    \"options\": {\n        \"functionsNodeVersion\": 12,\n        \"functionsRuntimeOptions\": {\n          \"memory\": \"2GB\",\n          \"timeoutSeconds\": 10,\n          \"vpcConnector\": \"my-vpc-connector\",\n          \"vpcConnectorEgressSettings\": \"PRIVATE_RANGES_ONLY\"\n        }\n    }\n}\n```\n\n### Working with multiple Firebase Projects\n\nIf you have multiple build targets and deploy targets, it is possible to specify them in your `angular.json` or `workspace.json`.\n\nIt is possible to use either your project name or project alias in `firebaseProject`. The setting provided here is equivalent to passing a project name or alias to `firebase deploy --project projectNameOrAlias`.\n\nThe `buildTarget` simply points to an existing build configuration for your project. Most projects have a default configuration and a production configuration (commonly activated by using the `--prod` flag) but it is possible to specify as many build configurations as needed.\n\nYou may specify a `buildTarget` and `firebaseProject` in your `options` as follows:\n\n```json\n\"deploy\": {\n    \"builder\": \"@angular/fire:deploy\",\n    \"options\": {\n        \"buildTarget\": \"projectName:build\",\n        \"firebaseProject\": \"developmentProject\"\n    },\n    \"configurations\": {\n        \"production\": {\n            \"buildTarget\": \"projectName:build:production\",\n            \"firebaseProject\": \"productionProject\"\n        }\n    }\n}\n```\n\nThe above configuration specifies the following:\n\n1. `ng deploy` will deploy the default project with default configuration.\n2. `ng deploy projectName` will deploy the specified project with default configuration.\n3. `ng deploy projectName --prod` or `ng deploy projectName --configuration='production'` will deploy `projectName` with production build settings to your production environment.\n\nAll of the options are optional. If you do not specify a `buildTarget`, it defaults to a production build (`projectName:build:production`). If you do not specify a `firebaseProject`, it defaults to the first matching deploy target found in your `.firebaserc` (where your projectName is the same as your Firebase deploy target name). The `configurations` section is also optional.\n"
  },
  {
    "path": "site/src/get-started/get-started.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/get-started/index.md",
    "content": "---\neleventyNavigation:\n  key: Get started\n  order: 1\n---\n"
  },
  {
    "path": "site/src/get-started/local-development.md",
    "content": "---\ntitle: Local development\neleventyNavigation:\n  key: Local development\n  parent: Get started\n---\n\n## Connect to the Firebase Emulator Suite\n\nIn this guide, we'll look at how to use `@angular/fire` to connect an Angular application with the Firebase Emulator Suite to start prototyping your apps.\n\nThere are four supported emulators, all of them available at the Firebase suite workflow:\n\n- [Authentication Emulator](https://firebase.google.com/docs/emulator-suite/connect_auth)\n- [Realtime Database Emulator](https://firebase.google.com/docs/emulator-suite/connect_rtdb)\n- [Cloud Firestore Emulator](https://firebase.google.com/docs/emulator-suite/connect_firestore)\n- [Cloud Functions Emulator](https://firebase.google.com/docs/emulator-suite/connect_functions)\n\n*The Auth Emulator only works with Firebase v8 and above, which is supported by `@angular/fire` 6.1.0 or higher*.\n\nBefore configuring these emulators at the Angular App, be sure to install the ones you need by following the [Install, configure and integrate Local Emulator Suite](https://firebase.google.com/docs/emulator-suite/install_and_configure) documentation.\n\nInitialize firebase to your project:\n\n```shell\nfirebase init\n```\n\nThen launch the emulator setup wizard:\n\n```shell\nfirebase init emulators\n```\n\nFollow the instructions to download whatever emulator you want to use then checkout that the `firebase.json` file got updated with the default ports per emulator, something like this:\n\n```json\n{\n  // Existing firebase configuration ...\n  // Optional emulator configuration. Default\n  // values are used if absent.\n  \"emulators\": {\n    \"firestore\": {\n      \"port\": \"8080\"\n    },\n    \"ui\": {\n      \"enabled\": true, // Default is `true`\n      \"port\": 4000     // If unspecified, see CLI log for selected port\n    },\n    \"auth\": {\n      \"port\": \"9099\"\n    },\n    \"functions\": {\n      \"port\": \"5001\"\n    },\n    \"database\": {\n      \"port\": \"9000\"\n    },\n    \"pubsub\": {\n      \"port\": \"8085\"\n    }\n  }\n}\n```\n\n## Import the DI Tokens at your AppModule\n\nConfiguring your app to connect to local emulators is easily done by using dependency injection tokens provided by the library. However, there are slighty changes between 6.0.0 and 6.1.0 in the way it was done.\n\nEach module (database, firestore, auth, function) provides `USE_EMULATOR` token to configure the emulator `host` and `port` by passing a tuple of `[string, number]` values, which are set by default to `localhost` and the asigned port from your `firebase.json` file.\n\nImport these tokens at your `app.module.ts` as follow:\n\n```ts\nimport { USE_EMULATOR as USE_AUTH_EMULATOR } from '@angular/fire/auth';\nimport { USE_EMULATOR as USE_DATABASE_EMULATOR } from '@angular/fire/database';\nimport { USE_EMULATOR as USE_FIRESTORE_EMULATOR } from '@angular/fire/firestore';\nimport { USE_EMULATOR as USE_FUNCTIONS_EMULATOR } from '@angular/fire/functions';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    // ... Existing Providers\n    { provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9099] : undefined },\n    { provide: USE_DATABASE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9000] : undefined },\n    { provide: USE_FIRESTORE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 8080] : undefined },\n    { provide: USE_FUNCTIONS_EMULATOR, useValue: environment.useEmulators ? ['localhost', 5001] : undefined },\n  ]\n})\nexport class AppModule { }\n```\n\nThe environment `useEmulators` flag is used to control whenever the app should connect to the emulators, which is usually done in non-production environments.\n\nAlso you can opt-in the new way of setting the Cloud Functions [origin](https://firebase.google.com/docs/functions/locations) in Firebase v8 by using the `NEW_ORIGIN_BEHAVIOR` token in conjuction with the already present `ORIGIN` token.\n\n```ts\nimport { isDevMode, NgModule } from '@angular/core';\nimport { ORIGIN as FUNCTIONS_ORIGIN, NEW_ORIGIN_BEHAVIOR } from '@angular/fire/functions';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    // ... Existing Providers\n    { provide: NEW_ORIGIN_BEHAVIOR, useValue: true },\n    { provide: FUNCTIONS_ORIGIN, useFactory: () => isDevMode() ? undefined : location.origin },\n  ]\n})\nexport class AppModule { }\n```\n\n## Older method (6.0.0)\n\nWith the exception of the Auth Emulator, the old way of setting the `host` and `port` for each emulator was done using a different set of tokens by passing the entire url path as string.\n\n```ts\nimport { URL as DATABASE_URL } from '@angular/fire/database';\nimport { ORIGIN as FUNCTIONS_ORIGIN } from '@angular/fire/functions';\nimport { SETTINGS as FIRESTORE_SETTINGS } from '@angular/fire/firestore';\n\n@NgModule({\n  // ... Existing configuration\n  providers: [\n    {\n      provide: DATABASE_URL,\n      useValue: environment.useEmulators ? `http://localhost:9000?ns=${environment.firebase.projectId}` : undefined\n    },\n    { provide: FIRESTORE_SETTINGS, useValue: environment.useEmulators ? { host: 'localhost:8080', ssl: false } : {} },\n    { provide: FUNCTIONS_ORIGIN, useFactory: environment.useEmulators ? 'http://localhost:5001' : undefined },\n  ]\n})\nexport class AppModule { }\n```\n\nFor older versions, please upgrade your app to latest version to get the advantages of these new features :rocket: \n"
  },
  {
    "path": "site/src/get-started/quick-start.md",
    "content": "---\ntitle: Quick start\neleventyNavigation:\n  key: Quick start\n  parent: Get started\n---\n\n## Create a new project\n\n```bash\nnpm install -g @angular/cli\nng new <project-name>\ncd <project-name>\n```\n\nThe Angular CLI's `new` command will set up the latest Angular build in a new project structure.\n\n## Install AngularFire and Firebase\n\n```bash\nng add @angular/fire\n```\n\nNow that you have a new project setup, install AngularFire and Firebase from npm.\n\n## Add Firebase config to environments variable\n\nOpen `/src/environments/environment.ts`, create it if it doesn't exist, and add your Firebase configuration. You can find your project configuration in [the Firebase Console](https://console.firebase.google.com). Click the Gear icon next to Project Overview, in the Your Apps section, create a new app and choose the type Web. Give the app a name and copy the config values provided.\n\n```ts\nexport const environment = {\n  production: false,\n  firebase: {\n    apiKey: '<your-key>',\n    authDomain: '<your-project-authdomain>',\n    databaseURL: '<your-database-URL>',\n    projectId: '<your-project-id>',\n    storageBucket: '<your-storage-bucket>',\n    messagingSenderId: '<your-messaging-sender-id>',\n    appId: '<your-app-id>',\n    measurementId: '<your-measurement-id>'\n  }\n};\n```\n\n## Configuring Firebase in your Angular Application\n\n### Set up Firebase for `@NgModule` based apps\nFor applications bootstrapped using `@NgModule`, add the Firebase providers to the imports array of the `@NgModule` decorator metadata.\n\nIn `/src/app/app.module.ts` update the code to:.\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    provideFirebaseApp(() => initializeApp(environment.firebase)),\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n### Set up Firebase for Standalone API based apps\nBeginning in [Angular v14](https://blog.angular.io/angular-v14-is-now-available-391a6db736af) applications can be built and bootstrapped using the set of [Standalone APIs](https://angular.io/guide/standalone-components).\n\nThe provider configuration for these applications should be added to the `bootstrapApplication` function in `main.ts`:\n\n```ts\nimport { initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { getAuth, provideAuth } from '@angular/fire/auth';\nimport { bootstrapApplication } from '@angular/platform-browser';\nimport { AppComponent } from './app/app.component';\nimport { environment } from './environments/environment';\n\n\nbootstrapApplication(AppComponent, {\n  providers: [\n    provideFirebaseApp(()=> initializeApp(environment.firebase))\n  ],\n}).catch(err => console.error(err));\n```\n\n### Configuring Firebase features\n\nAfter adding the Firbase app providers, you also need to add providers for the each of  Firebase features your application needs.\n\nFor example if your application uses both Google Analytics and the Firestore database you would add `provideAnalytics` and `provideFirestore`:\n\n```ts\n// Module based configuration app.module.ts\n\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { provideAnalytics, getAnalytics } from '@angular/fire/analytics';\nimport { provideFirestore, getFirestore } from '@angular/fire/firestore';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    provideFirebaseApp(() => initializeApp(environment.firebase)),\n    provideAnalytics(()=> getAnalytics()),\n    provideFirestore(() => getFirestore()),\n    AngularFireAnalyticsModule,\n    AngularFirestoreModule\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\n```ts\n// Standalone API based config (main.ts)\nimport { initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { provideFirestore, getFirestore } from '@angular/fire/firestore'\nimport { getAuth, provideAuth } from '@angular/fire/auth';\nimport { bootstrapApplication } from '@angular/platform-browser';\nimport { AppComponent } from './app/app.component';\nimport { environment } from './environments/environment';\n\n\nbootstrapApplication(AppComponent, {\n  providers: [\n    provideFirebaseApp(() => initializeApp(environment.firebase)),\n    provideAuth(() => getAuth()),\n    provideFirestore(() => getFirestore())\n  ],\n}).catch(err => console.error(err));\n```\n## Inject `AngularFirestore`\n\nOpen `/src/app/app.component.ts`, and make sure to modify/delete any tests to get the sample working (tests are still important, you know):\n\n```ts\nimport { Component, inject } from '@angular/core';\nimport { Firestore } from '@angular/fire/firestore';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: 'app.component.html',\n  styleUrls: ['app.component.css']\n})\nexport class AppComponent {\n  private firestore: AngularFirestore = inject(Firestore)\n  ...\n}\n```\n\n## Bind a Firestore collection to a list\n\nIn `/src/app/app.component.ts`:\n\n```ts\nimport { Component } from '@angular/core';\nimport { Firestore, collection } from '@angular/fire/firestore';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: 'app.component.html',\n  styleUrls: ['app.component.css']\n})\nexport class AppComponent {\n  private firestore: Firestore = inject(Firestore);\n  items$: Observable<any[]>;\n\n  constructor() {\n    const itemsCollectionRef = collection(this.firestore, 'items');\n    this.items = collectionData(itemsCollectionRef) as Observable<any[]>;\n  }\n}\n```\n\nOpen `/src/app/app.component.html`:\n\n```html\n<ul>\n  <li class=\"text\" *ngFor=\"let item of items$ | async\">\n    {{item.name}}\n  </li>\n</ul>\n```\n\n## Run your app locally\n\n```bash\nng serve\n```\n\nYour Angular app will compile and serve locally, visit it we should see an empty list.\n\nIn another tab [start adding data to an `items` collection in Firestore](https://firebase.google.com/docs/firestore/manage-data/add-data). *As we're not authenticating users yet, be sure to start Firestore in **test mode** or allow reading from the `items` collection in Security Rules (`allow read: if true`).*\n\nOnce you've created a `items` collection and are inserting documents, you should see data streaming into your Angular application.\n\n## Deploy your app\n\nFinally, we can deploy the application to Firebase hosting:\n\n```bash\nng deploy\n```"
  },
  {
    "path": "site/src/index.md",
    "content": "---\nlayout: default.njk\n---\n\n{% headingone %}AngularFire{% endheadingone %}\n\n{% subheading %}The official library for Angular and Firebase{% endsubheading %}\n\n<div class=\"flex flex-col py-4 lg:flex-row xl:flex-row mb-8\">\n  <section class=\"flex mb-4 lg:mr-4 xl:mr-4 lg:mb-0 xl:mb-0\">\n    {%- linkbutton \"/get-started/quick-start\" %}\n      Get started\n    {%- endlinkbutton %}   \n  </section>\n  <section class=\"\">\n    {%- linkbutton \"https://github.com/angular/fire\", \"secondary\", true %}\n      GitHub\n    {%- endlinkbutton %}  \n  </section>          \n</div>\n\n{% disclaimerprod %}\n\n## What is AngularFire?\n\nAngularFire smooths over the rough edges an Angular developer might encounter when implementing the framework-agnostic Firebase JS SDK & aims to provide a more natural developer experience by conforming to Angular conventions.\n\n### Dependency injection\nProvide and Inject Firebase services in your components\n\n### Zone.js wrappers\nStable zones allow proper functionality of service workers, forms, SSR, and pre-rendering\n\n### Observable based\nUtilize RxJS rather than callbacks for realtime streams\n\n### NgRx friendly API\nIntegrate with NgRx using AngularFire's action based APIs.\n\n### Lazy-loading\nAngularFire dynamically imports much of Firebase, reducing time to load your app\n\n### Deploy schematics\nGet your Angular application deployed on Firebase Hosting with a single command\n\n### Google Analytics\nZero-effort Angular Router awareness in Google Analytics\n\n### Router Guards\nGuard your Angular routes with built-in Firebase Authentication checks\n"
  },
  {
    "path": "site/src/ionic/authentication.md",
    "content": "---\ntitle: Authentication\neleventyNavigation:\n  key: Authentication\n  parent: Ionic\n---\n\n## Setting up Ionic and Firebase Auth\n\nFirst start out by installing the needed plugins below.\n \n```\nionic cordova plugin add cordova-universal-links-plugin\nionic cordova plugin add cordova-plugin-buildinfo\nionic cordova plugin add cordova-plugin-browsertab\nionic cordova plugin add cordova-plugin-inappbrowser\n(for ios)\nionic cordova plugin add cordova-plugin-customurlscheme \n```\n\n## Add Firebase to your Ionic app\n\nFollow [this tutorial](https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md) to make a basic setup for your Ionic project.\n\n### To set up in an Android app\n\nGo to [Firebase console](https://console.firebase.google.com/) then click *Add Firebase to your Android app* and follow the setup steps.\n\n## Set up Firebase Authentication for Cordova\n\n*This is a summary from the [Firebase instructions](https://firebase.google.com/docs/auth/web/cordova).*\n\n### Setup Dynamic Link\nIn the Firebase console, open the *Dynamic Links* section at bottom left panel, setup by their instruction\n\nAdd this to config.xml at root level of project:\n\n```xml\n     <universal-links>\n        <!-- this is dynamic link created in firebase -->\n        <host name=\"zm4e4.app.goo.gl\" scheme=\"https\" />\n        <!-- this is your firebase app link -->\n        <host name=\"routing-aadd4.firebaseapp.com\" scheme=\"https\">\n            <path url=\"/__/auth/callback\" />\n        </host>\n    </universal-links>\n    <!-- for android -->\n    <preference name=\"AndroidLaunchMode\" value=\"singleTask\" />\n```\nMake sure your `<widget id=\"com.yourandroid.id\" ... >` the same with Android app's id you added in Firebase.\n\n## Add login code\n\nIn `login.service.ts` add this function: \n\n```ts\n\nimport { AngularFireAuth } from '@angular/fire/auth';\nimport firebase from 'firebase/app';\nimport AuthProvider = firebase.auth.AuthProvider;\n\nexport class AuthService {\n    private user: firebase.User;\n\tconstructor(public afAuth: AngularFireAuth) {\n\t\tafAuth.authState.subscribe(user => {\n\t\t\tthis.user = user;\n\t\t});\n\t}\n  \n  signInWithFacebook() {\n\t\tconsole.log('Sign in with Facebook');\n\t\treturn this.oauthSignIn(new firebase.auth.FacebookAuthProvider());\n\t}\n\n  signInWithGoogle() {\n\t\tconsole.log('Sign in with Google');\n\t\treturn this.oauthSignIn(new firebase.auth.GoogleAuthProvider());\n\t}\n\n  private oauthSignIn(provider: AuthProvider) {\n\t\tif (!(<any>window).cordova) {\n\t\t\treturn this.afAuth.auth.signInWithPopup(provider);\n\t\t} else {\n\t\t\treturn this.afAuth.auth.signInWithRedirect(provider)\n\t\t\t.then(() => {\n\t\t\t\treturn this.afAuth.auth.getRedirectResult().then( result => {\n\t\t\t\t\t// This gives you an Access Token. You can use it to access the associated APIs.\n\t\t\t\t\tlet token = result.credential.accessToken;\n\t\t\t\t\t// The signed-in user info.\n\t\t\t\t\tlet user = result.user;\n\t\t\t\t\tconsole.log(token, user);\n\t\t\t\t}).catch(function(error) {\n\t\t\t\t\t// Handle Errors here.\n\t\t\t\t\talert(error.message);\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t}\n}\n```\n"
  },
  {
    "path": "site/src/ionic/getting-started.md",
    "content": "---\ntitle: Getting started\neleventyNavigation:\n  key: Getting started\n  parent: Ionic\n---\n\n## Setup with Ionic CLI\n\nBefore you start installing AngularFire, make sure you have latest version of Ionic cli installed. To verify run the command `ionic -v` and check your version. The CLI should be at least version 3.0.0 or greater.\n\nIf not, you may need to do the following:\n\n```bash\n# if you have the wrong cli version only\nnpm uninstall -g ionic\nnpm cache clean\n\n# reinstall clean version\nnpm install -g @ionic/cli\n```\n\n## Create a new project\n\n```bash\nionic start <project-name>\ncd <project-name>\n```\n\nThe Ionic CLI's `start` command will prompt you to pick a starting template, and scaffold out the project for you.\n\n## Test your Setup\n\n```bash\nionic serve\n```\n\nYour default browser should start up and display a working Ionic app.\n\n## Install AngularFire & Firebase\n\n```bash\nnpm install @angular/fire firebase --save\n```\n\nNow that you have a new project setup, install AngularFire and Firebase from npm.\n\n### Add Firebase config to environments variable\n\nLet's create a new file, `src/environment.ts` and start adding our Firebase config:\n\n```ts\nexport const firebaseConfig = {\n  apiKey: '<your-key>',\n  authDomain: '<your-project-authdomain>',\n  databaseURL: '<your-database-URL>',\n  projectId: '<your-project-id>',\n  storageBucket: '<your-storage-bucket>',\n  messagingSenderId: '<your-messaging-sender-id>'\n};\n```\n\n\n## Add the `AngularFireModule`\n\nOpen `/src/app/app.module.ts`, inject the Firebase providers, and specify your Firebase configuration. This can be found in your project at [the Firebase Console](https://console.firebase.google.com):\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { IonicApp, IonicModule } from 'ionic-angular';\nimport { MyApp } from './app.component';\n\nimport { AngularFireModule } from '@angular/fire';\nimport { firebaseConfig } from '../environment';\n\n@NgModule({\n  declarations: [ MyApp ],\n  imports: [\n    BrowserModule,\n    IonicModule.forRoot(MyApp),\n    AngularFireModule.initializeApp(firebaseConfig)\n  ],\n  bootstrap: [IonicApp],\n})\nexport class AppModule {}\n\n```\n\nThere will be more or less imports depending on your app. This is just an example setup.\n\n## Custom FirebaseApp Names\nYou can optionally provide a custom FirebaseApp name with `initializeApp`.\n\n```ts\n@NgModule({\n  declarations: [ MyApp ],\n  imports: [\n    BrowserModule,\n    IonicModule.forRoot(MyApp),\n    AngularFireModule.initializeApp(firebaseConfig, 'my-app-name')\n  ],\n  bootstrap: [IonicApp],\n})\nexport class AppModule {}\n```\n\n## Adding Feature Modules\n\nIf your application was using both Firebase Auth and the Realtime Database you would add the following modules.\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { IonicApp, IonicModule } from 'ionic-angular';\nimport { MyApp } from './app.component';\n\nimport { AngularFireModule } from '@angular/fire';\nimport { firebaseConfig } from '../environment';\nimport { AngularFireDatabaseModule } from '@angular/fire/database';\nimport { AngularFireAuthModule } from '@angular/fire/auth';\n\n\n@NgModule({\n  declarations: [ MyApp ],\n  imports: [\n    BrowserModule,\n    // imports firebase/app needed for everything\n    AngularFireModule.initializeApp(firebaseConfig), \n    // imports firebase/database, only needed for database features\n    AngularFireDatabaseModule, \n    // imports firebase/auth, only needed for auth features\n    AngularFireAuthModule, \n    IonicModule.forRoot(MyApp),\n  ],\n  bootstrap: [IonicApp],\n})\n\n```\n\n### Inject AngularFireDatabase\n\nOpen `/src/pages/home/home.ts`, and start to import `AngularFireDatabase`.\n\n```ts\nimport { Component } from '@angular/core';\nimport { NavController } from 'ionic-angular';\nimport { AngularFireDatabase } from '@angular/fire/database';\nimport { Observable } from 'rxjs/Observable';\n\n@Component({\n  selector: 'page-home',\n  templateUrl: 'home.html'\n})\nexport class HomePage {\n  items: Observable<any[]>;\n  constructor(\n    public db: AngularFireDatabase,\n    public navCtrl: NavController,\n  ) {}\n\n}\n```\n\n### 8. Bind to a list\n\nIn `/src/pages/home/home.ts`:\n\n```ts\nimport { Component } from '@angular/core';\nimport { NavController } from 'ionic-angular';\nimport { AngularFireDatabase } from '@angular/fire/database';\nimport { Observable } from 'rxjs/Observable';\n\n@Component({\n  selector: 'page-home',\n  templateUrl: `{%raw%}\n<ion-header>\n  ---\n</ion-header>\n\n<ion-content padding>\n  <ion-item *ngFor=\"let item of items | async\">\n    {{item | json}}\n  </ion-item>\n</ion-content>{%endraw%}`\n})\nexport class HomePage {\n  items: Observable<any[]>;\n  constructor(\n    public db: AngularFireDatabase,\n    public navCtrl: NavController,\n  ) {\n    this.items = db.list('list').valueChanges();\n  }\n\n}\n```\n\n"
  },
  {
    "path": "site/src/ionic/index.md",
    "content": "---\neleventyNavigation:\n  key: Ionic\n  order: 12\n---\n\n"
  },
  {
    "path": "site/src/ionic/ionic.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/js/click-card.js",
    "content": "customElements.define('eap-click-card', class extends HTMLElement {\n  connectedCallback() {\n    let down;\n    let up;\n    // Enhance to a pointer only if the JavaScript applies\n    this.style.cursor = 'pointer';\n    // Note: This only works for a single link or the first one.\n    const firstOrOnlyLink = this.querySelector('a');\n    this.onmousedown = () => down = +new Date();\n    this.onmouseup = () => {\n      up = +new Date();\n      if ((up - down) < 200) {\n        firstOrOnlyLink.click();\n      }\n    }\n  }\n});"
  },
  {
    "path": "site/src/js/menu-button.js",
    "content": "customElements.define('eap-menu-button', class extends HTMLElement {\n  connectedCallback() {\n    const menuId = this.getAttribute('data-menu-id');\n    const menuEl = document.getElementById(menuId);\n    const button = document.createElement('button');\n    button.classList.add('fixed', 'w-16', 'h-16', 'text-white', 'rounded-full', 'shadow-lg', 'bottom-6', 'right-6', 'bg-grey-700', 'focus:ring-grey-600' , 'z-50', 'focus:ring-4', 'md:hidden', 'lg:hidden', 'xl:hidden');\n    button.textContent = '🔥';\n    this.appendChild(button);\n    button.addEventListener('click', clickEvent => {\n      menuEl.classList.toggle('slideIn');\n    });\n  }\n});\n"
  },
  {
    "path": "site/src/js/tab-switcher.js",
    "content": "customElements.define('eap-tab-switcher', class extends HTMLElement {});\ncustomElements.define('eap-tab-list', class extends HTMLElement {\n  connectedCallback() {\n    this.buttonTabs = this.querySelectorAll('button');\n    for(let button of this.buttonTabs) {\n      button.addEventListener('click', clickEvent => {\n        const activeButton = this.querySelector('button[aria-selected=\"true\"]');\n        const activePanelId = activeButton.dataset.panel;\n        const panelToDisplayId = button.dataset.panel;\n        const panelToDisplay = document.querySelector(`#${panelToDisplayId}`);\n        const activePanel = document.querySelector(`#${activePanelId}`);\n        if(activeButton.id !== button.id) {\n          button.setAttribute('aria-selected', true);\n          activeButton.setAttribute('aria-selected', false);\n          panelToDisplay.classList.add('block');\n          panelToDisplay.classList.remove('hidden');\n          activePanel.classList.remove('block');\n          activePanel.classList.add('hidden');\n        }\n      });\n    }\n  }\n});\ncustomElements.define('eap-tab-panel-list', class extends HTMLElement {});\ncustomElements.define('eap-tab-panel', class extends HTMLElement { });"
  },
  {
    "path": "site/src/messaging/getting-started.md",
    "content": "---\ntitle: Getting started\neleventyNavigation:\n  key: Getting started\n  parent: Messaging\n---\n\n## Using AngularFireMessaging\n\nThe FCM JavaScript API lets you receive notification messages in web apps running in browsers that support the Push API.\n\n## Not readily compatible with the Angular Service Worker\n\nIf you are using the Angular Service Worker, you are not currently able to use AngularFireMessaging out-of-the-box. If you'd like this feature please add your 👍 to [this issue](https://github.com/angular/angular/issues/34352).\n\nYour alternatives are to use\n- [WorkboxJS](https://developers.google.com/web/tools/workbox/){.text-blue .underline}\n- Follow the discussion in [this issue](https://github.com/angular/angular/issues/34352){.text-blue .underline} and [here](https://github.com/angular/angularfire/discussions/1923){.text-blue .underline}, manually registering the Angular Service Worker\n- The Firebase Messaging Service Worker, which is detailed below\n\n## Import the `NgModule`\n\nPush Notifications for AngularFire are contained in the `@angular/fire/messaging` module namespace. Import the `AngularFireMessagingModule` in your `NgModule`. This sets up the `AngularFireMessaging` service for dependency injection.\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { AngularFireModule } from '@angular/fire';\nimport { AngularFireMessagingModule } from '@angular/fire/messaging';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireMessagingModule\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\n### Setting up the Firebase Messaging Service Worker\n\nThere are two parts to Firebase Messaging, a Service Worker and the DOM API. AngularFireMessaging allows you to request permission, get tokens, delete tokens, and subscribe to messages on the DOM side. To register to receive notifications you need to set up the Service Worker. [The official Firebase documentation for setting up the details exactly how to do that](https://firebase.google.com/docs/cloud-messaging/js/client). \n\nYou can either use the `firebase-messaging-sw.js` file provided in the docs or you can set your own Service Worker to import that script. Make sure to set up your `angular.json` file to copy over the Service Worker file:\n\n```json\n  \"assets\": [\n    \"assets\",\n    \"favicon.ico\",\n    \"firebase-messaging-sw.js\",\n    \"manifest.json\"\n  ],\n```\n\n[Warning] Remember update the `firebase-messaging-sw.js` everytime you update the `firebase` in package.json. The missmatch version could lead to unable to receive notification in `foreground`, you can create your `firebase-messaging-sw.js` like this:\n\n```js\n// Give the service worker access to Firebase Messaging.\n// Note that you can only use Firebase Messaging here, other Firebase libraries\n// are not available in the service worker.\nimportScripts('https://www.gstatic.com/firebasejs/[the number of version matching with firebase in package.json]/firebase-app.js');\nimportScripts('https://www.gstatic.com/firebasejs/[for example: 8.2.6]/firebase-messaging.js');\n\n// Initialize the Firebase app in the service worker by passing in the\n// messagingSenderId.\n\nfirebase.initializeApp({\n    apiKey: '<your-key>',\n    authDomain: '<your-project-authdomain>',\n    databaseURL: '<your-database-URL>',\n    projectId: '<your-project-id>',\n    storageBucket: '<your-storage-bucket>',\n    messagingSenderId: '<your-messaging-sender-id>'\n});\n\n// Retrieve an instance of Firebase Messaging so that it can handle background\n// messages.\nconst messaging = firebase.messaging();\n```\n\n### Requesting permission\n\nOnce you have the Firebase Messaging Service Worker set up and installed, you need to request permission to send a user notifications. While the browser will popup a UI for you, it is highly recommend to ask the user for permission with a custom UI and only ask when it makes sense. If you blindly ask for permission, you have an extremely high chance of getting denied or blocked.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/messaging';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"requestPermission()\">\n    Hello this is a chat app. You should let us send you notifications for this reason.\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  requestPermission() {\n    this.afMessaging.requestPermission\n      .subscribe(\n        () => { console.log('Permission granted!'); },\n        (error) => { console.error(error); },  \n      );\n  }\n}\n```\n\nOnce you have the permission of the user, you need their token. You can do this with the `getToken` observable or the `tokenChanges` observable. The `tokenChanges` observable listens for token refreshes whereas the `getToken` observable is a one-time call.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/messaging';\nimport { mergeMapTo } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"requestPermission()\">\n    Hello this is a chat app. You should let us send you notifications for this reason.\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  requestPermission() {\n    this.afMessaging.requestPermission\n      .pipe(mergeMapTo(this.afMessaging.tokenChanges))\n      .subscribe(\n        (token) => { console.log('Permission granted! Save to the server!', token); },\n        (error) => { console.error(error); },  \n      );\n  }\n}\n```\n\nOnce you have a user's token, you need to save it to the server in order to send them notifications in response to events. Let's say you want to send a push each time a user sends a chat message. Once a user grants permission, you can send the token to the Realtime Database or Cloud Firestore and associate it with a unique id, like a Firebase Auth UID. You can then create a Cloud Function trigger that looks up the user's token when a chat message is created.\n\n### Shortcutting token requests\n\nAn easier way of requesting permission and getting tokens is with the `requestToken` observable. It combines the two steps above into one observable.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/messaging';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"requestPermission()\">\n    Hello this is a chat app. You should let us send you notifications for this reason.\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  requestPermission() {\n    this.afMessaging.requestToken\n      .subscribe(\n        (token) => { console.log('Permission granted! Save to the server!', token); },\n        (error) => { console.error(error); },  \n      );\n  }\n}\n```\n\nThe `requestToken` observable uses the `tokenChanges` observable to listen to refreshes.\n\n### Deleting tokens\n\nNeed to delete a user's token? Not a problem.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/messaging';\nimport { mergeMap } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"deleteMyToken()\">\n    Delete my token\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  deleteToken() {\n    this.afMessaging.getToken\n      .pipe(mergeMap(token => this.afMessaging.deleteToken(token)))\n      .subscribe(\n        (token) => { console.log('Token deleted!'); },\n      );\n  }\n}\n```\n\nThe code above requests the current user's token and passes it to the `deleteToken()` observable.\n\n### Subscribing to foreground messages\n\nOnce you have a user's token and they are subscribed, you can listen to messages in the foreground. The Firebase Messaging Service Worker handles background push notifications.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireMessaging } from '@angular/fire/messaging';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <button (click)=\"listen()\">\n    Get notified!\n  </button>\n  `\n})\nexport class AppComponent {\n  constructor(private afMessaging: AngularFireMessaging) { }\n  listen() {\n    this.afMessaging.messages\n      .subscribe((message) => { console.log(message); });\n  }\n}\n```\n\n### Sending notifications\n\n[Sending a notification](https://firebase.google.com/docs/cloud-messaging/js/first-message) requires a call to a server. You can do this directly with an HTTP call or you can even build a Cloud Function to do this in response to an event. A Cloud Function trigger is ideal because you have trusted access to the database and can securely look up tokens to send to the right user. If you want to send push notifications via HTTP requests you'll need to secure the API call. This is usually done with a Firebase Auth UID. On the server you can verify the UID with the Firebase Admin SDK and allow access to get a user's push id.\n\nThe [Firebase Admin SDK has helper functions for sending notifications](https://firebase.google.com/docs/cloud-messaging/admin/send-messages) to the user and subscribing them to topics, which [simplifies sending grouped messages](https://firebase.google.com/docs/cloud-messaging/admin/manage-topic-subscriptions)."
  },
  {
    "path": "site/src/messaging/index.md",
    "content": "---\neleventyNavigation:\n  key: Messaging\n  order: 8\n---\n\n"
  },
  {
    "path": "site/src/messaging/messaging.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/performance/getting-started.md",
    "content": "---\ntitle: Getting started\neleventyNavigation:\n  key: Getting started\n  parent: Performance\n---\n\n## Automatic page load tracing\n\nUnderstand your Angular application's real-world performance with [Firebase Performance Monitoring](https://firebase.google.com/docs/perf-mon). Performance Monitoring automatically provides a trace for **page load** when you add `AngularFirePerformanceModule` into your App Module's imports.\n\n```ts\nimport { AngularFireModule } from '@angular/fire';\nimport { AngularFirePerformanceModule, PerformanceMonitoringService } from '@angular/fire/performance';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFirePerformanceModule,\n    ...\n  ],\n  providers: [\n    PerformanceMonitoringService\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\nThe page load trace breaks down into the following default metrics:\n\n* [First paint traces](https://firebase.google.com/docs/perf-mon/automatic-web#first-paint){.text-blue .underline} — measure the time between when the user navigates to a page and when any visual change happens\n* [First contentful paint traces](https://firebase.google.com/docs/perf-mon/automatic-web#contentful-paint){.text-blue .underline} — measure the time between when a user navigates to a page and when meaningful content displays, like an image or text\n* [domInteractive traces](https://firebase.google.com/docs/perf-mon/automatic-web#domInteractive){.text-blue .underline} — measure the time between when the user navigates to a page and when the page is considered interactive for the user\n* [domContentLoadedEventEnd traces](https://firebase.google.com/docs/perf-mon/automatic-web#domContentLoaded){.text-blue .underline} — measure the time between when the user navigates to a page and when the initial HTML document is completely loaded and parsed\n* [loadEventEnd traces](https://firebase.google.com/docs/perf-mon/automatic-web#loadEventEnd){.text-blue .underline} — measure the time between when the user navigates to the page and when the current document's load event completes\n* [First input delay traces](https://firebase.google.com/docs/perf-mon/automatic-web#input-delay){.text-blue .underline} — measure the time between when the user interacts with a page and when the browser is able to respond to that input\n* *Angular specific traces* - `PerformanceMonitoringService` will measure the time needed for `ApplicationRef.isStable` to be true, an important metric to track if you're concerned about solving Zone.js issues for proper functionality of NGSW and Server Side Rendering\n\n## Measuring First Input Delay\n\nFirst Input Delay (FID) measures the time from when a user first interacts with your site (i.e. when they click a link, tap on a button, or use a custom, JavaScript-powered control) to the time when the browser is actually able to respond to that interaction. [See the article on the Google Developer's Blog for more information on FID.](https://developers.google.com/web/updates/2018/05/first-input-delay)\n\nIn order to track first input delay, you'll want to [polyfill the browser performance API](https://github.com/GoogleChromeLabs/first-input-delay):\n\n```bash\nnpm install --save-dev first-input-delay\n```\n\nThen add `import 'first-input-delay';` to your `src/polyfills.ts`.\n\n## Manual traces\n\nYou can inject `AngularFirePerformance` to perform manual traces.\n\n```ts\nconstructor(private performance: AngularFirePerformance) {}\n\n// ...\n\nconst trace = await this.performance.trace('some-trace');\ntrace.start();\n// Dome something you want to trace\ntrace.stop();\n```\n\n## RxJS operators\n\nAngularFire provides a number of RxJS operators which wrap the User Timing API. These are picked up by performance monitoring tools such as Chrome Inspector and Firebase Performance Monitoring.\n\n```ts\nimport { trace } from '@angular/fire/performance';\n\n// ...\n\nconstructor(private performance: AngularFirePerformance, private afs: AngularFirestore) {}\n\nngOnInit() {\n  this.articles = afs.collection('articles')\n      .collection('articles', ref => ref.orderBy('publishedAt', 'desc'))\n      .snapshotChanges()\n      .pipe(\n        // measure the amount of time between the Observable being subscribed to and first emission (or completion)\n        trace('getArticles'),\n        map(articles => ...)\n      );\n}\n```\n\n### `trace(name: string)`\n\nThe most basic operator, `trace` will measure the amount of time it takes for your observable to either complete or emit its first value. Beyond the basic trace there are several other operators:\n\n```ts\ntraceUntil(\n  name: string,\n  test: (T) => Boolean,\n  options?: { orComplete?: true }\n)\n```\n\nTrace the observable until the first emission that passes the provided test.\n\nIf the `orComplete` option is passed it will complete the trace when the observable completes, even if an emission never passed the provided test.\n\n```ts\ntraceWhile(\n  name: string,\n  test: (T) => Boolean,\n  options?: { orComplete?: true }\n)\n```\n\nStarting with an emission that passes the provided test, trace until an emission fails the test.\n\nIf the `orComplete` option is passed it will complete any existing trace when the observable completes.\n\n### `traceUntilLast(name: string)`\n\nTrace the observable until completion.\n\n### `traceUntilFirst(name: string)`\n\nTraces the observable until the first emission.\n\n## Configuration via Dependency Injection\n\nSet `INSTRUMENTATION_ENABLED` or `DATA_COLLECTION_ENABLED` to false disable all automatic and custom traces respectively.\n"
  },
  {
    "path": "site/src/performance/index.md",
    "content": "---\neleventyNavigation:\n  key: Performance\n  order: 10\n---\n"
  },
  {
    "path": "site/src/performance/performance.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/remote-config/getting-started.md",
    "content": "---\ntitle: Getting started\neleventyNavigation:\n  key: Getting started\n  parent: Remote Config\n---\n\n## Getting started with Remote Config (BETA)\n\n`AngularFireRemoteConfig` dynamically imports the `firebase/remote-config` library on demand, provides convenience observables, pipes, and a promisified version of the [Firebase Remote Config SDK (`firebase.remoteConfig.RemoteConfig`)](https://firebase.google.com/docs/reference/js/firebase.remoteconfig.RemoteConfig).\n\n## API\n\n```ts\nclass AngularFireRemoteConfigModule { }\n\ninterface ConfigTemplate {[key:string]: string|number|boolean}\n\ntype Parameter extends remoteConfig.Value {\n  key: string,\n  fetchTimeMillis: number\n}\n\nclass AngularFireRemoteConfig {\n  changes:    Observable<Parameter>;\n  parameters: Observable<Parameter[]>;\n  numbers:    Observable<{[key:string]: number|undefined}>  & {[key:string]: Observable<number>};\n  booleans:   Observable<{[key:string]: boolean|undefined}> & {[key:string]: Observable<boolean>};\n  strings:    Observable<{[key:string]: string|undefined}>  & {[key:string]: Observable<string|undefined>};\n  \n  // from firebase.remoteConfig() proxy:\n  activate: () => Promise<boolean>;\n  ensureInitialized: () => Promise<void>;\n  fetch: () => Promise<void>;\n  fetchAndActivate: () => Promise<boolean>;\n  getAll: () => Promise<{[key:string]: remoteConfig.Value}>;\n  getBoolean: (key:string) => Promise<boolean>;\n  getNumber: (key:string) => Promise<number>;\n  getString: (key:string) => Promise<string>;\n  getValue: (key:string) => Promise<remoteConfig.Value>;\n  setLogLevel: (logLevel: remoteConfig.LogLevel) => Promise<void>;\n  settings: Promise<remoteConfig.Settings>;\n  defaultConfig: Promise<{[key: string]: string | number | boolean}>;\n  fetchTimeMillis: Promise<number>;\n  lastFetchStatus: Promise<remoteConfig.FetchStatus>;\n}\n\n// Pipes for working with .changes and .parameters\nfilterRemote: () => MonoTypeOperatorFunction<Parameter | Parameter[]>\nfilterFresh: (interval: number) => MonoTypeOperatorFunction<Parameter | Parameter[]>\nbudget: <T>(interval: number) => MonoTypeOperatorFunction<T>\n\n// scanToObject is for use with .changes\nscanToObject: () => OperatorFunction<Parameter, {[key: string]: string|undefined}>\n\n// mapToObject is the same behavior as scanToObject but for use with .parameters\nmapToObject: () => OperatorFunction<Parameter[], {[key: string]: string|undefined}>\n\nSETTINGS = InjectionToken<remoteConfig.Settings>;\nDEFAULTS = InjectionToken<ConfigTemplate>;\n```\n\nUsing the `SETTINGS` DI Token (*default: {}*) will allow you to [configure Firebase Remote Config](https://firebase.google.com/docs/reference/js/firebase.remoteconfig.Settings.html).\n\n## Configure default values\n\nProviding `DEFAULTS ({[key: string]: string | number | boolean})` tells `AngularFireRemoteConfig` to emit the provided defaults first. This allows you to count on Remote Config when the user is offline or in environments that the Remote Config service does not handle (i.e. Server Side Rendering).\n\n```ts\nimport { AngularFireRemoteConfigModule, DEFAULTS, SETTINGS } from '@angular/fire/remote-config';\n\n@NgModule({\n  imports: [\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireRemoteConfigModule\n  ],\n  providers: [\n    { provide: DEFAULTS, useValue: { enableAwesome: true } },\n    {\n      provide: SETTINGS,\n      useFactory: () => isDevMode() ? { minimumFetchIntervalMillis: 10_000 } : {}\n    }\n  ]\n})\nexport class AppModule { }\n...\n\nconstructor(remoteConfig: AngularFireRemoteConfig) {\n  remoteConfig.changes.pipe(\n    filterFresh(172_800_000), // ensure we have values from at least 48 hours ago\n    first(),\n    // scanToObject when used this way is similar to defaults\n    // but most importantly smart-casts remote config values and adds type safety\n    scanToObject({\n      enableAwesome: true,\n      titleBackgroundColor: 'blue',\n      titleFontSize: 12\n    })\n  ).subscribe(…);\n\n  // all remote config values cast as strings\n  remoteConfig.strings.subscribe(...)\n  remoteConfig.booleans.subscribe(...); // as booleans\n  remoteConfig.numbers.subscribe(...); // as numbers\n\n  // convenience for observing a single string\n  remoteConfig.strings.titleBackgroundColor.subscribe(...);\n  remoteConfig.booleans.enableAwesome.subscribe(...); // boolean\n  remoteConfig.numbers.titleBackgroundColor.subscribe(...); // number\n\n  // however those may emit more than once as the remote config cache fires and gets fresh values\n  // from the server. You can filter it out of .changes for more control:\n  remoteConfig.changes.pipe(\n    filter(param => param.key === 'titleBackgroundColor'),\n    map(param => param.asString())\n    // budget at most 800ms and return the freshest value possible in that time\n    // our budget pipe is similar to timeout but won't error or abort the pending server fetch\n    // (it won't emit it, if the deadline is exceeded, but it will have been fetched so can use the\n    // freshest values on next subscription)\n    budget(800),\n    last()\n  ).subscribe(...)\n\n  // just like .changes, but scanned into an array\n  remoteConfig.parameters.subscribe(all => ...);\n\n  // or make promisified firebase().remoteConfig() calls direct off AngularFireRemoteConfig\n  // using our proxy\n  remoteConfig.getAll().then(all => ...);\n  remoteConfig.lastFetchStatus.then(status => ...);\n}\n```\n"
  },
  {
    "path": "site/src/remote-config/index.md",
    "content": "---\neleventyNavigation:\n  key: Remote Config\n  order: 9\n---\n"
  },
  {
    "path": "site/src/remote-config/remote-config.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/rtdb/index.md",
    "content": "---\neleventyNavigation:\n  key: RTDB\n  order: 4\n---\n"
  },
  {
    "path": "site/src/rtdb/lists.md",
    "content": "---\ntitle: Lists\neleventyNavigation:\n  key: Lists\n  parent: RTDB\n---\n\n## Retrieving data as lists\n\nAngularFire synchronizes data as lists using the `AngularFireList` service. The `AngularFireList` service is not created by itself, but through the `AngularFireDatabase` service. The guide below demonstrates how to retrieve, save, and remove data as lists.\n\n## Injecting the `AngularFireDatabase` service\n\n*Make sure you have bootstrapped your application for AngularFire. See the Installation guide for bootstrap setup.*\n\nAngularFireDatabase is a service which can be injected through the constructor of your Angular component or `@Injectable()` service. In the previous step, we modified the `/src/app/app.component.ts` to retrieve data as an object. In this step, let's start with a clean slate.\n\nReplace your  `/src/app/app.component.ts` from previous step to look like below.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase } from '@angular/fire/database';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: 'app.component.html',\n  styleUrls: ['app.component.css']\n})\nexport class AppComponent {\n  constructor(db: AngularFireDatabase) { }\n}\n```\n\nIn this section, we're going to modify the `/src/app/app.component.ts`  to retrieve data as list, but before that let's look at ways around how to bind to a list.\n\n## Create a list binding\n\nData is retrieved through the `AngularFireDatabase` service. The service is also generic. Provide the singular type and not the array type.\n\n```ts\nconst listRef = db.list('items');\nconst shirtsRef = db.list<Shirt>('shirts');\n```\n\n### Retrieve data\n\nTo get the list in realtime, create a list binding as a property of your component or service. Then in your template, you can use the `async` pipe to unwrap the binding.\n\nUpdate `/src/app/app.component.ts` to import `AngularFireList` from `@angular/fire` and iterate through the list once data is retrieved. Also note the change in attribute `templateUrl` to inline `template` below.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase } from '@angular/fire/database';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n  <ul>\n    <li *ngFor=\"let item of items | async\">\n       {{ item | json }}\n    </li>\n  </ul>\n  {%endraw%}`,\n})\nexport class AppComponent {\n  items: Observable<any[]>;\n  constructor(db: AngularFireDatabase) {\n    this.items = db.list('items').valueChanges();\n  }\n}\n```\n\n## `AngularFireAction` - Action based API\n\nAngularFire provides methods that stream data back as redux compatible actions. This gives you extra horsepower when using libraries like Animations, ngrx, and ReactiveForms. \n\n### `valueChanges()`\n\n*What is it?* - Returns an Observable of data as a synchronized array of JSON objects. All Snapshot metadata is stripped and just the method provides only the data.\n\n*Why would you use it?* - When you just need a list of data. No snapshot metadata is attached to the resulting array which makes it simple to render to a view.\n\n*When would you not use it?* - When you need a more complex data structure than an array or you need the `key` of each snapshot for data manipulation methods. This method assumes you either are saving the `key` for the snapshot data or using a \"readonly\" approach.\n\n### `snapshotChanges()`\n\n*What is it?* - Returns an Observable of data as a synchronized array of `AngularFireAction<DatabaseSnapshot>[]`.\n\n*Why would you use it?* - When you need a list of data but also want to keep around metadata. Metadata provides you the underyling `DatabaseReference` and snapshot key. Having the snapshot's `key` around makes it easier to use data manipulation methods. This method gives you more horsepower with other Angular integrations such as ngrx, forms, and animations due to the `type` property. The `type` property on each `AngularFireAction` is useful for ngrx reducers, form states, and animation states.\n\n*When would you not use it?* - When you need a more complex data structure than an array or if you need to process changes as they occur. This array is synchronized with the remote and local changes in the Firebase Database.\n\n### `stateChanges()`\n\n*What is it?* - Returns an Observable of the most recent change as an `AngularFireAction`.\n\n*Why would you use it?* - The above methods return a singular `AngularFireAction` from each child event that occurs. `stateChanges()` emits changes as they occur rather than syncing the query order. This works well for ngrx integrations as you can build your own data structure in your reducer methods.\n\n*When would you not use it?* - When you just need a list of data. This is a more advanced usage of `AngularFireDatabase`.\n\n### `auditTrail()`\n\n*What is it?* - Returns an Observable of `AngularFireAction[]` as they occur. Similar to `stateChanges()`, but instead it keeps around the trail of events as an array.\n\n*Why would you use it?* - This method is like `stateChanges()` except it is not ephemeral. It collects each change in an array as they occur. This is useful for ngrx integrations where you need to replay the entire state of an application. This also works as a great debugging tool for all applications. You can simple write `db.list('items').auditTrail().subscribe(console.log)` and check the events in the console as they occur.\n\n*When would you not use it?* - When you just need a list of data. This is a more advanced usage of AngularFireDatabase.\n\n### Limiting events\n\nThere are four child events: `\"child_added\"`, `\"child_changed\"`, `\"child_removed\"`, and `\"child_moved\"`. Each streaming method listens to all four by default. However, your site may only be intrested in one of these events. You can specify which events you'd like to use through the first parameter of each method:\n\n```ts\nthis.itemsRef = db.list('items');\nthis.itemsRef.snapshotChanges(['child_added'])\n  .subscribe(actions => {\n    actions.forEach(action => {\n      console.log(action.type);\n      console.log(action.key);\n      console.log(action.payload.val());\n    });\n  });\n```\n\n## API Summary\n\nThe table below highlights some of the common methods on the `AngularFireList`.\n\n| method   |                    | \n| ---------|--------------------| \n| `push(value: T)` | Creates a new record on the list, using the Realtime Database's push-ids. | \n| `update(keyRefOrSnap: string, value: T)` | Firebase | AFUnwrappedSnapshot, value: Object) | Updates an existing item in the array. Accepts a key, database reference, or an unwrapped snapshot. |\n| `remove(key: string?)` | Deletes the item by key. If no parameter is provided, the entire list will be deleted. |\n\n## Returning promises\n\nEach data operation method in the table above returns a promise. However,\nyou should rarely need to use the completion promise to indicate success, \nbecause the realtime database keeps the list in sync. \n\nThe promise can be useful to chain multiple operations, catching possible errors\nfrom security rules denials, or for debugging.\n\n```ts\nconst promise = db.list('items').remove();\npromise\n  .then(_ => console.log('success'))\n  .catch(err => console.log(err, 'You do not have access!'));\n```\n\n## Adding new items\n\nUse the `push()` method to add new items on the list.\n\n```ts\nconst itemsRef = db.list('items');\nitemsRef.push({ name: newName });\n```\n\n### Replacing items in the list using `set`\n\nUse the `set()` method to update existing items.\n\n```ts\nconst itemsRef = db.list('items');\n// to get a key, check the Example app below\nitemsRef.set('key-of-some-data', { size: newSize });\n```\n\nReplaces the current value in the database with the new value specified as the parameter. This is called a destructive update, because it deletes everything currently in place and saves the new value.\n\n## Updating items in the list using `update`\n\nUse the `update()` method to update existing items.\n\n```ts\nconst itemsRef = db.list('items');\n// to get a key, check the Example app below\nitemsRef.update('key-of-some-data', { size: newSize });\n```\n\nNote that this updates the current value with in the database with the new value specified as the parameter. This is called a non-destructive update, because it only updates the values specified.\n\n### Removing items from the list\nUse the `remove()` method to remove data at the list item's location.\n\n```ts\nconst itemsRef = db.list('items');\n// to get a key, check the Example app below\nitemsRef.remove('key-of-some-data');\n```\n\n## Deleting the entire list\n\nIf you omit the `key` parameter from `.remove()` it deletes the entire list.\n\n```ts\nconst itemsRef = db.list('items');\nitemsRef.remove();\n```\n\nThe following is a complete example of deleting an entire list.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase, AngularFireList } from '@angular/fire/database';\nimport { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <ul>\n    <li *ngFor=\"let item of items | async\">\n      <input type=\"text\" #updatetext [value]=\"item.text\" />\n      <button (click)=\"updateItem(item.key, updatetext.value)\">Update</button>\n      <button (click)=\"deleteItem(item.key)\">Delete</button>\n    </li>\n  </ul>\n  <input type=\"text\" #newitem />\n  <button (click)=\"addItem(newitem.value)\">Add</button>\n  <button (click)=\"deleteEverything()\">Delete All</button>\n  `,\n})\nexport class AppComponent {\n  itemsRef: AngularFireList<any>;\n  items: Observable<any[]>;\n  constructor(db: AngularFireDatabase) {\n    this.itemsRef = db.list('messages');\n    // Use snapshotChanges().map() to store the key\n    this.items = this.itemsRef.snapshotChanges().pipe(\n      map(changes => \n        changes.map(c => ({ key: c.payload.key, ...c.payload.val() }))\n      )\n    );\n  }\n  addItem(newName: string) {\n    this.itemsRef.push({ text: newName });\n  }\n  updateItem(key: string, newText: string) {\n    this.itemsRef.update(key, { text: newText });\n  }\n  deleteItem(key: string) {\n    this.itemsRef.remove(key);\n  }\n  deleteEverything() {\n    this.itemsRef.remove();\n  }\n}\n```\n\n"
  },
  {
    "path": "site/src/rtdb/objects.md",
    "content": "---\ntitle: Objects\neleventyNavigation:\n  key: Objects\n  parent: RTDB\n---\n\n## Retrieving data as objects\n\nThe `AngularFireObject` is a service for manipulating and streaming object data. The `AngularFireObject` service is not created by itself, but through the `AngularFireDatabase` service.\n\n## Injecting the `AngularFireDatabase` service\n\n*Make sure you have bootstrapped your application for AngularFire. See the Installation guide for bootstrap setup.*\n\n`AngularFireDatabase` is a service which can be injected through the constructor of your Angular component or `@Injectable()` service.\n\nIf you've followed the earlier step \"Installation and Setup\"  your `/src/app/app.component.ts` should look like below. \n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase } from '@angular/fire/database';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  templateUrl: 'app.component.html',\n  styleUrls: ['app.component.css']\n})\nexport class AppComponent {\n  items: Observable<any[]>;\n  constructor(db: AngularFireDatabase) {\n    this.items = db.list('items').valueChanges();\n  }\n}\n```\n\nIn this section, we're going to modify the `/src/app/app.component.ts`  to retrieve data as object.\n\n## Create an object binding\n\n```ts\nconst relative = db.object('item').valueChanges();\n```\n\n## Retrieve data\n\nTo get the object in realtime, create an object binding as a property of your component or service.\n\nThen in your template, you can use the `async` pipe to unwrap the binding.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase } from '@angular/fire/database';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n  <h1>{{ (item | async)?.name }}</h1>\n  {%endraw%}`,\n})\nexport class AppComponent {\n  item: Observable<any>;\n  constructor(db: AngularFireDatabase) {\n    this.item = db.object('item').valueChanges();\n  }\n}\n```\n\n## API Summary\n\nThe table below highlights some of the common methods on the `AngularFireObject`.\n\n| method   |                    | \n| ---------|--------------------| \n| `set(value: T)`      | Replaces the current value in the database with the new value specified as the parameter. This is called a **destructive** update, because it deletes everything currently in place and saves the new value. | \n| `update(value: T)`   | Updates the current value with in the database with the new value specified as the parameter. This is called a **non-destructive** update, because it only updates the values specified. |\n| `remove()`   | Deletes all data present at that location. Same as calling `set(null)`. |\n\n## Returning promises\n\nEach data operation method in the table above returns a promise. However,\nyou should rarely need to use the completion promise to indicate success, \nbecause the realtime database keeps the object in sync. \n\nThe promise can be useful to chain multiple operations, catching possible errors from security rules denials, or for debugging.\n\n```ts\nconst promise = db.object('item').remove();\npromise\n  .then(_ => console.log('success'))\n  .catch(err => console.log(err, 'You dont have access!'));\n```\n\n## Saving data\n\nUse the `set()` method for **destructive updates**.\n\n```ts\nconst itemRef = db.object('item');\nitemRef.set({ name: 'new name!'});\n```\n\n## Updating data\n\nUse the `update()` method for **non-destructive updates**.\n\n```ts\nconst itemRef = db.object('item');\nitemRef.update({ age: newAge });\n```\n\n**Only objects are allowed for updates, not primitives**. This is because\nusing an update with a primitive is the exact same as doing a `.set()` with a primitive.\n\n## Deleting data\n\nUse the `remove()` method to remove data at the object's location.\n\n```ts\nconst itemRef = db.object('item');\nitemRef.remove();\n```\n\n**Example app**: \n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase, AngularFireObject } from '@angular/fire/database';\nimport { Observable } from 'rxjs';\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n  <h1>{{ item | async | json }}</h1>\n  <input type=\"text\" #newname placeholder=\"Name\" />\n  <input type=\"text\" #newsize placeholder=\"Size\" />\n  <br />\n  <button (click)=\"save(newname.value)\">Set Name</button>\n  <button (click)=\"update(newsize.value)\">Update Size</button>\n  <button (click)=\"delete()\">Delete</button>\n  {%endraw%}`,\n})\nexport class AppComponent {\n  itemRef: AngularFireObject<any>;\n  item: Observable<any>;\n  constructor(db: AngularFireDatabase) {\n    this.itemRef = db.object('item');\n    this.item = this.itemRef.valueChanges();\n  }\n  save(newName: string) {\n    this.itemRef.set({ name: newName });\n  }\n  update(newSize: string) {\n    this.itemRef.update({ size: newSize });\n  }\n  delete() {\n    this.itemRef.remove();\n  }\n}\n```\n\n## Retrieving the snapshot\n\nAngularFire `valueChanges()` unwraps the Firebase DataSnapshot by default, but you can get the data as the original snapshot by using the `snapshotChanges()` option.\n\n```ts\nthis.itemRef = db.object('item');\nthis.itemRef.snapshotChanges().subscribe(action => {\n  console.log(action.type);\n  console.log(action.key)\n  console.log(action.payload.val())\n});\n```\n\n## Querying?\n\nBecause `AngularFireObject` synchronizes objects from the realtime database, sorting will have no effect for queries that are not also limited by a range. For example, when paginating you would provide a query with a sort and filter. Both the sort operation and the filter operation affect which subset of the data is returned by the query; however, because the resulting object is simply json, the sort order will not be preseved locally. Hence, for operations that require sorting, you are probably looking for a list.\n"
  },
  {
    "path": "site/src/rtdb/querying.md",
    "content": "---\ntitle: Querying\neleventyNavigation:\n  key: Querying\n  parent: RTDB\n---\n\n## Querying lists\n\nLists of data in the Realtime Database can be filtered down using specific querying methods. When these querying methods are combined with RxJS operators you can achieve dynamic querying which re-triggers the query when a source observable changes. This is great for updating queries in response to changes of an input or some other changing value.\n\n## Creating a query with constant values\n\nQueries are created by building on the [`firebase.database.Reference`](https://firebase.google.com/docs/reference/js/firebase.database.Reference).\n\n```ts\ndb.list('/items', ref => ref.orderByChild('size').equalTo('large'))\n```\n\n### Query options\n\n| Method   | Purpose            |\n| ---------|--------------------|\n| `orderByChild` | Specify a child to order by. |\n| `orderByKey` | Boolean to order by Firebase Database keys. |\n| `orderByValue` | Specify a value to order by. |\n| ~~`orderByPriority`~~<sup>1</sup> | Boolean to order by Firebase Database priority.|\n| `equalTo`<sup>2</sup> | Limit list to items that contain certain value. |\n| `limitToFirst` | Sets the maximum number of items to return from the beginning of the ordered list of results. |\n| `limitToLast` | Sets the maximum number of items to return from the end of the ordered list of results. |\n| `startAt`<sup>2</sup> | Return items greater than or equal to the specified key or value, depending on the order-by method chosen. |\n| `endAt`<sup>2</sup> | Return items less than or equal to the specified key or value, depending on the order-by method chosen. |\n\n:::annotations-section\n  <sup>1</sup> [This is the old way of doing things and is no longer recommended for use](https://youtu.be/3WTQZV5-roY?t=3m). Anything you can achieve with `orderByPriority` you should be doing with `orderByChild`.\n\n  <sup>2</sup> The Firebase SDK supports an optional `key` parameter for [`startAt`](https://firebase.google.com/docs/reference/js/firebase.database.Reference#startAt), [`endAt`](https://firebase.google.com/docs/reference/js/firebase.database.Reference#endAt), and [`equalTo`](https://firebase.google.com/docs/reference/js/firebase.database.Reference#equalTo) when ordering by child, value, or priority. You can specify the `key` parameter using an object literal that contains the `value` and the `key`. For example: `startAt: { value: 'some-value', key: 'some-key' }`.\n:::\n\nTo learn more about how sorting and ordering data works in Firebase, check out the Firebase documentation on [working with lists of data](https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data).\n\n## Invalid query combinations\n\n*Queries can only be ordered by one method.* This means you can only specify\n`orderByChild`, `orderByKey`, `orderByPriority`, or `orderByValue`.\n\n```ts\n// WARNING: Do not copy and paste. This will not work!\nref.orderByChild('size').equalTo('large').orderByKey(true)\n```\n\nYou can only use `limitToFirst` or `limitToLast`, but not both in combination.\n\n```ts\n// WARNING: Do not copy and paste. This will not work!\nref.limitToFirst(10).limitToLast(100)\n```\n\n## Dynamic querying\n\nTo enable dynamic queries one should lean on RxJS Operators like `switchMap`.\n\nAn RxJS Subject is imported below. A Subject is like an Observable, but can multicast to many Observers. Subjects are like EventEmitters: they maintain a registry of many listeners. See, [What is a Subject](http://reactivex.io/rxjs/manual/overview.html#subject) for more information.\n\nWhen we call [`switchMap` on the Subject](https://www.learnrxjs.io/operators/transformation/switchmap.html), we can map each value to a new Observable; in this case a database query.\n\n```ts\nconst size$ = new Subject<string>();\nconst queryObservable = size$.pipe(\n  switchMap(size => \n    db.list('/items', ref => ref.orderByChild('size').equalTo(size)).valueChanges()\n  )\n);\n\n// subscribe to changes\nqueryObservable.subscribe(queriedItems => {\n  console.log(queriedItems);  \n});\n\n// trigger the query\nsize$.next('large');\n\n// re-trigger the query\nsize$.next('small');\n```\n\nThe following is an example of dynamic querying. [See this example in action on StackBlitz](https://stackblitz.com/edit/angularfire-db-api-s8ip7m).\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireDatabase, AngularFireAction } from '@angular/fire/database';\nimport { Observable, Subscription, BehaviorSubject } from 'rxjs';\nimport { switchMap } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n  <h1>Firebase widgets!</h1>\n  <div *ngIf=\"items$ | async; let items; else loading\">\n    <ul>\n      <li *ngFor=\"let item of items\">\n        {{ item.payload.val().text }}\n        <code>{{ item.payload.key }}</code>\n      </li>\n    </ul>\n    <div *ngIf=\"items.length === 0\">No results, try clearing filters</div>\n  </div>\n  <ng-template #loading>Loading&hellip;</ng-template>\n  <div>\n    <h4>Filter by size</h4>\n    <button (click)=\"filterBy('small')\">Small</button>\n    <button (click)=\"filterBy('medium')\">Medium</button>\n    <button (click)=\"filterBy('large')\">Large</button>\n    <button (click)=\"filterBy('x-large')\">Extra Large</button>\n    <button (click)=\"filterBy(null)\" *ngIf=\"this.size$.getValue()\">\n      <em>clear filter</em>\n    </button>\n  </div>\n  {%endraw%}`,\n})\nexport class AppComponent {\n  items$: Observable<AngularFireAction<firebase.database.DataSnapshot>[]>;\n  size$: BehaviorSubject<string|null>;\n  \n  constructor(db: AngularFireDatabase) {\n    this.size$ = new BehaviorSubject(null);\n    this.items$ = this.size$.pipe(\n      switchMap(size => \n        db.list('/items', ref =>\n          size ? ref.orderByChild('size').equalTo(size) : ref\n        ).snapshotChanges()\n      )\n    );\n  }\n  filterBy(size: string|null) {\n    this.size$.next(size);\n  }\n}\n```\n\n*To run the above example as is, you need to have sample data in you firebase database with the following structure:*\n \n ```json\n{\n  \"items\": {\n    \"a\" : {\n      \"size\" : \"small\",\n      \"text\" : \"small thing\"\n    },\n    \"b\" : {\n      \"size\" : \"medium\",\n      \"text\" : \"medium sample\"\n    },\n    \"c\" : {\n      \"size\" : \"large\",\n      \"text\" : \"large widget\"\n    }\n  }\n}\n ```\n\n"
  },
  {
    "path": "site/src/rtdb/rtdb.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/shortcodes/buttons/index.js",
    "content": "/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst linkButton = {\n  name: \"linkbutton\",\n  type: \"addPairedShortcode\",\n  create (content, href, type='primary', external=false) {\n    const primaryClass = `link-button inline-block shadow-lg bg-blue text-white text-lg uppercase font-bold font-display tracking-wide rounded-lg px-8 py-3 text-center`;\n    const secondaryClass = `link-button inline-block shadow-lg bg-blue-200 text-black text-lg uppercase font-bold font-display tracking-wide rounded-lg px-8 py-3 text-center`;\n    const cssClass = type === 'primary' ? primaryClass : secondaryClass;\n    const externalAttrs = external ? 'rel=\"noopener\" target=\"blank\"' : '';\n    return `<a class=\"${cssClass}\" href=\"${href}\" ${externalAttrs}>${content}</a>`;\n  }\n}\n\nmodule.exports = {\n  shortcodes: [\n    linkButton,\n  ]\n};\n"
  },
  {
    "path": "site/src/shortcodes/disclaimerprod/index.js",
    "content": "/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Usage: {% disclaimerprod %}\nconst disclaimerprod = {\n  name: \"disclaimerprod\",\n  type: \"addShortcode\",\n  create() {\n    return `<div class=\"bg-yellow text-black p-8 rounded-lg shadow-lg text-base\">\n  <h4 class=\"uppercase tracking-wide font-bold mb-2 text-base\">Beta Site!</h4>\n  <p class=\"p-0 m-0\">This is a brand new guide site that is in beta. During this time period we'd love to hear your feedback on our <a href=\"https://github.com/angular/angularfire/discussions\" target=\"blank\" rel=\"opener\">GitHub Discussion board</a>. Please let us know what you think of the usability, content, and any ideas for improvement. All contributors are welcome!</p>\n</div>`;\n  }\n}\n\nmodule.exports = { \n  shortcodes: [\n    disclaimerprod\n  ]\n};\n"
  },
  {
    "path": "site/src/shortcodes/filters/index.js",
    "content": "const console = require('console');\nconst { resolve } = require('path');\n\nconst findByName = {\n  name: \"findByName\",\n  type: \"addNunjucksFilter\",\n  create(list, name) {\n    return list.find((item) => item.name === name);\n  }\n};\n\nconst log = {\n  name: \"log\",\n  type: \"addNunjucksFilter\",\n  create(object, logName) {\n    console.log(logName, object);\n    return object;\n  }\n};\n\nconst json = {\n  name: \"json\",\n  type: \"addNunjucksFilter\",\n  create(object, spacer = 3) {\n    let cache = [];\n    const json = JSON.stringify(\n      object,\n      (key, value) => {\n        if (typeof value === \"object\" && value !== null) {\n          if (cache.includes(value)) {\n            return;\n          }\n          cache.push(value);\n        }\n        return value;\n      },\n      spacer\n    );\n    cache = null;\n    return json;\n  }\n};\n\nconst findPreviousEntry = {\n  name: \"findPreviousEntry\",\n  type: \"addNunjucksFilter\",\n  create(children, eleventyNavigation) {\n    const itemIndex = children.findIndex(entry => entry.key === eleventyNavigation.key);\n    const previousIndex = itemIndex - 1;\n    return children[previousIndex];\n  }\n};\n\nconst findNextEntry = {\n  name: \"findNextEntry\",\n  type: \"addNunjucksFilter\",\n  create(children, eleventyNavigation) {\n    const itemIndex = children.findIndex(entry => entry.key === eleventyNavigation.key);\n    const nextIndex = itemIndex + 1;\n    return children[nextIndex];\n  }\n};\n\n/**\n * This filter reads the custom navigation in the global _data/ folder\n * and merges it with the eleventyNavigation config. Eleventy Navigation\n * works great for parent folders but it's less good for child navigation\n * when it comes to \"next/prev\" routing. This allows us to keep the good\n * parts of Eleventy Navigation and have a custom child path routing.\n * \n * Eventually I'd like to customize Eleventy Navigation to do child routing\n * because this is extremely inefficient to loop over nav for every page. It\n * doesn't effect this build too bad though.\n */\nconst mergeNavigation = {\n  name: \"mergeNavigation\",\n  type: \"addNunjucksFilter\",\n  create(eleventyNavigation) {\n    const customNavigation = require(resolve(__dirname, '../../_data/nextprev.json'));\n    const customKeys = Object.keys(customNavigation);\n    customKeys.forEach(key => {\n      const eleventyNavMatch = eleventyNavigation.find(item => item.key === key);\n      if(eleventyNavMatch != undefined) {\n        const matchKids = eleventyNavMatch.children;\n        const newKids = customNavigation[key].children.map(child => {\n          return matchKids.find(c => c.key === child.key);\n        });\n        eleventyNavigation.find(item => item.key === key).children = newKids;\n      }\n    });\n    return eleventyNavigation;\n  }  \n}\n\nmodule.exports = {\n  shortcodes: [\n    findByName,\n    log,\n    json,\n    findPreviousEntry,\n    findNextEntry,\n    mergeNavigation,\n  ],\n};\n"
  },
  {
    "path": "site/src/shortcodes/headings/index.js",
    "content": "/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Usage: {% headingone %} My title! {% endheadingone %}\nconst headingOne = {\n  name: \"headingone\",\n  type: \"addPairedShortcode\",\n  create (content) {\n    return `<h1 class=\"text-5xl font-bold leading-snug mb-2\">${ content }</h1>`\n  }\n};\n\nconst subHeading = {\n  name: \"subheading\",\n  type: \"addPairedShortcode\",\n  create (content) {\n    return `<div class=\"text-3xl font-display mb-8 text-grey-300\">${content}</div>`;\n  }\n};\n\nmodule.exports = {\n  shortcodes: [\n    headingOne,\n    subHeading,\n  ]\n};\n\n"
  },
  {
    "path": "site/src/shortcodes/includecode/fetch.js",
    "content": "/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst fetch = require(\"node-fetch\");\n\nfunction convertToGitHubApiUrl(githubPath) {\n  const urlPieces = githubPath.split('/');\n  const [user, repo] = urlPieces.slice(0, 2);\n  // TODO(davideast): Don't hardcode main branch\n  const githubApiUrl = [user, repo, 'master', ...urlPieces.slice(2, urlPieces.length)].join('/');\n  return `https://raw.githubusercontent.com/${githubApiUrl}`;\n}\n\nasync function fetchCode(githubPath) {\n  const githubApiUrl = convertToGitHubApiUrl(githubPath);\n  const response = await fetch(githubApiUrl);\n  return response.text();\n}\n\nmodule.exports = { fetchCode };\n"
  },
  {
    "path": "site/src/shortcodes/includecode/from-local.js",
    "content": "const { readFile } = require('fs');\nconst { resolve } = require('path');\nconst { promisify } = require('util');\nconst readFileAsync = promisify(readFile);\n\nfunction convertGitHubPathToLocal(githubPath) {\n  return resolve(__dirname, '../../../repo_clones', githubPath);\n}\n\nasync function fetchCode(githubPath = '') {\n  let content = '';\n  try {\n    const localPath = convertGitHubPathToLocal(githubPath);\n    content = await readFileAsync(localPath, 'utf-8');\n  } catch(error) {\n    console.error(error);\n    content = 'File not found 😭'; \n  }\n  return content;\n}\n\nmodule.exports = {\n  fetchCode,\n};\n"
  },
  {
    "path": "site/src/shortcodes/includecode/index.js",
    "content": "/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst { fetchCode } = require('./from-local');\nconst { processSnippet } = require('./snippets');\nconst prism = require('markdown-it-prism');\nconst MarkdownIt = require('markdown-it');\nconst md = new MarkdownIt({ html: true });\nmd.use(prism);\n\nfunction embedInCodeticks(code) {\n  return '```js\\n' + code + '\\n```';\n}\n\n// Usage: {% includecode github_path=\"firebase/snippets-web/snippets/auth-next/anonymous/auth_anon_sign_in.js\" %}\nconst includecode = {\n  name: \"includecode\",\n  type: \"addNunjucksAsyncShortcode\",\n  create({ github_path }) {\n    return fetchCode(github_path)\n      .then(processSnippet)\n      .then(embedInCodeticks)\n      .then(output => md.render(output));\n  }\n};\n\n// Usage: {% codeswitcher eap_github_path=\"\" current_github_path=\"\" %}\nconst codeswitcher = {\n  name: \"codeswitcher\",\n  type: \"addNunjucksAsyncShortcode\",\n  async create({ eap_github_path, current_github_path }) {    \n    \n    let eapCode = '';\n    if(eap_github_path != undefined && eap_github_path !== '') {\n      eapCode = await fetchCode(eap_github_path);\n      eapCode = processSnippet(eapCode);\n      eapCode = embedInCodeticks(eapCode);\n      eapCode = md.render(eapCode);\n      eapCode = eapCode.trim();\n    }\n\n    let currentCode = '';\n    if(current_github_path != undefined && current_github_path !== '') {\n      currentCode = await fetchCode(current_github_path);\n      currentCode = processSnippet(currentCode);\n      currentCode = embedInCodeticks(currentCode);\n      currentCode = md.render(currentCode);\n      eapCode = eapCode.trim();\n    }\n    const eapId = Math.random().toString(36).substring(7);\n    const currentId = Math.random().toString(36).substring(7);\n    return /*html*/`<eap-tab-switcher>\n  <eap-tab-list role=\"tablist\">\n    <button aria-selected=\"true\" id=\"aria-tab-${eapId}\" data-panel=\"tabpanel-${eapId}\" aria-controls=\"tabpanel-${eapId}\">\n      EAP Modular\n    </button>\n    <button id=\"aria-tab-${currentId}\" data-panel=\"tabpanel-${currentId}\" aria-controls=\"\">\n      v8 Current\n    </button>\n  </eap-tab-list>\n  <eap-tab-panel-list>\n    <eap-tab-panel id=\"tabpanel-${eapId}\" aria-labelledby=\"aria-tab-${eapId}\">${eapCode}</eap-tab-panel>\n    <eap-tab-panel id=\"tabpanel-${currentId}\" aria-labelledby=\"aria-tab-${currentId}\" class=\"hidden\">${currentCode}</eap-tab-panel>\n  </eap-tab-panel-list>\n</eap-tab-switcher>`;\n  }\n};\n\n// Usage: {% commonexample title=\"\" eap_github_path=\"\" current_github_path=\"\"  %}\nconst commonexample = {\n  name: \"commonexample\",\n  type: \"addNunjucksAsyncShortcode\",\n  async create({ title, eap_github_path, current_github_path, github_path }) {\n    const isEmpty = value => value == undefined || value === '';\n    const isSwitcher = (!isEmpty(eap_github_path) || !isEmpty(github_path)) && !isEmpty(current_github_path);\n    // TODO(davideast): Enable current_github_path as a single option\n    const pathToUse = !isEmpty(github_path) ? github_path : eap_github_path;\n    const codebox = isSwitcher ? \n       await codeswitcher.create({ eap_github_path: pathToUse, current_github_path }) :\n       await includecode.create({ github_path: pathToUse });\n    return md.render(`### ${title} \n${codebox}`);\n  }\n};\n\nmodule.exports = { \n  shortcodes: [\n    includecode,\n    codeswitcher,\n    commonexample,\n  ]\n};\n"
  },
  {
    "path": "site/src/shortcodes/includecode/snippets.js",
    "content": "// Modified from: https://github.com/firebase/snippets-web/blob/master/scripts/separate-snippets.ts\n\n// Regex for [START] and [END] snippet tags.\nconst RE_START_SNIPPET = /\\[START\\s+([A-Za-z_]+)\\s*\\]/;\nconst RE_END_SNIPPET = /\\[END\\s+([A-Za-z_]+)\\s*\\]/;\n\nfunction isBlank(line) {\n  return line.trim().length === 0;\n}\n\n/**\n * Change all [START foo] and [END foo] to be [START foosuffix] and [END foosuffix]\n */\nfunction removeSectionsFromSnippet(lines/* string[]*/) {\n  const outputLines = [];\n  for (const line of lines) {\n    if (!line.match(RE_START_SNIPPET) && !line.match(RE_END_SNIPPET)) {\n      outputLines.push(line);\n    }\n  }\n  return outputLines;\n}\n\n/**\n * Remove all left-padding so that the least indented line is left-aligned.\n */\nfunction adjustIndentation(lines /*: string[]*/) {\n  const nonBlankLines = lines.filter((l) => !isBlank(l));\n  const indentSizes = nonBlankLines.map((l) => l.length - l.trimLeft().length);\n  const minIndent = Math.min(...indentSizes);\n\n  const outputLines = [];\n  for (const line of lines) {\n    if (isBlank(line)) {\n      outputLines.push(\"\");\n    } else {\n      outputLines.push(line.substr(minIndent));\n    }\n  }\n  return outputLines;\n}\n\n/**\n * If the first line after leading comments is blank, remove it.\n */\nfunction removeFirstLineAfterComments(lines /*: string[]*/) {\n  const outputLines = [...lines];\n  const firstNonComment = outputLines.findIndex(\n    (l) => l.startsWith(\"// [START\")\n  );\n  return outputLines.slice(firstNonComment, outputLines.length);\n}\n\n/**\n * Turns a series of source lines into a standalone snippet file by running\n * a series of transformations.\n *\n * @param cones the code containing the snippet (including START/END comments)\n */\nfunction processSnippet(code /*: string[]*/) /*: string*/ {\n  const lines = code.split('\\n');\n  let outputLines = [...lines];\n\n  // Perform transformations individually, in order\n  outputLines = removeFirstLineAfterComments(outputLines);\n  outputLines = removeSectionsFromSnippet(outputLines);\n  outputLines = adjustIndentation(outputLines);\n\n  const content = [...outputLines].join(\"\\n\");\n  return content;\n}\n\nmodule.exports = { processSnippet };\n"
  },
  {
    "path": "site/src/shortcodes/includecode/transform.js",
    "content": "/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst { parse } = require(\"@babel/parser\")\nconst generate = require('@babel/generator').default;\nconst prettier = require(\"prettier\");\n\nfunction transform(githubCode) {\n  const parsedAST = parse(githubCode, {\n    sourceType: \"module\",\n  });\n  \n  const isFirst = index => index === 0;\n  \n  parsedAST.program.body.forEach((statement, index) => {\n  \n    // The first set of lines usually have comments and we \n    // always want them removed\n    if(isFirst(index)) {\n      // Remove all comments before leading statement\n      if(statement.leadingComments) {\n        delete statement.leadingComments;\n      }\n    }\n  \n    // Find any [START] or [END]\n    if(statement.leadingComments) {\n      statement.leadingComments = statement.leadingComments.filter(comment => {\n        return !comment.value.includes('[START') && !comment.value.includes('[END');\n      });\n    }\n  \n    // Remove any trailing comments because they likely should be\n    // leading comments. Babel guesses where comments go and you can \n    // find a comment as both trailing and leading. This will likely\n    // cause problems in the future, but right now it works with the\n    // code samples we use.\n    if(statement.trailingComments) {\n      statement.trailingComments = [];\n    }\n  });\n  \n  const { code } = generate({\n    type: \"Program\",\n    // passing a new copy of the body to avoid\n    // any reference problems\n    body: parsedAST.program.body.slice(),\n  });\n  return prettier.format(code, { parser: \"babel\" });\n}\n\nmodule.exports = { transform };\n"
  },
  {
    "path": "site/src/shortcodes/index.js",
    "content": "/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nconst { readdirSync, lstatSync } = require('fs');\nconst { resolve } = require('path');\n\n/**\n * This sets up the shortcodes plugin to dynamically register\n * any shortcode in this directory, as long as it is is in \n * its own directory, exported in an index.js with an exports\n * of an array of shortcodes.\n * \n * Example:\n *  / shortcodes\n *   / includecode\n *     + index.js\n *         module.exports = { shortcodes: [...] }\n */\n\nconst shortcodes = readdirSync(__dirname)\n  .map(relativePath => resolve(__dirname, relativePath))\n  .filter(absolutePath => lstatSync(absolutePath).isDirectory())\n  .map(path => require(path).shortcodes)\n  .flat();\n\nmodule.exports = {\n  shortcodes\n};\n"
  },
  {
    "path": "site/src/shortcodes/version/index.js",
    "content": "/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Usage: {% version %}\nconst version = {\n  name: \"version\",\n  type: \"addShortcode\",\n  create () {\n    return Date.now().toString();\n  }\n};\n\nmodule.exports = {\n  shortcodes: [\n    version,\n  ]\n};\n"
  },
  {
    "path": "site/src/storage/getting-started.md",
    "content": "---\ntitle: Getting started\neleventyNavigation:\n  key: Getting started\n  parent: Storage\n---\n\n\n## Using AngularFireStorage\n\nCloud Storage is designed to help you quickly and easily store and serve user-generated content, such as photos and videos.\n\n## Import the `NgModule`\n\nCloud Storage for AngularFire is contained in the `@angular/fire/storage` module namespace. Import the `AngularFireStorageModule` in your `NgModule`. This sets up the `AngularFireStorage` service for dependency injection.\n\n```ts\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { AngularFireModule } from '@angular/fire';\nimport { AngularFireStorageModule } from '@angular/fire/storage';\nimport { environment } from '../environments/environment';\n\n@NgModule({\n  imports: [\n    BrowserModule,\n    AngularFireModule.initializeApp(environment.firebase),\n    AngularFireStorageModule\n  ],\n  declarations: [ AppComponent ],\n  bootstrap: [ AppComponent ]\n})\nexport class AppModule {}\n```\n\nThe `BUCKET` injection token can be used to customise the storage bucket.\n\n```ts\nimport {AngularFireStorageModule, BUCKET } from '@angular/fire/storage';\n\n@NgModule({\n  providers: [\n    { provide: BUCKET, useValue: 'my-bucket-name' }\n  ],\n  ...\n})\nexport class AppModule {}\n```\n\n## Injecting the AngularFireStorage service\n\nOnce the `AngularFireStorageModule` is registered you can inject the `AngularFireStorage` service.\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/storage';\n\n@Component({\n  selector: 'app-component',\n  template: ``\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) { }\n}\n```\n\n## Uploading blobs\n\nThere are three options for uploading files.\n\n\n| method   |                    |\n| ---------|--------------------|\n| `put(data: Blob, metadata?: storage.UploadMetadata): AngularFireUploadTask` | Starts the upload of the blob to the storage reference's path. Returns an `AngularFireUploadTask` for upload monitoring. |\n| `putString(data: string, format?: StringFormat, metadata?: UploadMetadata): AngularFireUploadTask` | Updates an existing item in the array. Accepts a key, database reference, or an unwrapped snapshot. |\n| `upload(path: string, data: StringFormat, metadata?: UploadMetadata): AngularFireUploadTask` | Upload or update a new file to the storage reference's path. Returns an `AngularFireUploadTask` for upload monitoring. |\n\n## Uploading blobs with put\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/storage';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <input type=\"file\" (change)=\"uploadFile($event)\">\n  `\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) { }\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const ref = this.storage.ref(filePath);\n    const task = ref.put(file);\n  }\n}\n```\n\n## Uploading blobs with putString\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/storage';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <input type=\"file\" (change)=\"uploadFile($event)\">\n  `\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) { }\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const ref = this.storage.ref(filePath);\n    const task = ref.putString(file);\n  }\n}\n```\n\n## Uploading files with upload\n\n```ts\nimport { Component } from '@angular/core';\nimport { AngularFireStorage } from '@angular/fire/storage';\n\n@Component({\n  selector: 'app-root',\n  template: `\n  <input type=\"file\" (change)=\"uploadFile($event)\">\n  `\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) { }\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const task = this.storage.upload(filePath, file);\n  }\n}\n```\n\n## Monitoring upload percentage\n\nAn `AngularFireUploadTask` has methods for observing upload percentage as well as the final download URL.\n\n| method   |                    |\n| ---------|--------------------|\n| `snapshotChanges(): Observable<FirebaseStorage.UploadTaskSnapshot>` | Emits the raw `UploadTaskSnapshot` as the file upload progresses. |\n| `percentageChanges(): Observable<number>` | Emits the upload completion percentage. |\n| `getDownloadURL(): Observable<any>` | Emits the download url when available |\n\nThe method `getDownloadURL()` doesn't rely on the task anymore, hence, in order to get the url we should use the finalize method from RxJS on top of the storage ref.\n\n```ts\nimport { finalize } from 'rxjs/operators';\n\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}\n    <input type=\"file\" (change)=\"uploadFile($event)\" />\n    <div>{{ uploadPercent | async }}</div>\n    <a [href]=\"downloadURL | async\">{{ downloadURL | async }}</a>\n {%endraw%}`\n})\nexport class AppComponent {\n  uploadPercent: Observable<number>;\n  downloadURL: Observable<string>;\n  constructor(private storage: AngularFireStorage) {}\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const fileRef = this.storage.ref(filePath);\n    const task = this.storage.upload(filePath, file);\n\n    // observe percentage changes\n    this.uploadPercent = task.percentageChanges();\n    // get notified when the download URL is available\n    task.snapshotChanges().pipe(\n        finalize(() => this.downloadURL = fileRef.getDownloadURL() )\n     )\n    .subscribe()\n  }\n}\n```\n\n## Downloading Files\n\nA convenient pipe exists for simple in page references.\n\n```ts\n@Component({\n  selector: 'app-root',\n  template: `<img [src]=\"'users/davideast.jpg' | getDownloadURL\" />`\n})\nexport class AppComponent {}\n```\n\nTo download a file you'll need to create a reference and call the `getDownloadURL()` method on an `AngularFireStorageReference`.\n\n```ts\n@Component({\n  selector: 'app-root',\n  template: `<img [src]=\"profileUrl | async\" />`\n})\nexport class AppComponent {\n  profileUrl: Observable<string | null>;\n  constructor(private storage: AngularFireStorage) {\n     const ref = this.storage.ref('users/davideast.jpg');\n     this.profileUrl = ref.getDownloadURL();\n  }\n}\n```\n\n## Managing Metadata\n\nCloud Storage for Firebase allows you to upload and download metadata associated with files. This is useful because you can store important metadata and download it without needing to download the entire file.\n\n### Downloading metadata\n\n```ts\n@Component({\n  selector: 'app-root',\n  template: `{%raw%}<pre><code>{{ meta | async }}</code></pre>{%endraw%}`\n})\nexport class AppComponent {\n  meta: Observable<any>;\n  constructor(private storage: AngularFireStorage) {\n     const ref = this.storage.ref('users/davideast.jpg');\n     this.meta = ref.getMetadata();\n  }\n}\n```\n\n### Uploading metadata with files\n\n```ts\n@Component({\n  selector: 'app-root',\n  template: `\n    <input type=\"file\" (change)=\"uploadFile($event)\" />\n `\n})\nexport class AppComponent {\n  constructor(private storage: AngularFireStorage) {}\n  uploadFile(event) {\n    const file = event.target.files[0];\n    const filePath = 'name-your-file-path-here';\n    const ref = this.storage.ref(filePath);\n    const task = ref.put(file, { customMetadata: { blah: 'blah' } });\n  }\n}\n```\n"
  },
  {
    "path": "site/src/storage/index.md",
    "content": "---\neleventyNavigation:\n  key: Storage\n  order: 6\n---\n\n"
  },
  {
    "path": "site/src/storage/storage.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "site/src/styles/prism.css",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * prism.js custom theme for JavaScript, CSS and HTML\n * Based on default theme\n */\n\n code[class*=\"language-\"] {\n  padding: 0;\n}\n\ncode[class*=\"language-\"],\npre[class*=\"language-\"] {\n  color: aliceblue;\n  background: none;\n  font-size: 14px;\n  font-family: 'Roboto Mono', monospace;\n  font-weight: 400;\n  text-align: left;\n  white-space: pre;\n  word-spacing: normal;\n  word-break: normal;\n  word-wrap: normal;\n  line-height: 1.5;\n\n  -moz-tab-size: 4;\n  -o-tab-size: 4;\n  tab-size: 4;\n\n  -webkit-hyphens: none;\n  -moz-hyphens: none;\n  -ms-hyphens: none;\n  hyphens: none;\n}\n\ncode[class*=\"language-css\"],\npre[class*=\"language-css\"],\ncode[class*=\"language-html\"],\npre[class*=\"language-html\"] {\n color: #d0d2d1 !important;\n}\n\ncode[class*=\"language-html\"].token.punctuation,\npre[class*=\"language-html\"].token.punctuation {\n color: #4dd0e1 !important;\n}\n\npre[class*=\"language-\"]::-moz-selection, pre[class*=\"language-\"] ::-moz-selection,\ncode[class*=\"language-\"]::-moz-selection, code[class*=\"language-\"] ::-moz-selection {\n  text-shadow: none;\n  background: hsl(213, 92%, 85%);\n  opacity: 0.4;\n}\n\npre[class*=\"language-\"]::selection, pre[class*=\"language-\"] ::selection,\ncode[class*=\"language-\"]::selection, code[class*=\"language-\"] ::selection {\n  text-shadow: none;\n  background: #b3d4fc;\n  opacity: 0.4;\n}\n\n@media print {\n  code[class*=\"language-\"],\n  pre[class*=\"language-\"] {\n    text-shadow: none;\n  }\n}\n\n/* Code blocks */\npre[class*=\"language-\"] {\n  padding: 1em;\n  overflow: auto;\n}\n\n:not(pre) > code[class*=\"language-\"],\npre[class*=\"language-\"] {\n border-radius: 8px;\n background-color: #283142;\n margin-bottom: 2rem;\n margin-top: 2rem;\n /*TODO:(davideast) We have to set the max-width of the codeblock because \n   it causes the content to break out of the viewport. The \"break out\" \n   causes those annoying x axis overflows and scrolling on mobile devices.\n   Ideally there's a better solution. \n */\n max-width:100%;\n}\n\n/* Inline code */\n:not(pre) > code[class*=\"language-\"] {\n  padding: .1em;\n  border-radius: .3em;\n  white-space: normal;\n}\n\n.token.comment,\n.token.prolog,\n.token.doctype,\n.token.cdata {\n  color: #f06292;\n}\n\n.token.punctuation {\n  color: aliceblue;\n}\n\n.namespace {\n  opacity: .7;\n}\n\n.token.function,\n.token.property {\n  color: #4dd0e1;\n}\n\n.token.boolean,\n.token.number,\n.token.constant,\n.token.symbol,\n.token.deleted {\n  color: #9ccc65;\n}\n\n.token.tag,\n.token.selector,\n.token.string,\n.token.char,\n.token.builtin,\n.token.inserted {\n  color: #9ccc65;\n}\n\n.token.attr-name,\n.token.operator,\n.token.entity,\n.token.url,\n.language-css .token.string,\n.style .token.string {\n  color: #9ccc65;\n}\n\n.token.atrule,\n.token.attr-value,\n.token.keyword {\n  color: #4dd0e1;\n}\n\n.token.class-name {\n  color: #4dd0e1;\n}\n\n.token.regex,\n.token.important,\n.token.variable {\n  color: #4dd0e1;\n}\n\n.token.bold {\n  font-weight: bold;\n}\n.token.italic {\n  font-style: italic;\n}\n\n.token.entity {\n  cursor: help;\n}\n\neap-tab-panel :not(pre) > code[class*=\"language-\"],\neap-tab-panel pre[class*=\"language-\"] {\n padding: 0;\n margin: 0;\n}\n"
  },
  {
    "path": "site/src/styles/tailwind.config.js",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nmodule.exports = {\n  purge: [\n    \"src/**/*.njk\",\n    \"src/**/*.md\",\n    \"src/**/*.js\",\n  ],\n  darkMode: false, // or 'media' or 'class'\n  theme: {\n    fontFamily: {\n      body: ['Roboto', 'Arial', 'sans-serif'],\n      display: ['Google Sans', 'Arial', 'sans-serif'],\n      mono: ['Roboto Mono', 'monospace'],\n    },\n    extend: {\n      colors: {\n        'black': 'hsl(0 0% 0% / 87%)',\n        'blue-200': 'hsl(214 82% 50% / 7%)',\n        'blue': 'hsl(214 82% 50%)',\n        'navy': '#283142',\n        'grey': '#DADCE0',\n        'grey-200': '#ECEFF1',\n        'grey-300': 'hsl(0 0% 0% / 54%)',\n        'grey-600': 'hsl(213 5% 39% / 1)',\n        'grey-700': 'hsl(213 5% 19% / 1)',\n        'yellow': 'hsl(37 100% 94%)',\n        'orange': \"#FF8F00\",\n        'green': '#6CFF38',\n      }\n    },\n  },\n  variants: {\n    extend: {},\n  },\n  plugins: [],\n}"
  },
  {
    "path": "site/src/styles/tailwind.css",
    "content": "/**\n * Copyright 2021 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n \n @import \"tailwindcss/base\";\n @import \"tailwindcss/components\";\n @import \"tailwindcss/utilities\";\n \n @font-face {\n   font-family: 'Google Sans';\n   font-style: normal;\n   font-weight: 400;\n   src: url('/assets/GoogleSans-Regular.woff2') format('woff2');\n }\n \n @font-face {\n   font-family: 'Google Sans';\n   font-style: normal;\n   font-weight: 500;\n   src: url('/assets/GoogleSans-Medium.woff2') format('woff2');\n }\n \n @font-face {\n   font-family: 'Google Sans';\n   font-style: bold;\n   font-weight: 900;\n   src: url('/assets/GoogleSans-Bold.woff2') format('woff2');\n }\n \n @font-face {\n   font-family: 'Roboto';\n   font-style: normal;\n   font-weight: 400;\n   src: url('/assets/Roboto-Regular.woff2') format('woff2');\n }\n \n @font-face {\n   font-family: 'Roboto';\n   font-style: italic;\n   font-weight: 400;\n   src: url('/assets/Roboto-Italic.woff2') format('woff2');\n }\n \n @font-face {\n   font-family: 'Roboto';\n   font-style: bold;\n   font-weight: 900;\n   src: url('/assets/Roboto-900.woff2') format('woff2');\n }\n \n @font-face {\n   font-family: 'Roboto Mono';\n   font-style: normal;\n   font-weight: 400;\n   src: url('/assets/RobotoMono-Regular.woff2') format('woff2');\n }\n \n body {\n   background-color: hsl(255 1% 98%);\n   background-image: url(/assets/corner.svg);\n   background-position: top right;\n   background-repeat: no-repeat;\n   width: 100vw;\n }\n \n a[aria-current=\"page\"] {\n   @apply text-blue;\n }\n \n .docs-content main {\n   @apply grid min-h-screen;\n   grid-template-columns:[side] auto 1fr [stack];\n   grid-template-rows: [side] 1fr;\n   column-gap: 8vw;\n }\n \n .docs-content main > aside {\n   min-width: 32ch;\n   @apply sticky top-0 z-10 h-screen pl-8 pr-4 overflow-y-scroll;\n }\n \n .docs-content main > article {\n   max-width: 64ch;\n   @apply min-h-screen pr-8;\n }\n \n h1, h2, h3, h4, h5, h6 {\n   @apply font-display;\n }\n \n h1 {\n   @apply text-5xl font-bold font-display;\n }\n \n .docs-content main > article h2 {\n   @apply mt-12 mb-4 antialiased font-bold leading-snug text-black;\n   font-size: 24px;\n }\n \n .docs-content main > article h3 {\n   @apply mt-8 text-xl;\n }\n \n .docs-content main > article h4 {\n   @apply mt-2 text-lg leading-snug text-grey-600;\n }\n \n .docs-content main > article p {\n   @apply mb-6 text-lg;\n   line-height: 2rem;\n }\n \n /** \n   Don't go further than direct descendants for code styling\n   otherwise it will mess with the codeboxes \n */\n .docs-content main > article p > code {\n   @apply p-1 bg-gray-200 rounded-md;\n }\n \n .docs-content article p > b {\n   @apply font-display;\n }\n\n .docs-content article ol, .docs-content article ul:not(.prevnext-grid) {\n  list-style-type: initial;\n  padding: 0 2rem;\n  margin: 1rem 0;\n}\n \n table a, article p > a:not(.link-button) {\n   @apply underline text-blue;\n }\n\n .annotations-section p {\n   @apply text-sm !important;\n   line-height: 1.35rem !important;\n }\n \n @media (max-width: 775px) {\n \n   .docs-content main {\n     column-gap: unset;\n   }\n \n   .docs-content main > article {\n     @apply w-screen p-2;\n   }\n \n   .docs-content main > aside,\n   .docs-content main > article {\n     grid-area: side;\n   }\n \n   .docs-content main > aside {\n     transition: transform 0.25s cubic-bezier(0.445, 0.05, 0.55, 0.95);\n     transform: translateX(-200%);\n   }\n \n   .docs-content main > aside.slideIn {\n     transform: translateX(0);\n   }\n \n   .landing-container, .landing-faq {\n     width: 100vw !important;\n     padding-left: 2rem;\n     padding-right: 2rem;\n   }\n \n }\n \n @media (max-width: 420px) { \n   .landing-container h1 {\n     @apply text-4xl;\n   }\n   body.landing-content {\n     background-image: none;\n   }\n }\n \n /* Thanks to https://css-tricks.com/responsive-data-tables/ */\n table { \n   width: 100%;\n   border-collapse: collapse; \n   overflow-x: scroll;\n   overflow-wrap: break-word;\n   @apply text-sm;\n }\n /* Zebra striping */\n tr:nth-of-type(odd) { \n   @apply bg-gray-100;\n }\n th { \n   @apply font-bold tracking-wide uppercase font-display;\n }\n td, th { \n   @apply p-2 text-left;\n }\n \n @media \n only screen and (max-width: 760px),\n (min-device-width: 768px) and (max-device-width: 1024px)  {\n \n   /* Stack the table */\n   table, thead, tbody, th, td, tr { \n     display: block; \n   }\n   \n }\n \n eap-tab-switcher {\n   @apply block w-full overflow-x-hidden bg-navy rounded-t-md;\n }\n \n .docs-content article eap-tab-switcher {\n   @apply mb-6;\n }\n \n eap-tab-list {\n   @apply flex items-center h-16 bg-white border border-solid border-grey rounded-t-md font-display;\n }\n \n eap-tab-list button {\n   @apply p-4 text-sm font-medium text-gray-600;\n }\n \n eap-tab-list button[aria-selected=\"true\"] {\n   @apply text-blue;\n }\n \n eap-tab-panel-list {\n   @apply block p-4 overflow-x-scroll;\n }\n \n eap-tab-panel {\n   @apply block;\n }\n \n eap-tab-panel pre code {\n   @apply bg-navy;\n }\n \n eap-tab-panel {\n   @apply text-white;\n }\n \n .docs-content h3 + pre[class*=\"language-\"], h3 + eap-tab-switcher {\n   margin-top: .5rem;\n }\n \n eap-click-card {\n   @apply block;\n }\n \n .landing-container {\n   width: 84ch;\n   margin: 0 auto;\n }\n \n .landing-faq {\n   width: 64ch;\n }\n \n .code-editor {\n   display: grid;\n }\n \n .code-editor pre[class=\"language-js\"] {\n   border-radius: 0;\n   margin: 0;\n   padding: 2rem;\n }\n \n .code-editor .terminal {\n   height: 100%;\n   padding: 1rem;\n }\n \n .code-editor .terminal div {\n   opacity: 0;\n   overflow: hidden;\n   margin: 1rem;\n }\n \n .code-editor .terminal div:nth-child(2) {\n   animation: fadeIn 400ms cubic-bezier(0.47, 0, 0.745, 0.715) 2.5s forwards;\n }\n \n .code-editor .terminal div:nth-child(3) {\n   animation: fadeIn 400ms cubic-bezier(0.47, 0, 0.745, 0.715) 4s forwards;\n }\n \n .code-editor .terminal div:nth-child(4) {\n   animation: fadeIn 400ms cubic-bezier(0.47, 0, 0.745, 0.715) 5.5s forwards;\n }\n \n .code-editor .terminal div:nth-child(5), #btnShowCode {\n   animation: fadeIn 400ms cubic-bezier(0.47, 0, 0.745, 0.715) 7.5s forwards;\n }\n \n /* Thanks to https://css-tricks.com/snippets/css/typewriter-effect/ */\n .terminal .typewriter {\n   overflow: hidden; /* Ensures the content is not revealed until the animation */\n   white-space: nowrap; /* Keeps the content on a single line */\n   margin: 0 auto; /* Gives that scrolling effect as the typing happens */\n   letter-spacing: .1em; /* Adjust as needed */\n   animation: typing 3.65s steps(40, end) 1s forwards;\n }\n \n /* The typing effect */\n @keyframes typing {\n   from { opacity:1; width: 0 }\n   to { width: 100%; opacity:1; }\n }\n \n @keyframes fadeIn {\n   from { opacity: 0 }\n   to { opacity: 1; }\n }"
  },
  {
    "path": "site/src/universal/cloud-functions.md",
    "content": "---\ntitle: Cloud Functions\neleventyNavigation:\n  key: Cloud Functions\n  parent: Universal\n---\n\n## Deploying on Universal sites on Cloud Functions\n\nAfter [setting up your application with Angular Universal as outlined in Getting Started](getting-started.md), you're now ready to build your application for Firebase Hosting & Cloud Functions.\n\nCloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers. [Learn more about Cloud Functions for Firebase](https://firebase.google.com/docs/functions/).\n\nIf you don't already have the Firebase CLI installed, do so:\n\n```bash\nnpm i -g firebase-tools\nfirebase login\n```\n\nThen inside your project root, setup your Firebase CLI project:\n\n```bash\nfirebase init\n```\n\nConfigure whichever features you'd want to manage but make sure to select at least `functions` and `hosting`. Choose Typescript for Cloud Functions and use the default `public` directory for Hosting.\n\nAfter you're configured, you should now see a `firebase.json` file in your project root. Let's add the following `rewrites` directive to it:\n\n```js\n{\n  // ...\n  \"hosting\": {\n    // ...\n    \"rewrites\": [\n      { \"source\": \"**\", \"function\": \"universal\" }\n    ]\n  }\n}\n```\n\nThis will inform Firebase Hosting that it should proxy all requests to Cloud Functions, if a file isn't already present in the hosting directory. Let's go ahead and modify your `package.json` to build for Cloud Functions:\n\n```js\n\"scripts\": {\n  // ... omitted\n  \"build\": \"ng build && npm run copy:hosting && npm run build:ssr && npm run build:functions\",\n  \"copy:hosting\": \"cp -r ./dist/YOUR_PROJECT_NAME/* ./public && rm ./public/index.html\",\n  \"build:functions\": \"npm run --prefix functions build\"\n},\n```\n\nChange the build script in your `functions/package.json` to the following:\n\n```js\n\"scripts\": {\n    // ... omitted\n    \"build\": \"rm -r ./dist && cp -r ../dist . && tsc\",\n}\n```\n\nFinally, add the following to your `functions/src/index.ts`:\n\n```ts\nexport const universal = functions.https.onRequest((request, response) => {\n  require(`${process.cwd()}/dist/YOUR_PROJECT_NAME-webpack/server`).app(request, response);\n});\n```\n\nWe you should now be able to run `npm run build` to build your project for Firebase Hosting and Cloud Functions.\n\nTo test, spin up the emulator with `firebase serve`. Once you've confirmed it's working go ahead and `firebase deploy`.\n\n## Additional Resources\n\n- [Universal Starter Template](https://github.com/angular/universal-starter)\n- [FireShip: Angular Universal SSR with Firebase](https://fireship.io/lessons/angular-universal-firebase/)\n\n"
  },
  {
    "path": "site/src/universal/getting-started.md",
    "content": "---\ntitle: Getting started\neleventyNavigation:\n  key: Getting started\n  parent: Universal\n---\n\n## Getting started with AngularFire and Universal\n\nServer-side rendering (SSR) is the process of converting a JavaScript app to plain HTML at request-time, allowing search engine crawlers and linkbots to understand page content reliably. \n\n## Prerequisites\n\n- `@angular/cli >= v6.0`\n- `@angular/fire >= v5.0.0`\n\n## Generate the Angular Universal Server Module\n\nFirst, create a server module with the Angular CLI.\n\n```bash\nng generate universal --client-project <your-project>\n```\n\n## Build a Server with ExpressJS\n\n[ExpressJS](https://expressjs.com/) is a lightweight web framework that can serve http requests in Node. First, install the dev dependencies:\n\n```bash\nnpm install --save-dev @nguniversal/express-engine @nguniversal/module-map-ngfactory-loader express webpack-cli ts-loader ws xhr2\n```\n\nCreate a file called `server.ts` in the root of you project.\n\n```ts\n// These are important and needed before anything else\nimport 'zone.js/dist/zone-node';\nimport 'reflect-metadata';\n\nimport { enableProdMode } from '@angular/core';\nimport { ngExpressEngine } from '@nguniversal/express-engine';\nimport { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';\n\nimport * as express from 'express';\nimport { join } from 'path';\nimport { readFileSync } from 'fs';\n\n// Polyfills required for Firebase\n(global as any).WebSocket = require('ws');\n(global as any).XMLHttpRequest = require('xhr2');\n\n// Faster renders in prod mode\nenableProdMode();\n\n// Export our express server\nexport const app = express();\n\nconst DIST_FOLDER = join(process.cwd(), 'dist');\nconst APP_NAME = 'YOUR_PROJECT_NAME'; // TODO: replace me!\n\nconst { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require(`./dist/${APP_NAME}-server/main`);\n\n// index.html template\nconst template = readFileSync(join(DIST_FOLDER, APP_NAME, 'index.html')).toString();\n\napp.engine('html', ngExpressEngine({\n  bootstrap: AppServerModuleNgFactory,\n  providers: [\n    provideModuleMap(LAZY_MODULE_MAP)\n  ]\n}));\n\napp.set('view engine', 'html');\napp.set('views', join(DIST_FOLDER, APP_NAME));\n\n// Serve static files \napp.get('*.*', express.static(join(DIST_FOLDER, APP_NAME)));\n\n// All regular routes use the Universal engine\napp.get('*', (req, res) => {\n    res.render(join(DIST_FOLDER, APP_NAME, 'index.html'), { req });\n});\n\n// If we're not in the Cloud Functions environment, spin up a Node server\nif (!process.env.FUNCTION_NAME) {\n  const PORT = process.env.PORT || 4000;\n  app.listen(PORT, () => {\n    console.log(`Node server listening on http://localhost:${PORT}`);\n  });\n}\n```\n\n## Add a Webpack Config for the Express Server\n\nCreate a new file named `webpack.server.config.js` to bundle the express app from previous step.\n\n\n```js\nconst path = require('path');\nconst webpack = require('webpack');\n\nconst APP_NAME = 'YOUR_PROJECT_NAME'; // TODO: replace me!\n\nmodule.exports = {\n  entry: {  server: './server.ts' },\n  resolve: { extensions: ['.js', '.ts'] },\n  mode: 'development',\n  target: 'node',\n  externals: [\n    /* Firebase has some troubles being webpacked when in\n       in the Node environment, let's skip it.\n       Note: you may need to exclude other dependencies depending\n       on your project. */\n    /^firebase/\n  ],\n  output: {\n    // Export a UMD of the webpacked server.ts & deps, for\n    // rendering in Cloud Functions\n    path: path.join(__dirname, `dist/${APP_NAME}-webpack`),\n    library: 'app',\n    libraryTarget: 'umd',\n    filename: '[name].js'\n  },\n  module: {\n    rules: [\n      { test: /\\.ts$/, loader: 'ts-loader' }\n    ]\n  },\n  plugins: [\n    new webpack.ContextReplacementPlugin(\n      /(.+)?angular(\\\\|\\/)core(.+)?/,\n      path.join(__dirname, 'src'), // location of your src\n      {} // a map of your routes\n    ),\n    new webpack.ContextReplacementPlugin(\n      /(.+)?express(\\\\|\\/)(.+)?/,\n      path.join(__dirname, 'src'),\n      {}\n    )\n  ]\n}\n```\n\n## Build Scripts\n\nUpdate your `package.json` with the following build scripts, replacing `YOUR_PROJECT_NAME` with the name of your project.\n\n```js\n\"scripts\": {\n  // ... omitted\n  \"build\": \"ng build && npm run build:ssr\",\n  \"build:ssr\": \"ng run YOUR_PROJECT_NAME:server && npm run webpack:ssr\",\n  \"webpack:ssr\": \"webpack --config webpack.server.config.js\",\n  \"serve:ssr\": \"node dist/YOUR_PROJECT_NAME-webpack/server.js\"\n},\n```\n\nTest your app locally by running `npm run build && npm run serve:ssr`. \n"
  },
  {
    "path": "site/src/universal/index.md",
    "content": "---\neleventyNavigation:\n  key: Universal\n  order: 11\n---\n"
  },
  {
    "path": "site/src/universal/prerendering.md",
    "content": "---\ntitle: Prerendering\neleventyNavigation:\n  key: Prerendering\n  parent: Universal\n---\n\n## Prerendering Universal sites\n\nPrerendering a Universal application allows us to generate the HTML before the user requests it; increasing performance and decreasing cost. Let's configure your application to prerender and staticly serve it's most commonly accessed routes on Firebase Hosting.\n\nFirst create a `static.paths.js` in your project root, which lists the URLs you'd want to prerender:\n\n```js\nexport default [\n  '/',\n  '/another_path',\n  '/yet_another_path'\n];\n```\n\nInstall `mkdir-recursive` to make the next step a little easier:\n\n```bash\nnpm i --save-dev mkdir-recursive\n```\n\nNow replace the listener in your `server.ts` with the following:\n\n```ts\nimport { readFileSync, writeFileSync, existsSync } from 'fs';\nimport { renderModuleFactory } from '@angular/platform-server';\nimport { mkdirSync } from 'mkdir-recursive';\n\nif (process.env.PRERENDER) {\n\n    const routes = require('./static.paths').default;\n    Promise.all(\n        routes.map(route =>\n            renderModuleFactory(AppServerModuleNgFactory, {\n                document: template,\n                url: route,\n                extraProviders: [\n                    provideModuleMap(LAZY_MODULE_MAP)\n                ]\n            }).then(html => [route, html])\n        )\n    ).then(results => {\n        results.forEach(([route, html]) => {\n            const fullPath = join('./public', route);\n            if (!existsSync(fullPath)) { mkdirSync(fullPath); }\n            writeFileSync(join(fullPath, 'index.html'), html);\n        });\n        process.exit();\n    });\n\n} else if (!process.env.FUNCTION_NAME) {\n\n    // If we're not in the Cloud Functions environment, spin up a Node server\n    const PORT = process.env.PORT || 4000;\n    app.listen(PORT, () => {\n        console.log(`Node server listening on http://localhost:${PORT}`);\n    });\n\n}\n```\n\nNow if the `PRERENDER` environment variable is passed any value, instead of serving your application it will iterate over the paths in `static.paths.js`, render them, and write them to your `public` directory. *You could always make this a seperate script.*\n\nFinally make some modifications to your `package.json`, to prerender your content when you build:\n\n```js\n\"scripts\": {\n  // ... omitted\n  \"build\": \"ng build && npm run copy:hosting && npm run build:functions && npm run prerender:ssr\",\n  \"prerender:ssr\": \"PRERENDER=1 node dist/YOUR_PROJECT_NAME-webpack/server.js\",\n},\n```\n\nNow when you run `npm run build` the prerendered content should be available in your `/public` directory, ready for deployment on Firebase Hosting.\n"
  },
  {
    "path": "site/src/universal/universal.11tydata.json",
    "content": "{\n  \"layout\": \"guide.njk\",\n  \"tags\": \"guides\"\n}\n"
  },
  {
    "path": "src/ai/ai.module.ts",
    "content": "import {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { AI as FirebaseAI } from 'firebase/ai';\nimport { registerVersion } from 'firebase/app';\nimport { AI, AIInstances, AI_PROVIDER_NAME } from './ai';\n\nexport const PROVIDED_AI_INSTANCES = new InjectionToken<AI[]>('angularfire2.ai-instances');\n\nexport function defaultAIInstanceFactory(provided: FirebaseAI[]|undefined, defaultApp: FirebaseApp) {\n  const defaultAI = ɵgetDefaultInstanceOf<FirebaseAI>(AI_PROVIDER_NAME, provided, defaultApp);\n  return defaultAI && new AI(defaultAI);\n}\n\nexport function AIInstanceFactory(fn: (injector: Injector) => FirebaseAI) {\n  return (zone: NgZone, injector: Injector) => {\n    const ai = zone.runOutsideAngular(() => fn(injector));\n    return new AI(ai);\n  };\n}\n\nconst AI_INSTANCES_PROVIDER = {\n  provide: AIInstances,\n  deps: [\n    [new Optional(), PROVIDED_AI_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_AI_INSTANCE_PROVIDER = {\n  provide: AI,\n  useFactory: defaultAIInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_AI_INSTANCES ],\n    FirebaseApp,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_AI_INSTANCE_PROVIDER,\n    AI_INSTANCES_PROVIDER,\n  ]\n})\nexport class AIModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'ai');\n  }\n}\n\nexport function provideAI(fn: (injector: Injector) => FirebaseAI, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'ai');\n\n  return makeEnvironmentProviders([\n    DEFAULT_AI_INSTANCE_PROVIDER,\n    AI_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_AI_INSTANCES,\n      useFactory: AIInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        [new Optional(), AppCheckInstances ],\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/ai/ai.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AI, getAI, provideAI } from '@angular/fire/ai';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { COMMON_CONFIG } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('AI', () => {\n  let app: FirebaseApp;\n  let ai: AI;\n  let providedAI: AI;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideAI(() => {\n                    providedAI = getAI(getApp(appName));\n                    return providedAI;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        ai = TestBed.inject(AI);\n    });\n\n    it('should be injectable', () => {\n        expect(providedAI).toBeTruthy();\n        expect(ai).toEqual(providedAI);\n        expect(ai.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/ai/ai.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { AI as FirebaseAI } from 'firebase/ai';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface AI extends FirebaseAI {}\n\nexport class AI {\n  constructor(ai: FirebaseAI) {\n    return ai;\n  }\n}\n\nexport const AI_PROVIDER_NAME = 'AI';\n\n \nexport interface AIInstances extends Array<FirebaseAI> {}\n\nexport class AIInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseAI>(AI_PROVIDER_NAME);\n  }\n}\n\nexport const AIInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseAI>(AI_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/ai/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/ai';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  getAI as _getAI,\n  getGenerativeModel as _getGenerativeModel,\n  getImagenModel as _getImagenModel,\n  getLiveGenerativeModel as _getLiveGenerativeModel,\n  startAudioConversation as _startAudioConversation\n} from 'firebase/ai';\n\nexport const getAI = ɵzoneWrap(_getAI, true);\nexport const getGenerativeModel = ɵzoneWrap(_getGenerativeModel, true);\nexport const getImagenModel = ɵzoneWrap(_getImagenModel, true);\nexport const getLiveGenerativeModel = ɵzoneWrap(_getLiveGenerativeModel, true);\nexport const startAudioConversation = ɵzoneWrap(_startAudioConversation, true);\n"
  },
  {
    "path": "src/ai/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/ai/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/ai/public_api.ts",
    "content": "export { AI, AIInstances, AIInstance$ } from './ai';\nexport { provideAI, AIModule } from './ai.module';\nexport * from './firebase';\n"
  },
  {
    "path": "src/analytics/analytics.module.ts",
    "content": "import { isPlatformBrowser } from '@angular/common';\nimport {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  PLATFORM_ID,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { Analytics as FirebaseAnalytics } from 'firebase/analytics';\nimport { registerVersion } from 'firebase/app';\nimport { ANALYTICS_PROVIDER_NAME, Analytics, AnalyticsInstances } from './analytics';\nimport { ScreenTrackingService } from './screen-tracking.service';\nimport { UserTrackingService } from './user-tracking.service';\n\nexport const PROVIDED_ANALYTICS_INSTANCES = new InjectionToken<Analytics[]>('angularfire2.analytics-instances');\n\nexport function defaultAnalyticsInstanceFactory(provided: FirebaseAnalytics[]|undefined, defaultApp: FirebaseApp, platformId: object) {\n  if (!isPlatformBrowser(platformId)) { return null; }\n  const defaultAnalytics = ɵgetDefaultInstanceOf<FirebaseAnalytics>(ANALYTICS_PROVIDER_NAME, provided, defaultApp);\n  return defaultAnalytics && new Analytics(defaultAnalytics);\n}\n\nexport function analyticsInstanceFactory(fn: (injector: Injector) => FirebaseAnalytics) {\n  return (zone: NgZone, injector: Injector, platformId: object) => {\n    if (!isPlatformBrowser(platformId)) { return null; }\n    const analytics = zone.runOutsideAngular(() => fn(injector));\n    return new Analytics(analytics);\n  };\n}\n\nconst ANALYTICS_INSTANCES_PROVIDER = {\n  provide: AnalyticsInstances,\n  deps: [\n    [new Optional(), PROVIDED_ANALYTICS_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_ANALYTICS_INSTANCE_PROVIDER = {\n  provide: Analytics,\n  useFactory: defaultAnalyticsInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_ANALYTICS_INSTANCES ],\n    FirebaseApp,\n    PLATFORM_ID,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_ANALYTICS_INSTANCE_PROVIDER,\n    ANALYTICS_INSTANCES_PROVIDER\n  ]\n})\nexport class AnalyticsModule {\n  constructor(\n    @Optional() _screenTrackingService: ScreenTrackingService,\n    @Optional() _userTrackingService: UserTrackingService,\n  ) {\n    registerVersion('angularfire', VERSION.full, 'analytics');\n  }\n}\n\nexport function provideAnalytics(fn: (injector: Injector) => FirebaseAnalytics, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'analytics');\n\n  return makeEnvironmentProviders([\n    DEFAULT_ANALYTICS_INSTANCE_PROVIDER,\n    ANALYTICS_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_ANALYTICS_INSTANCES,\n      useFactory: analyticsInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        PLATFORM_ID,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        ...deps,\n      ],\n    },\n  ]);\n}\n"
  },
  {
    "path": "src/analytics/analytics.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { Analytics, getAnalytics, provideAnalytics } from '@angular/fire/analytics';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { COMMON_CONFIG_TOO } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('Analytics', () => {\n  let app: FirebaseApp;\n  let analytics: Analytics;\n  let providedAnalytics: Analytics;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG_TOO, appName)),\n                provideAnalytics(() => {\n                    providedAnalytics = getAnalytics(getApp(appName));\n                    return providedAnalytics;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        analytics = TestBed.inject(Analytics);\n    });\n\n    it('should be injectable', () => {\n        expect(providedAnalytics).toBeTruthy();\n        expect(analytics).toEqual(providedAnalytics);\n        expect(analytics.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/analytics/analytics.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { Analytics as FirebaseAnalytics } from 'firebase/analytics';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface Analytics extends FirebaseAnalytics {}\n\nexport class Analytics {\n  constructor(analytics: FirebaseAnalytics) {\n    return analytics;\n  }\n}\n\nexport const ANALYTICS_PROVIDER_NAME = 'analytics';\n\n \nexport interface AnalyticsInstances extends Array<FirebaseAnalytics> {}\n\nexport class AnalyticsInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseAnalytics>(ANALYTICS_PROVIDER_NAME);\n  }\n}\n\nexport const analyticInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseAnalytics>(ANALYTICS_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/analytics/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/analytics';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  getAnalytics as _getAnalytics,\n  getGoogleAnalyticsClientId as _getGoogleAnalyticsClientId,\n  initializeAnalytics as _initializeAnalytics,\n  isSupported as _isSupported,\n  logEvent as _logEvent,\n  setAnalyticsCollectionEnabled as _setAnalyticsCollectionEnabled,\n  setConsent as _setConsent,\n  setCurrentScreen as _setCurrentScreen,\n  setDefaultEventParameters as _setDefaultEventParameters,\n  setUserId as _setUserId,\n  setUserProperties as _setUserProperties,\n  settings as _settings\n} from 'firebase/analytics';\n\nexport const getAnalytics = ɵzoneWrap(_getAnalytics, true);\nexport const getGoogleAnalyticsClientId = ɵzoneWrap(_getGoogleAnalyticsClientId, true);\nexport const initializeAnalytics = ɵzoneWrap(_initializeAnalytics, true);\nexport const isSupported = ɵzoneWrap(_isSupported, false);\nexport const logEvent = ɵzoneWrap(_logEvent, false, 2);\nexport const setAnalyticsCollectionEnabled = ɵzoneWrap(_setAnalyticsCollectionEnabled, true, 2);\nexport const setConsent = ɵzoneWrap(_setConsent, true, 2);\nexport const setCurrentScreen = ɵzoneWrap(_setCurrentScreen, true, 2);\nexport const setDefaultEventParameters = ɵzoneWrap(_setDefaultEventParameters, true, 2);\nexport const setUserId = ɵzoneWrap(_setUserId, true, 2);\nexport const setUserProperties = ɵzoneWrap(_setUserProperties, true, 2);\nexport const settings = ɵzoneWrap(_settings, true);\n"
  },
  {
    "path": "src/analytics/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/analytics/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}"
  },
  {
    "path": "src/analytics/public_api.ts",
    "content": "export { Analytics, AnalyticsInstances, analyticInstance$ } from './analytics';\nexport { provideAnalytics, AnalyticsModule } from './analytics.module';\nexport * from './firebase';\nexport * from './screen-tracking.service';\nexport * from './user-tracking.service';\n"
  },
  {
    "path": "src/analytics/screen-tracking.service.ts",
    "content": "import { ComponentFactoryResolver, Injectable, Injector, NgZone, OnDestroy, Optional } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport { Title } from '@angular/platform-browser';\nimport { ActivationEnd, Router, ɵEmptyOutletComponent } from '@angular/router';\nimport { registerVersion } from 'firebase/app';\nimport { Observable, Subscription, of } from 'rxjs';\nimport { distinctUntilChanged, filter, groupBy, map, mergeMap, pairwise, startWith, switchMap } from 'rxjs/operators';\nimport { Analytics } from './analytics';\nimport { isSupported, logEvent } from './firebase';\nimport { UserTrackingService } from './user-tracking.service';\n\nconst FIREBASE_EVENT_ORIGIN_KEY = 'firebase_event_origin';\nconst FIREBASE_PREVIOUS_SCREEN_CLASS_KEY = 'firebase_previous_class';\nconst FIREBASE_PREVIOUS_SCREEN_INSTANCE_ID_KEY = 'firebase_previous_id';\nconst FIREBASE_PREVIOUS_SCREEN_NAME_KEY = 'firebase_previous_screen';\nconst FIREBASE_SCREEN_CLASS_KEY = 'firebase_screen_class';\nconst FIREBASE_SCREEN_INSTANCE_ID_KEY = 'firebase_screen_id';\nconst FIREBASE_SCREEN_NAME_KEY = 'firebase_screen';\nconst OUTLET_KEY = 'outlet';\nconst PAGE_PATH_KEY = 'page_path';\nconst PAGE_TITLE_KEY = 'page_title';\nconst SCREEN_CLASS_KEY = 'screen_class';\nconst SCREEN_NAME_KEY = 'screen_name';\nconst SCREEN_VIEW_EVENT = 'screen_view';\nconst EVENT_ORIGIN_AUTO = 'auto';\nconst SCREEN_INSTANCE_DELIMITER = '#';\n\n// this is an INT64 in iOS/Android but use INT32 cause javascript\nlet nextScreenInstanceID = Math.floor(Math.random() * (2 ** 32 - 1)) - 2 ** 31;\n\nconst knownScreenInstanceIDs: Record<string, number> = {};\n\nconst getScreenInstanceID = (params: Record<string, any>) => {\n  // unique the screen class against the outlet name\n  const screenInstanceKey = [\n    params[SCREEN_CLASS_KEY],\n    params[OUTLET_KEY]\n  ].join(SCREEN_INSTANCE_DELIMITER);\n  // eslint-disable-next-line no-prototype-builtins\n  if (knownScreenInstanceIDs.hasOwnProperty(screenInstanceKey)) {\n    return knownScreenInstanceIDs[screenInstanceKey];\n  } else {\n    const ret = nextScreenInstanceID++;\n    knownScreenInstanceIDs[screenInstanceKey] = ret;\n    return ret;\n  }\n};\n\nexport const ɵscreenViewEvent = (\n  router: Router,\n  title: Title|null,\n  componentFactoryResolver: ComponentFactoryResolver,\n): Observable<{\n  [SCREEN_NAME_KEY]: string,\n  [PAGE_PATH_KEY]: string,\n  [FIREBASE_EVENT_ORIGIN_KEY]: 'auto',\n  [FIREBASE_SCREEN_NAME_KEY]: string,\n  [OUTLET_KEY]: string,\n  [PAGE_TITLE_KEY]?: string,\n  [SCREEN_CLASS_KEY]: string,\n  [FIREBASE_SCREEN_CLASS_KEY]: string,\n  [FIREBASE_SCREEN_INSTANCE_ID_KEY]: number,\n  [FIREBASE_PREVIOUS_SCREEN_CLASS_KEY]: string,\n  [FIREBASE_PREVIOUS_SCREEN_NAME_KEY]: string,\n  [FIREBASE_PREVIOUS_SCREEN_INSTANCE_ID_KEY]: number,\n}> => {\n  const activationEndEvents = router.events.pipe(filter<ActivationEnd>(e => e instanceof ActivationEnd));\n  return activationEndEvents.pipe(\n    switchMap<ActivationEnd, Observable<Record<string, any>|null>>(activationEnd => {\n      // router parseUrl is having trouble with outlets when they're empty\n      // e.g, /asdf/1(bob://sally:asdf), so put another slash in when empty\n      const urlTree = router.parseUrl(router.url.replace(/(?:\\().+(?:\\))/g, a => a.replace('://', ':///')));\n      const pagePath = urlTree.root.children[activationEnd.snapshot.outlet]?.toString() || '';\n      const actualSnapshot = router.routerState.root.children.map(it => it).find(it => it.outlet === activationEnd.snapshot.outlet);\n\n      if (!actualSnapshot) {\n        return of(null);\n      }\n\n      let actualDeep = actualSnapshot;\n      while (actualDeep.firstChild) {\n        actualDeep = actualDeep.firstChild;\n      }\n      const screenName = actualDeep.pathFromRoot.map(s => s.routeConfig?.path).filter(it => it).join('/') || '/';\n\n      const params = {\n        [SCREEN_NAME_KEY]: screenName,\n        [PAGE_PATH_KEY]: `/${pagePath}`,\n        [FIREBASE_EVENT_ORIGIN_KEY]: EVENT_ORIGIN_AUTO,\n        [FIREBASE_SCREEN_NAME_KEY]: screenName,\n        [OUTLET_KEY]: activationEnd.snapshot.outlet\n      };\n      if (title) {\n        params[PAGE_TITLE_KEY] = title.getTitle();\n      }\n\n      let component = actualSnapshot.component;\n      if (component) {\n        if (component === ɵEmptyOutletComponent) {\n          let deepSnapshot = activationEnd.snapshot;\n          // TODO when might there be mutple children, different outlets? explore\n          while (deepSnapshot.firstChild) {\n            deepSnapshot = deepSnapshot.firstChild;\n          }\n          component = deepSnapshot.component;\n        }\n      } else {\n        component = activationEnd.snapshot.component;\n      }\n\n      if (typeof component === 'string') {\n        return of({ ...params, [SCREEN_CLASS_KEY]: component });\n      } else if (component) {\n        const componentFactory = componentFactoryResolver.resolveComponentFactory(component);\n        return of({ ...params, [SCREEN_CLASS_KEY]: componentFactory.selector });\n      }\n      // lazy loads cause extra activations, ignore\n      return of(null);\n    }),\n    filter(it => !!it),\n    map(params => ({\n      [FIREBASE_SCREEN_CLASS_KEY]: params[SCREEN_CLASS_KEY],\n      [FIREBASE_SCREEN_INSTANCE_ID_KEY]: getScreenInstanceID(params),\n      ...params\n    })),\n    groupBy(it => it[OUTLET_KEY]),\n    mergeMap(it => it.pipe(\n      distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)),\n      startWith<any, any>(undefined),\n      pairwise(),\n      map(([prior, current]) =>\n        prior ? {\n          [FIREBASE_PREVIOUS_SCREEN_CLASS_KEY]: prior[SCREEN_CLASS_KEY],\n          [FIREBASE_PREVIOUS_SCREEN_NAME_KEY]: prior[SCREEN_NAME_KEY],\n          [FIREBASE_PREVIOUS_SCREEN_INSTANCE_ID_KEY]: prior[FIREBASE_SCREEN_INSTANCE_ID_KEY],\n          ...current\n        } : current\n      ),\n    ))\n  );\n};\n\n@Injectable()\nexport class ScreenTrackingService implements OnDestroy {\n\n  private disposable: Subscription | undefined;\n\n  constructor(\n    @Optional() router: Router,\n    @Optional() title: Title,\n    componentFactoryResolver: ComponentFactoryResolver,\n    zone: NgZone,\n    @Optional() userTrackingService: UserTrackingService,\n    injector: Injector,\n  ) {\n    registerVersion('angularfire', VERSION.full, 'screen-tracking');\n    // The APP_INITIALIZER that is making isSupported() sync for the sake of convenient DI\n    // may not be done when services are initialized. Guard the functionality by first ensuring\n    // that the (global) promise has resolved, then get Analytics from the injector.\n    isSupported().then(() => {\n      const analytics = injector.get(Analytics);\n      if (!router || !analytics) { return; }\n      zone.runOutsideAngular(() => {\n        this.disposable = ɵscreenViewEvent(router, title, componentFactoryResolver).pipe(\n          switchMap(async params => {\n            if (userTrackingService) { await userTrackingService.initialized; }\n            return logEvent(analytics, SCREEN_VIEW_EVENT, params);\n          })\n        ).subscribe();\n      });\n    });\n  }\n\n  ngOnDestroy() {\n    if (this.disposable) {\n      this.disposable.unsubscribe();\n    }\n  }\n\n}\n"
  },
  {
    "path": "src/analytics/user-tracking.service.ts",
    "content": "import { Injectable, Injector, NgZone, OnDestroy } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport { Auth, authState } from '@angular/fire/auth';\nimport { registerVersion } from 'firebase/app';\nimport { Subscription } from 'rxjs';\nimport { Analytics } from './analytics';\nimport { isSupported, setUserId } from './firebase';\n\n@Injectable()\nexport class UserTrackingService implements OnDestroy {\n\n  public readonly initialized: Promise<void>;\n  private disposables: Subscription[] = [];\n\n  constructor(\n    auth: Auth,\n    zone: NgZone,\n    injector: Injector,\n  ) {\n    registerVersion('angularfire', VERSION.full, 'user-tracking');\n    let resolveInitialized: () => void;\n    this.initialized = zone.runOutsideAngular(() => new Promise(resolve => { resolveInitialized = resolve; }));\n    // The APP_INITIALIZER that is making isSupported() sync for the sake of convenient DI\n    // may not be done when services are initialized. Guard the functionality by first ensuring\n    // that the (global) promise has resolved, then get Analytics from the injector.\n    isSupported().then(() => {\n      const analytics = injector.get(Analytics);\n      if (analytics) {\n        this.disposables = [\n          // TODO add credential tracking back in\n          authState(auth).subscribe(user => {\n            setUserId(analytics, user?.uid);\n            resolveInitialized();\n          }),\n        ];\n      } else {\n        resolveInitialized();\n      }\n    });\n  }\n\n  ngOnDestroy() {\n    this.disposables.forEach(it => it.unsubscribe());\n  }\n}\n"
  },
  {
    "path": "src/app/app.module.ts",
    "content": "import {\n  EnvironmentProviders,\n  Inject,\n  InjectionToken,\n  Injector,\n  VERSION as NG_VERSION,\n  NgModule,\n  NgZone,\n  Optional,\n  PLATFORM_ID,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers } from '@angular/fire';\nimport { FirebaseApp as IFirebaseApp, getApp, registerVersion } from 'firebase/app';\nimport { FirebaseApp, FirebaseApps } from './app';\n\nexport function defaultFirebaseAppFactory(provided: FirebaseApp[]|undefined) {\n  // Use the provided app, if there is only one, otherwise fetch the default app\n  if (provided && provided.length === 1) { return provided[0]; }\n  return new FirebaseApp(getApp());\n}\n\n// With FIREBASE_APPS I wanted to capture the default app instance, if it is initialized by\n// the reserved URL; ɵPROVIDED_FIREBASE_APPS is not for public consumption and serves to ensure that all\n// provideFirebaseApp(...) calls are satisfied before FirebaseApp$ or FirebaseApp is resolved\nexport const PROVIDED_FIREBASE_APPS = new InjectionToken<FirebaseApp[]>('angularfire2._apps');\n\n// Injecting FirebaseApp will now only inject the default Firebase App\n// this allows allows beginners to import /__/firebase/init.js to auto initialize Firebase App\n// from the reserved URL.\nconst DEFAULT_FIREBASE_APP_PROVIDER = {\n  provide: FirebaseApp,\n  useFactory: defaultFirebaseAppFactory,\n  deps: [\n    [new Optional(), PROVIDED_FIREBASE_APPS ],\n  ],\n};\n\nconst FIREBASE_APPS_PROVIDER = {\n  provide: FirebaseApps,\n  deps: [\n    [new Optional(), PROVIDED_FIREBASE_APPS ],\n  ],\n};\n\nexport function firebaseAppFactory(fn: (injector: Injector) => IFirebaseApp) {\n  return (zone: NgZone, injector: Injector) => {\n    const platformId = injector.get(PLATFORM_ID);\n    registerVersion('angularfire', VERSION.full, 'core');\n    registerVersion('angularfire', VERSION.full, 'app');\n    // eslint-disable-next-line @typescript-eslint/no-base-to-string\n    registerVersion('angular', NG_VERSION.full, platformId.toString());\n\n    const app = zone.runOutsideAngular(() => fn(injector));\n    return new FirebaseApp(app);\n  };\n}\n\n@NgModule({\n  providers: [\n    DEFAULT_FIREBASE_APP_PROVIDER,\n    FIREBASE_APPS_PROVIDER,\n  ]\n})\nexport class FirebaseAppModule {\n  constructor(@Inject(PLATFORM_ID) platformId: object) {\n    registerVersion('angularfire', VERSION.full, 'core');\n    registerVersion('angularfire', VERSION.full, 'app');\n    // eslint-disable-next-line @typescript-eslint/no-base-to-string\n    registerVersion('angular', NG_VERSION.full, platformId.toString());\n  }\n}\n\n// Calling initializeApp({ ... }, 'name') multiple times will add more FirebaseApps into the FIREBASE_APPS\n// injection scope. This allows developers to more easily work with multiple Firebase Applications. Downside\n// is that DI for app name and options doesn't really make sense anymore.\nexport function provideFirebaseApp(fn: (injector: Injector) => IFirebaseApp, ...deps: any[]): EnvironmentProviders {\n  return makeEnvironmentProviders([\n    DEFAULT_FIREBASE_APP_PROVIDER,\n    FIREBASE_APPS_PROVIDER,\n    {\n      provide: PROVIDED_FIREBASE_APPS,\n      useFactory: firebaseAppFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        ɵAngularFireSchedulers,\n        ...deps,\n      ],\n    }\n  ])\n}\n"
  },
  {
    "path": "src/app/app.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { COMMON_CONFIG } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('FirebaseApp', () => {\n  let app: FirebaseApp;\n  let providedApp: FirebaseApp;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => {\n                    providedApp = initializeApp(COMMON_CONFIG, appName);\n                    return providedApp;\n                })\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n    });\n\n    it('should be injectable', () => {\n        expect(app).toBeTruthy();\n        expect(app).toEqual(providedApp);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/app/app.ts",
    "content": "import { FirebaseApp as IFirebaseApp, getApps } from 'firebase/app';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// Need to turn the FirebaseApp interface exported by firebase/app into a class\n// as types don't work in Angular DI. We want developers to be able to inject FirebaseApp like so\n//   constructor(app: FirebaseApp)\n// the cleanest way to achieve this that I found is to export a new interface and class\n// the interface just extends the interface you want to turn into the class. This informs tyepscript\n// that the class has all the same methods/properties as the interface you want to extend without\n// breaking if Firebase adds/removes APIs in future releases. This was a big problem for @angular/fire\n// back when we constructed our own class. Then in the \"new class\" we just return the FirebaseApp in the\n// constructor, this also has the added benefit of Firebase methods taking our DI class without\n// casting. E.g,\n//   constructor(private app: FirebaseApp) { }\n//   ngOnDestroy() { deleteApp(this.app); }\n//\n \nexport interface FirebaseApp extends IFirebaseApp {}\n\nexport class FirebaseApp {\n  constructor(app: IFirebaseApp) {\n    return app;\n  }\n}\n\n \nexport interface FirebaseApps extends Array<IFirebaseApp> {}\n\nexport class FirebaseApps {\n  constructor() {\n    return getApps();\n  }\n}\n\nexport const firebaseApp$ = timer(0, 300).pipe(\n  concatMap(() => from(getApps())),\n  distinct(),\n);\n"
  },
  {
    "path": "src/app/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/app';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  deleteApp as _deleteApp,\n  getApp as _getApp,\n  getApps as _getApps,\n  initializeApp as _initializeApp,\n  initializeServerApp as _initializeServerApp,\n  onLog as _onLog,\n  registerVersion as _registerVersion,\n  setLogLevel as _setLogLevel\n} from 'firebase/app';\n\nexport const deleteApp = ɵzoneWrap(_deleteApp, true);\nexport const getApp = ɵzoneWrap(_getApp, true);\nexport const getApps = ɵzoneWrap(_getApps, true);\nexport const initializeApp = ɵzoneWrap(_initializeApp, true);\nexport const initializeServerApp = ɵzoneWrap(_initializeServerApp, true);\nexport const onLog = ɵzoneWrap(_onLog, true);\nexport const registerVersion = ɵzoneWrap(_registerVersion, true);\nexport const setLogLevel = ɵzoneWrap(_setLogLevel, true);\n"
  },
  {
    "path": "src/app/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/app/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}"
  },
  {
    "path": "src/app/public_api.ts",
    "content": "export { FirebaseApp, FirebaseApps, firebaseApp$ } from './app';\nexport { provideFirebaseApp, FirebaseAppModule } from './app.module';\nexport * from './firebase';\n"
  },
  {
    "path": "src/app-check/app-check.module.ts",
    "content": "import { isPlatformServer } from '@angular/common';\nimport {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  PLATFORM_ID,\n  isDevMode,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { registerVersion } from 'firebase/app';\nimport { AppCheck as FirebaseAppCheck } from 'firebase/app-check';\nimport { APP_CHECK_PROVIDER_NAME, AppCheck, AppCheckInstances } from './app-check';\n\nexport const PROVIDED_APP_CHECK_INSTANCES = new InjectionToken<AppCheck[]>('angularfire2.app-check-instances');\n\nexport function defaultAppCheckInstanceFactory(provided: FirebaseAppCheck[]|undefined, defaultApp: FirebaseApp) {\n  const defaultAppCheck = ɵgetDefaultInstanceOf<FirebaseAppCheck>(APP_CHECK_PROVIDER_NAME, provided, defaultApp);\n  return defaultAppCheck && new AppCheck(defaultAppCheck);\n}\n\nconst LOCALHOSTS = ['localhost', '0.0.0.0', '127.0.0.1'];\nconst isLocalhost = typeof window !== 'undefined' && LOCALHOSTS.includes(window.location.hostname);\n\nexport function appCheckInstanceFactory(fn: (injector: Injector) => FirebaseAppCheck) {\n   return (zone: NgZone, injector: Injector, platformId: unknown) => {\n    // Node should use admin token provider, browser devmode and localhost should use debug token\n    if (!isPlatformServer(platformId) && (isDevMode() || isLocalhost)) {\n      globalThis.FIREBASE_APPCHECK_DEBUG_TOKEN ??= true;\n    }\n    const appCheck = zone.runOutsideAngular(() => fn(injector));\n    return new AppCheck(appCheck);\n  };\n}\n\nconst APP_CHECK_INSTANCES_PROVIDER = {\n  provide: AppCheckInstances,\n  deps: [\n    [new Optional(), PROVIDED_APP_CHECK_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_APP_CHECK_INSTANCE_PROVIDER = {\n  provide: AppCheck,\n  useFactory: defaultAppCheckInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_APP_CHECK_INSTANCES ],\n    FirebaseApp,\n    PLATFORM_ID,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_APP_CHECK_INSTANCE_PROVIDER,\n    APP_CHECK_INSTANCES_PROVIDER,\n  ]\n})\nexport class AppCheckModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'app-check');\n  }\n}\n\nexport function provideAppCheck(fn: (injector: Injector) => FirebaseAppCheck, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'app-check');\n  return makeEnvironmentProviders([\n    DEFAULT_APP_CHECK_INSTANCE_PROVIDER,\n    APP_CHECK_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_APP_CHECK_INSTANCES,\n      useFactory: appCheckInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        PLATFORM_ID,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/app-check/app-check.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { Auth, connectAuthEmulator, getAuth, provideAuth } from '@angular/fire/auth';\nimport { COMMON_CONFIG } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('Auth', () => {\n  let app: FirebaseApp;\n  let auth: Auth;\n  let providedAuth: Auth;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n          providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideAuth(() => {\n                    providedAuth = getAuth(getApp(appName));\n                    connectAuthEmulator(providedAuth, 'http://localhost:9098');\n                    return providedAuth;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        auth = TestBed.inject(Auth);\n    });\n\n    it('should be injectable', () => {\n        expect(auth).toBeTruthy();\n        expect(auth).toEqual(providedAuth);\n        expect(auth.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/app-check/app-check.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { AppCheck as FirebaseAppCheck } from 'firebase/app-check';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\nexport const APP_CHECK_PROVIDER_NAME = 'app-check';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface AppCheck extends FirebaseAppCheck {}\n\nexport class AppCheck {\n  constructor(appCheck: FirebaseAppCheck) {\n    return appCheck;\n  }\n}\n\n \nexport interface AppCheckInstances extends Array<AppCheck> {}\n\nexport class AppCheckInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<AppCheck>(APP_CHECK_PROVIDER_NAME);\n  }\n}\n\nexport const appCheckInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseAppCheck>(APP_CHECK_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/app-check/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/app-check';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  getLimitedUseToken as _getLimitedUseToken,\n  getToken as _getToken,\n  initializeAppCheck as _initializeAppCheck,\n  onTokenChanged as _onTokenChanged,\n  setTokenAutoRefreshEnabled as _setTokenAutoRefreshEnabled\n} from 'firebase/app-check';\n\nexport const getLimitedUseToken = ɵzoneWrap(_getLimitedUseToken, true, 2);\nexport const getToken = ɵzoneWrap(_getToken, true);\nexport const initializeAppCheck = ɵzoneWrap(_initializeAppCheck, true);\nexport const onTokenChanged = ɵzoneWrap(_onTokenChanged, true);\nexport const setTokenAutoRefreshEnabled = ɵzoneWrap(_setTokenAutoRefreshEnabled, true);\n"
  },
  {
    "path": "src/app-check/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/app-check/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}"
  },
  {
    "path": "src/app-check/public_api.ts",
    "content": "export { AppCheck, appCheckInstance$, AppCheckInstances } from './app-check';\nexport { provideAppCheck, AppCheckModule } from './app-check.module';\nexport * from './firebase';\n"
  },
  {
    "path": "src/auth/auth.module.ts",
    "content": "import {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { registerVersion } from 'firebase/app';\nimport { Auth as FirebaseAuth } from 'firebase/auth';\nimport { AUTH_PROVIDER_NAME, Auth, AuthInstances } from './auth';\n\nexport const PROVIDED_AUTH_INSTANCES = new InjectionToken<Auth[]>('angularfire2.auth-instances');\n\nexport function defaultAuthInstanceFactory(provided: FirebaseAuth[]|undefined, defaultApp: FirebaseApp) {\n  const defaultAuth = ɵgetDefaultInstanceOf<FirebaseAuth>(AUTH_PROVIDER_NAME, provided, defaultApp);\n  return defaultAuth && new Auth(defaultAuth);\n}\n\nexport function authInstanceFactory(fn: (injector: Injector) => FirebaseAuth) {\n  return (zone: NgZone, injector: Injector) => {\n    const auth = zone.runOutsideAngular(() => fn(injector));\n    return new Auth(auth);\n  };\n}\n\nconst AUTH_INSTANCES_PROVIDER = {\n  provide: AuthInstances,\n  deps: [\n    [new Optional(), PROVIDED_AUTH_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_AUTH_INSTANCE_PROVIDER = {\n  provide: Auth,\n  useFactory: defaultAuthInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_AUTH_INSTANCES ],\n    FirebaseApp,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_AUTH_INSTANCE_PROVIDER,\n    AUTH_INSTANCES_PROVIDER,\n  ]\n})\nexport class AuthModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'auth');\n  }\n}\n\nexport function provideAuth(fn: (injector: Injector) => FirebaseAuth, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'auth');\n  return makeEnvironmentProviders([\n    DEFAULT_AUTH_INSTANCE_PROVIDER,\n    AUTH_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_AUTH_INSTANCES,\n      useFactory: authInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        [new Optional(), AppCheckInstances ],\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/auth/auth.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { Auth, connectAuthEmulator, getAuth, provideAuth } from '@angular/fire/auth';\nimport { COMMON_CONFIG, authEmulatorPort } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('Auth', () => {\n  let app: FirebaseApp;\n  let auth: Auth;\n  let providedAuth: Auth;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideAuth(() => {\n                    providedAuth = getAuth(getApp(appName));\n                    connectAuthEmulator(providedAuth, `http://localhost:${authEmulatorPort}`, { disableWarnings: true });\n                    return providedAuth;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        auth = TestBed.inject(Auth);\n    });\n\n    it('should be injectable', () => {\n        expect(providedAuth).toBeTruthy();\n        expect(auth).toEqual(providedAuth);\n        expect(auth.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/auth/auth.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { Auth as FirebaseAuth } from 'firebase/auth';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\nexport const AUTH_PROVIDER_NAME = 'auth';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface Auth extends FirebaseAuth {}\n\nexport class Auth {\n  constructor(auth: FirebaseAuth) {\n    return auth;\n  }\n}\n\n \nexport interface AuthInstances extends Array<FirebaseAuth> {}\n\nexport class AuthInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseAuth>(AUTH_PROVIDER_NAME);\n  }\n}\n\nexport const authInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseAuth>(AUTH_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/auth/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/auth';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  applyActionCode as _applyActionCode,\n  beforeAuthStateChanged as _beforeAuthStateChanged,\n  checkActionCode as _checkActionCode,\n  confirmPasswordReset as _confirmPasswordReset,\n  connectAuthEmulator as _connectAuthEmulator,\n  createUserWithEmailAndPassword as _createUserWithEmailAndPassword,\n  deleteUser as _deleteUser,\n  fetchSignInMethodsForEmail as _fetchSignInMethodsForEmail,\n  getAdditionalUserInfo as _getAdditionalUserInfo,\n  getAuth as _getAuth,\n  getIdToken as _getIdToken,\n  getIdTokenResult as _getIdTokenResult,\n  getMultiFactorResolver as _getMultiFactorResolver,\n  getRedirectResult as _getRedirectResult,\n  initializeAuth as _initializeAuth,\n  initializeRecaptchaConfig as _initializeRecaptchaConfig,\n  isSignInWithEmailLink as _isSignInWithEmailLink,\n  linkWithCredential as _linkWithCredential,\n  linkWithPhoneNumber as _linkWithPhoneNumber,\n  linkWithPopup as _linkWithPopup,\n  linkWithRedirect as _linkWithRedirect,\n  onAuthStateChanged as _onAuthStateChanged,\n  onIdTokenChanged as _onIdTokenChanged,\n  parseActionCodeURL as _parseActionCodeURL,\n  reauthenticateWithCredential as _reauthenticateWithCredential,\n  reauthenticateWithPhoneNumber as _reauthenticateWithPhoneNumber,\n  reauthenticateWithPopup as _reauthenticateWithPopup,\n  reauthenticateWithRedirect as _reauthenticateWithRedirect,\n  reload as _reload,\n  revokeAccessToken as _revokeAccessToken,\n  sendEmailVerification as _sendEmailVerification,\n  sendPasswordResetEmail as _sendPasswordResetEmail,\n  sendSignInLinkToEmail as _sendSignInLinkToEmail,\n  setPersistence as _setPersistence,\n  signInAnonymously as _signInAnonymously,\n  signInWithCredential as _signInWithCredential,\n  signInWithCustomToken as _signInWithCustomToken,\n  signInWithEmailAndPassword as _signInWithEmailAndPassword,\n  signInWithEmailLink as _signInWithEmailLink,\n  signInWithPhoneNumber as _signInWithPhoneNumber,\n  signInWithPopup as _signInWithPopup,\n  signInWithRedirect as _signInWithRedirect,\n  signOut as _signOut,\n  unlink as _unlink,\n  updateCurrentUser as _updateCurrentUser,\n  updateEmail as _updateEmail,\n  updatePassword as _updatePassword,\n  updatePhoneNumber as _updatePhoneNumber,\n  updateProfile as _updateProfile,\n  useDeviceLanguage as _useDeviceLanguage,\n  validatePassword as _validatePassword,\n  verifyBeforeUpdateEmail as _verifyBeforeUpdateEmail,\n  verifyPasswordResetCode as _verifyPasswordResetCode\n} from 'firebase/auth';\n\nexport const applyActionCode = ɵzoneWrap(_applyActionCode, true);\nexport const beforeAuthStateChanged = ɵzoneWrap(_beforeAuthStateChanged, true);\nexport const checkActionCode = ɵzoneWrap(_checkActionCode, true);\nexport const confirmPasswordReset = ɵzoneWrap(_confirmPasswordReset, true, 2);\nexport const connectAuthEmulator = ɵzoneWrap(_connectAuthEmulator, true);\nexport const createUserWithEmailAndPassword = ɵzoneWrap(_createUserWithEmailAndPassword, true, 2);\nexport const deleteUser = ɵzoneWrap(_deleteUser, true, 2);\nexport const fetchSignInMethodsForEmail = ɵzoneWrap(_fetchSignInMethodsForEmail, true, 2);\nexport const getAdditionalUserInfo = ɵzoneWrap(_getAdditionalUserInfo, true, 2);\nexport const getAuth = ɵzoneWrap(_getAuth, true);\nexport const getIdToken = ɵzoneWrap(_getIdToken, true);\nexport const getIdTokenResult = ɵzoneWrap(_getIdTokenResult, true);\nexport const getMultiFactorResolver = ɵzoneWrap(_getMultiFactorResolver, true);\nexport const getRedirectResult = ɵzoneWrap(_getRedirectResult, true);\nexport const initializeAuth = ɵzoneWrap(_initializeAuth, true);\nexport const initializeRecaptchaConfig = ɵzoneWrap(_initializeRecaptchaConfig, true);\nexport const isSignInWithEmailLink = ɵzoneWrap(_isSignInWithEmailLink, true);\nexport const linkWithCredential = ɵzoneWrap(_linkWithCredential, true, 2);\nexport const linkWithPhoneNumber = ɵzoneWrap(_linkWithPhoneNumber, true, 2);\nexport const linkWithPopup = ɵzoneWrap(_linkWithPopup, true, 2);\nexport const linkWithRedirect = ɵzoneWrap(_linkWithRedirect, true, 2);\nexport const onAuthStateChanged = ɵzoneWrap(_onAuthStateChanged, true);\nexport const onIdTokenChanged = ɵzoneWrap(_onIdTokenChanged, true);\nexport const parseActionCodeURL = ɵzoneWrap(_parseActionCodeURL, true);\nexport const reauthenticateWithCredential = ɵzoneWrap(_reauthenticateWithCredential, true, 2);\nexport const reauthenticateWithPhoneNumber = ɵzoneWrap(_reauthenticateWithPhoneNumber, true, 2);\nexport const reauthenticateWithPopup = ɵzoneWrap(_reauthenticateWithPopup, true, 2);\nexport const reauthenticateWithRedirect = ɵzoneWrap(_reauthenticateWithRedirect, true, 2);\nexport const reload = ɵzoneWrap(_reload, true, 2);\nexport const revokeAccessToken = ɵzoneWrap(_revokeAccessToken, true, 2);\nexport const sendEmailVerification = ɵzoneWrap(_sendEmailVerification, true, 2);\nexport const sendPasswordResetEmail = ɵzoneWrap(_sendPasswordResetEmail, true, 2);\nexport const sendSignInLinkToEmail = ɵzoneWrap(_sendSignInLinkToEmail, true, 2);\nexport const setPersistence = ɵzoneWrap(_setPersistence, true);\nexport const signInAnonymously = ɵzoneWrap(_signInAnonymously, true, 2);\nexport const signInWithCredential = ɵzoneWrap(_signInWithCredential, true, 2);\nexport const signInWithCustomToken = ɵzoneWrap(_signInWithCustomToken, true, 2);\nexport const signInWithEmailAndPassword = ɵzoneWrap(_signInWithEmailAndPassword, true, 2);\nexport const signInWithEmailLink = ɵzoneWrap(_signInWithEmailLink, true, 2);\nexport const signInWithPhoneNumber = ɵzoneWrap(_signInWithPhoneNumber, true, 2);\nexport const signInWithPopup = ɵzoneWrap(_signInWithPopup, true, 2);\nexport const signInWithRedirect = ɵzoneWrap(_signInWithRedirect, true, 2);\nexport const signOut = ɵzoneWrap(_signOut, true, 2);\nexport const unlink = ɵzoneWrap(_unlink, true, 2);\nexport const updateCurrentUser = ɵzoneWrap(_updateCurrentUser, true, 2);\nexport const updateEmail = ɵzoneWrap(_updateEmail, true, 2);\nexport const updatePassword = ɵzoneWrap(_updatePassword, true, 2);\nexport const updatePhoneNumber = ɵzoneWrap(_updatePhoneNumber, true, 2);\nexport const updateProfile = ɵzoneWrap(_updateProfile, true, 2);\nexport const useDeviceLanguage = ɵzoneWrap(_useDeviceLanguage, true, 2);\nexport const validatePassword = ɵzoneWrap(_validatePassword, true, 2);\nexport const verifyBeforeUpdateEmail = ɵzoneWrap(_verifyBeforeUpdateEmail, true, 2);\nexport const verifyPasswordResetCode = ɵzoneWrap(_verifyPasswordResetCode, true, 2);\n"
  },
  {
    "path": "src/auth/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/auth/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}"
  },
  {
    "path": "src/auth/public_api.ts",
    "content": "export { Auth, AuthInstances, authInstance$ } from './auth';\nexport { provideAuth, AuthModule } from './auth.module';\nexport * from './rxfire';\nexport * from './firebase';\n"
  },
  {
    "path": "src/auth/rxfire.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  authState as _authState,\n  idToken as _idToken,\n  user as _user\n} from 'rxfire/auth';\n\nexport const authState = ɵzoneWrap(_authState, true);\nexport const idToken = ɵzoneWrap(_idToken, true);\nexport const user = ɵzoneWrap(_user, true);\n"
  },
  {
    "path": "src/auth-guard/auth-guard.module.ts",
    "content": "import { NgModule } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport { registerVersion } from 'firebase/app';\nimport { AuthGuard } from './auth-guard';\n\n@NgModule({\n  providers: [ AuthGuard ]\n})\nexport class AuthGuardModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'auth-guard');\n  }\n}\n"
  },
  {
    "path": "src/auth-guard/auth-guard.spec.ts",
    "content": "import { APP_BASE_HREF } from '@angular/common';\nimport { TestBed } from '@angular/core/testing';\nimport { getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { connectAuthEmulator, getAuth, provideAuth } from '@angular/fire/auth';\nimport { AuthGuard, AuthGuardModule } from '@angular/fire/auth-guard';\nimport { Router, RouterModule } from '@angular/router';\nimport { COMMON_CONFIG } from '../test-config';\nimport { rando } from '../utils';\n\nclass TestComponent { }\n\ndescribe('AuthGuard', () => {\n  let router: Router;\n  let appName: string;\n\n  beforeEach(() => {\n    appName = rando();\n    TestBed.configureTestingModule({\n      imports: [\n        AuthGuardModule,\n        RouterModule.forRoot([\n          { path: 'a', component: TestComponent, canActivate: [AuthGuard] }\n        ])\n      ],\n      providers: [\n        provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n        provideAuth(() => {\n          const auth = getAuth(getApp(appName));\n          connectAuthEmulator(auth, 'http://localhost:9098');\n          return auth;\n        }),\n        { provide: APP_BASE_HREF, useValue: 'http://localhost:4200/' }\n      ]\n    });\n\n    router = TestBed.inject(Router);\n  });\n\n  it('should be injectable', () => {\n    expect(AuthGuard).toBeTruthy();\n  });\n\n  it('router should be valid', () => {\n    expect(router).toBeTruthy();\n  });\n\n});\n"
  },
  {
    "path": "src/auth-guard/auth-guard.ts",
    "content": "import { Injectable } from '@angular/core';\nimport { Auth, user } from '@angular/fire/auth';\nimport { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';\nimport { User } from 'firebase/auth';\nimport { Observable, UnaryFunction, of, pipe } from 'rxjs';\nimport { map, switchMap, take } from 'rxjs/operators';\n\nexport type AuthPipeGenerator = (next: ActivatedRouteSnapshot, state: RouterStateSnapshot) => AuthPipe;\nexport type AuthPipe = UnaryFunction<Observable<User|null>, Observable<boolean|string|any[]>>;\n\nexport const loggedIn: AuthPipe = map(user => !!user);\n\n@Injectable({\n  providedIn: 'any'\n})\nexport class AuthGuard implements CanActivate {\n\n  constructor(private router: Router, private auth: Auth) {}\n\n  canActivate = (next: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {\n    const authPipeFactory = next.data.authGuardPipe as AuthPipeGenerator || (() => loggedIn);\n    return user(this.auth).pipe(\n      take(1),\n      authPipeFactory(next, state),\n      map(can => {\n        if (typeof can === 'boolean') {\n          return can;\n        } else if (Array.isArray(can)) {\n          return this.router.createUrlTree(can);\n        } else {\n          // TODO(EdricChan03): Add tests\n          return this.router.parseUrl(can);\n        }\n      })\n    );\n  }\n\n}\n\nexport const canActivate = (pipe: AuthPipeGenerator) => ({\n  canActivate: [ AuthGuard ], data: { authGuardPipe: pipe }\n});\n\nexport const isNotAnonymous: AuthPipe = map(user => !!user && !user.isAnonymous);\nexport const idTokenResult = switchMap((user: User|null) => user ? user.getIdTokenResult() : of(null));\nexport const emailVerified: AuthPipe = map(user => !!user && user.emailVerified);\nexport const customClaims = pipe(idTokenResult, map(idTokenResult => idTokenResult ? idTokenResult.claims : []));\nexport const hasCustomClaim: (claim: string) => AuthPipe =\n  // eslint-disable-next-line no-prototype-builtins\n  (claim) => pipe(customClaims, map(claims =>  claims.hasOwnProperty(claim)));\nexport const redirectUnauthorizedTo: (redirect: string|any[]) => AuthPipe =\n  (redirect) => pipe(loggedIn, map(loggedIn => loggedIn || redirect));\nexport const redirectLoggedInTo: (redirect: string|any[]) => AuthPipe =\n  (redirect) => pipe(loggedIn, map(loggedIn => loggedIn && redirect || true));\n"
  },
  {
    "path": "src/auth-guard/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/auth-guard/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/auth-guard/public_api.ts",
    "content": "export * from './auth-guard';\nexport * from './auth-guard.module';\n"
  },
  {
    "path": "src/compat/analytics/analytics.module.ts",
    "content": "import { NgModule, Optional } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { AngularFireAnalytics } from './analytics';\nimport { ScreenTrackingService } from './screen-tracking.service';\nimport { UserTrackingService } from './user-tracking.service';\n\n@NgModule({\n  providers: [ AngularFireAnalytics ]\n})\nexport class AngularFireAnalyticsModule {\n  constructor(\n    analytics: AngularFireAnalytics,\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    @Optional() screenTracking: ScreenTrackingService,\n    // eslint-disable-next-line @typescript-eslint/no-unused-vars\n    @Optional() userTracking: UserTrackingService,\n  ) {\n    firebase.registerVersion('angularfire', VERSION.full, 'analytics-compat');\n    // calling anything on analytics will eagerly load the SDK\n    analytics.app.then(() => undefined);\n  }\n}\n"
  },
  {
    "path": "src/compat/analytics/analytics.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireAnalytics, AngularFireAnalyticsModule } from '@angular/fire/compat/analytics';\nimport { COMMON_CONFIG } from '../../test-config';\nimport { rando } from '../../utils';\n\n\ndescribe('AngularFireAnalytics', () => {\n  let analytics: AngularFireAnalytics;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireAnalyticsModule\n      ]\n    });\n\n    analytics = TestBed.inject(AngularFireAnalytics);\n  });\n\n  it('should be exist', () => {\n    expect(analytics instanceof AngularFireAnalytics).toBe(true);\n  });\n\n  it('should have the Firebase Functions instance', () => {\n    expect(analytics.app).toBeDefined();\n  });\n\n});\n"
  },
  {
    "path": "src/compat/analytics/analytics.ts",
    "content": "import { isPlatformBrowser } from '@angular/common';\nimport { Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID } from '@angular/core';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { ɵPromiseProxy, ɵapplyMixins, ɵcacheInstance, ɵlazySDKProxy } from '@angular/fire/compat';\nimport { FirebaseApp } from '@angular/fire/compat';\nimport { isSupported } from 'firebase/analytics';\nimport firebase from 'firebase/compat/app';\nimport { EMPTY, of } from 'rxjs';\nimport { map, observeOn, shareReplay, switchMap } from 'rxjs/operators';\nimport { proxyPolyfillCompat } from './base';\n\nexport type Config = Record<string, any>;\n\nexport const COLLECTION_ENABLED = new InjectionToken<boolean>('angularfire2.analytics.analyticsCollectionEnabled');\nexport const APP_VERSION = new InjectionToken<string>('angularfire2.analytics.appVersion');\nexport const APP_NAME = new InjectionToken<string>('angularfire2.analytics.appName');\nexport const DEBUG_MODE = new InjectionToken<boolean>('angularfire2.analytics.debugMode');\nexport const CONFIG = new InjectionToken<Config>('angularfire2.analytics.config');\n\nconst APP_NAME_KEY = 'app_name';\nconst APP_VERSION_KEY = 'app_version';\nconst DEBUG_MODE_KEY = 'debug_mode';\nconst GTAG_CONFIG_COMMAND = 'config';\nconst GTAG_FUNCTION_NAME = 'gtag'; // TODO rename these\nconst DATA_LAYER_NAME = 'dataLayer';\nconst SEND_TO_KEY = 'send_to';\n\n \nexport interface AngularFireAnalytics extends ɵPromiseProxy<firebase.analytics.Analytics> {\n}\n\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFireAnalytics {\n\n  private measurementId: string;\n  private analyticsInitialized = new Promise<void>(() => undefined);\n\n  async updateConfig(config: Config) {\n    await this.analyticsInitialized;\n    window[GTAG_FUNCTION_NAME](GTAG_CONFIG_COMMAND, this.measurementId, { ...config, update: true });\n  }\n\n  constructor(\n    app: FirebaseApp,\n    @Optional() @Inject(COLLECTION_ENABLED) analyticsCollectionEnabled: boolean | null,\n    @Optional() @Inject(APP_VERSION) providedAppVersion: string | null,\n    @Optional() @Inject(APP_NAME) providedAppName: string | null,\n    @Optional() @Inject(DEBUG_MODE) debugModeEnabled: boolean | null,\n    @Optional() @Inject(CONFIG) providedConfig: Config | null,\n\n    @Inject(PLATFORM_ID) platformId: object,\n    zone: NgZone,\n    schedulers: ɵAngularFireSchedulers,\n  ) {\n\n    if (isPlatformBrowser(platformId)) {\n\n      window[DATA_LAYER_NAME] = window[DATA_LAYER_NAME] || [];\n\n      // It turns out we can't rely on the measurementId in the Firebase config JSON\n      // this identifier is not stable. firebase/analytics does a call to get a fresh value\n      // falling back on the one in the config. Rather than do that ourselves we should listen\n      // on our gtag function for a analytics config command\n      // e.g, ['config', measurementId, { origin: 'firebase', firebase_id }]\n      const parseMeasurementId = (...args: any[]) => {\n        if (args[0] === 'config' && args[2].origin === 'firebase') {\n          this.measurementId = args[1];\n          return true;\n        } else {\n          return false;\n        }\n      };\n\n      const patchGtag = (fn?: (...args: any[]) => void) => {\n        window[GTAG_FUNCTION_NAME] = (...args: any[]) => {\n          if (fn) {\n            fn(...args);\n          }\n          // Inject app_name and app_version into events\n          // TODO(jamesdaniels): I'm doing this as documented but it's still not\n          //   showing up in the console. Investigate. Guessing it's just part of the\n          //   whole GA4 transition mess.\n          if (args[0] === 'event' && args[2][SEND_TO_KEY] === this.measurementId) {\n            if (providedAppName) {\n              args[2][APP_NAME_KEY] = providedAppName;\n            }\n            if (providedAppVersion) {\n              args[2][APP_VERSION_KEY] = providedAppVersion;\n            }\n          }\n          if (debugModeEnabled && typeof console !== 'undefined') {\n            // eslint-disable-next-line no-console\n            console.info(...args);\n          }\n          /**\n           * According to the gtag documentation, this function that defines a custom data layer cannot be\n           * an arrow function because 'arguments' is not an array. It is actually an object that behaves\n           * like an array and contains more information then just indexes. Transforming this into arrow function\n           * caused issue #2505 where analytics no longer sent any data.\n           */\n          (function(..._args: any[]) {\n            window[DATA_LAYER_NAME].push(arguments);\n          })(...args);\n        };\n      };\n\n      // Unclear if we still need to but I was running into config/events I passed\n      // to gtag before ['js' timestamp] weren't getting parsed, so let's make a promise\n      // that resolves when firebase/analytics has configured gtag.js that we wait on\n      // before sending anything\n      const firebaseAnalyticsAlreadyInitialized = window[DATA_LAYER_NAME].some(parseMeasurementId);\n      if (firebaseAnalyticsAlreadyInitialized) {\n        this.analyticsInitialized = Promise.resolve();\n        patchGtag();\n      } else {\n        this.analyticsInitialized = new Promise(resolve => {\n          patchGtag((...args) => {\n            if (parseMeasurementId(...args)) {\n              resolve();\n            }\n          });\n        });\n      }\n\n      if (providedConfig) {\n        this.updateConfig(providedConfig);\n      }\n      if (debugModeEnabled) {\n        this.updateConfig({ [DEBUG_MODE_KEY]: 1 });\n      }\n\n    } else {\n\n      this.analyticsInitialized = Promise.resolve();\n\n    }\n\n    const analytics = of(undefined).pipe(\n      observeOn(schedulers.outsideAngular),\n      switchMap(isSupported),\n      switchMap(supported => supported ? zone.runOutsideAngular(() => import('firebase/compat/analytics')) : EMPTY),\n      map(() => {\n        return ɵcacheInstance(`analytics`, 'AngularFireAnalytics', app.name, () => {\n          const analytics = app.analytics();\n          if (analyticsCollectionEnabled === false) {\n            analytics.setAnalyticsCollectionEnabled(false);\n          }\n          return analytics;\n        }, [app, analyticsCollectionEnabled, providedConfig, debugModeEnabled]);\n      }),\n      shareReplay({ bufferSize: 1, refCount: false })\n    );\n\n    return ɵlazySDKProxy(this, analytics, zone);\n\n  }\n\n}\n\nɵapplyMixins(AngularFireAnalytics, [proxyPolyfillCompat]);\n"
  },
  {
    "path": "src/compat/analytics/base.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\n// Export a null object with the same keys as firebase/compat/analytics, so Proxy can work with proxy-polyfill in Internet Explorer\nexport const proxyPolyfillCompat = {\n  app: null,\n  logEvent: null,\n  setCurrentScreen: null,\n  setUserId: null,\n  setUserProperties: null,\n  setAnalyticsCollectionEnabled: null,\n};\n"
  },
  {
    "path": "src/compat/analytics/index.ts",
    "content": "export * from './public_api';\n"
  },
  {
    "path": "src/compat/analytics/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/analytics/package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/analytics/public_api.ts",
    "content": "export * from './analytics';\nexport * from './analytics.module';\nexport * from './screen-tracking.service';\nexport * from './user-tracking.service';\n"
  },
  {
    "path": "src/compat/analytics/screen-tracking.service.ts",
    "content": "import { ComponentFactoryResolver, Injectable, NgZone, OnDestroy, Optional } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport { ɵscreenViewEvent } from '@angular/fire/analytics';\nimport { Title } from '@angular/platform-browser';\nimport { Router } from '@angular/router';\nimport firebase from 'firebase/compat/app';\nimport { Subscription } from 'rxjs';\nimport { switchMap } from 'rxjs/operators';\nimport { AngularFireAnalytics } from './analytics';\nimport { UserTrackingService } from './user-tracking.service';\n\nconst SCREEN_VIEW_EVENT = 'screen_view';\n\n@Injectable()\nexport class ScreenTrackingService implements OnDestroy {\n\n  private disposable: Subscription | undefined;\n\n  constructor(\n    analytics: AngularFireAnalytics,\n    @Optional() router: Router,\n    @Optional() title: Title,\n    componentFactoryResolver: ComponentFactoryResolver,\n    zone: NgZone,\n    @Optional() userTrackingService: UserTrackingService,\n  ) {\n    firebase.registerVersion('angularfire', VERSION.full, 'compat-screen-tracking');\n    if (!router || !analytics) { return this; }\n    zone.runOutsideAngular(() => {\n      this.disposable = ɵscreenViewEvent(router, title, componentFactoryResolver).pipe(\n          switchMap(async params => {\n            if (userTrackingService) {\n              await userTrackingService.initialized;\n            }\n            return await analytics.logEvent(SCREEN_VIEW_EVENT, params);\n          })\n      ).subscribe();\n    });\n  }\n\n  ngOnDestroy() {\n    if (this.disposable) {\n      this.disposable.unsubscribe();\n    }\n  }\n\n}\n"
  },
  {
    "path": "src/compat/analytics/user-tracking.service.ts",
    "content": "import { isPlatformBrowser } from '@angular/common';\nimport { Inject, Injectable, NgZone, OnDestroy, PLATFORM_ID } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport { AngularFireAuth } from '@angular/fire/compat/auth';\nimport firebase from 'firebase/compat/app';\nimport { Subscription } from 'rxjs';\nimport { AngularFireAnalytics } from './analytics';\n\n@Injectable()\nexport class UserTrackingService implements OnDestroy {\n\n  initialized: Promise<void>;\n  private disposables: Subscription[] = [];\n\n  // TODO a user properties injector\n  constructor(\n    analytics: AngularFireAnalytics,\n\n    @Inject(PLATFORM_ID) platformId: object,\n    auth: AngularFireAuth,\n    zone: NgZone,\n  ) {\n    firebase.registerVersion('angularfire', VERSION.full, 'compat-user-tracking');\n    if (isPlatformBrowser(platformId)) {\n      let resolveInitialized;\n      this.initialized = zone.runOutsideAngular(() => new Promise(resolve => resolveInitialized = resolve));\n      this.disposables = [\n          auth.authState.subscribe(user => {\n            analytics.setUserId(user?.uid);\n            resolveInitialized();\n          }),\n          auth.credential.subscribe(credential => {\n            if (credential) {\n              const method = credential.user.isAnonymous ? 'anonymous' : credential.additionalUserInfo.providerId;\n              if (credential.additionalUserInfo.isNewUser) {\n                analytics.logEvent('sign_up', { method });\n              }\n              analytics.logEvent('login', { method });\n            }\n          })\n      ];\n    } else {\n      this.initialized = Promise.resolve();\n    }\n\n  }\n\n  ngOnDestroy() {\n    this.disposables.forEach(it => it.unsubscribe());\n  }\n}\n"
  },
  {
    "path": "src/compat/angularfire2.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { ɵZoneScheduler } from '@angular/fire';\nimport { AngularFireModule, FirebaseApp } from '@angular/fire/compat';\nimport { TestScheduler } from 'rxjs/testing';\nimport { COMMON_CONFIG } from '../../src/test-config';\nimport { rando } from '../../src/utils';\n\ndescribe('angularfire', () => {\n  let app: FirebaseApp;\n  let appName: string;\n\n  beforeEach(() => {\n\n    appName = rando();\n\n    TestBed.configureTestingModule({\n      imports: [AngularFireModule.initializeApp(COMMON_CONFIG, appName)]\n    });\n\n    app = TestBed.inject(FirebaseApp);\n  });\n\n  describe('ZoneScheduler', () => {\n    it('should execute the scheduled work inside the specified zone', done => {\n      const ngZone = Zone.current.fork({\n        name: 'ngZone'\n      });\n      const rootZone = Zone.current;\n\n      // Mimic real behavior: Executing in Angular\n      ngZone.run(() => {\n        const outsideAngularScheduler = new ɵZoneScheduler(rootZone);\n        outsideAngularScheduler.schedule(() => {\n          expect(Zone.current.name).not.toEqual('ngZone');\n          done();\n        });\n      });\n    });\n\n    it('should execute nested scheduled work inside the specified zone', done => {\n      const testScheduler = new TestScheduler(null);\n      testScheduler.run(helpers => {\n        const outsideAngularScheduler = new ɵZoneScheduler(Zone.current, testScheduler);\n\n        const ngZone = Zone.current.fork({\n          name: 'ngZone'\n        });\n\n        let callbacksRan = 0;\n\n        // Mimic real behavior: Executing in Angular\n        ngZone.run(() => {\n          outsideAngularScheduler.schedule(() => {\n            callbacksRan++;\n            expect(Zone.current.name).not.toEqual('ngZone');\n\n            ngZone.run(() => {\n              // Sync queueing\n              outsideAngularScheduler.schedule(() => {\n                callbacksRan++;\n                expect(Zone.current.name).not.toEqual('ngZone');\n              });\n\n              // Async (10ms delay) nested scheduling\n              outsideAngularScheduler.schedule(() => {\n                callbacksRan++;\n                expect(Zone.current.name).not.toEqual('ngZone');\n              }, 10);\n\n              // Simulate flush from inside angular-\n              helpers.flush();\n              done();\n              expect(callbacksRan).toEqual(3);\n            });\n          });\n          helpers.flush();\n        });\n      });\n    });\n  });\n\n  describe('FirebaseApp', () => {\n\n    it('should provide a FirebaseApp for the FirebaseApp binding', () => {\n      expect(typeof app.delete).toBe('function');\n    });\n\n    if (typeof window !== 'undefined') {\n      it('should have the provided name', () => {\n        expect(app.name).toBe(appName);\n      });\n    }\n  });\n});\n"
  },
  {
    "path": "src/compat/auth/auth.module.ts",
    "content": "import { NgModule } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { AngularFireAuth } from './auth';\n\n@NgModule({\n  providers: [ AngularFireAuth ]\n})\nexport class AngularFireAuthModule {\n  constructor() {\n    firebase.registerVersion('angularfire', VERSION.full, 'auth-compat');\n  }\n}\n"
  },
  {
    "path": "src/compat/auth/auth.spec.ts",
    "content": "/* eslint-disable @typescript-eslint/ban-ts-comment */\nimport { TestBed } from '@angular/core/testing';\nimport { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire/compat';\nimport { AngularFireAuth, AngularFireAuthModule, SETTINGS, USE_EMULATOR } from '@angular/fire/compat/auth';\nimport firebase from 'firebase/compat/app';\nimport { Observable, Subject } from 'rxjs';\nimport { COMMON_CONFIG, authEmulatorPort } from '../../../src/test-config';\nimport 'firebase/compat/auth';\nimport { rando } from '../../../src/utils';\n\nconst firebaseUser = {\n  uid: '12345',\n  providerData: [{ displayName: 'jeffbcrossyface' }]\n} as firebase.User;\n\ndescribe('AngularFireAuth', () => {\n  let afAuth: AngularFireAuth;\n  let mockAuthState: Subject<firebase.User>;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireAuthModule\n      ],\n      providers: [\n        { provide: SETTINGS, useValue: { appVerificationDisabledForTesting: true } },\n        { provide: USE_EMULATOR, useValue: [`http://localhost:${authEmulatorPort}`] },\n      ]\n    });\n\n    afAuth = TestBed.inject(AngularFireAuth);\n\n    mockAuthState = new Subject<firebase.User>();\n    // @ts-ignore\n    spyOn(afAuth, 'authState').and.returnValue(mockAuthState);\n    // @ts-ignore\n    spyOn(afAuth, 'idToken').and.returnValue(mockAuthState);\n    (afAuth as any).authState = mockAuthState as Observable<firebase.User>;\n    (afAuth as any).idToken = mockAuthState as Observable<firebase.User>;\n  });\n\n  describe('Zones', () => {\n    it('should call operators and subscriber in the same zone as when service was initialized', (done) => {\n      // Initialize the app outside of the zone, to mimick real life behavior.\n      const ngZone = Zone.current.fork({\n        name: 'ngZone'\n      });\n      ngZone.run(() => {\n        const subs = [\n          afAuth.authState.subscribe(() => {\n            expect(Zone.current.name).toBe('ngZone');\n            done();\n          }, done.fail),\n          // afAuth.authState.subscribe(() => {\n          //   expect(Zone.current.name).toBe('ngZone');\n          //   done();\n          // }, done.fail)\n        ];\n        mockAuthState.next(firebaseUser);\n        subs.forEach(s => s.unsubscribe());\n      });\n    });\n  });\n\n  it('should exist', () => {\n    expect(afAuth instanceof AngularFireAuth).toBe(true);\n  });\n\n  it('should have an initialized Firebase app', () => {\n    expect(afAuth.app).toBeDefined();\n  });\n\n  it('should have disabled app verification for testing', async () => {\n    const app = await afAuth.app;\n    expect(app.auth().settings.appVerificationDisabledForTesting).toBe(true);\n  });\n\n  it('should emit auth updates through authState', (done: any) => {\n    let count = 0;\n\n    // Check that the first value is null and second is the auth user\n    const subs = afAuth.authState.subscribe({\n      next: (user => {\n        if (count === 0) {\n          expect(user).toBe(null);\n          count = count + 1;\n          mockAuthState.next(firebaseUser);\n        } else {\n          expect(user).toEqual(firebaseUser);\n          subs.unsubscribe();\n          done();\n        }\n      }),\n      error: done,\n      complete: done.fail\n    });\n    mockAuthState.next(null);\n  });\n\n  it('should emit auth updates through idToken', (done: any) => {\n    let count = 0;\n\n    // Check that the first value is null and second is the auth user\n    const subs = afAuth.idToken.subscribe({\n      next: user => {\n        if (count === 0) {\n          expect(user).toBe(null);\n          count = count + 1;\n          mockAuthState.next(firebaseUser);\n        } else {\n          expect(user as any).toEqual(firebaseUser);\n          subs.unsubscribe();\n          done();\n        }\n      },\n      error: done,\n      complete: done.fail\n    });\n    mockAuthState.next(null);\n  });\n\n});\n\ndescribe('AngularFireAuth with different app', () => {\n  let app: FirebaseApp;\n  let afAuth: AngularFireAuth;\n  let firebaseAppName: string;\n\n  beforeEach(() => {\n    firebaseAppName = rando();\n\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireAuthModule\n      ],\n      providers: [\n        { provide: FIREBASE_APP_NAME, useValue: firebaseAppName },\n        { provide: FIREBASE_OPTIONS, useValue: COMMON_CONFIG },\n        { provide: USE_EMULATOR, useValue: [`http://localhost:${authEmulatorPort}`] },\n      ]\n    });\n    app = TestBed.inject(FirebaseApp);\n    afAuth = TestBed.inject(AngularFireAuth);\n  });\n\n  describe('<constructor>', () => {\n\n    it('should be an AngularFireAuth type', () => {\n      expect(afAuth instanceof AngularFireAuth).toEqual(true);\n    });\n\n    it('should have an initialized Firebase app', () => {\n      expect(afAuth.app).toBeDefined();\n    });\n\n    it('should have an initialized Firebase app instance member', async () => {\n      const itsApp = await afAuth.app;\n      expect(itsApp).toEqual(app);\n    });\n  });\n\n});\n"
  },
  {
    "path": "src/compat/auth/auth.ts",
    "content": "import { isPlatformServer } from '@angular/common';\nimport { EnvironmentInjector, Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID, inject } from '@angular/core';\nimport { pendingUntilEvent } from '@angular/core/rxjs-interop';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { ɵPromiseProxy, ɵapplyMixins, ɵlazySDKProxy } from '@angular/fire/compat';\nimport { FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp, ɵcacheInstance, ɵfirebaseAppFactory } from '@angular/fire/compat';\nimport { FirebaseOptions } from 'firebase/app';\nimport firebase from 'firebase/compat/app';\nimport { Observable, Subject, from, merge, of } from 'rxjs';\nimport { filter, first, map, observeOn, shareReplay, subscribeOn, switchMap, switchMapTo } from 'rxjs/operators';\nimport { proxyPolyfillCompat } from './base';\n\n \nexport interface AngularFireAuth extends ɵPromiseProxy<firebase.auth.Auth> {}\n\ntype UseEmulatorArguments = Parameters<firebase.auth.Auth['useEmulator']>;\nexport const USE_EMULATOR = new InjectionToken<UseEmulatorArguments>('angularfire2.auth.use-emulator');\n\nexport const SETTINGS = new InjectionToken<firebase.auth.AuthSettings>('angularfire2.auth.settings');\nexport const TENANT_ID = new InjectionToken<string>('angularfire2.auth.tenant-id');\nexport const LANGUAGE_CODE = new InjectionToken<string>('angularfire2.auth.langugage-code');\nexport const USE_DEVICE_LANGUAGE = new InjectionToken<boolean>('angularfire2.auth.use-device-language');\nexport const PERSISTENCE = new InjectionToken<string>('angularfire.auth.persistence');\n\nexport const ɵauthFactory = (\n  app: FirebaseApp, zone: NgZone, useEmulator: UseEmulatorArguments|null,\n  tenantId: string, languageCode: string|null, useDeviceLanguage: boolean|null,\n  settings: firebase.auth.AuthSettings|null, persistence: string|null,\n) => ɵcacheInstance(`${app.name}.auth`, 'AngularFireAuth', app.name, () => {\n  const auth = zone.runOutsideAngular(() => app.auth());\n  if (useEmulator) {\n    auth.useEmulator(...useEmulator);\n  }\n  if (tenantId) {\n    auth.tenantId = tenantId;\n  }\n  auth.languageCode = languageCode;\n  if (useDeviceLanguage) {\n    auth.useDeviceLanguage();\n  }\n  if (settings) {\n    for (const [k, v] of Object.entries(settings)) {\n      auth.settings[k] = v;\n    }\n  }\n  if (persistence) {\n    auth.setPersistence(persistence);\n  }\n  return auth;\n}, [useEmulator, tenantId, languageCode, useDeviceLanguage, settings, persistence]);\n\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFireAuth {\n\n  private readonly injector = inject(EnvironmentInjector);\n\n  /**\n   * Observable of authentication state; as of Firebase 4.0 this is only triggered via sign-in/out\n   */\n  public readonly authState: Observable<firebase.User|null>;\n\n  /**\n   * Observable of the currently signed-in user's JWT token used to identify the user to a Firebase service (or null).\n   */\n  public readonly idToken: Observable<string|null>;\n\n  /**\n   * Observable of the currently signed-in user (or null).\n   */\n  public readonly user: Observable<firebase.User|null>;\n\n  /**\n   * Observable of the currently signed-in user's IdTokenResult object which contains the ID token JWT string and other\n   * helper properties for getting different data associated with the token as well as all the decoded payload claims\n   * (or null).\n   */\n  public readonly idTokenResult: Observable<firebase.auth.IdTokenResult|null>;\n\n  /**\n   * Observable of the currently signed-in user's credential, or null\n   */\n  public readonly credential: Observable<Required<firebase.auth.UserCredential>|null>;\n\n  constructor(\n    @Inject(FIREBASE_OPTIONS) options: FirebaseOptions,\n    @Optional() @Inject(FIREBASE_APP_NAME) name: string|null|undefined,\n\n    @Inject(PLATFORM_ID) platformId: object,\n    zone: NgZone,\n    schedulers: ɵAngularFireSchedulers,\n    @Optional() @Inject(USE_EMULATOR) useEmulator: any, // can't use the tuple here\n    @Optional() @Inject(SETTINGS) settings: any, // can't use firebase.auth.AuthSettings here\n    @Optional() @Inject(TENANT_ID) tenantId: string | null,\n    @Optional() @Inject(LANGUAGE_CODE) languageCode: string | null,\n    @Optional() @Inject(USE_DEVICE_LANGUAGE) useDeviceLanguage: boolean | null,\n    @Optional() @Inject(PERSISTENCE) persistence: string | null,\n    @Optional() _appCheckInstances: AppCheckInstances,\n  ) {\n    const logins = new Subject<Required<firebase.auth.UserCredential>>();\n\n    const auth = of(undefined).pipe(\n      observeOn(schedulers.outsideAngular),\n      switchMap(() => zone.runOutsideAngular(() => import('firebase/compat/auth'))),\n      map(() => ɵfirebaseAppFactory(options, zone, name)),\n      map(app => ɵauthFactory(app, zone, useEmulator, tenantId, languageCode, useDeviceLanguage, settings, persistence)),\n      shareReplay({ bufferSize: 1, refCount: false }),\n    );\n\n    if (isPlatformServer(platformId)) {\n\n      this.authState = this.user = this.idToken = this.idTokenResult = this.credential = of(null);\n\n    } else {\n\n      // HACK, as we're exporting auth.Auth, rather than auth, developers importing firebase.auth\n      //       (e.g, `import { auth } from 'firebase/compat/app'`) are getting an undefined auth object unexpectedly\n      //       as we're completely lazy. Let's eagerly load the Auth SDK here.\n      //       There could potentially be race conditions still... but this greatly decreases the odds while\n      //       we reevaluate the API.\n      auth.pipe(first()).subscribe();\n\n      const redirectResult = auth.pipe(\n        switchMap(auth => auth.getRedirectResult().then(it => it, () => null)),\n        pendingUntilEvent(this.injector),\n        shareReplay({ bufferSize: 1, refCount: false }),\n      );\n\n      const authStateChanged = auth.pipe(\n        switchMap(auth => new Observable<firebase.User|null>(sub =>\n          ({ unsubscribe: zone.runOutsideAngular(() => auth.onAuthStateChanged(\n            next => sub.next(next),\n            err => sub.error(err),\n            () => sub.complete()\n          ))})\n        )),\n      );\n\n      const idTokenChanged = auth.pipe(\n        switchMap(auth => new Observable<firebase.User|null>(sub =>\n          ({ unsubscribe: zone.runOutsideAngular(() => auth.onIdTokenChanged(\n            next => sub.next(next),\n            err => sub.error(err),\n            () => sub.complete()\n          ))})\n        ))\n      );\n\n      this.authState = redirectResult.pipe(\n        switchMapTo(authStateChanged),\n        subscribeOn(schedulers.outsideAngular),\n        observeOn(schedulers.insideAngular),\n      );\n\n      this.user = redirectResult.pipe(\n        switchMapTo(idTokenChanged),\n        subscribeOn(schedulers.outsideAngular),\n        observeOn(schedulers.insideAngular),\n      );\n\n      this.idToken = this.user.pipe(\n        switchMap(user => user ? from(user.getIdToken()) : of(null))\n      );\n\n      this.idTokenResult = this.user.pipe(\n        switchMap(user => user ? from(user.getIdTokenResult()) : of(null))\n      );\n\n      this.credential = merge(\n        redirectResult,\n        logins,\n        // pipe in null authState to make credential zipable, just a weird devexp if\n        // authState and user go null to still have a credential\n        this.authState.pipe(filter(it => !it))\n      ).pipe(\n        // handle the { user: { } } when a user is already logged in, rather have null\n        // TODO handle the type corcersion better\n        map(credential => credential?.user ? credential as Required<firebase.auth.UserCredential> : null),\n        subscribeOn(schedulers.outsideAngular),\n        observeOn(schedulers.insideAngular),\n      );\n\n    }\n\n    return ɵlazySDKProxy(this, auth, zone, { spy: {\n      apply: (name, _, val) => {\n        // If they call a signIn or createUser function listen into the promise\n        // this will give us the user credential, push onto the logins Subject\n        // to be consumed in .credential\n        if (name.startsWith('signIn') || name.startsWith('createUser')) {\n          // TODO fix the types, the trouble is UserCredential has everything optional\n          val.then((user: firebase.auth.UserCredential) => logins.next(user as any));\n        }\n      }\n    }});\n\n  }\n\n}\n\nɵapplyMixins(AngularFireAuth, [proxyPolyfillCompat]);\n"
  },
  {
    "path": "src/compat/auth/base.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\n// Export a null object with the same keys as firebase/compat/auth, so Proxy can work with proxy-polyfill in Internet Explorer\nexport const proxyPolyfillCompat = {\n  name: null,\n  config: null,\n  emulatorConfig: null,\n  app: null,\n  applyActionCode: null,\n  checkActionCode: null,\n  confirmPasswordReset: null,\n  createUserWithEmailAndPassword: null,\n  currentUser: null,\n  fetchSignInMethodsForEmail: null,\n  isSignInWithEmailLink: null,\n  getRedirectResult: null,\n  languageCode: null,\n  settings: null,\n  onAuthStateChanged: null,\n  onIdTokenChanged: null,\n  sendSignInLinkToEmail: null,\n  sendPasswordResetEmail: null,\n  setPersistence: null,\n  signInAndRetrieveDataWithCredential: null,\n  signInAnonymously: null,\n  signInWithCredential: null,\n  signInWithCustomToken: null,\n  signInWithEmailAndPassword: null,\n  signInWithPhoneNumber: null,\n  signInWithEmailLink: null,\n  signInWithPopup: null,\n  signInWithRedirect: null,\n  signOut: null,\n  tenantId: null,\n  updateCurrentUser: null,\n  useDeviceLanguage: null,\n  useEmulator: null,\n  verifyPasswordResetCode: null,\n};\n"
  },
  {
    "path": "src/compat/auth/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/auth/package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/auth/public_api.ts",
    "content": "\nimport 'firebase/compat/auth'; // removed in build process when not UMD\n\nexport * from './auth';\nexport * from './auth.module';\n"
  },
  {
    "path": "src/compat/auth-guard/auth-guard.module.ts",
    "content": "import { NgModule } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { AngularFireAuthGuard } from './auth-guard';\n\n@NgModule({\n  providers: [ AngularFireAuthGuard ]\n})\nexport class AngularFireAuthGuardModule {\n  constructor() {\n    firebase.registerVersion('angularfire', VERSION.full, 'auth-guard-compat');\n  }\n}\n"
  },
  {
    "path": "src/compat/auth-guard/auth-guard.spec.ts",
    "content": "import { APP_BASE_HREF } from '@angular/common';\nimport { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireAuthGuard, AngularFireAuthGuardModule } from '@angular/fire/compat/auth-guard';\nimport { Router, RouterModule } from '@angular/router';\nimport { COMMON_CONFIG } from '../../../src/test-config';\nimport { rando } from '../../../src/utils';\n\nclass TestComponent { }\n\ndescribe('AngularFireAuthGuard', () => {\n  let router: Router;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireAuthGuardModule,\n        RouterModule.forRoot([\n          { path: 'a', component: TestComponent, canActivate: [AngularFireAuthGuard] }\n        ])\n      ],\n      providers: [\n        { provide: APP_BASE_HREF, useValue: 'http://localhost:4200/' }\n      ]\n    });\n\n    router = TestBed.inject(Router);\n  });\n\n  it('should be injectable', () => {\n    expect(router).toBeTruthy();\n  });\n});\n"
  },
  {
    "path": "src/compat/auth-guard/auth-guard.ts",
    "content": "import { Injectable } from '@angular/core';\nimport { AngularFireAuth } from '@angular/fire/compat/auth';\nimport { ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot } from '@angular/router';\nimport firebase from 'firebase/compat/app';\nimport { Observable, UnaryFunction, of, pipe } from 'rxjs';\nimport { map, switchMap, take } from 'rxjs/operators';\n\nexport type AuthPipeGenerator = (next: ActivatedRouteSnapshot, state: RouterStateSnapshot) => AuthPipe;\nexport type AuthPipe = UnaryFunction<Observable<firebase.User|null>, Observable<boolean|string|any[]>>;\n\nexport const loggedIn: AuthPipe = map(user => !!user);\n\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFireAuthGuard implements CanActivate {\n\n  constructor(private router: Router, private auth: AngularFireAuth) {}\n\n  canActivate = (next: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {\n    const authPipeFactory = next.data.authGuardPipe as AuthPipeGenerator || (() => loggedIn);\n    return this.auth.user.pipe(\n      take(1),\n      authPipeFactory(next, state),\n      map(can => {\n        if (typeof can === 'boolean') {\n          return can;\n        } else if (Array.isArray(can)) {\n          return this.router.createUrlTree(can);\n        } else {\n          // TODO(EdricChan03): Add tests\n          return this.router.parseUrl(can);\n        }\n      })\n    );\n  }\n\n}\n\nexport const canActivate = (pipe: AuthPipeGenerator) => ({\n  canActivate: [ AngularFireAuthGuard ], data: { authGuardPipe: pipe }\n});\n\n\nexport const isNotAnonymous: AuthPipe = map(user => !!user && !user.isAnonymous);\nexport const idTokenResult = switchMap((user: firebase.User|null) => user ? user.getIdTokenResult() : of(null));\nexport const emailVerified: AuthPipe = map(user => !!user && user.emailVerified);\nexport const customClaims = pipe(idTokenResult, map(idTokenResult => idTokenResult ? idTokenResult.claims : []));\nexport const hasCustomClaim: (claim: string) => AuthPipe =\n  // eslint-disable-next-line no-prototype-builtins\n  (claim) => pipe(customClaims, map(claims =>  claims.hasOwnProperty(claim)));\nexport const redirectUnauthorizedTo: (redirect: string|any[]) => AuthPipe =\n  (redirect) => pipe(loggedIn, map(loggedIn => loggedIn || redirect));\nexport const redirectLoggedInTo: (redirect: string|any[]) => AuthPipe =\n  (redirect) => pipe(loggedIn, map(loggedIn => loggedIn && redirect || true));\n"
  },
  {
    "path": "src/compat/auth-guard/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/auth-guard/package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/auth-guard/public_api.ts",
    "content": "export * from './auth-guard';\nexport * from './auth-guard.module';\n"
  },
  {
    "path": "src/compat/cache.ts",
    "content": "import { isDevMode } from '@angular/core';\n\nexport function ɵcacheInstance<T>(cacheKey: any, moduleName: string, appName: string, fn: () => T, deps: any): T {\n  const [, instance, cachedDeps] = globalThis.ɵAngularfireInstanceCache.find((it: any) => it[0] === cacheKey) || [];\n  if (instance) {\n    if (!matchDep(deps, cachedDeps)) {\n      log('error', `${moduleName} was already initialized on the ${appName} Firebase App with different settings.${IS_HMR ? ' You may need to reload as Firebase is not HMR aware.' : ''}`);\n      log('warn', {is: deps, was: cachedDeps});\n    }\n    return instance;\n  } else {\n    const newInstance = fn();\n    globalThis.ɵAngularfireInstanceCache.push([cacheKey, newInstance, deps]);\n    return newInstance;\n  }\n}\n\nfunction matchDep(a: any, b: any) {\n  try {\n    return a.toString() === b.toString();\n  } catch (_) {\n    return a === b;\n  }\n}\n\nconst IS_HMR = typeof module !== 'undefined' && !!(module as any).hot;\n\nconst log = (level: 'log'|'error'|'info'|'warn', ...args: any) => {\n  if (isDevMode() && typeof console !== 'undefined') {\n    // eslint-disable-next-line no-console\n    console[level](...args);\n  }\n};\n\nglobalThis.ɵAngularfireInstanceCache ||= [];\n"
  },
  {
    "path": "src/compat/database/database.module.ts",
    "content": "import { NgModule } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { AngularFireDatabase } from './database';\n\n@NgModule({\n  providers: [ AngularFireDatabase ]\n})\nexport class AngularFireDatabaseModule {\n  constructor() {\n    firebase.registerVersion('angularfire', VERSION.full, 'rtdb-compat');\n  }\n}\n"
  },
  {
    "path": "src/compat/database/database.spec.ts",
    "content": "import { NgZone } from '@angular/core';\nimport { TestBed } from '@angular/core/testing';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseApp } from '@angular/fire/compat';\nimport { AngularFireDatabase, AngularFireDatabaseModule, USE_EMULATOR } from '@angular/fire/compat/database';\nimport 'firebase/compat/database';\nimport { COMMON_CONFIG, databaseEmulatorPort } from '../../../src/test-config';\nimport { rando } from '../../../src/utils';\n\ndescribe('AngularFireDatabase', () => {\n  let app: FirebaseApp;\n  let db: AngularFireDatabase;\n  let zone: NgZone;\n  let firebaseAppName: string;\n\n  beforeEach(() => {\n    firebaseAppName = rando();\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, firebaseAppName),\n        AngularFireDatabaseModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', databaseEmulatorPort] }\n      ]\n    });\n\n    app = TestBed.inject(FirebaseApp);\n    db = TestBed.inject(AngularFireDatabase);\n    zone = TestBed.inject(NgZone);\n  });\n\n  describe('<constructor>', () => {\n\n    it('should be an AngularFireDatabase type', () => {\n      expect(db instanceof AngularFireDatabase).toEqual(true);\n    });\n\n    it('should have an initialized Firebase app', () => {\n      expect(db.database.app).toBeDefined();\n    });\n\n    it('should accept a Firebase App in the constructor', (done) => {\n      const schedulers = TestBed.runInInjectionContext(() => new ɵAngularFireSchedulers());\n      const database =  TestBed.runInInjectionContext(() => new AngularFireDatabase(\n        app.options, rando(), undefined, {}, zone, schedulers, undefined, undefined,\n        undefined, undefined, undefined, undefined, undefined, undefined, undefined,\n      ));\n      expect(database instanceof AngularFireDatabase).toEqual(true);\n      // try { database.database.app.delete().then(done, done); } catch(e) { done(); }\n      done();\n    });\n\n    it('should have an initialized Firebase app instance member', () => {\n      expect(db.database.app.name).toEqual(firebaseAppName);\n    });\n\n  });\n\n});\n\ndescribe('AngularFireDatabase w/options', () => {\n  let db: AngularFireDatabase;\n  let firebaseAppName: string;\n  \n  beforeEach(() => {\n    firebaseAppName = rando();\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireDatabaseModule\n      ],\n      providers: [\n        { provide: FIREBASE_APP_NAME, useValue: firebaseAppName },\n        { provide: FIREBASE_OPTIONS, useValue: COMMON_CONFIG },\n        { provide: USE_EMULATOR, useValue: ['localhost', databaseEmulatorPort] }\n      ]\n    });\n\n    db = TestBed.inject(AngularFireDatabase);\n  });\n\n  describe('<constructor>', () => {\n\n    it('should be an AngularFireDatabase type', () => {\n      expect(db instanceof AngularFireDatabase).toEqual(true);\n    });\n\n    it('should have an initialized Firebase app', () => {\n      expect(db.database.app).toBeDefined();\n    });\n\n    it('should have an initialized Firebase app instance member', () => {\n      expect(db.database.app.name).toEqual(firebaseAppName);\n    });\n\n    /* INVESTIGATE database(url) does not seem to be working\n\n        it('database be pointing to the provided DB instance', () => {\n          expect(db.database.ref().toString()).toEqual(url);\n        });\n\n        it('list should be using the provided DB instance', () => {\n          expect(db.list(query).query.toString()).toEqual(`${url}/${query}`);\n        });\n\n        it('object should be using the provided DB instance', () => {\n          expect(db.object(query).query.toString()).toEqual(`${url}/${query}`);\n        });\n    */\n  });\n\n});\n"
  },
  {
    "path": "src/compat/database/database.ts",
    "content": "import { EnvironmentInjector, Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID, inject } from '@angular/core';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { FIREBASE_APP_NAME, FIREBASE_OPTIONS, ɵcacheInstance, ɵfirebaseAppFactory } from '@angular/fire/compat';\nimport {\n  SETTINGS as AUTH_SETTINGS,\n  AngularFireAuth,\n  LANGUAGE_CODE,\n  PERSISTENCE,\n  TENANT_ID,\n  USE_EMULATOR as USE_AUTH_EMULATOR,\n  USE_DEVICE_LANGUAGE,\n  ɵauthFactory,\n} from '@angular/fire/compat/auth';\nimport { FirebaseOptions } from 'firebase/app';\nimport firebase from 'firebase/compat/app';\nimport { AngularFireList, AngularFireObject, DatabaseQuery, PathReference, QueryFn } from './interfaces';\nimport { createListReference } from './list/create-reference';\nimport { createObjectReference } from './object/create-reference';\nimport { getRef } from './utils';\nimport 'firebase/compat/auth';\nimport 'firebase/compat/database';\n\nexport const URL = new InjectionToken<string>('angularfire2.realtimeDatabaseURL');\n\ntype UseEmulatorArguments = Parameters<firebase.database.Database['useEmulator']>;\nexport const USE_EMULATOR = new InjectionToken<UseEmulatorArguments>('angularfire2.database.use-emulator');\n\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFireDatabase {\n  public readonly database: firebase.database.Database;\n  private readonly injector = inject(EnvironmentInjector);\n\n  constructor(\n    @Inject(FIREBASE_OPTIONS) options: FirebaseOptions,\n    @Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,\n    @Optional() @Inject(URL) databaseURL: string | null,\n\n    @Inject(PLATFORM_ID) platformId: object,\n    zone: NgZone,\n    public schedulers: ɵAngularFireSchedulers,\n    @Optional() @Inject(USE_EMULATOR) _useEmulator: any, // tuple isn't working here\n    @Optional() auth: AngularFireAuth,\n    @Optional() @Inject(USE_AUTH_EMULATOR) useAuthEmulator: any,\n    @Optional() @Inject(AUTH_SETTINGS) authSettings: any, // can't use firebase.auth.AuthSettings here\n    @Optional() @Inject(TENANT_ID) tenantId: string | null,\n    @Optional() @Inject(LANGUAGE_CODE) languageCode: string | null,\n    @Optional() @Inject(USE_DEVICE_LANGUAGE) useDeviceLanguage: boolean | null,\n    @Optional() @Inject(PERSISTENCE) persistence: string | null,\n    @Optional() _appCheckInstances: AppCheckInstances,\n  ) {\n\n    const useEmulator: UseEmulatorArguments | null = _useEmulator;\n    const app = ɵfirebaseAppFactory(options, zone, name);\n\n    if (auth) {\n      ɵauthFactory(app, zone, useAuthEmulator, tenantId, languageCode, useDeviceLanguage, authSettings, persistence);\n    }\n\n    this.database = ɵcacheInstance(`${app.name}.database.${databaseURL}`, 'AngularFireDatabase', app.name, () => {\n      const database = zone.runOutsideAngular(() => app.database(databaseURL || undefined));\n      if (useEmulator) {\n        database.useEmulator(...useEmulator);\n      }\n      return database;\n    }, [useEmulator]);\n  }\n\n  list<T>(pathOrRef: PathReference, queryFn?: QueryFn): AngularFireList<T> {\n    const ref = inject(NgZone).runOutsideAngular(() => getRef(this.database, pathOrRef));\n    let query: DatabaseQuery = ref;\n    if (queryFn) {\n      query = queryFn(ref);\n    }\n    return createListReference<T>(query, this, this.injector);\n  }\n\n  object<T>(pathOrRef: PathReference): AngularFireObject<T> {\n    const ref = inject(NgZone).runOutsideAngular(() => getRef(this.database, pathOrRef));\n    return createObjectReference<T>(ref, this, this.injector);\n  }\n\n  createPushId() {\n    const ref = inject(NgZone).runOutsideAngular(() => this.database.ref());\n    return ref.push().key;\n  }\n\n}\n\nexport {\n  PathReference,\n  DatabaseSnapshot,\n  ChildEvent,\n  ListenEvent,\n  QueryFn,\n  AngularFireList,\n  AngularFireObject,\n  AngularFireAction,\n  Action,\n  SnapshotAction\n} from './interfaces';\n"
  },
  {
    "path": "src/compat/database/interfaces.ts",
    "content": "import firebase from 'firebase/compat/app';\nimport { Observable } from 'rxjs';\n\nexport type FirebaseOperation = string | firebase.database.Reference | firebase.database.DataSnapshot;\n\nexport interface AngularFireList<T> {\n  query: DatabaseQuery;\n  valueChanges(events?: ChildEvent[], options?: unknown): Observable<T[]>;\n  valueChanges<K extends string>(events?: ChildEvent[], options?: {idField: K}): Observable<(T & Partial<Record<K, string>>)[]>;\n  snapshotChanges(events?: ChildEvent[]): Observable<SnapshotAction<T>[]>;\n  stateChanges(events?: ChildEvent[]): Observable<SnapshotAction<T>>;\n  auditTrail(events?: ChildEvent[]): Observable<SnapshotAction<T>[]>;\n  update(item: FirebaseOperation, data: Partial<T>): Promise<void>;\n  set(item: FirebaseOperation, data: T): Promise<void>;\n  push(data: T): firebase.database.ThenableReference;\n  remove(item?: FirebaseOperation): Promise<void>;\n}\n\nexport interface AngularFireObject<T> {\n  query: DatabaseQuery;\n  valueChanges(): Observable<T | null>;\n  snapshotChanges(): Observable<SnapshotAction<T>>;\n  update(data: Partial<T>): Promise<void>;\n  set(data: T): Promise<void>;\n  remove(): Promise<void>;\n}\n\nexport interface FirebaseOperationCases {\n  stringCase: () => Promise<void>;\n  firebaseCase?: () => Promise<void>;\n  snapshotCase?: () => Promise<void>;\n  unwrappedSnapshotCase?: () => Promise<void>;\n}\n\nexport type QueryFn = (ref: DatabaseReference) => DatabaseQuery;\nexport type ChildEvent = 'child_added' | 'child_removed' | 'child_changed' | 'child_moved';\nexport type ListenEvent = 'value' | ChildEvent;\n\nexport interface Action<T> {\n  type: ListenEvent;\n  payload: T;\n}\n\nexport interface AngularFireAction<T> extends Action<T> {\n  prevKey: string | null | undefined;\n  key: string | null;\n}\n\nexport type SnapshotAction<T> = AngularFireAction<DatabaseSnapshot<T>>;\n\nexport type Primitive = number | string | boolean;\n\nexport interface DatabaseSnapshotExists<T> extends firebase.database.DataSnapshot {\n  exists(): true;\n  val(): T;\n  forEach(action: (a: DatabaseSnapshot<T>) => boolean): boolean;\n}\n\nexport interface DatabaseSnapshotDoesNotExist<T> extends firebase.database.DataSnapshot {\n  exists(): false;\n  val(): null;\n  forEach(action: (a: DatabaseSnapshot<T>) => boolean): boolean;\n}\n\nexport type DatabaseSnapshot<T> = DatabaseSnapshotExists<T> | DatabaseSnapshotDoesNotExist<T>;\n\nexport type DatabaseReference = firebase.database.Reference;\nexport type DatabaseQuery = firebase.database.Query;\nexport type DataSnapshot = firebase.database.DataSnapshot;\nexport type QueryReference = DatabaseReference | DatabaseQuery;\nexport type PathReference = QueryReference | string;\n"
  },
  {
    "path": "src/compat/database/list/audit-trail.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, USE_EMULATOR, auditTrail } from '@angular/fire/compat/database';\nimport firebase from 'firebase/compat/app';\nimport { skip } from 'rxjs/operators';\nimport { COMMON_CONFIG, databaseEmulatorPort } from '../../../../src/test-config';\nimport 'firebase/compat/database';\nimport { rando } from '../../../../src/utils';\n\ndescribe('auditTrail', () => {\n  let db: AngularFireDatabase;\n  let createRef: (path: string) => firebase.database.Reference;\n  let batch = {};\n  const items = [{ name: 'zero' }, { name: 'one' }, { name: 'two' }].map((item, i) => ({ key: i.toString(), ...item }));\n  Object.keys(items).forEach((key, i) => {\n    batch[i] = items[key];\n  });\n  // make batch immutable to preserve integrity\n  batch = Object.freeze(batch);\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireDatabaseModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', databaseEmulatorPort] }\n      ]\n    });\n\n    db = TestBed.inject(AngularFireDatabase);\n    createRef = (path: string) => db.database.ref(path);\n  });\n\n  function prepareAuditTrail(opts: { events?: ChildEvent[], skipnumber: number } = { skipnumber: 0 }) {\n    const { events, skipnumber } = opts;\n    const aref = createRef(rando());\n    aref.set(batch);\n    const changes = auditTrail(aref, events);\n    return {\n      changes: changes.pipe(skip(skipnumber)),\n      ref: aref\n    };\n  }\n\n  it('should listen to all events by default', (done) => {\n\n    const { changes } = prepareAuditTrail();\n    changes.subscribe(actions => {\n      const data = actions.map(a => a.payload.val());\n      expect(data).toEqual(items);\n      done();\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/database/list/audit-trail.ts",
    "content": "import { Observable, SchedulerLike } from 'rxjs';\nimport { map, scan, skipWhile, withLatestFrom } from 'rxjs/operators';\nimport { AngularFireAction, ChildEvent, DataSnapshot, DatabaseQuery, SnapshotAction } from '../interfaces';\nimport { fromRef } from '../observable/fromRef';\nimport { stateChanges } from './state-changes';\n\n\nexport function auditTrail<T>(query: DatabaseQuery, events?: ChildEvent[], scheduler?: SchedulerLike): Observable<SnapshotAction<T>[]> {\n  const auditTrail$ = stateChanges<T>(query, events)\n    .pipe(\n      scan((current, action) => [...current, action], [])\n    );\n  return waitForLoaded<T>(query, auditTrail$, scheduler);\n}\n\ninterface LoadedMetadata {\n  data: AngularFireAction<DataSnapshot>;\n  lastKeyToLoad: any;\n}\n\nfunction loadedData<T>(query: DatabaseQuery, scheduler?: SchedulerLike): Observable<LoadedMetadata> {\n  // Create an observable of loaded values to retrieve the\n  // known dataset. This will allow us to know what key to\n  // emit the \"whole\" array at when listening for child events.\n  return fromRef<T>(query, 'value', 'on', scheduler)\n  .pipe(\n    map(data => {\n      // Store the last key in the data set\n      let lastKeyToLoad;\n      // Loop through loaded dataset to find the last key\n      data.payload.forEach(child => {\n        lastKeyToLoad = child.key; return false;\n      });\n      // return data set and the current last key loaded\n      return { data, lastKeyToLoad };\n    })\n  );\n}\n\nfunction waitForLoaded<T>(query: DatabaseQuery, action$: Observable<SnapshotAction<T>[]>, scheduler?: SchedulerLike) {\n  const loaded$ = loadedData<T>(query, scheduler);\n  return loaded$\n    .pipe(\n      withLatestFrom(action$),\n      // Get the latest values from the \"loaded\" and \"child\" datasets\n      // We can use both datasets to form an array of the latest values.\n      map(([loaded, actions]) => {\n        // Store the last key in the data set\n        const lastKeyToLoad = loaded.lastKeyToLoad;\n        // Store all child keys loaded at this point\n        const loadedKeys = actions.map(snap => snap.key);\n        return { actions, lastKeyToLoad, loadedKeys };\n      }),\n      // This is the magical part, only emit when the last load key\n      // in the dataset has been loaded by a child event. At this point\n      // we can assume the dataset is \"whole\".\n      skipWhile(meta => !meta.loadedKeys.includes(meta.lastKeyToLoad)),\n      // Pluck off the meta data because the user only cares\n      // to iterate through the snapshots\n      map(meta => meta.actions)\n    );\n}\n"
  },
  {
    "path": "src/compat/database/list/changes.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireDatabase, AngularFireDatabaseModule, USE_EMULATOR, listChanges } from '@angular/fire/compat/database';\nimport firebase from 'firebase/compat/app';\nimport { skip, take } from 'rxjs/operators';\nimport { COMMON_CONFIG, databaseEmulatorPort } from '../../../../src/test-config';\nimport 'firebase/compat/database';\nimport { rando } from '../../../../src/utils';\n\ndescribe('listChanges', () => {\n  let db: AngularFireDatabase;\n  let ref: (path: string) => firebase.database.Reference;\n  let batch = {};\n  const items = [{ name: 'zero' }, { name: 'one' }, { name: 'two' }].map((item, i) => ({ key: i.toString(), ...item }));\n  Object.keys(items).forEach((key, i) => {\n    batch[i] = items[key];\n  });\n  // make batch immutable to preserve integrity\n  batch = Object.freeze(batch);\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireDatabaseModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', databaseEmulatorPort] }\n      ]\n    });\n\n    db = TestBed.inject(AngularFireDatabase);\n    ref = (path: string) => db.database.ref(path);\n  });\n\n  describe('events', () => {\n\n    it('should stream value at first', (done) => {\n      const someRef = ref(rando());\n      const obs = listChanges(someRef, ['child_added']);\n      obs.pipe(take(1)).subscribe(changes => {\n        const data = changes.map(change => change.payload.val());\n        expect(data).toEqual(items);\n      }).add(done);\n      someRef.set(batch);\n    });\n\n    it('should process a new child_added event', done => {\n      const aref = ref(rando());\n      const obs = listChanges(aref, ['child_added']);\n      obs.pipe(skip(1), take(1)).subscribe(changes => {\n        const data = changes.map(change => change.payload.val());\n        expect(data[3]).toEqual({ name: 'anotha one' });\n      }).add(done);\n      aref.set(batch);\n      aref.push({ name: 'anotha one' });\n    });\n\n    it('should stream in order events', (done) => {\n      const aref = ref(rando());\n      const obs = listChanges(aref.orderByChild('name'), ['child_added']);\n      obs.pipe(take(1)).subscribe(changes => {\n        const names = changes.map(change => change.payload.val().name);\n        expect(names[0]).toEqual('one');\n        expect(names[1]).toEqual('two');\n        expect(names[2]).toEqual('zero');\n      }).add(done);\n      aref.set(batch);\n    });\n\n    it('should stream in order events w/child_added', (done) => {\n      const aref = ref(rando());\n      const obs = listChanges(aref.orderByChild('name'), ['child_added']);\n      obs.pipe(skip(1), take(1)).subscribe(changes => {\n        const names = changes.map(change => change.payload.val().name);\n        expect(names[0]).toEqual('anotha one');\n        expect(names[1]).toEqual('one');\n        expect(names[2]).toEqual('two');\n        expect(names[3]).toEqual('zero');\n      }).add(done);\n      aref.set(batch);\n      aref.push({ name: 'anotha one' });\n    });\n\n    it('should stream events filtering', (done) => {\n      const aref = ref(rando());\n      const obs = listChanges(aref.orderByChild('name').equalTo('zero'), ['child_added']);\n      obs.pipe(skip(1), take(1)).subscribe(changes => {\n        const names = changes.map(change => change.payload.val().name);\n        expect(names[0]).toEqual('zero');\n        expect(names[1]).toEqual('zero');\n      }).add(done);\n      aref.set(batch);\n      aref.push({ name: 'zero' });\n    });\n\n\n    /* FLAKES? aref.set not fufilling\n\n    it('should process a new child_removed event', done => {\n      const aref = ref(rando());\n      const obs = listChanges(aref, ['child_added','child_removed']);\n      aref.set(batch).then(() => {\n        const sub = obs.pipe(skip(1),take(1)).subscribe(changes => {\n          const data = changes.map(change => change.payload.val());\n          expect(data.length).toEqual(items.length - 1);\n        }).add(done);\n        aref.child(items[0].key).remove();\n      });\n    });\n\n    it('should process a new child_changed event', (done) => {\n      const aref = ref(rando());\n      const obs = listChanges(aref, ['child_added','child_changed'])\n      aref.set(batch).then(() => {\n        const sub = obs.pipe(skip(1),take(1)).subscribe(changes => {\n          const data = changes.map(change => change.payload.val());\n          expect(data[1].name).toEqual('lol');\n        }).add(done);\n        aref.child(items[1].key).update({ name: 'lol'});\n      });\n    });\n\n    it('should process a new child_moved event', (done) => {\n      const aref = ref(rando());\n      const obs = listChanges(aref, ['child_added','child_moved'])\n      aref.set(batch).then(() => {\n        const sub = obs.pipe(skip(1),take(1)).subscribe(changes => {\n          const data = changes.map(change => change.payload.val());\n          // We moved the first item to the last item, so we check that\n          // the new result is now the last result\n          expect(data[data.length - 1]).toEqual(items[0]);\n        }).add(done);\n        aref.child(items[0].key).setPriority('a', () => {});\n      });\n    });*/\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/database/list/changes.ts",
    "content": "import { Observable, SchedulerLike, merge, of } from 'rxjs';\nimport { distinctUntilChanged, scan, switchMap } from 'rxjs/operators';\nimport { ChildEvent, DatabaseQuery, SnapshotAction } from '../interfaces';\nimport { fromRef } from '../observable/fromRef';\nimport { isNil } from '../utils';\n\n\nexport function listChanges<T = any>(ref: DatabaseQuery, events: ChildEvent[], scheduler?: SchedulerLike): Observable<SnapshotAction<T>[]> {\n  return fromRef(ref, 'value', 'once', scheduler).pipe(\n    switchMap(snapshotAction => {\n      const childEvent$ = [of(snapshotAction)];\n      events.forEach(event => childEvent$.push(fromRef(ref, event, 'on', scheduler)));\n      return merge(...childEvent$).pipe(scan(buildView, []));\n    }),\n    distinctUntilChanged()\n  );\n}\n\nfunction positionFor<T>(changes: SnapshotAction<T>[], key) {\n  const len = changes.length;\n  for (let i = 0; i < len; i++) {\n    if (changes[i].payload.key === key) {\n      return i;\n    }\n  }\n  return -1;\n}\n\nfunction positionAfter<T>(changes: SnapshotAction<T>[], prevKey?: string) {\n  if (isNil(prevKey)) {\n    return 0;\n  } else {\n    const i = positionFor(changes, prevKey);\n    if (i === -1) {\n      return changes.length;\n    } else {\n      return i + 1;\n    }\n  }\n}\n\nfunction buildView(current, action) {\n  const { payload, prevKey, key } = action;\n  const currentKeyPosition = positionFor(current, key);\n  const afterPreviousKeyPosition = positionAfter(current, prevKey);\n  switch (action.type) {\n    case 'value':\n      if (action.payload?.exists()) {\n        let prevKey = null;\n        action.payload.forEach(payload => {\n          const action = { payload, type: 'value', prevKey, key: payload.key };\n          prevKey = payload.key;\n          current = [...current, action];\n          return false;\n        });\n      }\n      return current;\n    case 'child_added':\n      if (currentKeyPosition > -1) {\n        // check that the previouskey is what we expect, else reorder\n        const previous = current[currentKeyPosition - 1];\n        if ((previous?.key || null) !== prevKey) {\n          current = current.filter(x => x.payload.key !== payload.key);\n          current.splice(afterPreviousKeyPosition, 0, action);\n        }\n      } else if (prevKey == null) {\n        return [action, ...current];\n      } else {\n        current = current.slice();\n        current.splice(afterPreviousKeyPosition, 0, action);\n      }\n      return current;\n    case 'child_removed':\n      return current.filter(x => x.payload.key !== payload.key);\n    case 'child_changed':\n      return current.map(x => x.payload.key === key ? action : x);\n    case 'child_moved':\n      if (currentKeyPosition > -1) {\n        const data = current.splice(currentKeyPosition, 1)[0];\n        current = current.slice();\n        current.splice(afterPreviousKeyPosition, 0, data);\n        return current;\n      }\n      return current;\n    // default will also remove null results\n    default:\n      return current;\n  }\n}\n"
  },
  {
    "path": "src/compat/database/list/create-reference.ts",
    "content": "import { Injector, NgZone, inject } from '@angular/core';\nimport { pendingUntilEvent } from '@angular/core/rxjs-interop';\nimport type { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { AngularFireDatabase } from '../database';\nimport { AngularFireList, ChildEvent, DatabaseQuery } from '../interfaces';\nimport { auditTrail } from './audit-trail';\nimport { createDataOperationMethod } from './data-operation';\nimport { createRemoveMethod } from './remove';\nimport { snapshotChanges } from './snapshot-changes';\nimport { stateChanges } from './state-changes';\n\nexport function createListReference<T= any>(query: DatabaseQuery, afDatabase: AngularFireDatabase, injector?: Injector): AngularFireList<T> {\n  const outsideAngularScheduler = afDatabase.schedulers.outsideAngular;\n  const refInZone = inject(NgZone).run(() => query.ref);\n  return {\n    query,\n    update: createDataOperationMethod(refInZone, 'update'),\n    set: createDataOperationMethod(refInZone, 'set'),\n    push: (data: T) => refInZone.push(data),\n    remove: createRemoveMethod(refInZone),\n    snapshotChanges(events?: ChildEvent[]) {\n      return snapshotChanges<T>(query, events, outsideAngularScheduler).pipe(pendingUntilEvent(injector));\n    },\n    stateChanges(events?: ChildEvent[]) {\n      return stateChanges<T>(query, events, outsideAngularScheduler).pipe(pendingUntilEvent(injector));\n    },\n    auditTrail(events?: ChildEvent[]) {\n      return auditTrail<T>(query, events, outsideAngularScheduler).pipe(pendingUntilEvent(injector));\n    },\n    valueChanges<K extends string>(events?: ChildEvent[], options?: {idField?: K}): Observable<(T & Record<string, string>)[]> {\n      const snapshotChanges$ = snapshotChanges<T>(query, events, outsideAngularScheduler);\n      return snapshotChanges$.pipe(\n        map(actions => actions.map(a => {\n          if (options?.idField) {\n            return {\n              ...a.payload.val() as T,\n              ...{\n                [options.idField]: a.key\n              }\n            };\n          } else {\n            return a.payload.val() as T & Record<string, string>\n          }\n        })),\n        pendingUntilEvent(injector)\n      );\n    }\n  };\n}\n"
  },
  {
    "path": "src/compat/database/list/data-operation.ts",
    "content": "import { DatabaseReference, DatabaseSnapshot, FirebaseOperation } from '../interfaces';\nimport { checkOperationCases } from '../utils';\n\nexport function createDataOperationMethod(ref: DatabaseReference, operation: string) {\n  return function dataOperation<T>(item: FirebaseOperation, value: T) {\n    return checkOperationCases(item, {\n      stringCase: () => ref.child(item as string)[operation](value),\n      firebaseCase: () => (item as DatabaseReference)[operation](value),\n      snapshotCase: () => (item as DatabaseSnapshot<T>).ref[operation](value)\n    });\n  };\n}\n"
  },
  {
    "path": "src/compat/database/list/remove.ts",
    "content": "import { DatabaseReference, DatabaseSnapshot, FirebaseOperation } from '../interfaces';\nimport { checkOperationCases } from '../utils';\n\n// TODO(davideast): Find out why TS thinks this returns firebase.Primise\n// instead of Promise.\nexport function createRemoveMethod<T>(ref: DatabaseReference) {\n  return function remove(item?: FirebaseOperation): any {\n    if (!item) { return ref.remove(); }\n    return checkOperationCases(item, {\n      stringCase: () => ref.child(item as string).remove(),\n      firebaseCase: () => (item as DatabaseReference).remove(),\n      snapshotCase: () => (item as DatabaseSnapshot<T>).ref.remove()\n    });\n  };\n}\n"
  },
  {
    "path": "src/compat/database/list/snapshot-changes.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, USE_EMULATOR, snapshotChanges } from '@angular/fire/compat/database';\nimport firebase from 'firebase/compat/app';\nimport { BehaviorSubject } from 'rxjs';\nimport { skip, switchMap, take } from 'rxjs/operators';\nimport { COMMON_CONFIG, databaseEmulatorPort } from '../../../../src/test-config';\nimport 'firebase/compat/database';\nimport { rando } from '../../../../src/utils';\n\ndescribe('snapshotChanges', () => {\n  let db: AngularFireDatabase;\n  let createRef: (path: string) => firebase.database.Reference;\n  let batch = {};\n  const items = [{ name: 'zero' }, { name: 'one' }, { name: 'two' }].map((item, i) => ({ key: i.toString(), ...item }));\n  Object.keys(items).forEach((key, i) => {\n    batch[i] = items[key];\n  });\n  // make batch immutable to preserve integrity\n  batch = Object.freeze(batch);\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireDatabaseModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', databaseEmulatorPort] }\n      ]\n    });\n\n    db = TestBed.inject(AngularFireDatabase);\n    createRef = (path: string) => db.database.ref(path);\n  });\n\n  function prepareSnapshotChanges(opts: { events?: ChildEvent[], skipnumber: number } = { skipnumber: 0 }) {\n    const { events, skipnumber } = opts;\n    const aref = createRef(rando());\n    const snapChanges = snapshotChanges(aref, events);\n    return {\n      snapChanges: snapChanges.pipe(skip(skipnumber)),\n      ref: aref\n    };\n  }\n\n  it('should listen to all events by default', (done) => {\n    const { snapChanges, ref } = prepareSnapshotChanges();\n    snapChanges.pipe(take(1)).subscribe(actions => {\n      const data = actions.map(a => a.payload.val());\n      expect(data).toEqual(items);\n    }).add(done);\n    ref.set(batch);\n  });\n\n  it('should handle multiple subscriptions (hot)', (done) => {\n    const { snapChanges, ref } = prepareSnapshotChanges();\n    const sub = snapChanges.subscribe(() => undefined);\n    sub.add(done);\n    snapChanges.pipe(take(1)).subscribe(actions => {\n      const data = actions.map(a => a.payload.val());\n      expect(data).toEqual(items);\n    }).add(sub);\n    ref.set(batch);\n  });\n\n  it('should handle multiple subscriptions (warm)', done => {\n    const { snapChanges, ref } = prepareSnapshotChanges();\n    snapChanges.pipe(take(1)).subscribe(() => undefined).add(() => {\n      snapChanges.pipe(take(1)).subscribe(actions => {\n        const data = actions.map(a => a.payload.val());\n        expect(data).toEqual(items);\n      }).add(done);\n    });\n    ref.set(batch);\n  });\n\n  it('should listen to only child_added events', (done) => {\n    const { snapChanges, ref } = prepareSnapshotChanges({ events: ['child_added'], skipnumber: 0 });\n    snapChanges.pipe(take(1)).subscribe(actions => {\n      const data = actions.map(a => a.payload.val());\n      expect(data).toEqual(items);\n    }).add(done);\n    ref.set(batch);\n  });\n\n  /* FLAKE? set promise not fufilling\n  it('should listen to only child_added, child_changed events', (done) => {\n    const { snapChanges, ref } = prepareSnapshotChanges({\n      events: ['child_added', 'child_changed'],\n      skipnumber: 1\n    });\n    const name = 'ligatures';\n    snapChanges.pipe(take(1)).subscribe(actions => {\n      const data = actions.map(a => a.payload!.val());;\n      const copy = [...items];\n      copy[0].name = name;\n      expect(data).toEqual(copy);\n    }).add(done);\n    ref.set(batch).then(() => {\n      ref.child(items[0].key).update({ name })\n    });\n  });*/\n\n  it('should handle empty sets', done => {\n    const aref = createRef(rando());\n    aref.set({});\n    snapshotChanges(aref).pipe(take(1)).subscribe(data => {\n      expect(data.length).toEqual(0);\n    }).add(done);\n  });\n\n  it('should handle dynamic queries that return empty sets', done => {\n    let count = 0;\n    const namefilter$ = new BehaviorSubject<number | null>(null);\n    const aref = createRef(rando());\n    aref.set(batch);\n    namefilter$.pipe(switchMap(name => {\n      const filteredRef = name ? aref.child('name').equalTo(name) : aref;\n      return snapshotChanges(filteredRef);\n    }), take(2)).subscribe(data => {\n      count = count + 1;\n      // the first time should all be 'added'\n      if (count === 1) {\n        expect(Object.keys(data).length).toEqual(3);\n        namefilter$.next(-1);\n      }\n      // on the second round, we should have filtered out everything\n      if (count === 2) {\n        expect(Object.keys(data).length).toEqual(0);\n      }\n    }).add(done);\n  });\n\n});\n"
  },
  {
    "path": "src/compat/database/list/snapshot-changes.ts",
    "content": "import { Observable, SchedulerLike } from 'rxjs';\nimport { ChildEvent, DatabaseQuery, SnapshotAction } from '../interfaces';\nimport { listChanges } from './changes';\nimport { validateEventsArray } from './utils';\n\nexport function snapshotChanges<T>(\n  query: DatabaseQuery,\n  events?: ChildEvent[],\n  scheduler?: SchedulerLike\n): Observable<SnapshotAction<T>[]> {\n  events = validateEventsArray(events);\n  return listChanges<T>(query, events, scheduler);\n}\n"
  },
  {
    "path": "src/compat/database/list/state-changes.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireDatabase, AngularFireDatabaseModule, ChildEvent, USE_EMULATOR, stateChanges } from '@angular/fire/compat/database';\nimport firebase from 'firebase/compat/app';\nimport { skip } from 'rxjs/operators';\nimport { COMMON_CONFIG, databaseEmulatorPort } from '../../../../src/test-config';\nimport 'firebase/compat/database';\nimport { rando } from '../../../../src/utils';\n\ndescribe('stateChanges', () => {\n  let db: AngularFireDatabase;\n  let createRef: (path: string) => firebase.database.Reference;\n  let batch = {};\n  const items = [{ name: 'zero' }, { name: 'one' }, { name: 'two' }].map((item, i) => ({ key: i.toString(), ...item }));\n  Object.keys(items).forEach((key, i) => {\n    batch[i] = items[key];\n  });\n  // make batch immutable to preserve integrity\n  batch = Object.freeze(batch);\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireDatabaseModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', databaseEmulatorPort] }\n      ]\n    });\n\n    db = TestBed.inject(AngularFireDatabase);\n    createRef = (path: string) => db.database.ref(path);\n  });\n\n  function prepareStateChanges(opts: { events?: ChildEvent[], skipnumber: number } = { skipnumber: 0 }) {\n    const { events, skipnumber } = opts;\n    const aref = createRef(rando());\n    aref.set(batch);\n    const changes = stateChanges(aref, events);\n    return {\n      changes: changes.pipe(skip(skipnumber)),\n      ref: aref\n    };\n  }\n\n  it('should listen to all events by default', (done) => {\n\n    const { changes } = prepareStateChanges({ skipnumber: 2 });\n    changes.subscribe(action => {\n      expect(action.key).toEqual('2');\n      expect(action.payload.val()).toEqual(items[items.length - 1]);\n      done();\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/database/list/state-changes.ts",
    "content": "import { SchedulerLike, merge } from 'rxjs';\nimport { ChildEvent, DatabaseQuery } from '../interfaces';\nimport { fromRef } from '../observable/fromRef';\nimport { validateEventsArray } from './utils';\n\nexport function stateChanges<T>(query: DatabaseQuery, events?: ChildEvent[], scheduler?: SchedulerLike) {\n  events = validateEventsArray(events);\n  const childEvent$ = events.map(event => fromRef<T>(query, event, 'on', scheduler));\n  return merge(...childEvent$);\n}\n"
  },
  {
    "path": "src/compat/database/list/utils.ts",
    "content": "import { isNil } from '../utils';\n\nexport function validateEventsArray(events?: any[]) {\n  if (isNil(events) || events.length === 0) {\n    events = ['child_added', 'child_removed', 'child_changed', 'child_moved'];\n  }\n  return events;\n}\n"
  },
  {
    "path": "src/compat/database/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/database/object/create-reference.ts",
    "content": "import { Injector } from '@angular/core';\nimport { pendingUntilEvent } from '@angular/core/rxjs-interop';\nimport { map } from 'rxjs/operators';\nimport { AngularFireDatabase } from '../database';\nimport { AngularFireObject, DatabaseQuery } from '../interfaces';\nimport { createObjectSnapshotChanges } from './snapshot-changes';\n\nexport function createObjectReference<T= any>(query: DatabaseQuery, afDatabase: AngularFireDatabase, injector?: Injector): AngularFireObject<T> {\n  return {\n    query,\n    snapshotChanges<T>() {\n      return createObjectSnapshotChanges<T>(query, afDatabase.schedulers.outsideAngular)().pipe(\n        pendingUntilEvent(injector)\n      );\n    },\n    update(data: Partial<T>) { return query.ref.update(data as any) as Promise<void>; },\n    set(data: T) { return query.ref.set(data) as Promise<void>; },\n    remove() { return query.ref.remove() as Promise<void>; },\n    valueChanges<T>() {\n      const snapshotChanges$ = createObjectSnapshotChanges(query, afDatabase.schedulers.outsideAngular)();\n      return snapshotChanges$.pipe(\n        pendingUntilEvent(injector),\n        map(action => action.payload.exists() ? action.payload.val() as T : null)\n      );\n    },\n  };\n}\n"
  },
  {
    "path": "src/compat/database/object/snapshot-changes.ts",
    "content": "import { Observable, SchedulerLike } from 'rxjs';\nimport { DatabaseQuery, SnapshotAction } from '../interfaces';\nimport { fromRef } from '../observable/fromRef';\n\nexport function createObjectSnapshotChanges<T>(query: DatabaseQuery, scheduler?: SchedulerLike) {\n  return function snapshotChanges(): Observable<SnapshotAction<T>> {\n    return fromRef(query, 'value', 'on', scheduler);\n  };\n}\n"
  },
  {
    "path": "src/compat/database/observable/fromRef.spec.ts",
    "content": "/* eslint-disable @typescript-eslint/unbound-method */\nimport { TestBed } from '@angular/core/testing';\nimport { ɵZoneScheduler } from '@angular/fire';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFireDatabase, AngularFireDatabaseModule, USE_EMULATOR, fromRef } from '@angular/fire/compat/database';\nimport firebase from 'firebase/compat/app';\nimport { take } from 'rxjs/operators';\nimport { TestScheduler } from 'rxjs/testing';\nimport { COMMON_CONFIG, databaseEmulatorPort } from '../../../../src/test-config';\nimport { rando } from '../../../../src/utils';\n\ndescribe('fromRef', () => {\n  let db: AngularFireDatabase;\n  let ref: (path: string) => firebase.database.Reference;\n  let batch = {};\n  const items = [{ name: 'one' }, { name: 'two' }, { name: 'three' }].map(item => ({ key: rando(), ...item }));\n  Object.keys(items).forEach((key) => {\n    const itemValue = items[key];\n    batch[itemValue.key] = itemValue;\n  });\n  // make batch immutable to preserve integrity\n  batch = Object.freeze(batch);\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireDatabaseModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', databaseEmulatorPort] }\n      ]\n    });\n\n    db = TestBed.inject(AngularFireDatabase);\n    ref = (path: string) => db.database.ref(path);\n  });\n\n  it('it should be async by default', (done) => {\n    const itemRef = ref(rando());\n    itemRef.set(batch);\n    const obs = fromRef(itemRef, 'value');\n    let count = 0;\n    expect(count).toEqual(0);\n    const sub = obs.subscribe(() => {\n      count = count + 1;\n      expect(count).toEqual(1);\n      sub.unsubscribe();\n      done();\n    });\n    expect(count).toEqual(0);\n  });\n\n  it('should take a scheduler', done => {\n    const itemRef = ref(rando());\n    itemRef.set(batch);\n\n    const testScheduler = new TestScheduler((actual, expected) => {\n      expect(actual).toEqual(expected);\n    });\n    spyOn(testScheduler, 'schedule').and.callThrough();\n\n    const obs = fromRef(itemRef, 'value', 'once', testScheduler);\n    expect(testScheduler.schedule).not.toHaveBeenCalled();\n\n    obs.subscribe(() => {\n      expect(testScheduler.schedule).toHaveBeenCalled();\n      // done();\n    }, err => {\n      console.error(err);\n      expect(false).withContext('Shouldnt error').toEqual(true);\n      // done();\n    }, () => {\n      expect(testScheduler.schedule).toHaveBeenCalled();\n      done();\n    });\n    testScheduler.flush();\n  });\n\n  it('should schedule completed and error correctly', done => {\n    const testScheduler = new TestScheduler((actual, expected) => {\n      expect(actual).toEqual(expected);\n    });\n    spyOn(testScheduler, 'schedule').and.callThrough();\n\n    // Error\n    const errorObservable = fromRef({\n        once: (event, snap, err) => err()\n      } as any,\n      'value',\n      'once',\n      testScheduler\n    );\n    errorObservable.subscribe(() => {\n      fail('Should not emit');\n    }, () => {\n      expect(testScheduler.schedule).toHaveBeenCalled();\n    }, () => {\n      fail('Should not complete');\n    });\n\n    testScheduler.flush();\n\n    // Completed\n    const itemRef = ref(rando());\n    itemRef.set(batch);\n\n    const scheduler = new ɵZoneScheduler(Zone.current.fork({\n      name: 'ExpectedZone'\n    }));\n    const completeObservable = fromRef(\n      itemRef,\n      'value',\n      'once',\n      scheduler\n    );\n    completeObservable.subscribe(\n      () => undefined,\n      () => fail('Should not error'),\n      () => expect(Zone.current.name).toEqual('ExpectedZone')\n    );\n    testScheduler.flush();\n    done();\n  });\n\n\n  it('it should should handle non-existence', (done) => {\n    const itemRef = ref(rando());\n    itemRef.set({});\n    const obs = fromRef(itemRef, 'value');\n    obs.pipe(take(1)).subscribe(change => {\n      expect(change.payload.exists()).toEqual(false);\n      expect(change.payload.val()).toEqual(null);\n    }).add(done);\n  });\n\n  it('once should complete', (done) => {\n    const itemRef = ref(rando());\n    itemRef.set(batch);\n    const obs = fromRef(itemRef, 'value', 'once');\n    obs.subscribe(() => undefined, () => undefined, done);\n  });\n\n  it('it should listen and then unsubscribe', (done) => {\n    const itemRef = ref(rando());\n    itemRef.set(batch);\n    const obs = fromRef(itemRef, 'value');\n    let count = 0;\n    const sub = obs.subscribe(() => {\n      count = count + 1;\n      // hard coding count to one will fail if the unsub\n      // doesn't actually unsub\n      expect(count).toEqual(1);\n      done();\n      sub.unsubscribe();\n      itemRef.push({ name: 'anotha one' });\n    });\n  });\n\n  describe('events', () => {\n\n    it('should stream back a child_added event', done => {\n      const itemRef = ref(rando());\n      itemRef.set(batch);\n      const obs = fromRef(itemRef, 'child_added');\n      let count = 0;\n      const sub = obs.subscribe(change => {\n        count = count + 1;\n        const { type, payload } = change;\n        expect(type).toEqual('child_added');\n        expect(payload.val()).toEqual(batch[payload.key]);\n        if (count === items.length) {\n          done();\n          sub.unsubscribe();\n          expect(sub.closed).toEqual(true);\n        }\n      });\n    });\n\n    it('should stream back a child_changed event', done => {\n      const itemRef = ref(rando());\n      itemRef.set(batch);\n      const obs = fromRef(itemRef, 'child_changed');\n      const name = 'look at what you made me do';\n      const key = items[0].key;\n      const sub = obs.subscribe(change => {\n        const { type, payload } = change;\n        expect(type).toEqual('child_changed');\n        expect(payload.key).toEqual(key);\n        expect(payload.val()).toEqual({ key, name });\n        sub.unsubscribe();\n        done();\n      });\n      itemRef.child(key).update({ name });\n    });\n\n    it('should stream back a child_removed event', done => {\n      const itemRef = ref(rando());\n      itemRef.set(batch);\n      const obs = fromRef(itemRef, 'child_removed');\n      const key = items[0].key;\n      const name = items[0].name;\n      const sub = obs.subscribe(change => {\n        const { type, payload } = change;\n        expect(type).toEqual('child_removed');\n        expect(payload.key).toEqual(key);\n        expect(payload.val()).toEqual({ key, name });\n        sub.unsubscribe();\n        done();\n      });\n      itemRef.child(key).remove();\n    });\n\n    it('should stream back a child_moved event', done => {\n      const itemRef = ref(rando());\n      itemRef.set(batch);\n      const obs = fromRef(itemRef, 'child_moved');\n      const key = items[2].key;\n      const name = items[2].name;\n      const sub = obs.subscribe(change => {\n        const { type, payload } = change;\n        expect(type).toEqual('child_moved');\n        expect(payload.key).toEqual(key);\n        expect(payload.val()).toEqual({ key, name });\n        sub.unsubscribe();\n        done();\n      });\n      itemRef.child(key).setPriority(-100, () => undefined);\n    });\n\n    it('should stream back a value event', (done: any) => {\n      const itemRef = ref(rando());\n      itemRef.set(batch);\n      const obs = fromRef(itemRef, 'value');\n      const sub = obs.subscribe(change => {\n        const { type, payload } = change;\n        expect(type).toEqual('value');\n        expect(payload.val()).toEqual(batch);\n        done();\n        sub.unsubscribe();\n        expect(sub.closed).toEqual(true);\n      });\n    });\n\n    it('should stream back query results', (done: any) => {\n      const itemRef = ref(rando());\n      itemRef.set(batch);\n      const query = itemRef.orderByChild('name').equalTo(items[0].name);\n      const obs = fromRef(query, 'value');\n      obs.subscribe(change => {\n        let child = null;\n        change.payload.forEach(snap => {\n          child = snap.val();\n          return true;\n        });\n        expect(child).toEqual(items[0]);\n        done();\n      });\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/database/observable/fromRef.ts",
    "content": "import { Observable, SchedulerLike, asyncScheduler } from 'rxjs';\nimport { map, share } from 'rxjs/operators';\nimport { AngularFireAction, DatabaseQuery, DatabaseSnapshot, ListenEvent } from '../interfaces';\n\ninterface SnapshotPrevKey<T> {\n  snapshot: DatabaseSnapshot<T>;\n  prevKey: string | null | undefined;\n}\n\n/**\n * Create an observable from a Database Reference or Database Query.\n * @param ref Database Reference\n * @param event Listen event type ('value', 'added', 'changed', 'removed', 'moved')\n * @param listenType 'on' or 'once'\n * @param scheduler - Rxjs scheduler\n */\nexport function fromRef<T>(ref: DatabaseQuery,\n                           event: ListenEvent,\n                           listenType = 'on',\n                           scheduler: SchedulerLike = asyncScheduler\n): Observable<AngularFireAction<DatabaseSnapshot<T>>> {\n  return new Observable<SnapshotPrevKey<T>>(subscriber => {\n    let fn: any = null;\n    fn = ref[listenType](event, (snapshot, prevKey) => {\n      scheduler.schedule(() => {\n        subscriber.next({ snapshot, prevKey });\n      });\n      if (listenType === 'once') {\n        scheduler.schedule(() => subscriber.complete());\n      }\n    }, err => {\n      scheduler.schedule(() => subscriber.error(err));\n    });\n\n    if (listenType === 'on') {\n      return {\n        unsubscribe() {\n          if (fn != null) {\n            ref.off(event, fn);\n          }\n        }\n      };\n    } else {\n      return {\n        // eslint-disable-next-line @typescript-eslint/no-empty-function\n        unsubscribe() {\n        }\n      };\n    }\n  }).pipe(\n    map(payload => {\n      const { snapshot, prevKey } = payload;\n      let key: string | null = null;\n      if (snapshot.exists()) {\n        key = snapshot.key;\n      }\n      return { type: event, payload: snapshot, prevKey, key };\n    }),\n    share()\n  );\n}\n"
  },
  {
    "path": "src/compat/database/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/database/public_api.ts",
    "content": "export * from './database';\nexport * from './list/changes';\nexport * from './list/create-reference';\nexport * from './list/snapshot-changes';\nexport * from './list/state-changes';\nexport * from './list/audit-trail';\nexport * from './observable/fromRef';\nexport * from './database.module';\n"
  },
  {
    "path": "src/compat/database/utils.spec.ts",
    "content": "import * as utils from './utils';\n\ndescribe('utils', () => {\n\n  describe('isString', () => {\n\n    it('should be able to properly detect a string', () => {\n      const str = 'oh hai';\n      const notStr = 101;\n      const bool = true;\n      const nul = null;\n      const obj = {};\n      const fn = () => undefined;\n      const undef = undefined;\n      expect(utils.isString(str)).toBe(true);\n      expect(utils.isString(notStr)).toBe(false);\n      expect(utils.isString(bool)).toBe(false);\n      expect(utils.isString(nul)).toBe(false);\n      expect(utils.isString(obj)).toBe(false);\n      expect(utils.isString(fn)).toBe(false);\n      expect(utils.isString(undef)).toBe(false);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/database/utils.ts",
    "content": "import firebase from 'firebase/compat/app';\nimport { DatabaseReference, FirebaseOperation, FirebaseOperationCases, PathReference } from './interfaces';\n\nexport function isString(value: any): boolean {\n  return typeof value === 'string';\n}\n\nexport function isFirebaseDataSnapshot(value: any): boolean {\n  return typeof value.exportVal === 'function';\n}\n\nexport function isNil(obj: any): boolean {\n  return obj === undefined || obj === null;\n}\n\nexport function isFirebaseRef(value: any): boolean {\n  return typeof value.set === 'function';\n}\n\n/**\n * Returns a database reference given a Firebase App and an\n * absolute or relative path.\n * @param database - Firebase Database\n * @param pathRef - Database path, relative or absolute\n */\nexport function getRef(database: firebase.database.Database, pathRef: PathReference): DatabaseReference {\n  // if a db ref was passed in, just return it\n  return isFirebaseRef(pathRef) ? pathRef as DatabaseReference\n    : database.ref(pathRef as string);\n}\n\nexport function checkOperationCases(item: FirebaseOperation, cases: FirebaseOperationCases): Promise<void> {\n  if (isString(item)) {\n    return cases.stringCase();\n  } else if (isFirebaseRef(item)) {\n    return cases.firebaseCase();\n  } else if (isFirebaseDataSnapshot(item)) {\n    return cases.snapshotCase();\n  }\n  throw new Error(`Expects a string, snapshot, or reference. Got: ${typeof item}`);\n}\n"
  },
  {
    "path": "src/compat/firebase.app.module.ts",
    "content": "import {\n  Inject, InjectionToken, ModuleWithProviders, VERSION as NG_VERSION, NgModule, NgZone, Optional, PLATFORM_ID, isDevMode\n} from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport { FirebaseAppSettings, FirebaseOptions } from 'firebase/app';\nimport firebase from 'firebase/compat/app';\nimport { FirebaseApp } from './firebase.app';\n\nexport const FIREBASE_OPTIONS = new InjectionToken<FirebaseOptions>('angularfire2.app.options');\nexport const FIREBASE_APP_NAME = new InjectionToken<string | undefined>('angularfire2.app.name');\n\n\nexport function ɵfirebaseAppFactory(options: FirebaseOptions, zone: NgZone, nameOrConfig?: string | FirebaseAppSettings | null) {\n  const name = typeof nameOrConfig === 'string' && nameOrConfig || '[DEFAULT]';\n  const config = typeof nameOrConfig === 'object' && nameOrConfig || {};\n  config.name = config.name || name;\n  // Added any due to some inconsistency between @firebase/app and firebase types\n  const existingApp = firebase.apps.find(app => app && app.name === config.name);\n  // We support FirebaseConfig, initializeApp's public type only accepts string; need to cast as any\n  // Could be solved with https://github.com/firebase/firebase-js-sdk/pull/1206\n  const app = (existingApp || zone.runOutsideAngular(() => firebase.initializeApp(options, config as any)));\n  try {\n    if (JSON.stringify(options) !== JSON.stringify(app.options)) {\n      const hmr = !!(module as any).hot;\n      log('error', `${app.name} Firebase App already initialized with different options${hmr ? ', you may need to reload as Firebase is not HMR aware.' : '.'}`);\n    }\n  } catch (_) { /* empty */ }\n  return new FirebaseApp(app);\n}\n\nconst log = (level: 'log' | 'error' | 'info' | 'warn', ...args: any) => {\n  if (isDevMode() && typeof console !== 'undefined') {\n    // eslint-disable-next-line no-console\n    console[level](...args);\n  }\n};\n\nconst FIREBASE_APP_PROVIDER = {\n  provide: FirebaseApp,\n  useFactory: ɵfirebaseAppFactory,\n  deps: [\n    FIREBASE_OPTIONS,\n    NgZone,\n    [new Optional(), FIREBASE_APP_NAME]\n  ]\n};\n\n@NgModule({\n  providers: [FIREBASE_APP_PROVIDER]\n})\nexport class AngularFireModule {\n  static initializeApp(options: FirebaseOptions, nameOrConfig?: string | FirebaseAppSettings): ModuleWithProviders<AngularFireModule> {\n    return {\n      ngModule: AngularFireModule,\n      providers: [\n        { provide: FIREBASE_OPTIONS, useValue: options },\n        { provide: FIREBASE_APP_NAME, useValue: nameOrConfig }\n      ]\n    };\n  }\n\n  constructor(@Inject(PLATFORM_ID) platformId: object) {\n    firebase.registerVersion('angularfire', VERSION.full, 'core');\n    firebase.registerVersion('angularfire', VERSION.full, 'app-compat');\n    // eslint-disable-next-line @typescript-eslint/no-base-to-string\n    firebase.registerVersion('angular', NG_VERSION.full, platformId.toString());\n  }\n}\n"
  },
  {
    "path": "src/compat/firebase.app.ts",
    "content": "import firebase from 'firebase/compat/app';\n\n \nexport interface FirebaseApp extends firebase.app.App {}\n\nexport class FirebaseApp {\n  constructor(app: firebase.app.App) {\n    return app;\n  }\n}\n"
  },
  {
    "path": "src/compat/firestore/collection/changes.ts",
    "content": "import firebase from 'firebase/compat/app';\nimport { Observable, SchedulerLike } from 'rxjs';\nimport { distinctUntilChanged, map, pairwise, scan, startWith } from 'rxjs/operators';\nimport { Action, DocumentChange, DocumentChangeAction, DocumentChangeType, Query, QuerySnapshot } from '../interfaces';\nimport { fromCollectionRef } from '../observable/fromRef';\n\n\ntype ActionTupe = [Action<QuerySnapshot<firebase.firestore.DocumentData>>, Action<QuerySnapshot<firebase.firestore.DocumentData>>]\n/**\n * Return a stream of document changes on a query. These results are not in sort order but in\n * order of occurence.\n */\nexport function docChanges<T>(query: Query, scheduler?: SchedulerLike): Observable<DocumentChangeAction<T>[]> {\n  return fromCollectionRef(query, scheduler)\n    .pipe(\n      startWith<Action<QuerySnapshot<firebase.firestore.DocumentData>>, undefined>(undefined),\n      pairwise(),\n      map((actionTuple: ActionTupe) => {\n        const [priorAction, action] = actionTuple;\n        const docChanges = action.payload.docChanges();\n        const actions = docChanges.map(change => ({ type: change.type, payload: change }));\n        // the metadata has changed from the prior emission\n        if (priorAction && JSON.stringify(priorAction.payload.metadata) !== JSON.stringify(action.payload.metadata)) {\n          // go through all the docs in payload and figure out which ones changed\n          action.payload.docs.forEach((currentDoc, currentIndex) => {\n            const docChange = docChanges.find(d => d.doc.ref.isEqual(currentDoc.ref));\n            const priorDoc = priorAction?.payload.docs.find(d => d.ref.isEqual(currentDoc.ref));\n            if (docChange && JSON.stringify(docChange.doc.metadata) === JSON.stringify(currentDoc.metadata) ||\n              !docChange && priorDoc && JSON.stringify(priorDoc.metadata) === JSON.stringify(currentDoc.metadata)) {\n              // document doesn't appear to have changed, don't log another action\n            } else {\n              // since the actions are processed in order just push onto the array\n              actions.push({\n                type: 'modified',\n                payload: {\n                  oldIndex: currentIndex,\n                  newIndex: currentIndex,\n                  type: 'modified',\n                  doc: currentDoc\n                }\n              });\n            }\n          });\n        }\n        return actions as DocumentChangeAction<T>[];\n      }),\n  );\n}\n\n/**\n * Return a stream of document changes on a query. These results are in sort order.\n */\nexport function sortedChanges<T>(\n  query: Query,\n  events: DocumentChangeType[],\n  scheduler?: SchedulerLike): Observable<DocumentChangeAction<T>[]> {\n  return docChanges<T>(query, scheduler)\n    .pipe(\n      scan((current, changes) => combineChanges<T>(current, changes.map(it => it.payload), events), []),\n      distinctUntilChanged(), // cut down on unneed change cycles\n      map(changes => changes.map(c => ({ type: c.type, payload: c } as DocumentChangeAction<T>))));\n}\n\n/**\n * Combines the total result set from the current set of changes from an incoming set\n * of changes.\n */\nexport function combineChanges<T>(current: DocumentChange<T>[], changes: DocumentChange<T>[], events: DocumentChangeType[]) {\n  changes.forEach(change => {\n    // skip unwanted change types\n    if (events.includes(change.type)) {\n      current = combineChange(current, change);\n    }\n  });\n  return current;\n}\n\n/**\n * Splice arguments on top of a sliced array, to break top-level ===\n * this is useful for change-detection\n */\nfunction sliceAndSplice<T>(\n  original: T[],\n  start: number,\n  deleteCount: number,\n  ...args: T[]\n): T[] {\n  const returnArray = original.slice();\n  returnArray.splice(start, deleteCount, ...args);\n  return returnArray;\n}\n\n/**\n * Creates a new sorted array from a new change.\n * Build our own because we allow filtering of action types ('added', 'removed', 'modified') before scanning\n * and so we have greater control over change detection (by breaking ===)\n */\nexport function combineChange<T>(combined: DocumentChange<T>[], change: DocumentChange<T>): DocumentChange<T>[] {\n  switch (change.type) {\n    case 'added':\n      if (combined[change.newIndex]?.doc.ref.isEqual(change.doc.ref)) {\n        // Not sure why the duplicates are getting fired\n      } else {\n        return sliceAndSplice(combined, change.newIndex, 0, change);\n      }\n      break;\n    case 'modified':\n      if (combined[change.oldIndex] == null || combined[change.oldIndex].doc.ref.isEqual(change.doc.ref)) {\n        // When an item changes position we first remove it\n        // and then add it's new position\n        if (change.oldIndex !== change.newIndex) {\n          const copiedArray = combined.slice();\n          copiedArray.splice(change.oldIndex, 1);\n          copiedArray.splice(change.newIndex, 0, change);\n          return copiedArray;\n        } else {\n          return sliceAndSplice(combined, change.newIndex, 1, change);\n        }\n      }\n      break;\n    case 'removed':\n      if (combined[change.oldIndex]?.doc.ref.isEqual(change.doc.ref)) {\n        return sliceAndSplice(combined, change.oldIndex, 1);\n      }\n      break;\n  }\n  return combined;\n}\n"
  },
  {
    "path": "src/compat/firestore/collection/collection.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFirestore, AngularFirestoreCollection, AngularFirestoreModule, CollectionReference, QueryFn, USE_EMULATOR } from '@angular/fire/compat/firestore';\nimport { BehaviorSubject } from 'rxjs';\nimport { skip, switchMap, take } from 'rxjs/operators';\nimport { COMMON_CONFIG, firestoreEmulatorPort } from '../../../test-config';\nimport { rando } from '../../../utils';\nimport {\n  FAKE_STOCK_DATA,\n  Stock,\n  createRandomStocks,\n  delayAdd,\n  delayDelete,\n  delayUpdate,\n  randomName\n} from '../utils.spec';\n\nimport 'firebase/compat/firestore';\n\nasync function collectionHarness(afs: AngularFirestore, items: number, queryFn?: QueryFn<Stock>) {\n  const randomCollectionName = randomName(afs.firestore);\n  const ref = afs.firestore.collection(`${randomCollectionName}`) as CollectionReference<Stock>;\n  if (!queryFn) {\n    queryFn = (ref) => ref;\n  }\n  const stocks = new AngularFirestoreCollection<Stock>(ref, queryFn(ref), afs);\n  const names = await createRandomStocks(afs.firestore, ref, items);\n  return { randomCollectionName, ref, stocks, names };\n}\n\ndescribe('AngularFirestoreCollection', () => {\n\n  \n  let afs: AngularFirestore;\n\n  beforeEach(() => {\n    pending(\"These are pretty broken, investigate.\");\n\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFirestoreModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', firestoreEmulatorPort] }\n      ]\n    });\n\n    afs = TestBed.inject(AngularFirestore);\n  });\n\n  describe('valueChanges()', () => {\n\n    it('should get unwrapped snapshot', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.valueChanges()).subscribe(data => {\n          // unsub immediately as we will be deleting data at the bottom\n          // and that will trigger another subscribe callback and fail\n          // the test\n          sub.unsubscribe();\n          // We added four things. This should be four.\n          // This could not be four if the batch failed or\n          // if the collection state is altered during a test run\n          expect(data.length).toEqual(ITEMS);\n          data.forEach(stock => {\n            // We used the same piece of data so they should all equal\n            expect(stock).toEqual(FAKE_STOCK_DATA);\n          });\n          done();\n        });\n      })();\n    });\n\n    /* FLAKE? timing out\n        it('should optionally map the doc ID to the emitted data object', done => {\n          const ITEMS = 1;\n          const { ref, stocks, names } = await collectionHarness(afs, ITEMS);\n          const idField = 'myCustomID';\n          const sub = stocks.valueChanges({idField}).subscribe(data => {\n            sub.unsubscribe();\n            const stock = data[0];\n            expect(stock[idField]).toBeDefined();\n            expect(stock).toEqual(jasmine.objectContaining(FAKE_STOCK_DATA));\n            deleteThemAll(names, ref).then(done).catch(fail);\n          })\n        });*/\n\n    it('should handle multiple subscriptions (hot)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.valueChanges());\n        const sub = changes.subscribe(() => undefined);\n        sub.add(\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            sub.unsubscribe();\n            done();\n          })\n        );\n      })();\n    });\n\n    it('should handle multiple subscriptions (warm)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.valueChanges());\n        changes.pipe(take(1)).subscribe(() => undefined).add(() => {\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            done();\n          });\n        });\n      })();\n    });\n\n    it('should handle dynamic queries that return empty sets', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n\n        const pricefilter$ = new BehaviorSubject<number | null>(null);\n        const randomCollectionName = randomName(afs.firestore);\n        const ref = afs.firestore.collection(`${randomCollectionName}`);\n        await createRandomStocks(afs.firestore, ref, ITEMS);\n        const sub = pricefilter$.pipe(switchMap(price => {\n          return TestBed.runInInjectionContext(() => afs.collection(randomCollectionName, ref => price ? ref.where('price', '==', price) : ref).valueChanges());\n        })).subscribe(data => {\n          count = count + 1;\n          // the first time should all be 'added'\n          if (count === 1) {\n            expect(data.length).toEqual(ITEMS);\n            pricefilter$.next(-1);\n          }\n          // on the second round, we should have filtered out everything\n          if (count === 2) {\n            expect(data.length).toEqual(0);\n            sub.unsubscribe();\n            done();\n          }\n        });\n      })();\n    });\n\n  });\n\n  describe('snapshotChanges()', () => {\n\n    it('should listen to all snapshotChanges() by default', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n        const { stocks, names } = await collectionHarness(afs, ITEMS);\n        const firstName = names[0];\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges()).subscribe(data => {\n          count = count + 1;\n          // the first time should all be 'added'\n          if (count === 1) {\n            // make an update\n            stocks.doc(firstName).update({ price: 2 });\n          }\n          // on the second round, make sure the array is still the same\n          // length but the updated item is now modified\n          if (count === 2) {\n            expect(data.length).toEqual(ITEMS);\n            const change = data.find(x => x.payload.doc.id === firstName);\n            expect(change.type).toEqual('modified');\n            sub.unsubscribe();\n            done();\n          }\n        });\n      })();\n    });\n\n    it('should handle multiple subscriptions (hot)', done => {\n      async function setup() {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes$ = TestBed.runInInjectionContext(() => stocks.snapshotChanges());\n        const sub = changes$.subscribe(() => undefined);\n        sub.add(\n          changes$.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            sub.unsubscribe();\n            done();\n          })\n        );\n      }\n      setup()\n    });\n\n    it('should handle multiple subscriptions (warm)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.snapshotChanges());\n        changes.pipe(take(1)).subscribe(() => undefined).add(() => {\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            done();\n          });\n        });\n      })();\n    });\n\n    it('should update order on queries', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n        let firstIndex = 0;\n        const { stocks, names } =\n          await collectionHarness(afs, ITEMS, ref => ref.orderBy('price', 'desc'));\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges()).subscribe(data => {\n          count = count + 1;\n          // the first time should all be 'added'\n          if (count === 1) {\n            // make an update\n            firstIndex = data.find(d => d.payload.doc.id === names[0]).payload.newIndex;\n            stocks.doc(names[0]).update({ price: 2 });\n          }\n          // on the second round, make sure the array is still the same\n          // length but the updated item is now modified\n          if (count === 2) {\n            expect(data.length).toEqual(ITEMS);\n            const change = data.find(x => x.payload.doc.id === names[0]);\n            expect(change.type).toEqual('modified');\n            expect(change.payload.oldIndex).toEqual(firstIndex);\n            sub.unsubscribe();\n            done();\n          }\n        });\n      })();\n    });\n\n    it('should be able to filter snapshotChanges() types - modified', done => {\n      pending(\"TODO(jamesdaniels) find out why this is flaking with SDK v11\");\n      (async () => {\n        const ITEMS = 10;\n        const { stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges(['modified'])).pipe(skip(1)).subscribe(data => {\n          sub.unsubscribe();\n          const change = data.find(x => x.payload.doc.id === names[0]);\n          expect(data.length).toEqual(1);\n          expect(change.payload.doc.data().price).toEqual(2);\n          expect(change.type).toEqual('modified');\n          done();\n        });\n\n        delayUpdate(stocks, names[0], { price: 2 });\n      })();\n    });\n\n    it('should be able to filter snapshotChanges() types - added', done => {\n      (async () => {\n        const ITEMS = 10;\n        const { ref, stocks } = await collectionHarness(afs, ITEMS);\n\n        const nextId = ref.doc('a').id;\n\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges(['added'])).pipe(skip(1)).subscribe(data => {\n          sub.unsubscribe();\n          const change = data.find(x => x.payload.doc.id === nextId);\n          expect(data.length).toEqual(ITEMS + 1);\n          expect(change.payload.doc.data().price).toEqual(2);\n          expect(change.type).toEqual('added');\n          done();\n        });\n\n        delayAdd(stocks, nextId, { price: 2 });\n      })();\n    });\n\n    /* TODO(jamesdaniels): revisit this now that we have metadata\n    it('should be able to filter snapshotChanges() types - added/modified', done => {\n      (async () => {\n        const ITEMS = 10;\n        const harness = await collectionHarness(afs, ITEMS);\n        const { ref, stocks } = harness;\n        let names = harness.names;\n\n        const nextId = ref.doc('a').id;\n        let count = 0;\n\n        stocks.snapshotChanges(['added', 'modified']).pipe(skip(1), take(2)).subscribe(data => {\n          count += 1;\n          if (count === 1) {\n            const change = data.filter(x => x.payload.doc.id === nextId)[0];\n            expect(data.length).toEqual(ITEMS + 1);\n            expect(change.payload.doc.data().price).toEqual(2);\n            expect(change.type).toEqual('added');\n            delayUpdate(stocks, names[0], { price: 2 });\n          }\n          if (count === 2) {\n            const change = data.filter(x => x.payload.doc.id === names[0])[0];\n            expect(data.length).toEqual(ITEMS + 1);\n            expect(change.payload.doc.data().price).toEqual(2);\n            expect(change.type).toEqual('modified');\n          }\n        }).add(() => {\n          deleteThemAll(names, ref)\n              .then(() => {\n                done()\n              })\n              .catch(() => {\n                done.fail()\n              });\n        });\n\n        names = names.concat([nextId]);\n        delayAdd(stocks, nextId, { price: 2 });\n      })();\n    });\n    */\n\n    it('should be able to filter snapshotChanges() types - removed', done => {\n      (async () => {\n        const ITEMS = 10;\n        const { stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges(['added', 'removed'])).pipe(skip(1)).subscribe(data => {\n          sub.unsubscribe();\n          const change = data.filter(x => x.payload.doc.id === names[0]);\n          expect(data.length).toEqual(ITEMS - 1);\n          expect(change.length).toEqual(0);\n          done();\n        });\n\n        delayDelete(stocks, names[0], 400);\n      })();\n    });\n\n  });\n\n  describe('stateChanges()', () => {\n\n    it('should get stateChanges() updates', done => {\n      (async () => {\n        const ITEMS = 10;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.stateChanges()).subscribe(data => {\n          // unsub immediately as we will be deleting data at the bottom\n          // and that will trigger another subscribe callback and fail\n          // the test\n          sub.unsubscribe();\n          // We added ten things. This should be ten.\n          // This could not be ten if the batch failed or\n          // if the collection state is altered during a test run\n          expect(data.length).toEqual(ITEMS);\n          data.forEach(action => {\n            // We used the same piece of data so they should all equal\n            expect(action.payload.doc.data()).toEqual(FAKE_STOCK_DATA);\n          });\n          done();\n        });\n      })();\n    });\n\n    it('should listen to all stateChanges() by default', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n        const { stocks, names } = await collectionHarness(afs, ITEMS);\n        TestBed.runInInjectionContext(() => stocks.stateChanges()).subscribe(data => {\n          count = count + 1;\n          if (count === 1) {\n            stocks.doc(names[0]).update({ price: 2 });\n          }\n          if (count === 2) {\n            expect(data.length).toEqual(1);\n            expect(data[0].type).toEqual('modified');\n            done();\n          }\n        });\n      })();\n    });\n\n    it('should handle multiple subscriptions (hot)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.stateChanges());\n        const sub = changes.subscribe(() => undefined);\n        sub.add(\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            sub.unsubscribe();\n            done();\n          })\n        );\n      })();\n    });\n\n    it('should handle multiple subscriptions (warm)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.stateChanges());\n        changes.pipe(take(1)).subscribe(() => undefined).add(() => {\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            done();\n          });\n        });\n      })();\n    });\n\n    it('should be able to filter stateChanges() types - modified', done => {\n      pending(\"TODO(jamesdaniels) find out why this is flaking with SDK v11\");\n      (async () => {\n        const ITEMS = 10;\n        const { stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.stateChanges(['modified'])).pipe(skip(1), take(1)).subscribe(data => {\n          sub.unsubscribe();\n          expect(data.length).toEqual(1);\n          expect(data[0].payload.doc.data().price).toEqual(2);\n          expect(data[0].type).toEqual('modified');\n          done();\n        });\n\n        delayUpdate(stocks, names[0], { price: 2 });\n      })();\n    });\n\n    it('should be able to filter stateChanges() types - added', done => {\n      (async () => {\n        const ITEMS = 10;\n\n        const { ref, stocks } = await collectionHarness(afs, ITEMS);\n        \n        const sub = TestBed.runInInjectionContext(() => stocks.stateChanges(['added'])).pipe(skip(1)).subscribe(data => {\n          sub.unsubscribe();\n          expect(data.length).toEqual(1);\n          expect(data[0].payload.doc.data().price).toEqual(2);\n          expect(data[0].type).toEqual('added');\n          done();\n        });\n\n        const nextId = ref.doc('a').id;\n        delayAdd(stocks, nextId, { price: 2 });\n      })();\n    });\n\n    it('should be able to filter stateChanges() types - removed', done => {\n      (async () => {\n        const ITEMS = 10;\n        const { stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.stateChanges(['removed'])).pipe(skip(1), take(1)).subscribe(data => {\n          sub.unsubscribe();\n          expect(data.length).toEqual(1);\n          expect(data[0].type).toEqual('removed');\n          done();\n        });\n\n        delayDelete(stocks, names[0], 400);\n      })();\n    });\n\n    it('stateChanges() should emit on empty collection', done => {\n      TestBed.runInInjectionContext(() => afs.collection('EMPTY_COLLECTION').stateChanges()).pipe(take(1)).subscribe(data => {\n        expect(data.length).toEqual(0);\n        done();\n      });\n    });\n\n    it('stateChanges() w/filter should emit on empty collection', done => {\n      TestBed.runInInjectionContext(() => afs.collection('EMPTY_COLLECTION').stateChanges(['added'])).pipe(take(1)).subscribe(data => {\n        expect(data.length).toEqual(0);\n        done();\n      });\n    });\n\n  });\n\n  describe('auditTrail()', () => {\n    it('should listen to all events for auditTrail() by default', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n        const { stocks, names } = await collectionHarness(afs, ITEMS);\n        const sub =TestBed.runInInjectionContext(() => stocks.auditTrail()).subscribe(data => {\n          count = count + 1;\n          if (count === 1) {\n            stocks.doc(names[0]).update({ price: 2 });\n          }\n          if (count === 2) {\n            sub.unsubscribe();\n            expect(data.length).toEqual(ITEMS + 1);\n            expect(data[data.length - 1].type).toEqual('modified');\n            done();\n          }\n        });\n      })();\n    });\n\n    it('should be able to filter auditTrail() types - removed', done => {\n      (async () => {\n        const ITEMS = 10;\n        const { stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.auditTrail(['removed'])).pipe(skip(1), take(1)).subscribe(data => {\n          sub.unsubscribe();\n          expect(data.length).toEqual(1);\n          expect(data[0].type).toEqual('removed');\n          done();\n        });\n\n        delayDelete(stocks, names[0], 400);\n      })();\n    });\n  });\n\n});\n"
  },
  {
    "path": "src/compat/firestore/collection/collection.ts",
    "content": "import { EnvironmentInjector, inject } from '@angular/core';\nimport { pendingUntilEvent } from '@angular/core/rxjs-interop';\nimport firebase from 'firebase/compat/app';\nimport { Observable, from } from 'rxjs';\nimport { filter, map, pairwise, scan, startWith } from 'rxjs/operators';\nimport { AngularFirestoreDocument } from '../document/document';\nimport { AngularFirestore } from '../firestore';\nimport { CollectionReference, DocumentChangeAction, DocumentChangeType, DocumentData, DocumentReference, Query } from '../interfaces';\nimport { fromCollectionRef } from '../observable/fromRef';\nimport { docChanges, sortedChanges } from './changes';\n\ntype DocumentChangeTuple<T> = [DocumentChangeAction<T>[], DocumentChangeAction<T>[]];\n\nexport function validateEventsArray(events?: DocumentChangeType[]) {\n  if (!events || events.length === 0) {\n    events = ['added', 'removed', 'modified'];\n  }\n  return events;\n}\n\n/**\n * AngularFirestoreCollection service\n *\n * This class creates a reference to a Firestore Collection. A reference and a query are provided in\n * in the constructor. The query can be the unqueried reference if no query is desired.The class\n * is generic which gives you type safety for data update methods and data streaming.\n *\n * This class uses Symbol.observable to transform into Observable using Observable.from().\n *\n * This class is rarely used directly and should be created from the AngularFirestore service.\n *\n * Example:\n *\n * const collectionRef = firebase.firestore.collection('stocks');\n * const query = collectionRef.where('price', '>', '0.01');\n * const fakeStock = new AngularFirestoreCollection<Stock>(collectionRef, query);\n *\n * // NOTE!: the updates are performed on the reference not the query\n * await fakeStock.add({ name: 'FAKE', price: 0.01 });\n *\n * // Subscribe to changes as snapshots. This provides you data updates as well as delta updates.\n * fakeStock.valueChanges().subscribe(value => console.log(value));\n */\nexport class AngularFirestoreCollection<T = DocumentData> {\n  private readonly injector = inject(EnvironmentInjector);\n\n  /**\n   * The constructor takes in a CollectionReference and Query to provide wrapper methods\n   * for data operations and data streaming.\n   *\n   * Note: Data operation methods are done on the reference not the query. This means\n   * when you update data it is not updating data to the window of your query unless\n   * the data fits the criteria of the query. See the AssociatedRefence type for details\n   * on this implication.\n   */\n  constructor(\n    public readonly ref: CollectionReference<T>,\n    private readonly query: Query<T>,\n    private readonly afs: AngularFirestore) { }\n\n  /**\n   * Listen to the latest change in the stream. This method returns changes\n   * as they occur and they are not sorted by query order. This allows you to construct\n   * your own data structure.\n   */\n  stateChanges(events?: DocumentChangeType[]): Observable<DocumentChangeAction<T>[]> {\n    let source = docChanges<T>(this.query, this.afs.schedulers.outsideAngular);\n    if (events && events.length > 0) {\n      source = source.pipe(\n        map(actions => actions.filter(change => events.includes(change.type)))\n      );\n    }\n    return source.pipe(\n      // We want to filter out empty arrays, but always emit at first, so the developer knows\n      // that the collection has been resolve; even if it's empty\n      startWith<DocumentChangeAction<T>[], undefined>(undefined),\n      pairwise(),\n      filter(([prior, current]: DocumentChangeTuple<T>) => current.length > 0 || !prior),\n      map(([, current]) => current),\n      pendingUntilEvent(this.injector)\n    );\n  }\n\n  /**\n   * Create a stream of changes as they occur it time. This method is similar to stateChanges()\n   * but it collects each event in an array over time.\n   */\n  auditTrail(events?: DocumentChangeType[]): Observable<DocumentChangeAction<T>[]> {\n    return this.stateChanges(events).pipe(scan((current, action) => [...current, ...action], []));\n  }\n\n  /**\n   * Create a stream of synchronized changes. This method keeps the local array in sorted\n   * query order.\n   */\n  snapshotChanges(events?: DocumentChangeType[]): Observable<DocumentChangeAction<T>[]> {\n    const validatedEvents = validateEventsArray(events);\n    const scheduledSortedChanges$ = sortedChanges<T>(this.query, validatedEvents, this.afs.schedulers.outsideAngular);\n    return scheduledSortedChanges$.pipe(\n      pendingUntilEvent(this.injector)\n    );\n  }\n\n  /**\n   * Listen to all documents in the collection and its possible query as an Observable.\n   *\n   * If the `idField` option is provided, document IDs are included and mapped to the\n   * provided `idField` property name.\n   */\n  valueChanges(): Observable<T[]>;\n  // eslint-disable-next-line no-empty-pattern\n  valueChanges({}): Observable<T[]>;\n  valueChanges<K extends string>(options: {idField: K}): Observable<(T & Record<K, string>)[]>;\n  valueChanges<K extends string>(options: {idField?: K} = {}): Observable<T[]> {\n    return fromCollectionRef<T>(this.query, this.afs.schedulers.outsideAngular)\n      .pipe(\n        map(actions => actions.payload.docs.map(a => {\n          if (options.idField) {\n            return {\n              ...a.data() as any,\n              ...{ [options.idField]: a.id }\n            } as T & Record<K, string>;\n          } else {\n            return a.data();\n          }\n        })),\n        pendingUntilEvent(this.injector)\n      );\n  }\n\n  /**\n   * Retrieve the results of the query once.\n   */\n  get(options?: firebase.firestore.GetOptions) {\n    return from(this.query.get(options)).pipe(\n      pendingUntilEvent(this.injector)\n    );\n  }\n\n  /**\n   * Add data to a collection reference.\n   *\n   * Note: Data operation methods are done on the reference not the query. This means\n   * when you update data it is not updating data to the window of your query unless\n   * the data fits the criteria of the query.\n   */\n  add(data: T): Promise<DocumentReference<T>> {\n    return this.ref.add(data);\n  }\n\n  /**\n   * Create a reference to a single document in a collection.\n   */\n  doc<T2 = T>(path?: string): AngularFirestoreDocument<T2> {\n    // TODO is there a better way to solve this type issue\n    return new AngularFirestoreDocument(this.ref.doc(path) as any, this.afs);\n  }\n}\n"
  },
  {
    "path": "src/compat/firestore/collection-group/collection-group.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFirestore, AngularFirestoreCollectionGroup , AngularFirestoreModule, Query, QueryGroupFn, USE_EMULATOR } from '@angular/fire/compat/firestore';\nimport { BehaviorSubject } from 'rxjs';\nimport { skip, switchMap, take } from 'rxjs/operators';\nimport { COMMON_CONFIG, firestoreEmulatorPort } from '../../../test-config';\nimport { rando } from '../../../utils';\nimport {\n  FAKE_STOCK_DATA,\n  Stock,\n  createRandomStocks,\n  delayAdd,\n  delayDelete,\n  delayUpdate,\n  randomName\n} from '../utils.spec';\nimport 'firebase/compat/firestore';\n\nasync function collectionHarness(afs: AngularFirestore, items: number, queryGroupFn?: QueryGroupFn<Stock>) {\n  const randomCollectionName = randomName(afs.firestore);\n  const ref = TestBed.runInInjectionContext(() => afs.firestore.collection(`${randomCollectionName}`));\n  const firestore = afs.firestore;\n  const collectionGroup = TestBed.runInInjectionContext(() => firestore.collectionGroup(randomCollectionName)) as Query<Stock>;\n  const queryFn = queryGroupFn || (ref => ref);\n  const stocks = new AngularFirestoreCollectionGroup<Stock>(queryFn(collectionGroup), afs);\n  const names = await TestBed.runInInjectionContext(() => createRandomStocks(afs.firestore, ref, items));\n  return { randomCollectionName, ref, stocks, names };\n}\n\ndescribe('AngularFirestoreCollectionGroup', () => {\n  let afs: AngularFirestore;\n  \n  beforeEach(() => {\n    pending(\"These are pretty broken, investigate.\");\n\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFirestoreModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', firestoreEmulatorPort] }\n      ]\n    });\n\n    afs = TestBed.inject(AngularFirestore);\n  });\n\n  describe('valueChanges()', () => {\n\n    it('should get unwrapped snapshot', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.valueChanges()).subscribe(data => {\n          // unsub immediately as we will be deleting data at the bottom\n          // and that will trigger another subscribe callback and fail\n          // the test\n          sub.unsubscribe();\n          // We added four things. This should be four.\n          // This could not be four if the batch failed or\n          // if the collection state is altered during a test run\n          expect(data.length).toEqual(ITEMS);\n          data.forEach(stock => {\n            // We used the same piece of data so they should all equal\n            expect(stock).toEqual(FAKE_STOCK_DATA);\n          });\n          done();\n        });\n      })();\n    });\n\n    it('should handle multiple subscriptions (hot)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.valueChanges());\n        const sub = changes.subscribe(() => undefined);\n        sub.add(\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            sub.unsubscribe();\n            done();\n          })\n        );\n      })();\n    });\n\n    it('should handle multiple subscriptions (warm)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.valueChanges());\n        changes.pipe(take(1)).subscribe(() => undefined).add(() => {\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            done();\n          })\n        });\n      })();\n    });\n\n    it('should handle dynamic queries that return empty sets', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n\n        const pricefilter$ = new BehaviorSubject<number | null>(null);\n        const randomCollectionName = randomName(afs.firestore);\n        const ref = TestBed.runInInjectionContext(() => afs.firestore.collection(`${randomCollectionName}`));\n        await createRandomStocks(afs.firestore, ref, ITEMS);\n        const sub = pricefilter$.pipe(switchMap(price => {\n          return TestBed.runInInjectionContext(() => afs.collection(randomCollectionName, ref => price ? ref.where('price', '==', price) : ref).valueChanges());\n        })).subscribe(data => {\n          count = count + 1;\n          // the first time should all be 'added'\n          if (count === 1) {\n            expect(data.length).toEqual(ITEMS);\n            pricefilter$.next(-1);\n          }\n          // on the second round, we should have filtered out everything\n          if (count === 2) {\n            expect(data.length).toEqual(0);\n            sub.unsubscribe();\n            done();\n          }\n        });\n      })();\n    });\n\n    it('should return the document\\'s id along with the data if the idField option is provided.', done => {\n      (async () => {\n        const ITEMS = 4;\n        const DOC_ID = 'docId';\n        const { stocks } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.valueChanges({idField: DOC_ID})).subscribe(data => {\n          const allDocumentsHaveId = data.every(d => d.docId !== undefined);\n\n          expect(allDocumentsHaveId).toBe(true);\n          sub.unsubscribe();\n          done();\n        });\n      })();\n    });\n\n  });\n\n  describe('snapshotChanges()', () => {\n\n    it('should listen to all snapshotChanges() by default', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n        const { ref, stocks, names } = await collectionHarness(afs, ITEMS);\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges()).subscribe(data => {\n          count = count + 1;\n          // the first time should all be 'added'\n          if (count === 1) {\n            // make an update\n            ref.doc(names[0]).update({ price: 2 });\n          }\n          // on the second round, make sure the array is still the same\n          // length but the updated item is now modified\n          if (count === 2) {\n            expect(data.length).toEqual(ITEMS);\n            const change = data.find(x => x.payload.doc.id === names[0]);\n            expect(change.type).toEqual('modified');\n            sub.unsubscribe();\n            done();\n          }\n        });\n      })();\n    });\n\n    it('should handle multiple subscriptions (hot)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.snapshotChanges());\n        const sub = changes.subscribe(() => undefined);\n        sub.add(\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            sub.unsubscribe();\n            done();\n          })\n        );\n      })();\n    });\n\n    it('should handle multiple subscriptions (warm)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.snapshotChanges());\n        changes.pipe(take(1)).subscribe(() => undefined).add(() => {\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            done();\n          });\n        });\n      })();\n    });\n\n    it('should update order on queries', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n        let firstIndex = 0;\n        const { ref, stocks, names } =\n          await collectionHarness(afs, ITEMS, ref => ref.orderBy('price', 'desc'));\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges()).subscribe(data => {\n          count = count + 1;\n          // the first time should all be 'added'\n          if (count === 1) {\n            // make an update\n            firstIndex = data.find(d => d.payload.doc.id === names[0]).payload.newIndex;\n            ref.doc(names[0]).update({ price: 2 });\n          }\n          // on the second round, make sure the array is still the same\n          // length but the updated item is now modified\n          if (count === 2) {\n            expect(data.length).toEqual(ITEMS);\n            const change = data.find(x => x.payload.doc.id === names[0]);\n            expect(change.type).toEqual('modified');\n            expect(change.payload.oldIndex).toEqual(firstIndex);\n            sub.unsubscribe();\n            done();\n          }\n        });\n      })();\n    });\n\n    it('should be able to filter snapshotChanges() types - modified', done => {\n      pending(\"TODO(jamesdaniels) find out why this is flaking with SDK v11\");\n      (async () => {\n        const ITEMS = 10;\n        const { ref, stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges(['modified'])).pipe(skip(1)).subscribe(data => {\n          sub.unsubscribe();\n          const change = data.find(x => x.payload.doc.id === names[0]);\n          expect(data.length).toEqual(1);\n          expect(change.payload.doc.data().price).toEqual(2);\n          expect(change.type).toEqual('modified');\n          done();\n        });\n\n        delayUpdate(ref, names[0], { price: 2 });\n      })();\n    });\n\n    it('should be able to filter snapshotChanges() types - added', done => {\n      (async () => {\n        const ITEMS = 10;\n        const harness = await collectionHarness(afs, ITEMS);\n        const { randomCollectionName, ref, stocks } = harness;\n        let { names } = harness;\n        const nextId = ref.doc('a').id;\n\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges(['added'])).pipe(skip(1)).subscribe(data => {\n          sub.unsubscribe();\n          const change = data.find(x => x.payload.doc.id === nextId);\n          expect(data.length).toEqual(ITEMS + 1);\n          expect(change.payload.doc.data().price).toEqual(2);\n          expect(change.type).toEqual('added');\n          done();\n        });\n\n\n        names = names.concat([nextId]);\n        // TODO these two add tests are the only one really testing collection-group queries\n        //      should flex more, maybe split the stocks between more than one collection\n        delayAdd(ref.doc(names[0]).collection(randomCollectionName), nextId, { price: 2 });\n      })();\n    });\n\n    it('should be able to filter snapshotChanges() types - added w/same id', done => {\n      (async () => {\n        const ITEMS = 10;\n        const { randomCollectionName, ref, stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges(['added'])).pipe(skip(1)).subscribe(data => {\n          sub.unsubscribe();\n          const change = data.filter(x => x.payload.doc.id === names[0])[1];\n          expect(data.length).toEqual(ITEMS + 1);\n          expect(change.payload.doc.data().price).toEqual(3);\n          expect(change.type).toEqual('added');\n          done();\n        });\n\n        delayAdd(ref.doc(names[0]).collection(randomCollectionName), names[0], { price: 3 });\n      })();\n    });\n\n    /* TODO(jamesdaniels): revisit this test with metadata changes, need to do some additional skips\n    it('should be able to filter snapshotChanges() types - added/modified', done => {\n      (async () => {\n        const ITEMS = 10;\n\n        const harness = await collectionHarness(afs, ITEMS);\n        const { ref, stocks } = harness;\n        let { names } = harness;\n\n        const nextId = ref.doc('a').id;\n        let count = 0;\n\n        stocks.snapshotChanges(['added', 'modified']).pipe(skip(1), take(2)).subscribe(data => {\n          count += 1;\n          if (count === 1) {\n            const change = data.filter(x => x.payload.doc.id === nextId)[0];\n            expect(data.length).toEqual(ITEMS + 1);\n            expect(change.payload.doc.data().price).toEqual(2);\n            expect(change.type).toEqual('added');\n            delayUpdate(ref, names[0], { price: 2 });\n          }\n          if (count === 2) {\n            const change = data.filter(x => x.payload.doc.id === names[0])[0];\n            expect(data.length).toEqual(ITEMS + 1);\n            expect(change.payload.doc.data().price).toEqual(2);\n            expect(change.type).toEqual('modified');\n          }\n        }).add(() => {\n          deleteThemAll(names, ref)\n              .then(() => {\n                done()\n              })\n              .catch(() => {\n                done.fail()\n              });\n        });\n\n        names = names.concat([nextId]);\n        delayAdd(ref, nextId, { price: 2 });\n      })();\n    });\n    */\n\n    it('should be able to filter snapshotChanges() types - removed', done => {\n      (async () => {\n\n        const ITEMS = 10;\n        const { ref, stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.snapshotChanges(['added', 'removed'])).pipe(skip(1)).subscribe(data => {\n          sub.unsubscribe();\n          const change = data.filter(x => x.payload.doc.id === names[0]);\n          expect(data.length).toEqual(ITEMS - 1);\n          expect(change.length).toEqual(0);\n          done();\n        });\n\n        delayDelete(ref, names[0], 400);\n      })();\n    });\n\n  });\n\n  describe('stateChanges()', () => {\n\n    it('should get stateChanges() updates', done => {\n      (async () => {\n        const ITEMS = 10;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.stateChanges()).subscribe(data => {\n          // unsub immediately as we will be deleting data at the bottom\n          // and that will trigger another subscribe callback and fail\n          // the test\n          sub.unsubscribe();\n          // We added ten things. This should be ten.\n          // This could not be ten if the batch failed or\n          // if the collection state is altered during a test run\n          expect(data.length).toEqual(ITEMS);\n          data.forEach(action => {\n            // We used the same piece of data so they should all equal\n            expect(action.payload.doc.data()).toEqual(FAKE_STOCK_DATA);\n          });\n          done();\n        });\n      })();\n    });\n\n    it('should listen to all stateChanges() by default', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n        const { ref, stocks, names } = await collectionHarness(afs, ITEMS);\n        TestBed.runInInjectionContext(() => stocks.stateChanges()).subscribe(data => {\n          count = count + 1;\n          if (count === 1) {\n            ref.doc(names[0]).update({ price: 2 });\n          }\n          if (count === 2) {\n            expect(data.length).toEqual(1);\n            expect(data[0].type).toEqual('modified');\n            done();\n          }\n        });\n      })();\n    });\n\n    it('should handle multiple subscriptions (hot)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.stateChanges());\n        const sub = changes.subscribe(() => undefined);\n        sub.add(\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            sub.unsubscribe();\n            done();\n          })\n        );\n      })();\n    });\n\n    it('should handle multiple subscriptions (warm)', done => {\n      (async () => {\n        const ITEMS = 4;\n        const { stocks } = await collectionHarness(afs, ITEMS);\n        const changes = TestBed.runInInjectionContext(() => stocks.stateChanges());\n        changes.pipe(take(1)).subscribe(() => undefined).add(() => {\n          changes.pipe(take(1)).subscribe(data => {\n            expect(data.length).toEqual(ITEMS);\n            done();\n          });\n        });\n      })();\n    });\n\n    it('should be able to filter stateChanges() types - modified', done => {\n      pending(\"TODO(jamesdaniels) find out why this is flaking with SDK v11\");\n      (async () => {\n        const ITEMS = 10;\n        const { ref, stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.stateChanges(['modified'])).subscribe(data => {\n          sub.unsubscribe();\n          expect(data.length).toEqual(1);\n          expect(data[0].payload.doc.data().price).toEqual(2);\n          expect(data[0].type).toEqual('modified');\n          done();\n        });\n\n        delayUpdate(ref, names[0], { price: 2 });\n      })();\n    });\n\n    it('should be able to filter stateChanges() types - added', done => {\n      (async () => {\n        const ITEMS = 10;\n\n        const { ref, stocks } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.stateChanges(['added'])).pipe(skip(1)).subscribe(data => {\n          sub.unsubscribe();\n          expect(data.length).toEqual(1);\n          expect(data[0].payload.doc.data().price).toEqual(2);\n          expect(data[0].type).toEqual('added');\n          done();\n        });\n\n        const nextId = ref.doc('a').id;\n        delayAdd(ref, nextId, { price: 2 });\n      })();\n    });\n\n    it('should be able to filter stateChanges() types - removed', done => {\n      (async () => {\n        const ITEMS = 10;\n        const { ref, stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.stateChanges(['removed'])).subscribe(data => {\n          sub.unsubscribe();\n          expect(data.length).toEqual(1);\n          expect(data[0].type).toEqual('removed');\n          done();\n        });\n\n        delayDelete(ref, names[0], 400);\n      })();\n    });\n  });\n\n  describe('auditTrail()', () => {\n    it('should listen to all events for auditTrail() by default', done => {\n      (async () => {\n        const ITEMS = 10;\n        let count = 0;\n        const { ref, stocks, names } = await collectionHarness(afs, ITEMS);\n        const sub = TestBed.runInInjectionContext(() => stocks.auditTrail()).subscribe(data => {\n          count = count + 1;\n          if (count === 1) {\n            ref.doc(names[0]).update({ price: 2 });\n          }\n          if (count === 2) {\n            sub.unsubscribe();\n            expect(data.length).toEqual(ITEMS + 1);\n            expect(data[data.length - 1].type).toEqual('modified');\n            done();\n          }\n        });\n      })();\n    });\n\n    it('should be able to filter auditTrail() types - removed', done => {\n      (async () => {\n        const ITEMS = 10;\n        const { ref, stocks, names } = await collectionHarness(afs, ITEMS);\n\n        const sub = TestBed.runInInjectionContext(() => stocks.auditTrail(['removed'])).subscribe(data => {\n          sub.unsubscribe();\n          expect(data.length).toEqual(1);\n          expect(data[0].type).toEqual('removed');\n          done();\n        });\n\n        delayDelete(ref, names[0], 400);\n      })();\n    });\n  });\n\n});\n"
  },
  {
    "path": "src/compat/firestore/collection-group/collection-group.ts",
    "content": "import { EnvironmentInjector, inject } from '@angular/core';\nimport { pendingUntilEvent } from '@angular/core/rxjs-interop';\nimport firebase from 'firebase/compat/app';\nimport { Observable, from } from 'rxjs';\nimport { filter, map, scan } from 'rxjs/operators';\nimport { docChanges, sortedChanges } from '../collection/changes';\nimport { validateEventsArray } from '../collection/collection';\nimport { AngularFirestore } from '../firestore';\nimport { DocumentChangeAction, DocumentChangeType, DocumentData, Query } from '../interfaces';\nimport { fromCollectionRef } from '../observable/fromRef';\n\n/**\n * AngularFirestoreCollectionGroup service\n *\n * This class holds a reference to a Firestore Collection Group Query.\n *\n * This class uses Symbol.observable to transform into Observable using Observable.from().\n *\n * This class is rarely used directly and should be created from the AngularFirestore service.\n *\n * Example:\n *\n * const collectionGroup = firebase.firestore.collectionGroup('stocks');\n * const query = collectionRef.where('price', '>', '0.01');\n * const fakeStock = new AngularFirestoreCollectionGroup<Stock>(query, afs);\n *\n * // Subscribe to changes as snapshots. This provides you data updates as well as delta updates.\n * fakeStock.valueChanges().subscribe(value => console.log(value));\n */\nexport class AngularFirestoreCollectionGroup<T = DocumentData> {\n  private readonly injector = inject(EnvironmentInjector);\n\n  /**\n   * The constructor takes in a CollectionGroupQuery to provide wrapper methods\n   * for data operations and data streaming.\n   */\n  constructor(\n    private readonly query: Query<T>,\n    private readonly afs: AngularFirestore) { }\n\n  /**\n   * Listen to the latest change in the stream. This method returns changes\n   * as they occur and they are not sorted by query order. This allows you to construct\n   * your own data structure.\n   */\n  stateChanges(events?: DocumentChangeType[]): Observable<DocumentChangeAction<T>[]> {\n    if (!events || events.length === 0) {\n      return docChanges<T>(this.query, this.afs.schedulers.outsideAngular).pipe(\n        pendingUntilEvent(this.injector)\n      );\n    }\n    return docChanges<T>(this.query, this.afs.schedulers.outsideAngular)\n      .pipe(\n        map(actions => actions.filter(change => events.includes(change.type))),\n        filter(changes =>  changes.length > 0),\n        pendingUntilEvent(this.injector)\n      );\n  }\n\n  /**\n   * Create a stream of changes as they occur it time. This method is similar to stateChanges()\n   * but it collects each event in an array over time.\n   */\n  auditTrail(events?: DocumentChangeType[]): Observable<DocumentChangeAction<T>[]> {\n    return this.stateChanges(events).pipe(scan((current, action) => [...current, ...action], []));\n  }\n\n  /**\n   * Create a stream of synchronized changes. This method keeps the local array in sorted\n   * query order.\n   */\n  snapshotChanges(events?: DocumentChangeType[]): Observable<DocumentChangeAction<T>[]> {\n    const validatedEvents = validateEventsArray(events);\n    const scheduledSortedChanges$ = sortedChanges<T>(this.query, validatedEvents, this.afs.schedulers.outsideAngular);\n    return scheduledSortedChanges$.pipe(\n      pendingUntilEvent(this.injector)\n    );\n  }\n\n  /**\n   * Listen to all documents in the collection and its possible query as an Observable.\n   *\n   * If the `idField` option is provided, document IDs are included and mapped to the\n   * provided `idField` property name.\n   */\n  valueChanges(): Observable<T[]>;\n  // eslint-disable-next-line no-empty-pattern\n  valueChanges({}): Observable<T[]>;\n  valueChanges<K extends string>(options: {idField: K}): Observable<(T & Record<K, string>)[]>;\n  valueChanges<K extends string>(options: {idField?: K} = {}): Observable<T[]> {\n    const fromCollectionRefScheduled$ = fromCollectionRef<T>(this.query, this.afs.schedulers.outsideAngular);\n    return fromCollectionRefScheduled$\n      .pipe(\n        map(actions => actions.payload.docs.map(a => {\n          if (options.idField) {\n            return {\n              [options.idField]: a.id,\n              ...a.data()\n            } as T & Record<K, string>;\n          } else {\n            return a.data();\n          }\n        })),\n        pendingUntilEvent(this.injector)\n      );\n  }\n\n  /**\n   * Retrieve the results of the query once.\n   */\n  get(options?: firebase.firestore.GetOptions) {\n    return from(this.query.get(options)).pipe(\n      pendingUntilEvent(this.injector)\n    );\n  }\n\n}\n"
  },
  {
    "path": "src/compat/firestore/document/document.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFirestore, AngularFirestoreDocument, AngularFirestoreModule, DocumentReference, USE_EMULATOR } from '@angular/fire/compat/firestore';\nimport firebase from 'firebase/compat/app';\nimport { take } from 'rxjs/operators';\nimport { COMMON_CONFIG, firestoreEmulatorPort } from '../../../test-config';\nimport { rando } from '../../../utils';\nimport { FAKE_STOCK_DATA, Stock, randomName } from '../utils.spec';\nimport 'firebase/compat/firestore';\n\n// TODO(davideast): Investage this flake on Safari.\ndescribe('AngularFirestoreDocument', () => {\n  let afs: AngularFirestore;\n\n  beforeEach(() => {\n    pending(\"These are pretty broken, investigate.\");\n\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFirestoreModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', firestoreEmulatorPort] }\n      ]\n    });\n\n    afs = TestBed.inject(AngularFirestore);\n  });\n\n  describe('valueChanges()', () => {\n\n    it('should get unwrapped snapshot', done => {\n      (async () => {\n        const randomCollectionName = TestBed.runInInjectionContext(() => afs.firestore.collection('a').doc().id);\n        const ref = TestBed.runInInjectionContext(() => afs.firestore.doc(`${randomCollectionName}/FAKE`)) as firebase.firestore.DocumentReference<Stock>;\n        const stock = new AngularFirestoreDocument(ref, afs);\n        await TestBed.runInInjectionContext(() => stock.set(FAKE_STOCK_DATA));\n        const obs$ = TestBed.runInInjectionContext(() => stock.valueChanges());\n        obs$.pipe(take(1)).subscribe(data => {\n          expect(data).toEqual(FAKE_STOCK_DATA);\n          done();\n        });\n      })();\n    });\n\n    /* TODO(jamesdaniels): test is flaking, look into this\n    it('should optionally map the doc ID to the emitted data object', done => {\n      (async () => {\n        const randomCollectionName = afs.firestore.collection('a').doc().id;\n        const ref = afs.firestore.doc(`${randomCollectionName}/FAKE`);\n        const stock = new AngularFirestoreDocument<Stock>(ref, afs);\n        await stock.set(FAKE_STOCK_DATA);\n        const idField = 'myCustomID';\n        const obs$ = stock.valueChanges({ idField });\n        obs$.pipe(take(1)).subscribe(async data => {\n          expect(data[idField]).toBeDefined();\n          expect(data).toEqual(jasmine.objectContaining(FAKE_STOCK_DATA));\n          stock.delete().then(done).catch(done.fail);\n        });\n      })();\n    });*/\n\n  });\n\n  describe('snapshotChanges()', () => {\n\n    it('should get action updates', done => {\n      (async () => {\n        const randomCollectionName = randomName(afs.firestore);\n        const ref = TestBed.runInInjectionContext(() => afs.firestore.doc(`${randomCollectionName}/FAKE`)) as DocumentReference<Stock>;\n        const stock = new AngularFirestoreDocument<Stock>(ref, afs);\n        await TestBed.runInInjectionContext(() => stock.set(FAKE_STOCK_DATA));\n        const sub = TestBed.runInInjectionContext(() => stock.snapshotChanges()).subscribe(a => {\n          sub.unsubscribe();\n          expect(a.payload.exists).toBeTrue();\n          expect(a.payload.data()).toEqual(FAKE_STOCK_DATA);\n          done();\n        });\n      })();\n    });\n\n    it('should get unwrapped snapshot', done => {\n      (async () => {\n        const randomCollectionName = afs.firestore.collection('a').doc().id;\n        const ref = TestBed.runInInjectionContext(() => afs.firestore.doc(`${randomCollectionName}/FAKE`)) as DocumentReference<Stock>;\n        const stock = new AngularFirestoreDocument<Stock>(ref, afs);\n        await TestBed.runInInjectionContext(() => stock.set(FAKE_STOCK_DATA));\n        const obs$ = TestBed.runInInjectionContext(() => stock.valueChanges());\n        obs$.pipe(take(1)).subscribe(data => {\n          expect(data).toEqual(FAKE_STOCK_DATA);\n          done();\n        });\n      })();\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/firestore/document/document.ts",
    "content": "import { EnvironmentInjector, inject } from '@angular/core';\nimport { pendingUntilEvent } from '@angular/core/rxjs-interop';\nimport firebase from 'firebase/compat/app';\nimport { Observable, from } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { AngularFirestoreCollection } from '../collection/collection';\nimport { AngularFirestore, associateQuery } from '../firestore';\nimport { Action, DocumentData, DocumentReference, DocumentSnapshot, QueryFn, SetOptions } from '../interfaces';\nimport { fromDocRef } from '../observable/fromRef';\n\n/**\n * AngularFirestoreDocument service\n *\n * This class creates a reference to a Firestore Document. A reference is provided in\n * in the constructor. The class is generic which gives you type safety for data update\n * methods and data streaming.\n *\n * This class uses Symbol.observable to transform into Observable using Observable.from().\n *\n * This class is rarely used directly and should be created from the AngularFirestore service.\n *\n * Example:\n *\n * const fakeStock = new AngularFirestoreDocument<Stock>(doc('stocks/FAKE'));\n * await fakeStock.set({ name: 'FAKE', price: 0.01 });\n * fakeStock.valueChanges().map(snap => {\n *   if(snap.exists) return snap.data();\n *   return null;\n * }).subscribe(value => console.log(value));\n * // OR! Transform using Observable.from() and the data is unwrapped for you\n * Observable.from(fakeStock).subscribe(value => console.log(value));\n */\nexport class AngularFirestoreDocument<T = DocumentData> {\n  private readonly injector = inject(EnvironmentInjector);\n\n  /**\n   * The constructor takes in a DocumentReference to provide wrapper methods\n   * for data operations, data streaming, and Symbol.observable.\n   */\n  constructor(public ref: DocumentReference<T>, private afs: AngularFirestore) { }\n\n  /**\n   * Create or overwrite a single document.\n   */\n  set(data: T, options?: SetOptions): Promise<void> {\n    return this.ref.set(data, options);\n  }\n\n  /**\n   * Update some fields of a document without overwriting the entire document.\n   */\n  update(data: Partial<T>): Promise<void> {\n    return this.ref.update(data);\n  }\n\n  /**\n   * Delete a document.\n   */\n  delete(): Promise<void> {\n    return this.ref.delete();\n  }\n\n  /**\n   * Create a reference to a sub-collection given a path and an optional query\n   * function.\n   */\n  collection<R = DocumentData>(path: string, queryFn?: QueryFn): AngularFirestoreCollection<R> {\n    const collectionRef = this.ref.collection(path) as firebase.firestore.CollectionReference<R>;\n    const { ref, query } = associateQuery(collectionRef, queryFn);\n    return new AngularFirestoreCollection(ref, query, this.afs);\n  }\n\n  /**\n   * Listen to snapshot updates from the document.\n   */\n  snapshotChanges(): Observable<Action<DocumentSnapshot<T>>> {\n    const scheduledFromDocRef$ = fromDocRef<T>(this.ref, this.afs.schedulers.outsideAngular);\n    return scheduledFromDocRef$.pipe(\n      pendingUntilEvent(this.injector)\n    );\n  }\n\n  /**\n   * Listen to unwrapped snapshot updates from the document.\n   *\n   * If the `idField` option is provided, document IDs are included and mapped to the\n   * provided `idField` property name.\n   */\n  valueChanges(options?: unknown): Observable<T | undefined>;\n  valueChanges<K extends string>(options: { idField: K }): Observable<(T & Record<K, string>) | undefined>;\n  valueChanges<K extends string>(options: { idField?: K } = {}): Observable<T | undefined> {\n    return this.snapshotChanges().pipe(\n      map(({ payload }) =>\n        options.idField ? {\n          ...payload.data(),\n          ...{ [options.idField]: payload.id }\n        } as T & Record<K, string> : payload.data()\n      )\n    );\n  }\n\n  /**\n   * Retrieve the document once.\n   */\n  get(options?: firebase.firestore.GetOptions) {\n    return from(this.ref.get(options)).pipe(\n      pendingUntilEvent(this.injector)\n    );\n  }\n}\n"
  },
  {
    "path": "src/compat/firestore/firestore.module.ts",
    "content": "import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { AngularFirestore, ENABLE_PERSISTENCE, PERSISTENCE_SETTINGS } from './firestore';\nimport { PersistenceSettings } from './interfaces';\n\n@NgModule({\n  providers: [ AngularFirestore ]\n})\nexport class AngularFirestoreModule {\n  constructor() {\n    firebase.registerVersion('angularfire', VERSION.full, 'fst-compat');\n  }\n  /**\n   * Attempt to enable persistent storage, if possible\n   */\n  static enablePersistence(persistenceSettings?: PersistenceSettings): ModuleWithProviders<AngularFirestoreModule> {\n    return {\n      ngModule: AngularFirestoreModule,\n      providers: [\n        { provide: ENABLE_PERSISTENCE, useValue: true },\n        { provide: PERSISTENCE_SETTINGS, useValue: persistenceSettings },\n      ]\n    };\n  }\n}\n"
  },
  {
    "path": "src/compat/firestore/firestore.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS } from '@angular/fire/compat';\nimport { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument, AngularFirestoreModule, USE_EMULATOR } from '@angular/fire/compat/firestore';\nimport { COMMON_CONFIG, firestoreEmulatorPort } from '../../../src/test-config';\nimport 'firebase/compat/firestore';\nimport { rando } from '../../../src/utils';\n\ndescribe('AngularFirestore', () => {\n  let afs: AngularFirestore;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFirestoreModule.enablePersistence()\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', firestoreEmulatorPort] }\n      ]\n    });\n\n    afs = TestBed.inject(AngularFirestore);\n  });\n\n  it('should be the properly initialized type', () => {\n    expect(afs instanceof AngularFirestore).toBe(true);\n  });\n\n  it('should have an initialized Firebase app', () => {\n    expect(TestBed.runInInjectionContext(() => afs.firestore.app)).toBeDefined();\n  });\n\n  it('should create an AngularFirestoreDocument from a string path', () => {\n    const doc = TestBed.runInInjectionContext(() => afs.doc('a/doc'));\n    expect(doc instanceof AngularFirestoreDocument).toBe(true);\n  });\n\n  it('should create an AngularFirestoreDocument from a string path', () => {\n    const doc = TestBed.runInInjectionContext(() => afs.doc(afs.doc('a/doc').ref));\n    expect(doc instanceof AngularFirestoreDocument).toBe(true);\n  });\n\n  it('should create an AngularFirestoreCollection from a string path', () => {\n    const collection = TestBed.runInInjectionContext(() => afs.collection('stuffs'));\n    expect(collection instanceof AngularFirestoreCollection).toBe(true);\n  });\n\n  it('should create an AngularFirestoreCollection from a reference', () => {\n    const collection = TestBed.runInInjectionContext(() => afs.collection(afs.collection('stuffs').ref));\n    expect(collection instanceof AngularFirestoreCollection).toBe(true);\n  });\n\n  it('should throw on an invalid document path', () => {\n    const singleWrapper = () => TestBed.runInInjectionContext(() => afs.doc('collection'));\n    const tripleWrapper = () => TestBed.runInInjectionContext(() => afs.doc('collection/doc/subcollection'));\n    expect(singleWrapper).toThrowError();\n    expect(tripleWrapper).toThrowError();\n  });\n\n  it('should throw on an invalid collection path', () => {\n    const singleWrapper = () => TestBed.runInInjectionContext(() => afs.collection('collection/doc'));\n    const quadWrapper = () => TestBed.runInInjectionContext(() => afs.collection('collection/doc/subcollection/doc'));\n    expect(singleWrapper).toThrowError();\n    expect(quadWrapper).toThrowError();\n  });\n\n  if (typeof window === 'undefined') {\n\n    it('should not enable persistence (Node.js)', (done) => {\n      TestBed.runInInjectionContext(() => afs.persistenceEnabled$).subscribe(isEnabled => {\n        expect(isEnabled).toBe(false);\n        done();\n      });\n    });\n\n  } else {\n\n    it('should enable persistence', (done) => {\n      TestBed.runInInjectionContext(() => afs.persistenceEnabled$).subscribe(isEnabled => {\n        expect(isEnabled).toBe(true);\n        done();\n      });\n    });\n\n  }\n\n});\n\ndescribe('AngularFirestore with different app', () => {\n  let afs: AngularFirestore;\n  let firebaseAppName: string;\n\n  beforeEach(() => {\n    firebaseAppName = rando();\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFirestoreModule\n      ],\n      providers: [\n        { provide: FIREBASE_APP_NAME, useValue: firebaseAppName },\n        { provide: FIREBASE_OPTIONS, useValue: COMMON_CONFIG },\n        { provide: USE_EMULATOR, useValue: ['localhost', firestoreEmulatorPort] }\n      ]\n    });\n\n\n    afs = TestBed.inject(AngularFirestore);\n  });\n\n  describe('<constructor>', () => {\n\n    it('should be an AngularFirestore type', () => {\n      expect(afs instanceof AngularFirestore).toEqual(true);\n    });\n\n    it('should have an initialized Firebase app', () => {\n      expect(TestBed.runInInjectionContext(() => afs.firestore.app)).toBeDefined();\n    });\n\n    it('should have an initialized Firebase app instance member', () => {\n      expect(TestBed.runInInjectionContext(() => afs.firestore.app.name)).toEqual(firebaseAppName);\n    });\n  });\n\n});\n\n\ndescribe('AngularFirestore without persistance', () => {\n  let afs: AngularFirestore;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFirestoreModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', firestoreEmulatorPort] }\n      ]\n    });\n\n    afs = TestBed.inject(AngularFirestore);\n  });\n\n  it('should not enable persistence', (done) => {\n    TestBed.runInInjectionContext(() => afs.persistenceEnabled$).subscribe(isEnabled => {\n      expect(isEnabled).toBe(false);\n      done();\n    });\n  });\n\n});\n"
  },
  {
    "path": "src/compat/firestore/firestore.ts",
    "content": "import { isPlatformServer } from '@angular/common';\nimport { Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID, inject } from '@angular/core';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { FIREBASE_APP_NAME, FIREBASE_OPTIONS, ɵcacheInstance, ɵfirebaseAppFactory } from '@angular/fire/compat';\nimport {\n  SETTINGS as AUTH_SETTINGS,\n  AngularFireAuth,\n  LANGUAGE_CODE,\n  PERSISTENCE,\n  TENANT_ID,\n  USE_EMULATOR as USE_AUTH_EMULATOR,\n  USE_DEVICE_LANGUAGE,\n  ɵauthFactory,\n} from '@angular/fire/compat/auth';\nimport { FirebaseOptions } from 'firebase/app';\nimport firebase from 'firebase/compat/app';\nimport { Observable, from, of } from 'rxjs';\nimport { AngularFirestoreCollection } from './collection/collection';\nimport { AngularFirestoreCollectionGroup } from './collection-group/collection-group';\nimport { AngularFirestoreDocument } from './document/document';\nimport {\n  AssociatedReference,\n  CollectionReference,\n  DocumentReference,\n  PersistenceSettings,\n  Query,\n  QueryFn,\n  QueryGroupFn,\n  Settings\n} from './interfaces';\nimport 'firebase/compat/auth';\nimport 'firebase/compat/firestore';\n\n/**\n * The value of this token determines whether or not the firestore will have persistance enabled\n */\nexport const ENABLE_PERSISTENCE = new InjectionToken<boolean>('angularfire2.enableFirestorePersistence');\nexport const PERSISTENCE_SETTINGS = new InjectionToken<PersistenceSettings | undefined>('angularfire2.firestore.persistenceSettings');\nexport const SETTINGS = new InjectionToken<Settings>('angularfire2.firestore.settings');\n\ntype UseEmulatorArguments = Parameters<firebase.firestore.Firestore['useEmulator']>;\nexport const USE_EMULATOR = new InjectionToken<UseEmulatorArguments>('angularfire2.firestore.use-emulator');\n\n/**\n * A utility methods for associating a collection reference with\n * a query.\n *\n * @param collectionRef - A collection reference to query\n * @param queryFn - The callback to create a query\n *\n * Example:\n * const { query, ref } = associateQuery(docRef.collection('items'), ref => {\n *  return ref.where('age', '<', 200);\n * });\n */\nexport function associateQuery<T>(collectionRef: CollectionReference<T>, queryFn = ref => ref): AssociatedReference<T> {\n  const query = queryFn(collectionRef);\n  const ref = collectionRef;\n  return { query, ref };\n}\n\n/**\n * AngularFirestore Service\n *\n * This service is the main entry point for this feature module. It provides\n * an API for creating Collection and Reference services. These services can\n * then be used to do data updates and observable streams of the data.\n *\n * Example:\n *\n * import { Component } from '@angular/core';\n * import { AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument } from '@angular/fire/firestore';\n * import { Observable } from 'rxjs/Observable';\n * import { from } from 'rxjs/observable';\n *\n * @Component({\n *   selector: 'app-my-component',\n *   template: `\n *    <h2>Items for {{ (profile | async)?.name }}\n *    <ul>\n *       <li *ngFor=\"let item of items | async\">{{ item.name }}</li>\n *    </ul>\n *    <div class=\"control-input\">\n *       <input type=\"text\" #itemname />\n *       <button (click)=\"addItem(itemname.value)\">Add Item</button>\n *    </div>\n *   `\n * })\n * export class MyComponent implements OnInit {\n *\n *   // services for data operations and data streaming\n *   private readonly itemsRef: AngularFirestoreCollection<Item>;\n *   private readonly profileRef: AngularFirestoreDocument<Profile>;\n *\n *   // observables for template\n *   items: Observable<Item[]>;\n *   profile: Observable<Profile>;\n *\n *   // inject main service\n *   constructor(private readonly afs: AngularFirestore) {}\n *\n *   ngOnInit() {\n *     this.itemsRef = afs.collection('items', ref => ref.where('user', '==', 'davideast').limit(10));\n *     this.items = this.itemsRef.valueChanges().map(snap => snap.docs.map(data => doc.data()));\n *     // this.items = from(this.itemsRef); // you can also do this with no mapping\n *\n *     this.profileRef = afs.doc('users/davideast');\n *     this.profile = this.profileRef.valueChanges();\n *   }\n *\n *   addItem(name: string) {\n *     const user = 'davideast';\n *     this.itemsRef.add({ name, user });\n *   }\n * }\n */\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFirestore {\n  public readonly firestore: firebase.firestore.Firestore;\n  public readonly persistenceEnabled$: Observable<boolean>;\n  private readonly ngZone = inject(NgZone);\n\n  /**\n   * Each Feature of AngularFire has a FirebaseApp injected. This way we\n   * don't rely on the main Firebase App instance and we can create named\n   * apps and use multiple apps.\n   */\n  constructor(\n    @Inject(FIREBASE_OPTIONS) options: FirebaseOptions,\n    @Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,\n    @Optional() @Inject(ENABLE_PERSISTENCE) shouldEnablePersistence: boolean | null,\n    @Optional() @Inject(SETTINGS) settings: Settings | null,\n\n    @Inject(PLATFORM_ID) platformId: object,\n    zone: NgZone,\n    public schedulers: ɵAngularFireSchedulers,\n    @Optional() @Inject(PERSISTENCE_SETTINGS) persistenceSettings: PersistenceSettings | null,\n    @Optional() @Inject(USE_EMULATOR) _useEmulator: any,\n    @Optional() auth: AngularFireAuth,\n    @Optional() @Inject(USE_AUTH_EMULATOR) useAuthEmulator: any,\n    @Optional() @Inject(AUTH_SETTINGS) authSettings: any, // can't use firebase.auth.AuthSettings here\n    @Optional() @Inject(TENANT_ID) tenantId: string | null,\n    @Optional() @Inject(LANGUAGE_CODE) languageCode: string | null,\n    @Optional() @Inject(USE_DEVICE_LANGUAGE) useDeviceLanguage: boolean | null,\n    @Optional() @Inject(PERSISTENCE) persistence: string | null,\n    @Optional() _appCheckInstances: AppCheckInstances,\n  ) {\n    const app = ɵfirebaseAppFactory(options, zone, name);\n    const useEmulator: UseEmulatorArguments | null = _useEmulator;\n\n    if (auth) {\n      ɵauthFactory(app, zone, useAuthEmulator, tenantId, languageCode, useDeviceLanguage, authSettings, persistence);\n    }\n\n    [this.firestore, this.persistenceEnabled$] = ɵcacheInstance(`${app.name}.firestore`, 'AngularFirestore', app.name, () => {\n      const firestore = zone.runOutsideAngular(() => app.firestore());\n      if (settings) {\n        firestore.settings(settings);\n      }\n      if (useEmulator) {\n        firestore.useEmulator(...useEmulator);\n      }\n\n      if (shouldEnablePersistence && !isPlatformServer(platformId)) {\n        // We need to try/catch here because not all enablePersistence() failures are caught\n        // https://github.com/firebase/firebase-js-sdk/issues/608\n        const enablePersistence = () => {\n          try {\n            return from(firestore.enablePersistence(persistenceSettings || undefined).then(() => true, () => false));\n          } catch (e) {\n            if (typeof console !== 'undefined') { console.warn(e); }\n            return of(false);\n          }\n        };\n        return [firestore, zone.runOutsideAngular(enablePersistence)];\n      } else {\n        return [firestore, of(false)];\n      }\n\n    }, [settings, useEmulator, shouldEnablePersistence]);\n  }\n\n  /**\n   * Create a reference to a Firestore Collection based on a path or\n   * CollectionReference and an optional query function to narrow the result\n   * set.\n   */\n  collection<T>(path: string, queryFn?: QueryFn): AngularFirestoreCollection<T>;\n  collection<T>(ref: CollectionReference, queryFn?: QueryFn): AngularFirestoreCollection<T>;\n  collection<T>(pathOrRef: string | CollectionReference<T>, queryFn?: QueryFn): AngularFirestoreCollection<T> {\n    let collectionRef: CollectionReference<T>;\n    if (typeof pathOrRef === 'string') {\n      collectionRef = this.firestore.collection(pathOrRef) as firebase.firestore.CollectionReference<T>;\n    } else {\n      collectionRef = pathOrRef;\n    }\n    const { ref, query } = associateQuery<T>(collectionRef, queryFn);\n    const refInZone = this.ngZone.run(() => ref);\n    return new AngularFirestoreCollection<T>(refInZone, query, this);\n  }\n\n  /**\n   * Create a reference to a Firestore Collection Group based on a collectionId\n   * and an optional query function to narrow the result\n   * set.\n   */\n  collectionGroup<T>(collectionId: string, queryGroupFn?: QueryGroupFn<T>): AngularFirestoreCollectionGroup<T> {\n    const queryFn = queryGroupFn || (ref => ref);\n    const collectionGroup: Query<T> = this.firestore.collectionGroup(collectionId) as firebase.firestore.Query<T>;\n    return new AngularFirestoreCollectionGroup<T>(queryFn(collectionGroup), this);\n  }\n\n  /**\n   * Create a reference to a Firestore Document based on a path or\n   * DocumentReference. Note that documents are not queryable because they are\n   * simply objects. However, documents have sub-collections that return a\n   * Collection reference and can be queried.\n   */\n  doc<T>(path: string): AngularFirestoreDocument<T>;\n  doc<T>(ref: DocumentReference): AngularFirestoreDocument<T>;\n  doc<T>(pathOrRef: string | DocumentReference<T>): AngularFirestoreDocument<T> {\n    let ref: DocumentReference<T>;\n    if (typeof pathOrRef === 'string') {\n      ref = this.firestore.doc(pathOrRef) as firebase.firestore.DocumentReference<T>;\n    } else {\n      ref = pathOrRef;\n    }\n    const refInZone = this.ngZone.run(() => ref);\n    return new AngularFirestoreDocument<T>(refInZone, this);\n  }\n\n  /**\n   * Returns a generated Firestore Document Id.\n   */\n  createId() {\n    return this.firestore.collection('_').doc().id;\n  }\n}\n"
  },
  {
    "path": "src/compat/firestore/interfaces.ts",
    "content": "import firebase from 'firebase/compat/app';\nimport { Subscriber } from 'rxjs';\n\nexport type Settings =  firebase.firestore.Settings;\nexport type CollectionReference<T = DocumentData> = firebase.firestore.CollectionReference<T>;\nexport type DocumentReference<T = DocumentData> = firebase.firestore.DocumentReference<T>;\nexport type PersistenceSettings = firebase.firestore.PersistenceSettings;\nexport type DocumentChangeType = firebase.firestore.DocumentChangeType;\nexport type SnapshotOptions = firebase.firestore.SnapshotOptions;\nexport type FieldPath = firebase.firestore.FieldPath;\nexport type Query<T = DocumentData> = firebase.firestore.Query<T>;\n\nexport type SetOptions = firebase.firestore.SetOptions;\nexport type DocumentData = firebase.firestore.DocumentData;\n\nexport interface DocumentSnapshotExists<T> extends firebase.firestore.DocumentSnapshot<T> {\n  readonly exists: true;\n  data(options?: SnapshotOptions): T;\n}\n\nexport interface DocumentSnapshotDoesNotExist extends firebase.firestore.DocumentSnapshot {\n  readonly exists: false;\n  data(options?: SnapshotOptions): undefined;\n  get(fieldPath: string | FieldPath, options?: SnapshotOptions): undefined;\n}\n\nexport type DocumentSnapshot<T> = DocumentSnapshotExists<T> | DocumentSnapshotDoesNotExist;\n\nexport interface QueryDocumentSnapshot<T> extends firebase.firestore.QueryDocumentSnapshot<T> {\n  data(options?: SnapshotOptions): T;\n}\n\nexport interface QuerySnapshot<T> extends firebase.firestore.QuerySnapshot<T> {\n  readonly docs: QueryDocumentSnapshot<T>[];\n}\n\nexport interface DocumentChange<T> extends firebase.firestore.DocumentChange<T> {\n  readonly doc: QueryDocumentSnapshot<T>;\n}\n\nexport interface DocumentChangeAction<T> {\n  type: DocumentChangeType;\n  payload: DocumentChange<T>;\n}\n\nexport interface Action<T> {\n  type: string;\n  payload: T;\n}\n\nexport interface Reference {\n  onSnapshot: (options: firebase.firestore.SnapshotListenOptions, sub: Subscriber<any>) => any;\n}\n\n// A convience type for making a query.\n// Example: const query = (ref) => ref.where('name', == 'david');\nexport type QueryFn<T = DocumentData> = (ref: CollectionReference<T>) => Query<T>;\n\nexport type QueryGroupFn<T = DocumentData> = (query: Query<T>) => Query<T>;\n\n/**\n * A structure that provides an association between a reference\n * and a query on that reference. Note: Performing operations\n * on the reference can lead to confusing results with complicated\n * queries.\n *\n * Example:\n *\n * const query = ref.where('type', '==', 'Book').\n *                  .where('price', '>' 18.00)\n *                  .where('price', '<' 100.00)\n *                  .where('category', '==', 'Fiction')\n *                  .where('publisher', '==', 'BigPublisher')\n *\n * // This addition would not be a result of the query above\n * ref.add({\n *  type: 'Magazine',\n *  price: 4.99,\n *  category: 'Sports',\n *  publisher: 'SportsPublisher'\n * });\n */\nexport interface AssociatedReference<T = DocumentData> {\n  ref: CollectionReference<T>;\n  query: Query<T>;\n}\n"
  },
  {
    "path": "src/compat/firestore/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/firestore/observable/fromRef.ts",
    "content": "import { Observable, SchedulerLike, asyncScheduler } from 'rxjs';\nimport { map, pairwise, startWith } from 'rxjs/operators';\nimport { Action, DocumentReference, DocumentSnapshot, Query, QuerySnapshot, Reference } from '../interfaces';\n\nfunction _fromRef<R>(ref: Reference, scheduler: SchedulerLike = asyncScheduler): Observable<R> {\n  return new Observable(subscriber => {\n    let unsubscribe: () => void;\n    if (scheduler != null) {\n      scheduler.schedule(() => {\n        unsubscribe = ref.onSnapshot({ includeMetadataChanges: true }, subscriber);\n      });\n    } else {\n      unsubscribe = ref.onSnapshot({ includeMetadataChanges: true }, subscriber);\n    }\n\n    return () => {\n      if (unsubscribe != null) {\n        unsubscribe();\n      }\n    };\n  });\n}\n\nexport function fromRef<R, T>(ref: DocumentReference<T> | Query<T>, scheduler?: SchedulerLike) {\n  return _fromRef<R>(ref, scheduler);\n}\n\nexport function fromDocRef<T>(ref: DocumentReference<T>, scheduler?: SchedulerLike): Observable<Action<DocumentSnapshot<T>>> {\n  return fromRef<DocumentSnapshot<T>, T>(ref, scheduler)\n    .pipe(\n      startWith<DocumentSnapshot<T>, undefined>(undefined),\n      pairwise(),\n      map((snapshots: [DocumentSnapshot<T>, DocumentSnapshot<T>]) => {\n        const [priorPayload, payload] = snapshots;\n        if (!payload.exists) {\n          return { payload, type: 'removed' };\n        }\n        if (!priorPayload?.exists) {\n          return { payload, type: 'added' };\n        }\n        return { payload, type: 'modified' };\n      })\n    );\n}\n\nexport function fromCollectionRef<T>(ref: Query<T>, scheduler?: SchedulerLike): Observable<Action<QuerySnapshot<T>>> {\n  return fromRef<QuerySnapshot<T>, T>(ref, scheduler).pipe(map(payload => ({ payload, type: 'query' })));\n}\n"
  },
  {
    "path": "src/compat/firestore/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/firestore/public_api.ts",
    "content": "export * from './firestore';\nexport * from './firestore.module';\nexport * from './collection/collection';\nexport * from './collection-group/collection-group';\nexport * from './document/document';\nexport * from './collection/changes';\nexport * from './observable/fromRef';\nexport * from './interfaces';\n"
  },
  {
    "path": "src/compat/firestore/utils.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFirestoreCollection } from '@angular/fire/compat/firestore';\nimport firebase from 'firebase/compat/app';\n\nexport interface Stock {\n  name: string;\n  price: number;\n}\n\nexport const FAKE_STOCK_DATA = { name: 'FAKE', price: 1 };\n\nexport const randomName = (firestore): string => firestore.collection('a').doc().id;\n\nexport const createRandomStocks = async (\n  firestore: firebase.firestore.Firestore,\n  collectionRef: firebase.firestore.CollectionReference,\n  numberOfItems\n) => {\n  // Create a batch to update everything at once\n  const batch = TestBed.runInInjectionContext(() => firestore.batch());\n  // Store the random names to delete them later\n  let names: string[] = [];\n  Array.from(Array(numberOfItems)).forEach(() => {\n    const name = randomName(firestore);\n    TestBed.runInInjectionContext(() => batch.set(collectionRef.doc(name), FAKE_STOCK_DATA));\n    names = [...names, name];\n  });\n  // Create the batch entries\n  // Commit!\n  await TestBed.runInInjectionContext(() => batch.commit());\n  return names;\n};\n\nexport function deleteThemAll(names, ref) {\n  const promises = names.map(name => ref.doc(name).delete());\n  return Promise.all(promises);\n}\n\nexport function delayUpdate<T>(collection: AngularFirestoreCollection<T>|firebase.firestore.CollectionReference, path, data, delay = 250) {\n  setTimeout(() => {\n    TestBed.runInInjectionContext(() => collection.doc(path).update(data));\n  }, delay);\n}\n\nexport function delayAdd<T>(collection: AngularFirestoreCollection<T>|firebase.firestore.CollectionReference, path, data, delay = 250) {\n  setTimeout(() => {\n    TestBed.runInInjectionContext(() => collection.doc(path).set(data));\n  }, delay);\n}\n\nexport function delayDelete<T>(collection: AngularFirestoreCollection<T>|firebase.firestore.CollectionReference, path, delay = 250) {\n  setTimeout(() => {\n    TestBed.runInInjectionContext(() => collection.doc(path).delete());\n  }, delay);\n}\n"
  },
  {
    "path": "src/compat/functions/base.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\n// Export a null object with the same keys as firebase/compat/functions, so Proxy can work with proxy-polyfill in Internet Explorer\nexport const proxyPolyfillCompat = {\n  useEmulator: null,\n  useFunctionsEmulator: null,\n  httpsCallable: null,\n};\n"
  },
  {
    "path": "src/compat/functions/functions.module.ts",
    "content": "import { NgModule } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { AngularFireFunctions } from './functions';\n\n@NgModule({\n  providers: [ AngularFireFunctions ]\n})\nexport class AngularFireFunctionsModule {\n  constructor() {\n    firebase.registerVersion('angularfire', VERSION.full, 'fn-compat');\n  }\n}\n"
  },
  {
    "path": "src/compat/functions/functions.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS } from '@angular/fire/compat';\nimport { AngularFireFunctions, AngularFireFunctionsModule, REGION, USE_EMULATOR } from '@angular/fire/compat/functions';\nimport { COMMON_CONFIG } from '../../../src/test-config';\nimport 'firebase/compat/functions';\nimport { rando } from '../../../src/utils';\n\ndescribe('AngularFireFunctions', () => {\n  let afFns: AngularFireFunctions;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireFunctionsModule\n      ],\n      providers: [\n        { provide: USE_EMULATOR, useValue: ['localhost', 9999] },\n        { provide: REGION, useValue: 'us-central1' },\n      ]\n    });\n\n    afFns = TestBed.inject(AngularFireFunctions);\n  });\n\n  it('should exist', () => {\n    expect(afFns instanceof AngularFireFunctions).toBe(true);\n  });\n\n  it('should have the Firebase Functions instance', () => {\n    expect(afFns.useFunctionsEmulator).toBeDefined();\n  });\n\n});\n\ndescribe('AngularFireFunctions with different app', () => {\n  let afFns: AngularFireFunctions;\n  let firebaseAppName: string;\n\n  beforeEach(() => {\n    firebaseAppName = rando();\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireFunctionsModule\n      ],\n      providers: [\n        { provide: FIREBASE_APP_NAME, useValue: firebaseAppName },\n        { provide: FIREBASE_OPTIONS, useValue: COMMON_CONFIG },\n        { provide: USE_EMULATOR, useValue: ['localhost', 9999] },\n        { provide: REGION, useValue: 'us-central1' },\n      ]\n    });\n\n    afFns = TestBed.inject(AngularFireFunctions);\n  });\n\n  describe('<constructor>', () => {\n\n    it('should be an AngularFireAuth type', () => {\n      expect(afFns instanceof AngularFireFunctions).toEqual(true);\n    });\n\n    it('should have the Firebase Functions instance', () => {\n      expect(afFns.useFunctionsEmulator).toBeDefined();\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/functions/functions.ts",
    "content": "import { Inject, Injectable, InjectionToken, NgZone, Optional } from '@angular/core';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { ɵPromiseProxy, ɵapplyMixins, ɵlazySDKProxy } from '@angular/fire/compat';\nimport { FIREBASE_APP_NAME, FIREBASE_OPTIONS, ɵcacheInstance, ɵfirebaseAppFactory } from '@angular/fire/compat';\nimport { HttpsCallableOptions } from '@firebase/functions-types';\nimport { FirebaseOptions } from 'firebase/app';\nimport firebase from 'firebase/compat/app';\nimport { Observable, from, of } from 'rxjs';\nimport { map, observeOn, shareReplay, switchMap } from 'rxjs/operators';\nimport { proxyPolyfillCompat } from './base';\n\nexport const ORIGIN = new InjectionToken<string>('angularfire2.functions.origin');\nexport const REGION = new InjectionToken<string>('angularfire2.functions.region');\n\ntype UseEmulatorArguments = Parameters<firebase.functions.Functions['useEmulator']>;\nexport const USE_EMULATOR = new InjectionToken<UseEmulatorArguments>('angularfire2.functions.use-emulator');\n\n// override httpsCallable for compatibility with 5.x\n \nexport interface AngularFireFunctions extends Omit<ɵPromiseProxy<firebase.functions.Functions>, 'httpsCallable'> {\n}\n\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFireFunctions {\n\n  public readonly httpsCallable: <T = any, R = any>(name: string, options?: HttpsCallableOptions) => (data: T) => Observable<R>;\n\n  constructor(\n    @Inject(FIREBASE_OPTIONS) options: FirebaseOptions,\n    @Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,\n    zone: NgZone,\n    schedulers: ɵAngularFireSchedulers,\n    @Optional() @Inject(REGION) region: string | null,\n    @Optional() @Inject(ORIGIN) origin: string | null,\n    @Optional() @Inject(USE_EMULATOR) _useEmulator: any, // can't use the tuple here\n    @Optional() _appCheckInstances: AppCheckInstances,\n  ) {\n    const useEmulator: UseEmulatorArguments | null = _useEmulator;\n\n    const functions = of(undefined).pipe(\n      observeOn(schedulers.outsideAngular),\n      switchMap(() => import('firebase/compat/functions')),\n      map(() => ɵfirebaseAppFactory(options, zone, name)),\n      map(app => ɵcacheInstance(`${app.name}.functions.${region || origin}`, 'AngularFireFunctions', app.name, () => {\n        let functions: firebase.functions.Functions;\n        if (region && origin) {\n          throw new Error('REGION and ORIGIN can\\'t be used at the same time.');\n        }\n        functions = app.functions(region || origin || undefined);\n        if (useEmulator) {\n          functions.useEmulator(...useEmulator);\n        }\n        return functions;\n      }, [region, origin, useEmulator])),\n      shareReplay({ bufferSize: 1, refCount: false })\n    );\n\n    this.httpsCallable = <T = any, R = any>(name: string, options?: HttpsCallableOptions) =>\n      (data: T) => from(functions).pipe(\n        observeOn(schedulers.insideAngular),\n        switchMap(functions => functions.httpsCallable(name, options)(data)),\n        map(r => r.data as R)\n      );\n\n    return ɵlazySDKProxy(this, functions, zone);\n\n  }\n\n}\n\nɵapplyMixins(AngularFireFunctions, [proxyPolyfillCompat]);\n"
  },
  {
    "path": "src/compat/functions/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/functions/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/functions/public_api.ts",
    "content": "\nimport 'firebase/compat/functions'; // removed in build process when not UMD\n\nexport * from './functions';\nexport * from './functions.module';\n"
  },
  {
    "path": "src/compat/messaging/base.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\n// Export a null object with the same keys as firebase/compat/messaging, so Proxy can work with proxy-polyfill in Internet Explorer\nexport const proxyPolyfillCompat = {\n  deleteToken: null,\n  getToken: null,\n  onMessage: null,\n  onBackgroundMessage: null,\n};\n"
  },
  {
    "path": "src/compat/messaging/messaging.module.ts",
    "content": "import { NgModule } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { AngularFireMessaging } from './messaging';\n\n@NgModule({\n  providers: [ AngularFireMessaging ]\n})\nexport class AngularFireMessagingModule {\n  constructor() {\n    firebase.registerVersion('angularfire', VERSION.full, 'fcm-compat');\n  }\n}\n"
  },
  {
    "path": "src/compat/messaging/messaging.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS } from '@angular/fire/compat';\nimport { AngularFireMessaging, AngularFireMessagingModule } from '@angular/fire/compat/messaging';\nimport { COMMON_CONFIG } from '../../../src/test-config';\nimport { rando } from '../../../src/utils';\n\ndescribe('AngularFireMessaging', () => {\n  let afm: AngularFireMessaging;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireMessagingModule\n      ]\n    });\n\n    afm = TestBed.inject(AngularFireMessaging);\n  });\n\n  it('should be exist', () => {\n    expect(afm instanceof AngularFireMessaging).toBe(true);\n  });\n\n  it('should have the FCM instance', () => {\n    expect(afm.deleteToken).toBeDefined();\n  });\n\n});\n\nconst FIREBASE_APP_NAME_TOO = (Math.random() + 1).toString(36).substring(7);\n\ndescribe('AngularFireMessaging with different app', () => {\n  let afm: AngularFireMessaging;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireMessagingModule\n      ],\n      providers: [\n        { provide: FIREBASE_APP_NAME, useValue: FIREBASE_APP_NAME_TOO },\n        { provide: FIREBASE_OPTIONS, useValue: COMMON_CONFIG }\n      ]\n    });\n\n    afm = TestBed.inject(AngularFireMessaging);\n  });\n\n  describe('<constructor>', () => {\n\n    it('should be an AngularFireMessaging type', () => {\n      expect(afm instanceof AngularFireMessaging).toEqual(true);\n    });\n\n    it('should have the FCM instance', () => {\n      expect(afm.deleteToken).toBeDefined();\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/messaging/messaging.ts",
    "content": "import { Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID } from '@angular/core';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { ɵPromiseProxy, ɵapplyMixins, ɵlazySDKProxy } from '@angular/fire/compat';\nimport { FIREBASE_APP_NAME, FIREBASE_OPTIONS, ɵcacheInstance, ɵfirebaseAppFactory } from '@angular/fire/compat';\nimport { FirebaseOptions } from 'firebase/app';\nimport firebase from 'firebase/compat/app';\nimport { isSupported } from 'firebase/messaging';\nimport { EMPTY, Observable, concat, of } from 'rxjs';\nimport { catchError, defaultIfEmpty, map, mergeMap, observeOn, shareReplay, subscribeOn, switchMap, switchMapTo } from 'rxjs/operators';\nimport { proxyPolyfillCompat } from './base';\n\nexport const VAPID_KEY = new InjectionToken<string>('angularfire2.messaging.vapid-key');\nexport const SERVICE_WORKER = new InjectionToken<Promise<ServiceWorkerRegistration>>('angularfire2.messaging.service-worker-registeration');\n\n \nexport interface AngularFireMessaging extends Omit<ɵPromiseProxy<firebase.messaging.Messaging>, 'deleteToken' | 'getToken' | 'requestPermission'> {\n}\n\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFireMessaging {\n\n  public readonly requestPermission: Observable<NotificationPermission>;\n  public readonly getToken: Observable<string | null>;\n  public readonly tokenChanges: Observable<string | null>;\n  public readonly messages: Observable<firebase.messaging.MessagePayload>;\n  public readonly requestToken: Observable<string | null>;\n  public readonly deleteToken: (token: string) => Observable<boolean>;\n\n  constructor(\n    @Inject(FIREBASE_OPTIONS) options: FirebaseOptions,\n    @Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,\n\n    @Inject(PLATFORM_ID) platformId: object,\n    zone: NgZone,\n    schedulers: ɵAngularFireSchedulers,\n    @Optional() @Inject(VAPID_KEY) vapidKey: string|null,\n    @Optional() @Inject(SERVICE_WORKER) _serviceWorker: any,\n  ) {\n    const serviceWorker: Promise<ServiceWorkerRegistration> | null = _serviceWorker;\n\n    const messaging = of(undefined).pipe(\n      subscribeOn(schedulers.outsideAngular),\n      observeOn(schedulers.insideAngular),\n      switchMap(isSupported),\n      switchMap(supported => supported ? import('firebase/compat/messaging') : EMPTY),\n      map(() => ɵfirebaseAppFactory(options, zone, name)),\n      switchMap(app => ɵcacheInstance(`${app.name}.messaging`, 'AngularFireMessaging', app.name, () => {\n        return of(app.messaging());\n      }, [])),\n      shareReplay({ bufferSize: 1, refCount: false })\n    );\n\n\n    this.requestPermission = messaging.pipe(\n      subscribeOn(schedulers.outsideAngular),\n      observeOn(schedulers.insideAngular),\n      switchMap(() => Notification.requestPermission())\n    );\n\n    this.getToken = messaging.pipe(\n      subscribeOn(schedulers.outsideAngular),\n      observeOn(schedulers.insideAngular),\n      switchMap(async messaging => {\n        if (Notification.permission === 'granted') {\n          // eslint-disable-next-line @typescript-eslint/no-misused-promises\n          const serviceWorkerRegistration = serviceWorker ? await serviceWorker : null;\n          return await messaging.getToken({ vapidKey, serviceWorkerRegistration });\n        } else {\n          return null;\n        }\n      })\n    );\n\n    const notificationPermission$ = new Observable<void>(emitter => {\n      navigator.permissions.query({ name: 'notifications' }).then(notificationPerm => {\n        notificationPerm.onchange = () => emitter.next();\n      });\n    });\n\n\n    const tokenChange$ = messaging.pipe(\n      subscribeOn(schedulers.outsideAngular),\n      observeOn(schedulers.insideAngular),\n      switchMapTo(notificationPermission$),\n      switchMapTo(this.getToken)\n    );\n\n    this.tokenChanges = messaging.pipe(\n      subscribeOn(schedulers.outsideAngular),\n      observeOn(schedulers.insideAngular),\n      switchMap(() => concat(this.getToken, tokenChange$))\n    );\n\n\n    this.messages = messaging.pipe(\n      subscribeOn(schedulers.outsideAngular),\n      observeOn(schedulers.insideAngular),\n      switchMap(messaging => new Observable<firebase.messaging.MessagePayload>(emitter =>\n        messaging.onMessage(emitter)\n      )),\n    );\n\n    this.requestToken = messaging.pipe(\n      subscribeOn(schedulers.outsideAngular),\n      observeOn(schedulers.insideAngular),\n      switchMap(() => this.requestPermission),\n      catchError(() => of(null)),\n      mergeMap(() => this.tokenChanges)\n    );\n\n    this.deleteToken = () => messaging.pipe(\n      subscribeOn(schedulers.outsideAngular),\n      observeOn(schedulers.insideAngular),\n      switchMap(messaging => messaging.deleteToken()),\n      defaultIfEmpty(false)\n    );\n\n    return ɵlazySDKProxy(this, messaging, zone);\n  }\n\n}\n\nɵapplyMixins(AngularFireMessaging, [proxyPolyfillCompat]);\n"
  },
  {
    "path": "src/compat/messaging/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/messaging/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/messaging/public_api.ts",
    "content": "export * from './messaging';\nexport * from './messaging.module';\n"
  },
  {
    "path": "src/compat/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/performance/base.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\n// Export a null object with the same keys as firebase/compat/performance, so Proxy can work with proxy-polyfill in Internet Explorer\nexport const proxyPolyfillCompat = {\n  app: null,\n  trace: null,\n  instrumentationEnabled: null,\n  dataCollectionEnabled: null,\n};\n"
  },
  {
    "path": "src/compat/performance/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/performance/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/performance/performance.module.ts",
    "content": "import { NgModule, Optional } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { AngularFirePerformance } from './performance';\nimport { PerformanceMonitoringService } from './performance.service';\n\n@NgModule({\n  providers: [ AngularFirePerformance ]\n})\nexport class AngularFirePerformanceModule {\n  constructor(\n    perf: AngularFirePerformance,\n    @Optional() _: PerformanceMonitoringService\n  ) {\n    firebase.registerVersion('angularfire', VERSION.full, 'perf-compat');\n    // call anything here to get perf loading\n    perf.dataCollectionEnabled.then(() => undefined);\n  }\n}\n"
  },
  {
    "path": "src/compat/performance/performance.service.ts",
    "content": "import { ApplicationRef, Injectable, OnDestroy } from '@angular/core';\nimport { Subscription } from 'rxjs';\nimport { first, tap } from 'rxjs/operators';\n\nconst IS_STABLE_START_MARK = 'Zone';\nconst IS_STABLE_END_MARK = '_isStableEnd';\n\n@Injectable()\nexport class PerformanceMonitoringService implements OnDestroy {\n\n    private disposable: Subscription|undefined;\n\n    constructor(appRef: ApplicationRef) {\n         \n        if (typeof window !== 'undefined' && window.performance?.mark) {\n            this.disposable = appRef.isStable.pipe(\n                first(it => it),\n                tap(() => {\n                    window.performance.mark(IS_STABLE_END_MARK);\n                    window.performance.measure('isStable', IS_STABLE_START_MARK, IS_STABLE_END_MARK);\n                })\n            ).subscribe();\n        }\n    }\n\n    ngOnDestroy() {\n        if (this.disposable) { this.disposable.unsubscribe(); }\n    }\n\n}\n"
  },
  {
    "path": "src/compat/performance/performance.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule } from '@angular/fire/compat';\nimport { AngularFirePerformance, AngularFirePerformanceModule } from '@angular/fire/compat/performance';\nimport { COMMON_CONFIG } from '../../../src/test-config';\n\ndescribe('AngularFirePerformance', () => {\n  let afp: AngularFirePerformance;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        // NOTE: You must use the [DEFAULT] app instance\n        // for these tests to work.\n        AngularFireModule.initializeApp(COMMON_CONFIG),\n        AngularFirePerformanceModule\n      ]\n    });\n    afp = TestBed.inject(AngularFirePerformance);\n  });\n\n  it('should exist', () => {\n    expect(afp instanceof AngularFirePerformance).toBe(true);\n  });\n\n  it('should have the Performance instance', () => {\n    expect(afp.dataCollectionEnabled).toBeDefined();\n  });\n\n});\n"
  },
  {
    "path": "src/compat/performance/performance.ts",
    "content": "import { isPlatformBrowser } from '@angular/common';\nimport { Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID } from '@angular/core';\nimport { ɵPromiseProxy, ɵapplyMixins, ɵcacheInstance, ɵlazySDKProxy } from '@angular/fire/compat';\nimport { FirebaseApp } from '@angular/fire/compat';\nimport firebase from 'firebase/compat/app';\nimport { EMPTY, Observable, Subscription, of } from 'rxjs';\nimport { map, shareReplay, switchMap, tap } from 'rxjs/operators';\nimport { proxyPolyfillCompat } from './base';\n\nexport const INSTRUMENTATION_ENABLED = new InjectionToken<boolean>('angularfire2.performance.instrumentationEnabled');\nexport const DATA_COLLECTION_ENABLED = new InjectionToken<boolean>('angularfire2.performance.dataCollectionEnabled');\n\n \nexport interface AngularFirePerformance extends ɵPromiseProxy<firebase.performance.Performance> {\n}\n\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFirePerformance {\n\n  private readonly performance: Observable<firebase.performance.Performance>;\n\n  constructor(\n    app: FirebaseApp,\n    @Optional() @Inject(INSTRUMENTATION_ENABLED) instrumentationEnabled: boolean | null,\n    @Optional() @Inject(DATA_COLLECTION_ENABLED) dataCollectionEnabled: boolean | null,\n    private zone: NgZone,\n\n    @Inject(PLATFORM_ID) platformId: object\n  ) {\n\n    this.performance = of(undefined).pipe(\n      switchMap(() => isPlatformBrowser(platformId) ? zone.runOutsideAngular(() => import('firebase/compat/performance')) : EMPTY),\n      map(() => ɵcacheInstance(`performance`, 'AngularFirePerformance', app.name, () => {\n        const performance = zone.runOutsideAngular(() => app.performance());\n        if (instrumentationEnabled === false) {\n          performance.instrumentationEnabled = false;\n        }\n        if (dataCollectionEnabled === false) {\n          performance.dataCollectionEnabled = false;\n        }\n        return performance;\n      }, [instrumentationEnabled, dataCollectionEnabled])),\n      shareReplay({ bufferSize: 1, refCount: false })\n    );\n\n    return ɵlazySDKProxy(this, this.performance, zone);\n\n  }\n\n}\n\nconst trace$ = (traceId: string) => {\n   \n  if (typeof window !== 'undefined' && window.performance?.mark) {\n    const entries = window.performance.getEntriesByName(traceId, 'measure') || [];\n    const startMarkName = `_${traceId}Start[${entries.length}]`;\n    const endMarkName = `_${traceId}End[${entries.length}]`;\n    return new Observable<void>(emitter => {\n      window.performance.mark(startMarkName);\n      emitter.next();\n      return {\n        unsubscribe: () => {\n          window.performance.mark(endMarkName);\n          window.performance.measure(traceId, startMarkName, endMarkName);\n        }\n      };\n    });\n  } else {\n    return EMPTY;\n  }\n};\n\nexport const traceUntil = <T = any>(\n  name: string,\n  test: (a: T) => boolean,\n  options?: { orComplete?: boolean }\n) => (source$: Observable<T>) => new Observable<T>(subscriber => {\n  const traceSubscription = trace$(name).subscribe();\n  return source$.pipe(\n    tap(\n      a => test(a) && traceSubscription.unsubscribe(),\n      () => undefined,\n      () => options && options.orComplete && traceSubscription.unsubscribe()\n    )\n  ).subscribe(subscriber);\n});\n\nexport const traceWhile = <T = any>(\n  name: string,\n  test: (a: T) => boolean,\n  options?: { orComplete?: boolean }\n) => (source$: Observable<T>) => new Observable<T>(subscriber => {\n  let traceSubscription: Subscription | undefined;\n  return source$.pipe(\n    tap(\n      a => {\n        if (test(a)) {\n          traceSubscription = traceSubscription || trace$(name).subscribe();\n        } else {\n          if (traceSubscription) {\n            traceSubscription.unsubscribe();\n          }\n\n          traceSubscription = undefined;\n        }\n      },\n      () => undefined,\n      () => options?.orComplete && traceSubscription?.unsubscribe()\n    )\n  ).subscribe(subscriber);\n});\n\nexport const traceUntilComplete = <T = any>(name: string) => (source$: Observable<T>) => new Observable<T>(subscriber => {\n  const traceSubscription = trace$(name).subscribe();\n  return source$.pipe(\n    tap(\n      () => undefined,\n      () => undefined,\n      () => traceSubscription.unsubscribe()\n    )\n  ).subscribe(subscriber);\n});\n\nexport const traceUntilFirst = <T = any>(name: string) => (source$: Observable<T>) => new Observable<T>(subscriber => {\n  const traceSubscription = trace$(name).subscribe();\n  return source$.pipe(\n    tap(\n      () => traceSubscription.unsubscribe(),\n      () => undefined,\n      () => undefined    )\n  ).subscribe(subscriber);\n});\n\nexport const trace = <T = any>(name: string) => (source$: Observable<T>) => new Observable<T>(subscriber => {\n  const traceSubscription = trace$(name).subscribe();\n  return source$.pipe(\n    tap(\n      () => traceSubscription.unsubscribe(),\n      () => undefined,\n      () => traceSubscription.unsubscribe()\n    )\n  ).subscribe(subscriber);\n});\n\nɵapplyMixins(AngularFirePerformance, [proxyPolyfillCompat]);\n"
  },
  {
    "path": "src/compat/performance/public_api.ts",
    "content": "export * from './performance';\nexport * from './performance.module';\nexport * from './performance.service';\n"
  },
  {
    "path": "src/compat/proxy.ts",
    "content": "import { NgZone } from '@angular/core';\nimport { Observable } from 'rxjs';\n\ntype MyFunction = (...args: any[]) => any;\ntype FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends MyFunction ? K : never }[keyof T];\ntype ReturnTypeOrNever<T> = T extends MyFunction ? ReturnType<T> : never;\ntype ParametersOrNever<T> = T extends MyFunction ? Parameters<T> : never;\ntype PromiseReturningFunctionPropertyNames<T> = {\n  [K in FunctionPropertyNames<T>]: ReturnTypeOrNever<T[K]> extends Promise<any> ? K : never\n}[FunctionPropertyNames<T>];\ntype NonPromiseReturningFunctionPropertyNames<T> = {\n  [K in FunctionPropertyNames<T>]: ReturnTypeOrNever<T[K]> extends Promise<any> ? never : K\n}[FunctionPropertyNames<T>];\ntype NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends MyFunction ? never : K }[keyof T];\n\nexport type ɵPromiseProxy<T> = { [K in NonFunctionPropertyNames<T>]: Promise<T[K]> } &\n  { [K in NonPromiseReturningFunctionPropertyNames<T>]: (...args: ParametersOrNever<T[K]>) => Promise<ReturnTypeOrNever<T[K]>> } &\n  { [K in PromiseReturningFunctionPropertyNames<T>]: T[K] };\n\n// DEBUG quick debugger function for inline logging that typescript doesn't complain about\n//       wrote it for debugging the ɵlazySDKProxy, commenting out for now; should consider exposing a\n//       verbose mode for AngularFire in a future release that uses something like this in multiple places\n//       usage: () => log('something') || returnValue\n// const log = (...args: any[]): false => { console.log(...args); return false }\n\n// The problem here are things like ngOnDestroy are missing, then triggering the service\n// rather than dig too far; I'm capturing these as I go.\nconst noopFunctions = ['ngOnDestroy'];\n\n// INVESTIGATE should we make the Proxy revokable and do some cleanup?\n//             right now it's fairly simple but I'm sure this will grow in complexity\nexport const ɵlazySDKProxy = (klass: any, observable: Observable<any>, zone: NgZone, options: {\n  spy?: {\n    get?: ((name: string, it: any) => void),\n    apply?: ((name: string, args: any[], it: any) => void)\n  }\n} = {}) => {\n  return new Proxy(klass, {\n    get: (_, name: string) => zone.runOutsideAngular(() => {\n      if (klass[name]) {\n        if (options?.spy?.get) {\n          options.spy.get(name, klass[name]);\n        }\n        return klass[name];\n      }\n      if (noopFunctions.includes(name)) {\n        return () => undefined;\n      }\n      const promise = observable.toPromise().then(mod => {\n        const ret = mod?.[name];\n        // TODO move to proper type guards\n        if (typeof ret === 'function') {\n          return ret.bind(mod);\n        } else if (ret?.then) {\n          return ret.then((res: any) => zone.run(() => res));\n        } else {\n          return zone.run(() => ret);\n        }\n      });\n      // recurse the proxy\n      return new Proxy(() => undefined, {\n          get: (_, name) => promise[name],\n          // TODO handle callbacks as transparently as I can\n          apply: (self, _, args) => promise.then(it => {\n            const res = it?.(...args);\n            if (options?.spy?.apply) {\n              options.spy.apply(name, args, res);\n            }\n            return res;\n          })\n        }\n      );\n    })\n  });\n};\n\nexport const ɵapplyMixins = (derivedCtor: any, constructors: any[]) => {\n  constructors.forEach((baseCtor) => {\n    Object.getOwnPropertyNames(baseCtor.prototype || baseCtor).forEach((name) => {\n      Object.defineProperty(\n        derivedCtor.prototype,\n        name,\n        Object.getOwnPropertyDescriptor(baseCtor.prototype || baseCtor, name)\n      );\n    });\n  });\n};\n"
  },
  {
    "path": "src/compat/public_api.ts",
    "content": "export * from './proxy';\nexport * from './firebase.app';\nexport * from './firebase.app.module';\nexport * from './cache';\n"
  },
  {
    "path": "src/compat/remote-config/base.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\n// Export a null object with the same keys as firebase/compat/remote-config, so Proxy can work with proxy-polyfill in Internet Explorer\nexport const proxyPolyfillCompat = {\n  app: null,\n  settings: null,\n  defaultConfig: null,\n  fetchTimeMillis: null,\n  lastFetchStatus: null,\n  activate: null,\n  ensureInitialized: null,\n  fetch: null,\n  fetchAndActivate: null,\n  getAll: null,\n  getBoolean: null,\n  getNumber: null,\n  getString: null,\n  getValue: null,\n  setLogLevel: null,\n};\n"
  },
  {
    "path": "src/compat/remote-config/index.ts",
    "content": "export * from './public_api';\n"
  },
  {
    "path": "src/compat/remote-config/interfaces.ts",
    "content": "import firebase from 'firebase/compat/app';\n\nexport type Settings = firebase.remoteConfig.Settings;\n"
  },
  {
    "path": "src/compat/remote-config/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/remote-config/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/remote-config/public_api.ts",
    "content": "export * from './remote-config';\nexport * from './remote-config.module';\n"
  },
  {
    "path": "src/compat/remote-config/remote-config.module.ts",
    "content": "import { NgModule } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { AngularFireRemoteConfig } from './remote-config';\n\n@NgModule({\n  providers: [ AngularFireRemoteConfig ]\n})\nexport class AngularFireRemoteConfigModule {\n    constructor() {\n        firebase.registerVersion('angularfire', VERSION.full, 'rc-compat');\n    }\n}\n"
  },
  {
    "path": "src/compat/remote-config/remote-config.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS } from '@angular/fire/compat';\nimport { AngularFireRemoteConfig, AngularFireRemoteConfigModule, DEFAULTS, SETTINGS } from '@angular/fire/compat/remote-config';\nimport { COMMON_CONFIG } from '../../../src/test-config';\nimport { rando } from '../../../src/utils';\n\ndescribe('AngularFireRemoteConfig', () => {\n  let rc: AngularFireRemoteConfig;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireRemoteConfigModule\n      ]\n    });\n\n    rc = TestBed.inject(AngularFireRemoteConfig);\n  });\n\n  it('should be exist', () => {\n    expect(rc instanceof AngularFireRemoteConfig).toBe(true);\n  });\n\n  it('should have the Firebase Functions instance', () => {\n    expect(rc.getValue).toBeDefined();\n  });\n\n});\n\nconst FIREBASE_APP_NAME_TOO = (Math.random() + 1).toString(36).substring(7);\n\ndescribe('AngularFireRemoteConfig with different app', () => {\n  let rc: AngularFireRemoteConfig;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireRemoteConfigModule\n      ],\n      providers: [\n        { provide: FIREBASE_APP_NAME, useValue: FIREBASE_APP_NAME_TOO },\n        { provide: FIREBASE_OPTIONS, useValue: COMMON_CONFIG },\n        { provide: SETTINGS, useValue: {} },\n        { provide: DEFAULTS, useValue: {} }\n      ]\n    });\n\n    rc = TestBed.inject(AngularFireRemoteConfig);\n  });\n\n  describe('<constructor>', () => {\n\n    it('should be an AngularFireAuth type', () => {\n      expect(rc instanceof AngularFireRemoteConfig).toEqual(true);\n    });\n\n    it('should have the Firebase Functions instance', () => {\n      expect(rc.getValue).toBeDefined();\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/remote-config/remote-config.ts",
    "content": "import { EnvironmentInjector, Inject, Injectable, InjectionToken, NgZone, Optional, inject } from '@angular/core';\nimport { pendingUntilEvent } from '@angular/core/rxjs-interop';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { ɵPromiseProxy, ɵapplyMixins, ɵlazySDKProxy } from '@angular/fire/compat';\nimport { FIREBASE_APP_NAME, FIREBASE_OPTIONS, ɵcacheInstance, ɵfirebaseAppFactory } from '@angular/fire/compat';\nimport { FirebaseOptions } from 'firebase/app';\nimport firebase from 'firebase/compat/app';\nimport { isSupported } from 'firebase/remote-config';\nimport { EMPTY, MonoTypeOperatorFunction, Observable, OperatorFunction, concat, of, pipe } from 'rxjs';\nimport {\n  debounceTime,\n  distinctUntilChanged,\n  filter,\n  groupBy,\n  map,\n  mergeMap,\n  observeOn,\n  scan,\n  shareReplay,\n  startWith,\n  switchMap,\n  withLatestFrom\n} from 'rxjs/operators';\nimport { proxyPolyfillCompat } from './base';\nimport { Settings } from './interfaces';\n\nexport type ConfigTemplate = Record<string, string | number | boolean>;\n\nexport const SETTINGS = new InjectionToken<Settings>('angularfire2.remoteConfig.settings');\nexport const DEFAULTS = new InjectionToken<ConfigTemplate>('angularfire2.remoteConfig.defaultConfig');\n\n \nexport interface AngularFireRemoteConfig extends ɵPromiseProxy<firebase.remoteConfig.RemoteConfig> {\n}\n\nconst AS_TO_FN = { strings: 'asString', numbers: 'asNumber', booleans: 'asBoolean' };\nconst STATIC_VALUES = { numbers: 0, booleans: false, strings: undefined };\n\n// TODO look into the types here, I don't like the anys\nconst proxyAll = (observable: Observable<Parameter[]>, as: 'numbers' | 'booleans' | 'strings') => new Proxy(\n  observable.pipe(mapToObject(as as any)), {\n    get: (self, name: string) => self[name] || observable.pipe(\n      map(all => all.find(p => p.key === name)),\n      map(param => param ? param[AS_TO_FN[as]]() : STATIC_VALUES[as]),\n      distinctUntilChanged()\n    )\n  }\n) as any;\n\n// TODO export as implements Partial<...> so minor doesn't break us\nexport class Value implements firebase.remoteConfig.Value {\n  asBoolean() {\n    return ['1', 'true', 't', 'y', 'yes', 'on'].includes(this._value.toLowerCase());\n  }\n\n  asString() {\n    return this._value;\n  }\n\n  asNumber() {\n    return Number(this._value) || 0;\n  }\n\n  getSource() {\n    return this._source;\n  }\n\n  constructor(public _source: firebase.remoteConfig.ValueSource, public _value: string) {\n  }\n}\n\n// SEMVER use ConstructorParameters when we can support Typescript 3.6\nexport class Parameter extends Value {\n  constructor(public key: string, public fetchTimeMillis: number, source: firebase.remoteConfig.ValueSource, value: string) {\n    super(source, value);\n  }\n}\n\n// If it's a Parameter array, test any, else test the individual Parameter\nconst filterTest = (fn: (param: Parameter) => boolean) => filter<Parameter | Parameter[]>(it => Array.isArray(it) ? it.some(fn) : fn(it));\n\n// Allow the user to bypass the default values and wait till they get something from the server, even if it's a cached copy;\n// if used in conjuntion with first() it will only fetch RC values from the server if they aren't cached locally\nexport const filterRemote = () => filterTest(p => p.getSource() === 'remote');\n\n// filterFresh allows the developer to effectively set up a maximum cache time\nexport const filterFresh = (howRecentInMillis: number) => filterTest(p => p.fetchTimeMillis + howRecentInMillis >= new Date().getTime());\n\n\n// I ditched loading the defaults into RC and a simple map for scan since we already have our own defaults implementation.\n// The idea here being that if they have a default that never loads from the server, they will be able to tell via fetchTimeMillis\n// on the Parameter. Also if it doesn't come from the server it won't emit again in .changes, due to the distinctUntilChanged,\n// which we can simplify to === rather than deep comparison\nconst scanToParametersArray = (\n  remoteConfig: Observable<firebase.remoteConfig.RemoteConfig | undefined>\n): OperatorFunction<Record<string, firebase.remoteConfig.Value>, Parameter[]> => pipe(\n  withLatestFrom(remoteConfig),\n  scan((existing, [all, rc]) => {\n    // SEMVER use \"new Set\" to unique once we're only targeting es6\n    // at the scale we expect remote config to be at, we probably won't see a performance hit from this unoptimized uniqueness\n    // implementation.\n    // const allKeys = [...new Set([...existing.map(p => p.key), ...Object.keys(all)])];\n    const allKeys = [...existing.map(p => p.key), ...Object.keys(all)].filter((v, i, a) => a.indexOf(v) === i);\n    return allKeys.map(key => {\n      const updatedValue = all[key];\n      return updatedValue ? new Parameter(key, rc ? rc.fetchTimeMillis : -1, updatedValue.getSource(), updatedValue.asString())\n        : existing.find(p => p.key === key);\n    });\n  }, [] as Parameter[])\n);\n\n\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFireRemoteConfig {\n\n  readonly changes: Observable<Parameter>;\n  readonly parameters: Observable<Parameter[]>;\n  readonly numbers: Observable<Record<string, number | undefined>> & Record<string, Observable<number>>;\n  readonly booleans: Observable<Record<string, boolean | undefined>> & Record<string, Observable<boolean>>;\n  readonly strings: Observable<Record<string, string | undefined>> & Record<string, Observable<string | undefined>>;\n\n  private readonly injector = inject(EnvironmentInjector);\n\n  constructor(\n    @Inject(FIREBASE_OPTIONS) options: FirebaseOptions,\n    @Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,\n    @Optional() @Inject(SETTINGS) settings: Settings | null,\n    @Optional() @Inject(DEFAULTS) defaultConfig: ConfigTemplate | null,\n    private zone: NgZone,\n    schedulers: ɵAngularFireSchedulers,\n  ) {\n    const remoteConfig$ = of(undefined).pipe(\n      observeOn(schedulers.outsideAngular),\n      switchMap(() => isSupported()),\n      switchMap(isSupported => isSupported ? import('firebase/compat/remote-config') : EMPTY),\n      map(() => ɵfirebaseAppFactory(options, zone, name)),\n      map(app => ɵcacheInstance(`${app.name}.remote-config`, 'AngularFireRemoteConfig', app.name, () => {\n        const rc = app.remoteConfig();\n        if (settings) {\n          rc.settings = settings;\n        }\n        if (defaultConfig) {\n          rc.defaultConfig = defaultConfig;\n        }\n        return rc;\n      }, [settings, defaultConfig])),\n      startWith<firebase.remoteConfig.RemoteConfig, undefined>(undefined),\n      shareReplay({ bufferSize: 1, refCount: false })\n    ) as Observable<any>;\n\n    const loadedRemoteConfig$ = remoteConfig$.pipe(\n      filter<firebase.remoteConfig.RemoteConfig>(rc => !!rc)\n    );\n\n    const default$: Observable<Record<string, firebase.remoteConfig.Value>> = of(Object.keys(defaultConfig || {}).reduce(\n      (c, k) => ({ ...c, [k]: new Value('default', defaultConfig[k].toString()) }), {}\n    ));\n\n    // we should filter out the defaults we provided to RC, since we have our own implementation\n    // that gives us a -1 for fetchTimeMillis (so filterFresh can filter them out)\n    const filterOutDefaults = map<Record<string, firebase.remoteConfig.Value>, Record<string, firebase.remoteConfig.Value>>(all =>\n      Object.keys(all)\n        .filter(key => all[key].getSource() !== 'default')\n        .reduce((acc, key) => ({ ...acc, [key]: all[key] }), {})\n    );\n\n    const existing$ = loadedRemoteConfig$.pipe(\n      switchMap(rc =>\n        rc.activate()\n          .then(() => rc.ensureInitialized())\n          .then(() => rc.getAll())\n      ),\n      filterOutDefaults\n    );\n\n    const fresh$ = loadedRemoteConfig$.pipe(\n      switchMap(rc => zone.runOutsideAngular(() =>\n        rc.fetchAndActivate()\n          .then(() => rc.ensureInitialized())\n          .then(() => rc.getAll())\n      )),\n      filterOutDefaults\n    );\n\n    this.parameters = concat(default$, existing$, fresh$).pipe(\n      scanToParametersArray(remoteConfig$),\n      pendingUntilEvent(this.injector),\n      shareReplay({ bufferSize: 1, refCount: true })\n    );\n\n    this.changes = this.parameters.pipe(\n      switchMap(params => of(...params)),\n      groupBy(param => param.key),\n      mergeMap(group => group.pipe(\n        distinctUntilChanged()\n      ))\n    );\n\n    this.strings = proxyAll(this.parameters, 'strings');\n    this.booleans = proxyAll(this.parameters, 'booleans');\n    this.numbers = proxyAll(this.parameters, 'numbers');\n\n    return ɵlazySDKProxy(this, loadedRemoteConfig$, zone);\n  }\n\n}\n\n\nexport const budget = <T>(interval: number): MonoTypeOperatorFunction<T> => (source: Observable<T>) => new Observable<T>(observer => {\n  let timedOut = false;\n  // TODO use scheduler task rather than settimeout\n  const timeout = setTimeout(() => {\n    observer.complete();\n    timedOut = true;\n  }, interval);\n  return source.subscribe({\n    next(val) {\n      if (!timedOut) {\n        observer.next(val);\n      }\n    },\n    error(err) {\n      if (!timedOut) {\n        clearTimeout(timeout);\n        observer.error(err);\n      }\n    },\n    complete() {\n      if (!timedOut) {\n        clearTimeout(timeout);\n        observer.complete();\n      }\n    }\n  });\n});\n\nconst typedMethod = (it: any) => {\n  switch (typeof it) {\n    case 'string':\n      return 'asString';\n    case 'boolean':\n      return 'asBoolean';\n    case 'number':\n      return 'asNumber';\n    default:\n      return 'asString';\n  }\n};\n\n\nexport function scanToObject(): OperatorFunction<Parameter, Record<string, string | undefined>>;\nexport function scanToObject(to: 'numbers'): OperatorFunction<Parameter, Record<string, number | undefined>>;\nexport function scanToObject(to: 'booleans'): OperatorFunction<Parameter, Record<string, boolean | undefined>>;\n \nexport function scanToObject(to: 'strings'): OperatorFunction<Parameter, Record<string, string | undefined>>;\nexport function scanToObject<T extends ConfigTemplate>(template: T): OperatorFunction<Parameter, T & Record<string, string | undefined>>;\nexport function scanToObject<T extends ConfigTemplate>(to: 'numbers' | 'booleans' | 'strings' | T = 'strings') {\n  return pipe(\n    // TODO cleanup\n    scan(\n      (c, p: Parameter) => ({\n        ...c, [p.key]: typeof to === 'object' ?\n          p[typedMethod(to[p.key])]() :\n          p[AS_TO_FN[to]]()\n      }),\n      typeof to === 'object' ?\n        to as T & Record<string, string | undefined> :\n        {} as Record<string, number | boolean | string>\n    ),\n    debounceTime(1),\n    budget(10),\n    distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b))\n  );\n}\n\nexport function mapToObject(): OperatorFunction<Parameter[], Record<string, string | undefined>>;\nexport function mapToObject(to: 'numbers'): OperatorFunction<Parameter[], Record<string, number | undefined>>;\nexport function mapToObject(to: 'booleans'): OperatorFunction<Parameter[], Record<string, boolean | undefined>>;\n \nexport function mapToObject(to: 'strings'): OperatorFunction<Parameter[], Record<string, string | undefined>>;\nexport function mapToObject<T extends ConfigTemplate>(template: T):\n  OperatorFunction<Parameter[], T & Record<string, string | undefined>>;\nexport function mapToObject<T extends ConfigTemplate>(to: 'numbers' | 'booleans' | 'strings' | T = 'strings') {\n  return pipe(\n    // TODO this is getting a little long, cleanup\n    map((params: Parameter[]) => params.reduce(\n      (c, p) => ({\n        ...c, [p.key]: typeof to === 'object' ?\n          p[typedMethod(to[p.key])]() :\n          p[AS_TO_FN[to]]()\n      }),\n      typeof to === 'object' ?\n        to as T & Record<string, string | undefined> :\n        {} as Record<string, number | boolean | string>\n    )),\n    distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b))\n  );\n}\n\nɵapplyMixins(AngularFireRemoteConfig, [proxyPolyfillCompat]);\n"
  },
  {
    "path": "src/compat/storage/interfaces.ts",
    "content": "import firebase from 'firebase/compat/app';\n\nexport type UploadTask = firebase.storage.UploadTask;\nexport type UploadTaskSnapshot = firebase.storage.UploadTaskSnapshot;\nexport type UploadMetadata = firebase.storage.UploadMetadata;\n\nexport type SettableMetadata = firebase.storage.SettableMetadata;\nexport type Reference = firebase.storage.Reference;\nexport type StringFormat = firebase.storage.StringFormat;\nexport type ListResult = firebase.storage.ListResult;\nexport type ListOptions = firebase.storage.ListOptions;\n"
  },
  {
    "path": "src/compat/storage/ng-package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/compat/storage/observable/fromTask.ts",
    "content": "import { Observable } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\nimport { UploadTask, UploadTaskSnapshot } from '../interfaces';\n\n// need to import, else the types become import('firebase/compat/app').default.storage.UploadTask\n// and it no longer works w/Firebase v7\n\n// Things aren't working great, I'm having to put in a lot of work-arounds for what\n// appear to be Firebase JS SDK bugs https://github.com/firebase/firebase-js-sdk/issues/4158\nexport function fromTask(task: UploadTask) {\n  return new Observable<UploadTaskSnapshot>(subscriber => {\n    const progress = (snap: UploadTaskSnapshot) => subscriber.next(snap);\n    const error = e => subscriber.error(e);\n    const complete = () => subscriber.complete();\n    // emit the current snapshot, so they don't have to wait for state_changes\n    // to fire next... this is stale if the task is no longer running :(\n    progress(task.snapshot);\n    const unsub = task.on('state_changed', progress);\n    // it turns out that neither task snapshot nor 'state_changed' fire the last\n    // snapshot before completion, the one with status 'success\" and 100% progress\n    // so let's use the promise form of the task for that\n    task.then(snapshot => {\n      progress(snapshot);\n      complete();\n    }, e => {\n      // TODO investigate, again this is stale, we never fire a canceled or error it seems\n      progress(task.snapshot);\n      error(e);\n    });\n    // on's type if Function, rather than () => void, need to wrap\n    return function unsubscribe() {\n      unsub();\n    };\n  }).pipe(\n    // deal with sync emissions from first emitting `task.snapshot`, this makes sure\n    // that if the task is already finished we don't emit the old running state\n    debounceTime(0)\n  );\n}\n"
  },
  {
    "path": "src/compat/storage/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/compat/storage/pipes/storageUrl.pipe.ts",
    "content": "import { AsyncPipe } from '@angular/common';\nimport { ChangeDetectorRef, NgModule, OnDestroy, Optional, Pipe, PipeTransform, TransferState, makeStateKey } from '@angular/core';\nimport { Observable, of } from 'rxjs';\nimport { tap } from 'rxjs/operators';\nimport { AngularFireStorage } from '../storage';\n\n/** to be used with in combination with | async */\n@Pipe({\n  name: 'getDownloadURL',\n  pure: false,\n})\nexport class GetDownloadURLPipe implements PipeTransform, OnDestroy {\n\n  private asyncPipe: AsyncPipe;\n  private path: string;\n  private downloadUrl$: Observable<any>;\n\n  constructor(\n    private storage: AngularFireStorage,\n    cdr: ChangeDetectorRef,\n    @Optional() private state: TransferState\n  ) {\n    this.asyncPipe = new AsyncPipe(cdr);\n  }\n\n  transform(path: string) {\n    if (path !== this.path) {\n      this.path = path;\n      const key = makeStateKey<string>(`|getDownloadURL|${path}`);\n      const existing = this.state?.get(key, undefined);\n      this.downloadUrl$ = existing ? of(existing) : this.storage.ref(path).getDownloadURL().pipe(\n        tap(it => this.state?.set(key, it))\n      );\n    }\n    return this.asyncPipe.transform(this.downloadUrl$);\n  }\n\n  ngOnDestroy() {\n    this.asyncPipe.ngOnDestroy();\n  }\n\n}\n\n@NgModule({\n  imports: [ GetDownloadURLPipe ],\n  exports: [ GetDownloadURLPipe ],\n})\nexport class GetDownloadURLPipeModule {}\n"
  },
  {
    "path": "src/compat/storage/public_api.ts",
    "content": "export * from './ref';\nexport * from './storage';\nexport * from './task';\nexport * from './observable/fromTask';\nexport * from './storage.module';\nexport * from './pipes/storageUrl.pipe';\n"
  },
  {
    "path": "src/compat/storage/ref.ts",
    "content": "import { Injector } from '@angular/core';\nimport { pendingUntilEvent } from '@angular/core/rxjs-interop';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { Observable, from, of } from 'rxjs';\nimport { observeOn, switchMap } from 'rxjs/operators';\nimport { ListOptions, ListResult, Reference, SettableMetadata, StringFormat, UploadMetadata } from './interfaces';\nimport { AngularFireUploadTask, createUploadTask } from './task';\n\nexport interface AngularFireStorageReference {\n  getDownloadURL(): Observable<any>;\n  getMetadata(): Observable<any>;\n  delete(): Observable<any>;\n  child(path: string): AngularFireStorageReference;\n  updateMetadata(meta: SettableMetadata): Observable<any>;\n  put(data: any, metadata?: UploadMetadata  ): AngularFireUploadTask;\n  putString(data: string, format?: string  , metadata?: UploadMetadata  ): AngularFireUploadTask;\n  list(options?: ListOptions): Observable<ListResult>;\n  listAll(): Observable<ListResult>;\n}\n\n/**\n * Create an AngularFire wrapped Storage Reference. This object\n * creates observable methods from promise based methods.\n */\nexport function createStorageRef(\n  ref: Reference,\n  injector?: Injector\n): AngularFireStorageReference {\n  return {\n    getDownloadURL: () => of(undefined).pipe(\n      observeOn(injector.get(ɵAngularFireSchedulers).outsideAngular),\n      switchMap(() => ref.getDownloadURL()),\n      pendingUntilEvent(injector)\n    ),\n    getMetadata: () => of(undefined).pipe(\n      observeOn(injector.get(ɵAngularFireSchedulers).outsideAngular),\n      switchMap(() => ref.getMetadata()),\n      pendingUntilEvent(injector)\n    ),\n    delete: () => from(ref.delete()),\n    child: (path: string) => createStorageRef(ref.child(path), injector),\n    updateMetadata: (meta: SettableMetadata) => from(ref.updateMetadata(meta)),\n    put: (data: any, metadata?: UploadMetadata) => {\n      const task = ref.put(data, metadata);\n      return createUploadTask(task);\n    },\n    putString: (data: string, format?: StringFormat, metadata?: UploadMetadata) => {\n      const task = ref.putString(data, format, metadata);\n      return createUploadTask(task);\n    },\n    list: (options?: ListOptions) => from(ref.list(options)),\n    listAll: () => from(ref.listAll())\n  };\n}\n"
  },
  {
    "path": "src/compat/storage/storage.module.ts",
    "content": "import { NgModule } from '@angular/core';\nimport { VERSION } from '@angular/fire';\nimport firebase from 'firebase/compat/app';\nimport { GetDownloadURLPipeModule } from './pipes/storageUrl.pipe';\nimport { AngularFireStorage } from './storage';\n\n@NgModule({\n  imports: [ GetDownloadURLPipeModule ],\n  exports: [ GetDownloadURLPipeModule ],\n  providers: [ AngularFireStorage ]\n})\nexport class AngularFireStorageModule {\n  constructor() {\n    firebase.registerVersion('angularfire', VERSION.full, 'gcs-compat');\n  }\n}\n"
  },
  {
    "path": "src/compat/storage/storage.spec.ts",
    "content": "import { ChangeDetectorRef } from '@angular/core';\nimport { TestBed } from '@angular/core/testing';\nimport { AngularFireModule, FIREBASE_APP_NAME, FIREBASE_OPTIONS } from '@angular/fire/compat';\nimport { AngularFireStorage, AngularFireStorageModule, AngularFireUploadTask, BUCKET, USE_EMULATOR, fromTask } from '@angular/fire/compat/storage';\nimport firebase from 'firebase/compat/app';\nimport { forkJoin } from 'rxjs';\nimport { mergeMap, tap } from 'rxjs/operators';\nimport { COMMON_CONFIG, storageEmulatorPort } from '../../test-config';\nimport { rando } from '../../utils';\nimport 'firebase/compat/storage';\n\nif (typeof XMLHttpRequest === 'undefined') {\n  globalThis.XMLHttpRequest = require('xhr2');\n}\n\nconst blobOrBuffer = (data: string, options: unknown) => {\n  if (typeof Blob === 'undefined') {\n    return Buffer.from(data, 'utf8');\n  } else {\n    return new Blob([JSON.stringify(data)], options);\n  }\n};\n\ndescribe('AngularFireStorage', () => {\n  let afStorage: AngularFireStorage;\n\n  beforeEach(() => {\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireStorageModule,\n      ],\n      providers: [\n        ChangeDetectorRef,\n        { provide: USE_EMULATOR, useValue: ['localhost', storageEmulatorPort] }\n      ]\n    });\n\n    afStorage = TestBed.inject(AngularFireStorage);\n  });\n\n  it('should exist', () => {\n    expect(afStorage instanceof AngularFireStorage).toBe(true);\n  });\n\n  it('should have the Firebase storage instance', () => {\n    expect(afStorage.storage).toBeDefined();\n  });\n\n  it('should have an initialized Firebase app', () => {\n    expect(afStorage.storage.app).toBeDefined();\n  });\n\n  describe('upload task', () => {\n\n    it('should upload and delete a file', (done) => {\n      const data = { angular: 'fire' };\n      const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' });\n      const ref = TestBed.runInInjectionContext(() => afStorage.ref(rando()));\n      const task = TestBed.runInInjectionContext(() => ref.put(blob));\n      let emissionCount = 0;\n      let lastSnap: firebase.storage.UploadTaskSnapshot;\n      TestBed.runInInjectionContext(() => task.snapshotChanges())\n        .subscribe(\n          snap => {\n            lastSnap = snap;\n            emissionCount++;\n            expect(snap).toBeDefined();\n          },\n          done.fail,\n          () => {\n            expect(lastSnap.state).toBe('success');\n            expect(emissionCount).toBeGreaterThan(0);\n            ref.delete().subscribe(done, done.fail);\n          });\n    });\n\n    it('should upload a file and observe the download url', (done) => {\n      const data = {angular: 'fire'};\n      const blob = blobOrBuffer(JSON.stringify(data), {type: 'application/json'});\n      const ref = TestBed.runInInjectionContext(() => afStorage.ref(rando()));\n      TestBed.runInInjectionContext(() => ref.put(blob)).then(() => {\n        const url$ = TestBed.runInInjectionContext(() => ref.getDownloadURL());\n        url$.subscribe(\n          url => {\n            expect(url).toBeDefined();\n          },\n          done.fail,\n          () => {\n            ref.delete().subscribe(done, done.fail);\n          }\n        );\n      });\n    });\n\n    it('should resolve the task as a promise', (done) => {\n      const data = { angular: 'promise' };\n      const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' });\n      const ref = TestBed.runInInjectionContext(() => afStorage.ref(rando()));\n      const task: AngularFireUploadTask = TestBed.runInInjectionContext(() => ref.put(blob));\n      task.then(snap => {\n        expect(snap).toBeDefined();\n        done();\n      }).catch(done.fail);\n    });\n\n    it('should cancel the task', (done) => {\n      const data = { angular: 'promise' };\n      const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' });\n      const ref = TestBed.runInInjectionContext(() => afStorage.ref(rando()));\n      const task: AngularFireUploadTask = TestBed.runInInjectionContext(() => ref.put(blob));\n      let emissionCount = 0;\n      let lastSnap: firebase.storage.UploadTaskSnapshot;\n      TestBed.runInInjectionContext(() => task.snapshotChanges()).subscribe(snap => {\n        emissionCount++;\n        lastSnap = snap;\n        if (emissionCount === 1) {\n          task.cancel();\n        }\n      }, () => {\n        // TODO investigate, this doesn't appear to work...\n        // https://github.com/firebase/firebase-js-sdk/issues/4158\n        // expect(lastSnap.state).toEqual('canceled');\n        expect(emissionCount).toEqual(1);\n        expect(lastSnap.state).toEqual('running');\n        done();\n      }, done.fail);\n    });\n\n    it('should be able to pause/resume the task', (done) => {\n      const data = { angular: 'promise' };\n      const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' });\n      const ref = TestBed.runInInjectionContext(() => afStorage.ref(rando()));\n      const task: AngularFireUploadTask = TestBed.runInInjectionContext(() => ref.put(blob));\n      let paused = false;\n      task.pause();\n      TestBed.runInInjectionContext(() => task.snapshotChanges()).subscribe(snap => {\n        if (snap.state === 'paused') {\n          paused = true;\n          task.resume();\n        }\n      }, done.fail, () => {\n        expect(paused).toBeTruthy();\n        done();\n      });\n    });\n\n    it('should work with an already finished task', (done) => {\n      const data = {angular: 'promise'};\n      const blob = blobOrBuffer(JSON.stringify(data), {type: 'application/json'});\n      const ref = TestBed.runInInjectionContext(() => afStorage.storage.ref(rando()));\n      const task = TestBed.runInInjectionContext(() => ref.put(blob));\n      let emissionCount = 0;\n      let lastSnap: firebase.storage.UploadTaskSnapshot;\n      task.then(_snap => {\n        fromTask(task).subscribe(\n          snap => {\n            lastSnap = snap;\n            emissionCount++;\n            expect(snap).toBeDefined();\n          },\n          done.fail,\n          () => {\n            expect(lastSnap.state).toBe('success');\n            expect(emissionCount).toBe(1);\n            ref.delete().then(done, done.fail);\n          });\n      });\n    });\n\n  });\n\n  describe('reference', () => {\n\n    it('it should upload, download, and delete', (done) => {\n      const data = { angular: 'fire' };\n      const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' });\n      const ref = TestBed.runInInjectionContext(() => afStorage.ref(rando()));\n      const task = TestBed.runInInjectionContext(() => ref.put(blob));\n      // Wait for the upload\n      forkJoin([TestBed.runInInjectionContext(() => task.snapshotChanges())])\n        .pipe(\n          // get the url download\n          mergeMap(() => TestBed.runInInjectionContext(() => ref.getDownloadURL())),\n          // assert the URL\n          tap(url => expect(url).toBeDefined()),\n          // Delete the file\n          mergeMap(() => ref.delete())\n        )\n        // finish the test\n        .subscribe(done, done.fail);\n    });\n\n    it('should upload, get metadata, and delete', (done) => {\n      pending(\"Not sure why this is busted.\");\n      const data = { angular: 'fire' };\n      const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' });\n      const ref = TestBed.runInInjectionContext(() => afStorage.ref(rando()));\n      const task = TestBed.runInInjectionContext(() => ref.put(blob, { customMetadata: { blah: 'blah' } }));\n      // Wait for the upload\n      forkJoin([TestBed.runInInjectionContext(() => task.snapshotChanges())])\n        .pipe(\n          // get the metadata download\n          mergeMap(() => TestBed.runInInjectionContext(() => ref.getMetadata())),\n          // assert the URL\n          tap(meta => expect(meta.customMetadata).toEqual({ blah: 'blah' })),\n        )\n        // finish the test\n        .subscribe(done, done.fail);\n    });\n\n  });\n\n});\n\ndescribe('AngularFireStorage w/options', () => {\n  let afStorage: AngularFireStorage;\n  let firebaseAppName: string;\n  let storageBucket: string;\n\n  beforeEach(() => {\n    firebaseAppName = rando();\n    storageBucket = 'angularfire2-test2';\n    TestBed.configureTestingModule({\n      imports: [\n        AngularFireModule.initializeApp(COMMON_CONFIG, rando()),\n        AngularFireStorageModule\n      ],\n      providers: [\n        { provide: FIREBASE_APP_NAME, useValue: firebaseAppName },\n        { provide: FIREBASE_OPTIONS, useValue: COMMON_CONFIG },\n        { provide: BUCKET, useValue: storageBucket },\n        { provide: USE_EMULATOR, useValue: ['localhost', storageEmulatorPort] },\n      ]\n    });\n\n    afStorage = TestBed.inject(AngularFireStorage);\n  });\n\n  describe('<constructor>', () => {\n\n    it('should exist', () => {\n      expect(afStorage instanceof AngularFireStorage).toBe(true);\n    });\n\n    it('should have the Firebase storage instance', () => {\n      expect(afStorage.storage).toBeDefined();\n    });\n\n    it('should have an initialized Firebase app', () => {\n      expect(afStorage.storage.app).toBeDefined();\n    });\n\n    it('should be hooked up the right app', () => {\n      expect(afStorage.storage.app.name).toEqual(firebaseAppName);\n    });\n\n    it('storage be pointing towards a different bucket', () => {\n      expect(afStorage.storage.ref().toString()).toEqual(`gs://${storageBucket}/`);\n    });\n\n    // TODO tests for Node?\n    if (typeof Blob !== 'undefined') {\n\n      it('it should upload, download, and delete', (done) => {\n        const data = { angular: 'fire' };\n        const blob = blobOrBuffer(JSON.stringify(data), { type: 'application/json' });\n        const name = rando();\n        const ref = TestBed.runInInjectionContext(() => afStorage.ref(name));\n        const task = TestBed.runInInjectionContext(() => ref.put(blob));\n        // Wait for the upload\n        forkJoin([TestBed.runInInjectionContext(() => task.snapshotChanges())])\n          .pipe(\n            // get the url download\n            mergeMap(() => TestBed.runInInjectionContext(() => ref.getDownloadURL())),\n            // assert the URL\n            tap(url => expect(url).toMatch(new RegExp(`http:\\\\/\\\\/localhost:9199\\\\/v0\\\\/b\\\\/${storageBucket}\\\\/o\\\\/${name}`))),\n            // Delete the file\n            mergeMap(() => ref.delete())\n          )\n          // finish the test\n          .subscribe(done, done.fail);\n      });\n\n    }\n\n  });\n\n});\n"
  },
  {
    "path": "src/compat/storage/storage.ts",
    "content": "import { EnvironmentInjector, Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID, inject } from '@angular/core';\nimport { ɵAngularFireSchedulers } from '@angular/fire';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { FIREBASE_APP_NAME, FIREBASE_OPTIONS, ɵcacheInstance, ɵfirebaseAppFactory } from '@angular/fire/compat';\nimport { FirebaseOptions } from 'firebase/app';\nimport firebase from 'firebase/compat/app';\nimport { UploadMetadata } from './interfaces';\nimport { createStorageRef } from './ref';\nimport 'firebase/compat/storage';\n\nexport const BUCKET = new InjectionToken<string>('angularfire2.storageBucket');\nexport const MAX_UPLOAD_RETRY_TIME = new InjectionToken<number>('angularfire2.storage.maxUploadRetryTime');\nexport const MAX_OPERATION_RETRY_TIME = new InjectionToken<number>('angularfire2.storage.maxOperationRetryTime');\n\ntype UseEmulatorArguments = Parameters<firebase.storage.Storage['useEmulator']>;\nexport const USE_EMULATOR = new InjectionToken<UseEmulatorArguments>('angularfire2.storage.use-emulator');\n\n/**\n * AngularFireStorage Service\n *\n * This service is the main entry point for this feature module. It provides\n * an API for uploading and downloading binary files from Cloud Storage for\n * Firebase.\n */\n@Injectable({\n  providedIn: 'any'\n})\nexport class AngularFireStorage {\n  public readonly storage: firebase.storage.Storage;\n  private readonly injector = inject(EnvironmentInjector);\n\n  constructor(\n    @Inject(FIREBASE_OPTIONS) options: FirebaseOptions,\n    @Optional() @Inject(FIREBASE_APP_NAME) name: string | null | undefined,\n    @Optional() @Inject(BUCKET) storageBucket: string | null,\n\n    @Inject(PLATFORM_ID) platformId: object,\n    zone: NgZone,\n    schedulers: ɵAngularFireSchedulers,\n    @Optional() @Inject(MAX_UPLOAD_RETRY_TIME) maxUploadRetryTime: any,\n    @Optional() @Inject(MAX_OPERATION_RETRY_TIME) maxOperationRetryTime: any,\n    @Optional() @Inject(USE_EMULATOR) _useEmulator: any,\n    @Optional() _appCheckInstances: AppCheckInstances,\n  ) {\n    const app = ɵfirebaseAppFactory(options, zone, name);\n    this.storage = ɵcacheInstance(`${app.name}.storage.${storageBucket}`, 'AngularFireStorage', app.name, () => {\n      const storage = zone.runOutsideAngular(() => app.storage(storageBucket || undefined));\n      const useEmulator = _useEmulator as UseEmulatorArguments|null;\n      if (useEmulator) {\n        storage.useEmulator(...useEmulator);\n      }\n      if (maxUploadRetryTime) {\n        storage.setMaxUploadRetryTime(maxUploadRetryTime);\n      }\n      if (maxOperationRetryTime) {\n        storage.setMaxOperationRetryTime(maxOperationRetryTime);\n      }\n      return storage;\n    }, [maxUploadRetryTime, maxOperationRetryTime]);\n  }\n\n  ref(path: string) {\n    return createStorageRef(this.storage.ref(path), this.injector);\n  }\n\n  refFromURL(path: string) {\n    return createStorageRef(this.storage.refFromURL(path), this.injector);\n  }\n\n  upload(path: string, data: any, metadata?: UploadMetadata) {\n    const storageRef = this.storage.ref(path);\n    const ref = createStorageRef(storageRef, this.injector);\n    return ref.put(data, metadata);\n  }\n\n}\n"
  },
  {
    "path": "src/compat/storage/task.ts",
    "content": "import { Observable } from 'rxjs';\nimport { map } from 'rxjs/operators';\nimport { UploadTask, UploadTaskSnapshot } from './interfaces';\nimport { fromTask } from './observable/fromTask';\n\nexport interface AngularFireUploadTask {\n  task: UploadTask;\n  snapshotChanges(): Observable<UploadTaskSnapshot | undefined>;\n  percentageChanges(): Observable<number | undefined>;\n  pause(): boolean;\n  cancel(): boolean;\n  resume(): boolean;\n  then(\n    onFulfilled?: ((a: UploadTaskSnapshot) => any) | null,\n    onRejected?: ((a: Error) => any) | null\n  ): Promise<any>;\n  catch(onRejected: (a: Error) => any): Promise<any>;\n}\n\n/**\n * Create an AngularFireUploadTask from a regular UploadTask from the Storage SDK.\n * This method creates an observable of the upload and returns on object that provides\n * multiple methods for controlling and monitoring the file upload.\n */\nexport function createUploadTask(task: UploadTask): AngularFireUploadTask {\n  const inner$ = fromTask(task);\n  return {\n    task,\n    then: task.then.bind(task),\n    catch: task.catch.bind(task),\n    pause: task.pause.bind(task),\n    cancel: task.cancel.bind(task),\n    resume: task.resume.bind(task),\n    snapshotChanges: () => inner$,\n    percentageChanges: () => inner$.pipe(\n      map(s => s.bytesTransferred / s.totalBytes * 100)\n    )\n  };\n}\n"
  },
  {
    "path": "src/core.ts",
    "content": "import { Version } from '@angular/core';\nimport { ComponentContainer } from '@firebase/component';\nimport { FirebaseApp, getApps } from 'firebase/app';\n\nexport const VERSION = new Version('ANGULARFIRE2_VERSION');\n\nexport const ɵisSupportedError = (module: string) =>\n  `The APP_INITIALIZER that is \"making\" isSupported() sync for the sake of convenient DI has not resolved in this\ncontext. Rather than injecting ${module} in the constructor, first ensure that ${module} is supported by calling\n\\`await isSupported()\\`, then retrieve the instance from the injector manually \\`injector.get(${module})\\`.`;\n\n// TODO is there a better way to get at the internal types?\ninterface FirebaseAppWithContainer extends FirebaseApp {\n  container: ComponentContainer;\n}\n\nexport function ɵgetDefaultInstanceOf<T= unknown>(identifier: string, provided: T[]|undefined, defaultApp: FirebaseApp): T|undefined  {\n  if (provided) {\n    // Was provide* only called once? If so grab that\n    if (provided.length === 1) { return provided[0]; }\n    const providedUsingDefaultApp = provided.filter((it: any) => it.app === defaultApp);\n    // Was provide* only called once, using the default app? If so use that\n    if (providedUsingDefaultApp.length === 1) { return providedUsingDefaultApp[0]; }\n  }\n  // Grab the default instance from the defaultApp\n  const defaultAppWithContainer: FirebaseAppWithContainer = defaultApp as any;\n  const provider = defaultAppWithContainer.container.getProvider(identifier as never);\n  return provider.getImmediate({ optional: true });\n}\n\nexport const ɵgetAllInstancesOf = <T= unknown>(identifier: string, app?: FirebaseApp): T[] => {\n  const apps = app ? [app] : getApps();\n  const instances: any[] = [];\n  apps.forEach((app: FirebaseAppWithContainer) => {\n    const provider: any = app.container.getProvider(identifier as never);\n    provider.instances.forEach((instance: any) => {\n      if (!instances.includes(instance)) {\n        instances.push(instance);\n      }\n    });\n  });\n  return instances;\n};\n"
  },
  {
    "path": "src/data-connect/data-connect.module.ts",
    "content": "import {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { registerVersion } from 'firebase/app';\nimport { DATA_CONNECT_PROVIDER_NAME, DataConnect, DataConnectInstances } from './data-connect';\n\nconst PROVIDED_DATA_CONNECT_INSTANCES = new InjectionToken<DataConnect[]>('angularfire2.data-connect-instances');\n\nexport function defaultDataConnectInstanceFactory(provided: DataConnect[]|undefined, defaultApp: FirebaseApp) {\n  return ɵgetDefaultInstanceOf<DataConnect>(DATA_CONNECT_PROVIDER_NAME, provided, defaultApp);\n}\n\nexport function dataConnectInstanceFactory(fn: (injector: Injector) => DataConnect) {\n  return (zone: NgZone, injector: Injector) => {\n    return zone.runOutsideAngular(() => fn(injector));\n  };\n}\n\nconst DATA_CONNECT_INSTANCES_PROVIDER = {\n  provide: DataConnectInstances,\n  deps: [\n    [new Optional(), PROVIDED_DATA_CONNECT_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_DATA_CONNECT_INSTANCE_PROVIDER = {\n  provide: DataConnect,\n  useFactory: defaultDataConnectInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_DATA_CONNECT_INSTANCES ],\n    FirebaseApp,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_DATA_CONNECT_INSTANCE_PROVIDER,\n    DATA_CONNECT_INSTANCES_PROVIDER,\n  ]\n})\nexport class DataConnectModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'fdc');\n  }\n}\n\nexport function provideDataConnect(fn: (injector: Injector) => DataConnect, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'fdc');\n\n  return makeEnvironmentProviders([\n    DEFAULT_DATA_CONNECT_INSTANCE_PROVIDER,\n    DATA_CONNECT_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_DATA_CONNECT_INSTANCES,\n      useFactory: dataConnectInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        ...deps,\n      ],\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/data-connect/data-connect.spec.ts",
    "content": "/*\nimport { TestBed } from '@angular/core/testing';\nimport { getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { DataConnect, getDataConnect, provideDataConnect } from '@angular/fire/data-connect';\nimport { COMMON_CONFIG } from '../test-config';\nimport { rando } from '../utils';\n\n\ndescribe('DataConnect', () => {\n  let dataConnect: DataConnect;\n  let providedDataConnect: DataConnect;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideDataConnect(() => {\n                  providedDataConnect = getDataConnect(getApp(appName));\n                  return providedDataConnect;\n                }),\n            ],\n        });\n        dataConnect = TestBed.inject(DataConnect);\n    });\n\n    it('should be injectable', () => {\n      expect(providedDataConnect).toBeTruthy();\n      expect(dataConnect).toEqual(providedDataConnect);\n    });\n\n  });\n\n});\n*/"
  },
  {
    "path": "src/data-connect/data-connect.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { DataConnect } from 'firebase/data-connect';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\nexport { DataConnect };\n\nexport const DATA_CONNECT_PROVIDER_NAME = 'data-connect';\n\n \nexport interface DataConnectInstances extends Array<DataConnect> {}\n\nexport class DataConnectInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<DataConnect>(DATA_CONNECT_PROVIDER_NAME);\n  }\n}\n\nexport const dataConnectInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<DataConnect>(DATA_CONNECT_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/data-connect/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/data-connect';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  connectDataConnectEmulator as _connectDataConnectEmulator,\n  executeMutation as _executeMutation,\n  executeQuery as _executeQuery,\n  getDataConnect as _getDataConnect,\n  mutationRef as _mutationRef,\n  queryRef as _queryRef,\n  setLogLevel as _setLogLevel,\n  subscribe as _subscribe,\n  terminate as _terminate,\n  toQueryRef as _toQueryRef\n} from 'firebase/data-connect';\n\nexport const connectDataConnectEmulator = ɵzoneWrap(_connectDataConnectEmulator, true);\nexport const executeMutation = ɵzoneWrap(_executeMutation, true);\nexport const executeQuery = ɵzoneWrap(_executeQuery, true);\nexport const getDataConnect = ɵzoneWrap(_getDataConnect, true);\nexport const mutationRef = ɵzoneWrap(_mutationRef, true, 2);\nexport const queryRef = ɵzoneWrap(_queryRef, true, 2);\nexport const setLogLevel = ɵzoneWrap(_setLogLevel, true);\nexport const subscribe = ɵzoneWrap(_subscribe, true);\nexport const terminate = ɵzoneWrap(_terminate, true);\nexport const toQueryRef = ɵzoneWrap(_toQueryRef, true, 2);\n"
  },
  {
    "path": "src/data-connect/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/data-connect/overrides.ts",
    "content": "import { isMessagingSupportedFactory } from './is-messaging-supported-factory';\n\nexport const isSupported = isMessagingSupportedFactory.async;\n"
  },
  {
    "path": "src/data-connect/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/data-connect/public_api.ts",
    "content": "export { DataConnectInstances, DataConnect, dataConnectInstance$ } from './data-connect';\nexport { provideDataConnect, DataConnectModule } from './data-connect.module';\nexport * from './firebase';\n"
  },
  {
    "path": "src/database/database.module.ts",
    "content": "import {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { AuthInstances } from '@angular/fire/auth';\nimport { registerVersion } from 'firebase/app';\nimport { Database as FirebaseDatabase } from 'firebase/database';\nimport { DATABASE_PROVIDER_NAME, Database, DatabaseInstances } from './database';\n\nexport const PROVIDED_DATABASE_INSTANCES = new InjectionToken<Database[]>('angularfire2.database-instances');\n\nexport function defaultDatabaseInstanceFactory(provided: FirebaseDatabase[]|undefined, defaultApp: FirebaseApp) {\n  const defaultDatabase = ɵgetDefaultInstanceOf<FirebaseDatabase>(DATABASE_PROVIDER_NAME, provided, defaultApp);\n  return defaultDatabase && new Database(defaultDatabase);\n}\n\nexport function databaseInstanceFactory(fn: (injector: Injector) => FirebaseDatabase) {\n  return (zone: NgZone, injector: Injector) => {\n    const database = zone.runOutsideAngular(() => fn(injector));\n    return new Database(database);\n  };\n}\n\nconst DATABASE_INSTANCES_PROVIDER = {\n  provide: DatabaseInstances,\n  deps: [\n    [new Optional(), PROVIDED_DATABASE_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_DATABASE_INSTANCE_PROVIDER = {\n  provide: Database,\n  useFactory: defaultDatabaseInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_DATABASE_INSTANCES ],\n    FirebaseApp,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_DATABASE_INSTANCE_PROVIDER,\n    DATABASE_INSTANCES_PROVIDER,\n  ]\n})\nexport class DatabaseModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'rtdb');\n  }\n}\n\nexport function provideDatabase(fn: (injector: Injector) => FirebaseDatabase, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'rtdb');\n  return makeEnvironmentProviders([\n    DEFAULT_DATABASE_INSTANCE_PROVIDER,\n    DATABASE_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_DATABASE_INSTANCES,\n      useFactory: databaseInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        // Database+Auth work better if Auth is loaded first\n        [new Optional(), AuthInstances ],\n        [new Optional(), AppCheckInstances ],\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/database/database.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { Database, connectDatabaseEmulator, getDatabase, provideDatabase } from '@angular/fire/database';\nimport { COMMON_CONFIG } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('Database', () => {\n  let app: FirebaseApp;\n  let database: Database;\n  let providedDatabase: Database;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideDatabase(() => {\n                    providedDatabase = getDatabase(getApp(appName));\n                    connectDatabaseEmulator(providedDatabase, 'localhost', 9002);\n                    return providedDatabase;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        database = TestBed.inject(Database);\n    });\n\n    it('should be injectable', () => {\n        expect(providedDatabase).toBeTruthy();\n        expect(database).toEqual(providedDatabase);\n        expect(database.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/database/database.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { Database as FirebaseDatabase } from 'firebase/database';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface Database extends FirebaseDatabase {}\n\nexport class Database {\n  constructor(database: FirebaseDatabase) {\n    return database;\n  }\n}\n\nexport const DATABASE_PROVIDER_NAME = 'database';\n\n \nexport interface DatabaseInstances extends Array<FirebaseDatabase> {}\n\nexport class DatabaseInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseDatabase>(DATABASE_PROVIDER_NAME);\n  }\n}\n\nexport const databaseInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseDatabase>(DATABASE_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/database/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/database';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  child as _child,\n  connectDatabaseEmulator as _connectDatabaseEmulator,\n  enableLogging as _enableLogging,\n  endAt as _endAt,\n  endBefore as _endBefore,\n  equalTo as _equalTo,\n  forceLongPolling as _forceLongPolling,\n  forceWebSockets as _forceWebSockets,\n  get as _get,\n  getDatabase as _getDatabase,\n  goOffline as _goOffline,\n  goOnline as _goOnline,\n  increment as _increment,\n  limitToFirst as _limitToFirst,\n  limitToLast as _limitToLast,\n  off as _off,\n  onChildAdded as _onChildAdded,\n  onChildChanged as _onChildChanged,\n  onChildMoved as _onChildMoved,\n  onChildRemoved as _onChildRemoved,\n  onDisconnect as _onDisconnect,\n  onValue as _onValue,\n  orderByChild as _orderByChild,\n  orderByKey as _orderByKey,\n  orderByPriority as _orderByPriority,\n  orderByValue as _orderByValue,\n  push as _push,\n  query as _query,\n  ref as _ref,\n  refFromURL as _refFromURL,\n  remove as _remove,\n  runTransaction as _runTransaction,\n  set as _set,\n  setPriority as _setPriority,\n  setWithPriority as _setWithPriority,\n  startAfter as _startAfter,\n  startAt as _startAt,\n  update as _update\n} from 'firebase/database';\n\nexport const child = ɵzoneWrap(_child, true, 2);\nexport const connectDatabaseEmulator = ɵzoneWrap(_connectDatabaseEmulator, true);\nexport const enableLogging = ɵzoneWrap(_enableLogging, true);\nexport const endAt = ɵzoneWrap(_endAt, true, 2);\nexport const endBefore = ɵzoneWrap(_endBefore, true, 2);\nexport const equalTo = ɵzoneWrap(_equalTo, true, 2);\nexport const forceLongPolling = ɵzoneWrap(_forceLongPolling, true);\nexport const forceWebSockets = ɵzoneWrap(_forceWebSockets, true);\nexport const get = ɵzoneWrap(_get, true);\nexport const getDatabase = ɵzoneWrap(_getDatabase, true);\nexport const goOffline = ɵzoneWrap(_goOffline, true);\nexport const goOnline = ɵzoneWrap(_goOnline, true);\nexport const increment = ɵzoneWrap(_increment, true, 2);\nexport const limitToFirst = ɵzoneWrap(_limitToFirst, true, 2);\nexport const limitToLast = ɵzoneWrap(_limitToLast, true, 2);\nexport const off = ɵzoneWrap(_off, true);\nexport const onChildAdded = ɵzoneWrap(_onChildAdded, true);\nexport const onChildChanged = ɵzoneWrap(_onChildChanged, true);\nexport const onChildMoved = ɵzoneWrap(_onChildMoved, true);\nexport const onChildRemoved = ɵzoneWrap(_onChildRemoved, true);\nexport const onDisconnect = ɵzoneWrap(_onDisconnect, true);\nexport const onValue = ɵzoneWrap(_onValue, true);\nexport const orderByChild = ɵzoneWrap(_orderByChild, true, 2);\nexport const orderByKey = ɵzoneWrap(_orderByKey, true, 2);\nexport const orderByPriority = ɵzoneWrap(_orderByPriority, true, 2);\nexport const orderByValue = ɵzoneWrap(_orderByValue, true, 2);\nexport const push = ɵzoneWrap(_push, true, 2);\nexport const query = ɵzoneWrap(_query, true, 2);\nexport const ref = ɵzoneWrap(_ref, true, 2);\nexport const refFromURL = ɵzoneWrap(_refFromURL, true, 2);\nexport const remove = ɵzoneWrap(_remove, true, 2);\nexport const runTransaction = ɵzoneWrap(_runTransaction, true);\nexport const set = ɵzoneWrap(_set, true, 2);\nexport const setPriority = ɵzoneWrap(_setPriority, true, 2);\nexport const setWithPriority = ɵzoneWrap(_setWithPriority, true, 2);\nexport const startAfter = ɵzoneWrap(_startAfter, true, 2);\nexport const startAt = ɵzoneWrap(_startAt, true, 2);\nexport const update = ɵzoneWrap(_update, true, 2);\n"
  },
  {
    "path": "src/database/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/database/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/database/public_api.ts",
    "content": "export { Database, DatabaseInstances, databaseInstance$ } from './database';\nexport { provideDatabase, DatabaseModule } from './database.module';\nexport * from './rxfire';\nexport * from './firebase';\n"
  },
  {
    "path": "src/database/rxfire.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  auditTrail as _auditTrail,\n  changeToData as _changeToData,\n  fromRef as _fromRef,\n  list as _list,\n  listVal as _listVal,\n  object as _object,\n  objectVal as _objectVal,\n  stateChanges as _stateChanges\n} from 'rxfire/database';\n\nexport {\n  ListenEvent,\n  ListenerMethods\n} from 'rxfire/database';\n\nexport const auditTrail = ɵzoneWrap(_auditTrail, true);\nexport const changeToData = ɵzoneWrap(_changeToData, true);\nexport const fromRef = ɵzoneWrap(_fromRef, true);\nexport const list = ɵzoneWrap(_list, true);\nexport const listVal = ɵzoneWrap(_listVal, true);\nexport const object = ɵzoneWrap(_object, true);\nexport const objectVal = ɵzoneWrap(_objectVal, true);\nexport const stateChanges = ɵzoneWrap(_stateChanges, true);\n"
  },
  {
    "path": "src/firestore/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/firestore';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  addDoc as _addDoc,\n  aggregateFieldEqual as _aggregateFieldEqual,\n  aggregateQuerySnapshotEqual as _aggregateQuerySnapshotEqual,\n  and as _and,\n  clearIndexedDbPersistence as _clearIndexedDbPersistence,\n  collection as _collection,\n  collectionGroup as _collectionGroup,\n  connectFirestoreEmulator as _connectFirestoreEmulator,\n  deleteAllPersistentCacheIndexes as _deleteAllPersistentCacheIndexes,\n  deleteDoc as _deleteDoc,\n  deleteField as _deleteField,\n  disableNetwork as _disableNetwork,\n  disablePersistentCacheIndexAutoCreation as _disablePersistentCacheIndexAutoCreation,\n  doc as _doc,\n  documentId as _documentId,\n  documentSnapshotFromJSON as _documentSnapshotFromJSON,\n  enableIndexedDbPersistence as _enableIndexedDbPersistence,\n  enableMultiTabIndexedDbPersistence as _enableMultiTabIndexedDbPersistence,\n  enableNetwork as _enableNetwork,\n  enablePersistentCacheIndexAutoCreation as _enablePersistentCacheIndexAutoCreation,\n  endAt as _endAt,\n  endBefore as _endBefore,\n  getAggregateFromServer as _getAggregateFromServer,\n  getCountFromServer as _getCountFromServer,\n  getDoc as _getDoc,\n  getDocFromCache as _getDocFromCache,\n  getDocFromServer as _getDocFromServer,\n  getDocs as _getDocs,\n  getDocsFromCache as _getDocsFromCache,\n  getDocsFromServer as _getDocsFromServer,\n  getFirestore as _getFirestore,\n  getPersistentCacheIndexManager as _getPersistentCacheIndexManager,\n  increment as _increment,\n  initializeFirestore as _initializeFirestore,\n  limit as _limit,\n  limitToLast as _limitToLast,\n  loadBundle as _loadBundle,\n  namedQuery as _namedQuery,\n  onSnapshot as _onSnapshot,\n  onSnapshotResume as _onSnapshotResume,\n  onSnapshotsInSync as _onSnapshotsInSync,\n  or as _or,\n  orderBy as _orderBy,\n  query as _query,\n  queryEqual as _queryEqual,\n  querySnapshotFromJSON as _querySnapshotFromJSON,\n  refEqual as _refEqual,\n  runTransaction as _runTransaction,\n  setDoc as _setDoc,\n  setIndexConfiguration as _setIndexConfiguration,\n  setLogLevel as _setLogLevel,\n  snapshotEqual as _snapshotEqual,\n  startAfter as _startAfter,\n  startAt as _startAt,\n  sum as _sum,\n  terminate as _terminate,\n  updateDoc as _updateDoc,\n  vector as _vector,\n  waitForPendingWrites as _waitForPendingWrites,\n  where as _where,\n  writeBatch as _writeBatch\n} from 'firebase/firestore';\n\nexport const addDoc = ɵzoneWrap(_addDoc, true, 2);\nexport const aggregateFieldEqual = ɵzoneWrap(_aggregateFieldEqual, true, 2);\nexport const aggregateQuerySnapshotEqual = ɵzoneWrap(_aggregateQuerySnapshotEqual, true, 2);\nexport const and = ɵzoneWrap(_and, true, 2);\nexport const clearIndexedDbPersistence = ɵzoneWrap(_clearIndexedDbPersistence, true);\nexport const collection = ɵzoneWrap(_collection, true, 2);\nexport const collectionGroup = ɵzoneWrap(_collectionGroup, true, 2);\nexport const connectFirestoreEmulator = ɵzoneWrap(_connectFirestoreEmulator, true);\nexport const deleteAllPersistentCacheIndexes = ɵzoneWrap(_deleteAllPersistentCacheIndexes, true);\nexport const deleteDoc = ɵzoneWrap(_deleteDoc, true, 2);\nexport const deleteField = ɵzoneWrap(_deleteField, true, 2);\nexport const disableNetwork = ɵzoneWrap(_disableNetwork, true);\nexport const disablePersistentCacheIndexAutoCreation = ɵzoneWrap(_disablePersistentCacheIndexAutoCreation, true);\nexport const doc = ɵzoneWrap(_doc, true, 2);\nexport const documentId = ɵzoneWrap(_documentId, true, 2);\nexport const documentSnapshotFromJSON = ɵzoneWrap(_documentSnapshotFromJSON, true);\nexport const enableIndexedDbPersistence = ɵzoneWrap(_enableIndexedDbPersistence, true);\nexport const enableMultiTabIndexedDbPersistence = ɵzoneWrap(_enableMultiTabIndexedDbPersistence, true);\nexport const enableNetwork = ɵzoneWrap(_enableNetwork, true);\nexport const enablePersistentCacheIndexAutoCreation = ɵzoneWrap(_enablePersistentCacheIndexAutoCreation, true);\nexport const endAt = ɵzoneWrap(_endAt, true, 2);\nexport const endBefore = ɵzoneWrap(_endBefore, true, 2);\nexport const getAggregateFromServer = ɵzoneWrap(_getAggregateFromServer, true);\nexport const getCountFromServer = ɵzoneWrap(_getCountFromServer, true);\nexport const getDoc = ɵzoneWrap(_getDoc, true);\nexport const getDocFromCache = ɵzoneWrap(_getDocFromCache, true);\nexport const getDocFromServer = ɵzoneWrap(_getDocFromServer, true);\nexport const getDocs = ɵzoneWrap(_getDocs, true);\nexport const getDocsFromCache = ɵzoneWrap(_getDocsFromCache, true);\nexport const getDocsFromServer = ɵzoneWrap(_getDocsFromServer, true);\nexport const getFirestore = ɵzoneWrap(_getFirestore, true);\nexport const getPersistentCacheIndexManager = ɵzoneWrap(_getPersistentCacheIndexManager, true);\nexport const increment = ɵzoneWrap(_increment, true, 2);\nexport const initializeFirestore = ɵzoneWrap(_initializeFirestore, true);\nexport const limit = ɵzoneWrap(_limit, true, 2);\nexport const limitToLast = ɵzoneWrap(_limitToLast, true, 2);\nexport const loadBundle = ɵzoneWrap(_loadBundle, true);\nexport const namedQuery = ɵzoneWrap(_namedQuery, true, 2);\nexport const onSnapshot = ɵzoneWrap(_onSnapshot, true);\nexport const onSnapshotResume = ɵzoneWrap(_onSnapshotResume, true);\nexport const onSnapshotsInSync = ɵzoneWrap(_onSnapshotsInSync, true);\nexport const or = ɵzoneWrap(_or, true, 2);\nexport const orderBy = ɵzoneWrap(_orderBy, true, 2);\nexport const query = ɵzoneWrap(_query, true, 2);\nexport const queryEqual = ɵzoneWrap(_queryEqual, true, 2);\nexport const querySnapshotFromJSON = ɵzoneWrap(_querySnapshotFromJSON, true);\nexport const refEqual = ɵzoneWrap(_refEqual, true, 2);\nexport const runTransaction = ɵzoneWrap(_runTransaction, true);\nexport const setDoc = ɵzoneWrap(_setDoc, true, 2);\nexport const setIndexConfiguration = ɵzoneWrap(_setIndexConfiguration, true);\nexport const setLogLevel = ɵzoneWrap(_setLogLevel, true);\nexport const snapshotEqual = ɵzoneWrap(_snapshotEqual, true, 2);\nexport const startAfter = ɵzoneWrap(_startAfter, true, 2);\nexport const startAt = ɵzoneWrap(_startAt, true, 2);\nexport const sum = ɵzoneWrap(_sum, true, 2);\nexport const terminate = ɵzoneWrap(_terminate, true);\nexport const updateDoc = ɵzoneWrap(_updateDoc, true, 2);\nexport const vector = ɵzoneWrap(_vector, true, 2);\nexport const waitForPendingWrites = ɵzoneWrap(_waitForPendingWrites, true);\nexport const where = ɵzoneWrap(_where, true, 2);\nexport const writeBatch = ɵzoneWrap(_writeBatch, true, 2);\n"
  },
  {
    "path": "src/firestore/firestore.module.ts",
    "content": "import {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { AuthInstances  } from '@angular/fire/auth';\nimport { registerVersion } from 'firebase/app';\nimport { Firestore as FirebaseFirestore } from 'firebase/firestore';\nimport { FIRESTORE_PROVIDER_NAME, Firestore, FirestoreInstances } from './firestore';\n\nexport const PROVIDED_FIRESTORE_INSTANCES = new InjectionToken<Firestore[]>('angularfire2.firestore-instances');\n\nexport function defaultFirestoreInstanceFactory(provided: FirebaseFirestore[]|undefined, defaultApp: FirebaseApp) {\n  const defaultFirestore = ɵgetDefaultInstanceOf<FirebaseFirestore>(FIRESTORE_PROVIDER_NAME, provided, defaultApp);\n  return defaultFirestore && new Firestore(defaultFirestore);\n}\n\nexport function firestoreInstanceFactory(fn: (injector: Injector) => FirebaseFirestore) {\n  return (zone: NgZone, injector: Injector) => {\n    const firestore = zone.runOutsideAngular(() => fn(injector));\n    return new Firestore(firestore);\n  };\n}\n\nconst FIRESTORE_INSTANCES_PROVIDER = {\n  provide: FirestoreInstances,\n  deps: [\n    [new Optional(), PROVIDED_FIRESTORE_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_FIRESTORE_INSTANCE_PROVIDER = {\n  provide: Firestore,\n  useFactory: defaultFirestoreInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_FIRESTORE_INSTANCES ],\n    FirebaseApp,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_FIRESTORE_INSTANCE_PROVIDER,\n    FIRESTORE_INSTANCES_PROVIDER,\n  ]\n})\nexport class FirestoreModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'fst');\n  }\n}\n\nexport function provideFirestore(fn: (injector: Injector) => FirebaseFirestore, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'fst');\n\n  return makeEnvironmentProviders([\n    DEFAULT_FIRESTORE_INSTANCE_PROVIDER,\n    FIRESTORE_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_FIRESTORE_INSTANCES,\n      useFactory: firestoreInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        // Firestore+Auth work better if Auth is loaded first\n        [new Optional(), AuthInstances ],\n        [new Optional(), AppCheckInstances ],\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/firestore/firestore.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { Firestore, connectFirestoreEmulator, getFirestore, provideFirestore } from '@angular/fire/firestore';\nimport { COMMON_CONFIG, firestoreEmulatorPort } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('Firestore', () => {\n  let app: FirebaseApp;\n  let firestore: Firestore;\n  let providedFirestore: Firestore;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideFirestore(() => {\n                    providedFirestore = getFirestore(getApp(appName));\n                    connectFirestoreEmulator(providedFirestore, 'localhost', firestoreEmulatorPort);\n                    return providedFirestore;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        firestore = TestBed.inject(Firestore);\n    });\n\n    it('should be injectable', () => {\n        expect(providedFirestore).toBeTruthy();\n        expect(firestore).toEqual(providedFirestore);\n        expect(firestore.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/firestore/firestore.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { Firestore as FirebaseFirestore } from 'firebase/firestore';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface Firestore extends FirebaseFirestore {}\n\nexport class Firestore {\n  constructor(firestore: FirebaseFirestore) {\n    return firestore;\n  }\n}\n\nexport const FIRESTORE_PROVIDER_NAME = 'firestore';\n\n \nexport interface FirestoreInstances extends Array<FirebaseFirestore> {}\n\nexport class FirestoreInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseFirestore>(FIRESTORE_PROVIDER_NAME);\n  }\n}\n\nexport const firestoreInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseFirestore>(FIRESTORE_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/firestore/lite/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/firestore/lite';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  addDoc as _addDoc,\n  aggregateFieldEqual as _aggregateFieldEqual,\n  aggregateQuerySnapshotEqual as _aggregateQuerySnapshotEqual,\n  and as _and,\n  collection as _collection,\n  collectionGroup as _collectionGroup,\n  connectFirestoreEmulator as _connectFirestoreEmulator,\n  deleteDoc as _deleteDoc,\n  deleteField as _deleteField,\n  doc as _doc,\n  documentId as _documentId,\n  endAt as _endAt,\n  endBefore as _endBefore,\n  getAggregate as _getAggregate,\n  getCount as _getCount,\n  getDoc as _getDoc,\n  getDocs as _getDocs,\n  getFirestore as _getFirestore,\n  increment as _increment,\n  initializeFirestore as _initializeFirestore,\n  limit as _limit,\n  limitToLast as _limitToLast,\n  or as _or,\n  orderBy as _orderBy,\n  query as _query,\n  queryEqual as _queryEqual,\n  refEqual as _refEqual,\n  runTransaction as _runTransaction,\n  setDoc as _setDoc,\n  setLogLevel as _setLogLevel,\n  snapshotEqual as _snapshotEqual,\n  startAfter as _startAfter,\n  startAt as _startAt,\n  sum as _sum,\n  terminate as _terminate,\n  updateDoc as _updateDoc,\n  vector as _vector,\n  where as _where,\n  writeBatch as _writeBatch\n} from 'firebase/firestore/lite';\n\nexport const addDoc = ɵzoneWrap(_addDoc, true, 2);\nexport const aggregateFieldEqual = ɵzoneWrap(_aggregateFieldEqual, true, 2);\nexport const aggregateQuerySnapshotEqual = ɵzoneWrap(_aggregateQuerySnapshotEqual, true, 2);\nexport const and = ɵzoneWrap(_and, true, 2);\nexport const collection = ɵzoneWrap(_collection, true, 2);\nexport const collectionGroup = ɵzoneWrap(_collectionGroup, true, 2);\nexport const connectFirestoreEmulator = ɵzoneWrap(_connectFirestoreEmulator, true);\nexport const deleteDoc = ɵzoneWrap(_deleteDoc, true, 2);\nexport const deleteField = ɵzoneWrap(_deleteField, true, 2);\nexport const doc = ɵzoneWrap(_doc, true, 2);\nexport const documentId = ɵzoneWrap(_documentId, true, 2);\nexport const endAt = ɵzoneWrap(_endAt, true, 2);\nexport const endBefore = ɵzoneWrap(_endBefore, true, 2);\nexport const getAggregate = ɵzoneWrap(_getAggregate, true);\nexport const getCount = ɵzoneWrap(_getCount, true);\nexport const getDoc = ɵzoneWrap(_getDoc, true);\nexport const getDocs = ɵzoneWrap(_getDocs, true);\nexport const getFirestore = ɵzoneWrap(_getFirestore, true);\nexport const increment = ɵzoneWrap(_increment, true, 2);\nexport const initializeFirestore = ɵzoneWrap(_initializeFirestore, true);\nexport const limit = ɵzoneWrap(_limit, true, 2);\nexport const limitToLast = ɵzoneWrap(_limitToLast, true, 2);\nexport const or = ɵzoneWrap(_or, true, 2);\nexport const orderBy = ɵzoneWrap(_orderBy, true, 2);\nexport const query = ɵzoneWrap(_query, true, 2);\nexport const queryEqual = ɵzoneWrap(_queryEqual, true, 2);\nexport const refEqual = ɵzoneWrap(_refEqual, true, 2);\nexport const runTransaction = ɵzoneWrap(_runTransaction, true);\nexport const setDoc = ɵzoneWrap(_setDoc, true, 2);\nexport const setLogLevel = ɵzoneWrap(_setLogLevel, true);\nexport const snapshotEqual = ɵzoneWrap(_snapshotEqual, true, 2);\nexport const startAfter = ɵzoneWrap(_startAfter, true, 2);\nexport const startAt = ɵzoneWrap(_startAt, true, 2);\nexport const sum = ɵzoneWrap(_sum, true, 2);\nexport const terminate = ɵzoneWrap(_terminate, true);\nexport const updateDoc = ɵzoneWrap(_updateDoc, true, 2);\nexport const vector = ɵzoneWrap(_vector, true, 2);\nexport const where = ɵzoneWrap(_where, true, 2);\nexport const writeBatch = ɵzoneWrap(_writeBatch, true, 2);\n"
  },
  {
    "path": "src/firestore/lite/lite.module.ts",
    "content": "import {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { AppCheckInstances} from \"@angular/fire/app-check\";\nimport { AuthInstances  } from '@angular/fire/auth';\nimport { registerVersion } from 'firebase/app';\nimport { Firestore as FirebaseFirestore } from 'firebase/firestore/lite';\nimport { FIRESTORE_PROVIDER_NAME, Firestore, FirestoreInstances } from './lite';\n\nexport const PROVIDED_FIRESTORE_INSTANCES = new InjectionToken<Firestore[]>('angularfire2.firestore-lite-instances');\n\nexport function defaultFirestoreInstanceFactory(provided: FirebaseFirestore[]|undefined, defaultApp: FirebaseApp) {\n  const defaultFirestore = ɵgetDefaultInstanceOf<FirebaseFirestore>(FIRESTORE_PROVIDER_NAME, provided, defaultApp);\n  return defaultFirestore && new Firestore(defaultFirestore);\n}\n\nexport function firestoreInstanceFactory(fn: (injector: Injector) => FirebaseFirestore) {\n  return (zone: NgZone, injector: Injector) => {\n    const firestore = zone.runOutsideAngular(() => fn(injector));\n    return new Firestore(firestore);\n  };\n}\n\nconst FIRESTORE_INSTANCES_PROVIDER = {\n  provide: FirestoreInstances,\n  deps: [\n    [new Optional(), PROVIDED_FIRESTORE_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_FIRESTORE_INSTANCE_PROVIDER = {\n  provide: Firestore,\n  useFactory: defaultFirestoreInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_FIRESTORE_INSTANCES ],\n    FirebaseApp,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_FIRESTORE_INSTANCE_PROVIDER,\n    FIRESTORE_INSTANCES_PROVIDER,\n  ]\n})\nexport class FirestoreModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'lite');\n  }\n}\n\nexport function provideFirestore(fn: (injector: Injector) => FirebaseFirestore, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'lite');\n\n  return makeEnvironmentProviders([\n    DEFAULT_FIRESTORE_INSTANCE_PROVIDER,\n    FIRESTORE_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_FIRESTORE_INSTANCES,\n      useFactory: firestoreInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        // Firestore+Auth work better if Auth is loaded first\n        [new Optional(), AuthInstances ],\n        [new Optional(), AppCheckInstances ],\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/firestore/lite/lite.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { Firestore, connectFirestoreEmulator, getFirestore, provideFirestore } from '@angular/fire/firestore/lite';\nimport { COMMON_CONFIG, firestoreEmulatorPort } from '../../test-config';\nimport { rando } from '../../utils';\n\ndescribe('Firestore-lite', () => {\n  let app: FirebaseApp;\n  let firestore: Firestore;\n  let providedFirestore: Firestore;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideFirestore(() => {\n                    providedFirestore = getFirestore(getApp(appName));\n                    connectFirestoreEmulator(providedFirestore, 'localhost', firestoreEmulatorPort);\n                    return providedFirestore;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        firestore = TestBed.inject(Firestore);\n    });\n\n    it('should be injectable', () => {\n        expect(providedFirestore).toBeTruthy();\n        expect(firestore).toEqual(providedFirestore);\n        expect(firestore.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/firestore/lite/lite.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { Firestore as FirebaseFirestore } from 'firebase/firestore/lite';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface Firestore extends FirebaseFirestore {}\n\nexport class Firestore {\n  constructor(firestore: FirebaseFirestore) {\n    return firestore;\n  }\n}\n\nexport const FIRESTORE_PROVIDER_NAME = 'firestore/lite';\n\n \nexport interface FirestoreInstances extends Array<FirebaseFirestore> {}\n\nexport class FirestoreInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseFirestore>(FIRESTORE_PROVIDER_NAME);\n  }\n}\n\nexport const firestoreInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseFirestore>(FIRESTORE_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/firestore/lite/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/firestore/lite/package.json",
    "content": "{\n  \"$schema\": \"../../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/firestore/lite/public_api.ts",
    "content": "export { Firestore, FirestoreInstances, firestoreInstance$ } from './lite';\nexport { FirestoreModule, provideFirestore } from './lite.module';\nexport * from './rxfire';\nexport * from './firebase';\n"
  },
  {
    "path": "src/firestore/lite/rxfire.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  collection as _collection,\n  collectionCount as _collectionCount,\n  collectionCountSnap as _collectionCountSnap,\n  collectionData as _collectionData,\n  doc as _doc,\n  docData as _docData,\n  fromRef as _fromRef,\n  snapToData as _snapToData\n} from 'rxfire/firestore/lite';\n\nexport const collectionSnapshots = ɵzoneWrap(_collection, true);\nexport const collectionCount = ɵzoneWrap(_collectionCount, true);\nexport const collectionCountSnap = ɵzoneWrap(_collectionCountSnap, true);\nexport const collectionData = ɵzoneWrap(_collectionData, true);\nexport const docSnapshots = ɵzoneWrap(_doc, true);\nexport const docData = ɵzoneWrap(_docData, true);\nexport const fromRef = ɵzoneWrap(_fromRef, true);\nexport const snapToData = ɵzoneWrap(_snapToData, true);\n"
  },
  {
    "path": "src/firestore/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/firestore/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/firestore/public_api.ts",
    "content": "export { Firestore, FirestoreInstances, firestoreInstance$ } from './firestore';\nexport { provideFirestore, FirestoreModule } from './firestore.module';\nexport * from './rxfire';\nexport * from './firebase';\n"
  },
  {
    "path": "src/firestore/rxfire.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  auditTrail as _auditTrail,\n  collection as _collection,\n  collectionChanges as _collectionChanges,\n  collectionCount as _collectionCount,\n  collectionCountSnap as _collectionCountSnap,\n  collectionData as _collectionData,\n  doc as _doc,\n  docData as _docData,\n  fromRef as _fromRef,\n  snapToData as _snapToData,\n  sortedChanges as _sortedChanges\n} from 'rxfire/firestore';\n\nexport const auditTrail = ɵzoneWrap(_auditTrail, true);\nexport const collectionSnapshots = ɵzoneWrap(_collection, true);\nexport const collectionChanges = ɵzoneWrap(_collectionChanges, true);\nexport const collectionCount = ɵzoneWrap(_collectionCount, true);\nexport const collectionCountSnap = ɵzoneWrap(_collectionCountSnap, true);\nexport const collectionData = ɵzoneWrap(_collectionData, true);\nexport const docSnapshots = ɵzoneWrap(_doc, true);\nexport const docData = ɵzoneWrap(_docData, true);\nexport const fromRef = ɵzoneWrap(_fromRef, true);\nexport const snapToData = ɵzoneWrap(_snapToData, true);\nexport const sortedChanges = ɵzoneWrap(_sortedChanges, true);\n"
  },
  {
    "path": "src/functions/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/functions';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  connectFunctionsEmulator as _connectFunctionsEmulator,\n  getFunctions as _getFunctions,\n  httpsCallable as _httpsCallable,\n  httpsCallableFromURL as _httpsCallableFromURL\n} from 'firebase/functions';\n\nexport const connectFunctionsEmulator = ɵzoneWrap(_connectFunctionsEmulator, true);\nexport const getFunctions = ɵzoneWrap(_getFunctions, true);\nexport const httpsCallable = ɵzoneWrap(_httpsCallable, true);\nexport const httpsCallableFromURL = ɵzoneWrap(_httpsCallableFromURL, true);\n"
  },
  {
    "path": "src/functions/functions.module.ts",
    "content": "import {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { AuthInstances } from '@angular/fire/auth';\nimport { registerVersion } from 'firebase/app';\nimport { Functions as FirebaseFunctions } from 'firebase/functions';\nimport { FUNCTIONS_PROVIDER_NAME, Functions, FunctionsInstances } from './functions';\n\nexport const PROVIDED_FUNCTIONS_INSTANCES = new InjectionToken<Functions[]>('angularfire2.functions-instances');\n\nexport function defaultFunctionsInstanceFactory(provided: FirebaseFunctions[]|undefined, defaultApp: FirebaseApp) {\n  const defaultAuth = ɵgetDefaultInstanceOf<FirebaseFunctions>(FUNCTIONS_PROVIDER_NAME, provided, defaultApp);\n  return defaultAuth && new Functions(defaultAuth);\n}\n\nexport function functionsInstanceFactory(fn: (injector: Injector) => FirebaseFunctions) {\n  return (zone: NgZone, injector: Injector) => {\n    const functions = zone.runOutsideAngular(() => fn(injector));\n    return new Functions(functions);\n  };\n}\n\nconst FUNCTIONS_INSTANCES_PROVIDER = {\n  provide: FunctionsInstances,\n  deps: [\n    [new Optional(), PROVIDED_FUNCTIONS_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_FUNCTIONS_INSTANCE_PROVIDER = {\n  provide: Functions,\n  useFactory: defaultFunctionsInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_FUNCTIONS_INSTANCES ],\n    FirebaseApp,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_FUNCTIONS_INSTANCE_PROVIDER,\n    FUNCTIONS_INSTANCES_PROVIDER,\n  ]\n})\nexport class FunctionsModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'fn');\n  }\n}\n\nexport function provideFunctions(fn: (injector: Injector) => FirebaseFunctions, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'fn');\n\n  return makeEnvironmentProviders([\n    DEFAULT_FUNCTIONS_INSTANCE_PROVIDER,\n    FUNCTIONS_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_FUNCTIONS_INSTANCES,\n      useFactory: functionsInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        // Defensively load Auth first, if provided\n        [new Optional(), AuthInstances ],\n        [new Optional(), AppCheckInstances ],\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/functions/functions.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { Functions, connectFunctionsEmulator, getFunctions, provideFunctions } from '@angular/fire/functions';\nimport { COMMON_CONFIG, functionsEmulatorPort } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('Functions', () => {\n  let app: FirebaseApp;\n  let functions: Functions;\n  let providedFunctions: Functions;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideFunctions(() => {\n                    providedFunctions = getFunctions(getApp(appName));\n                    connectFunctionsEmulator(providedFunctions, 'localhost', functionsEmulatorPort);\n                    return providedFunctions;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        functions = TestBed.inject(Functions);\n    });\n\n    it('should be injectable', () => {\n        expect(providedFunctions).toBeTruthy();\n        expect(functions).toEqual(providedFunctions);\n        expect(functions.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/functions/functions.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { Functions as FirebaseFunctions } from 'firebase/functions';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface Functions extends FirebaseFunctions {}\n\nexport class Functions {\n  constructor(functions: FirebaseFunctions) {\n    return functions;\n  }\n}\n\nexport const FUNCTIONS_PROVIDER_NAME = 'functions';\n\n \nexport interface FunctionsInstances extends Array<FirebaseFunctions> {}\n\nexport class FunctionsInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseFunctions>(FUNCTIONS_PROVIDER_NAME);\n  }\n}\n\nexport const functionInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseFunctions>(FUNCTIONS_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/functions/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/functions/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/functions/public_api.ts",
    "content": "export { provideFunctions, FunctionsModule } from './functions.module';\nexport { Functions, FunctionsInstances, functionInstance$ } from './functions';\nexport * from './rxfire';\nexport * from './firebase';\n"
  },
  {
    "path": "src/functions/rxfire.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  httpsCallable as _httpsCallable\n} from 'rxfire/functions';\n\nexport const httpsCallableData = ɵzoneWrap(_httpsCallable, true);\n"
  },
  {
    "path": "src/messaging/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/messaging';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  deleteToken as _deleteToken,\n  getMessaging as _getMessaging,\n  getToken as _getToken,\n  isSupported as _isSupported,\n  onMessage as _onMessage\n} from 'firebase/messaging';\n\nexport const deleteToken = ɵzoneWrap(_deleteToken, true, 2);\nexport const getMessaging = ɵzoneWrap(_getMessaging, true);\nexport const getToken = ɵzoneWrap(_getToken, true);\nexport const isSupported = ɵzoneWrap(_isSupported, false);\nexport const onMessage = ɵzoneWrap(_onMessage, false);\n"
  },
  {
    "path": "src/messaging/messaging.module.ts",
    "content": "import { isPlatformServer } from '@angular/common';\nimport {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  PLATFORM_ID,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { registerVersion } from 'firebase/app';\nimport { Messaging as FirebaseMessaging } from 'firebase/messaging';\nimport { MESSAGING_PROVIDER_NAME, Messaging, MessagingInstances } from './messaging';\n\nconst PROVIDED_MESSAGING_INSTANCES = new InjectionToken<Messaging[]>('angularfire2.messaging-instances');\n\nexport function defaultMessagingInstanceFactory(provided: FirebaseMessaging[]|undefined, defaultApp: FirebaseApp, platformId: object) {\n  if (isPlatformServer(platformId)) { return null; }\n  const defaultMessaging = ɵgetDefaultInstanceOf<FirebaseMessaging>(MESSAGING_PROVIDER_NAME, provided, defaultApp);\n  return defaultMessaging && new Messaging(defaultMessaging);\n}\n\nexport function messagingInstanceFactory(fn: (injector: Injector) => FirebaseMessaging) {\n  return (zone: NgZone, injector: Injector, platformId: object) => {\n    if (isPlatformServer(platformId)) { return null; }\n    const messaging = zone.runOutsideAngular(() => fn(injector));\n    return new Messaging(messaging);\n  };\n}\n\nconst MESSAGING_INSTANCES_PROVIDER = {\n  provide: MessagingInstances,\n  deps: [\n    [new Optional(), PROVIDED_MESSAGING_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_MESSAGING_INSTANCE_PROVIDER = {\n  provide: Messaging,\n  useFactory: defaultMessagingInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_MESSAGING_INSTANCES ],\n    FirebaseApp,\n    PLATFORM_ID,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_MESSAGING_INSTANCE_PROVIDER,\n    MESSAGING_INSTANCES_PROVIDER,\n  ]\n})\nexport class MessagingModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'fcm');\n  }\n}\n\nexport function provideMessaging(fn: (injector: Injector) => FirebaseMessaging, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'fcm');\n\n  return makeEnvironmentProviders([\n    DEFAULT_MESSAGING_INSTANCE_PROVIDER,\n    MESSAGING_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_MESSAGING_INSTANCES,\n      useFactory: messagingInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        PLATFORM_ID,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        ...deps,\n      ],\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/messaging/messaging.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { Messaging, getMessaging, isSupported, provideMessaging } from '@angular/fire/messaging';\nimport { COMMON_CONFIG } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('Messaging', () => {\n  let messaging: Messaging;\n  let providedMessaging: Messaging;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideMessaging(() => {\n                    providedMessaging = getMessaging(getApp(appName));\n                    return providedMessaging;\n                }),\n            ],\n        });\n        messaging = TestBed.inject(Messaging);\n    });\n\n    it('should be injectable', async () => {\n      const supported = await TestBed.runInInjectionContext(isSupported);\n      if (supported) {\n        expect(providedMessaging).toBeTruthy();\n        expect(messaging).toEqual(providedMessaging);\n      } else {\n        expect(providedMessaging).toBeUndefined();\n        expect(messaging).toBeNull();\n      }\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/messaging/messaging.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { Messaging as FirebaseMessaging } from 'firebase/messaging';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface Messaging extends FirebaseMessaging {}\n\nexport class Messaging {\n  constructor(messaging: FirebaseMessaging) {\n    return messaging;\n  }\n}\n\nexport const MESSAGING_PROVIDER_NAME = 'messaging';\n\n \nexport interface MessagingInstances extends Array<FirebaseMessaging> {}\n\nexport class MessagingInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseMessaging>(MESSAGING_PROVIDER_NAME);\n  }\n}\n\nexport const messagingInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseMessaging>(MESSAGING_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/messaging/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/messaging/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/messaging/public_api.ts",
    "content": "export { MessagingInstances, Messaging, messagingInstance$ } from './messaging';\nexport { provideMessaging, MessagingModule } from './messaging.module';\nexport * from './firebase';\n"
  },
  {
    "path": "src/ng-package.json",
    "content": "{\n  \"$schema\": \"./node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  },\n  \"dest\": \"../dist/packages-dist\",\n  \"allowedNonPeerDependencies\": [\n    \"@angular-devkit/schematics\", \"@schematics/angular\",\n    \"fuzzy\", \"inquirer-autocomplete-prompt\",\n    \"open\", \"jsonc-parser\", \"ora\", \"winston\",\n    \"triple-beam\", \"@schematics/angular\", \"node-fetch\",\n    \"semver\", \"inquirer\", \"fs-extra\",\n    \"firebase\", \"rxfire\"\n  ]\n}\n"
  },
  {
    "path": "src/package.json",
    "content": "{\n  \"$schema\": \"../node_modules/ng-packagr/package.schema.json\",\n  \"name\": \"@angular/fire\",\n  \"version\": \"ANGULARFIRE2_VERSION\",\n  \"description\": \"Angular + Firebase = ❤️\",\n  \"schematics\": \"./schematics/collection.json\",\n  \"builders\": \"./schematics/builders.json\",\n  \"keywords\": [\n    \"angular\",\n    \"firebase\",\n    \"rxjs\",\n    \"angularfire\",\n    \"angularfire2\"\n  ],\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/angular/angularfire.git\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/angular/angularfire/issues\"\n  },\n  \"homepage\": \"https://github.com/angular/angularfire#readme\",\n  \"author\": \"angular,firebase\",\n  \"license\": \"MIT\",\n  \"peerDependencies\": {\n    \"@angular/common\": \"^21.0.0\",\n    \"@angular/core\": \"^21.0.0\",\n    \"@angular/platform-browser\": \"^21.0.0\",\n    \"@angular/platform-browser-dynamic\": \"^21.0.0\",\n    \"@angular/platform-server\": \"^21.0.0\",\n    \"rxjs\": \"~7.8.0\",\n    \"firebase-tools\": \"^14.0.0\"\n  },\n  \"peerDependenciesMeta\": {\n    \"firebase-tools\": { \"optional\": true },\n    \"@angular/platform-server\": { \"optional\": true }\n  },\n  \"dependencies\": {\n    \"firebase\": \"^12.4.0\",\n    \"rxfire\": \"^6.1.0\",\n    \"@angular-devkit/schematics\": \"^21.0.0\",\n    \"@schematics/angular\": \"^21.0.0\",\n    \"tslib\": \"^2.3.0\"\n  },\n  \"ng-update\": {\n    \"migrations\": \"./schematics/migration.json\"\n  }\n}\n"
  },
  {
    "path": "src/performance/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/performance';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  getPerformance as _getPerformance,\n  initializePerformance as _initializePerformance,\n  trace as _trace\n} from 'firebase/performance';\n\nexport const getPerformance = ɵzoneWrap(_getPerformance, true);\nexport const initializePerformance = ɵzoneWrap(_initializePerformance, true);\nexport const trace = ɵzoneWrap(_trace, true, 2);\n"
  },
  {
    "path": "src/performance/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/performance/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/performance/performance.module.ts",
    "content": "import { isPlatformBrowser } from '@angular/common';\nimport {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  PLATFORM_ID,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { registerVersion } from 'firebase/app';\nimport { FirebasePerformance } from 'firebase/performance';\nimport { PERFORMANCE_PROVIDER_NAME, Performance, PerformanceInstances } from './performance';\n\nexport const PROVIDED_PERFORMANCE_INSTANCES = new InjectionToken<Performance[]>('angularfire2.performance-instances');\n\nexport function defaultPerformanceInstanceFactory(\n  provided: FirebasePerformance[]|undefined,\n  defaultApp: FirebaseApp,\n\n  platform: object\n) {\n  if (!isPlatformBrowser(platform)) { return null; }\n  const defaultPerformance = ɵgetDefaultInstanceOf<FirebasePerformance>(PERFORMANCE_PROVIDER_NAME, provided, defaultApp);\n  return defaultPerformance && new Performance(defaultPerformance);\n}\n\nexport function performanceInstanceFactory(fn: (injector: Injector) => FirebasePerformance) {\n\n  return (zone: NgZone, platform: object, injector: Injector) => {\n    if (!isPlatformBrowser(platform)) { return null; }\n    const performance = zone.runOutsideAngular(() => fn(injector));\n    return new Performance(performance);\n  };\n}\n\nconst PERFORMANCE_INSTANCES_PROVIDER = {\n  provide: PerformanceInstances,\n  deps: [\n    [new Optional(), PROVIDED_PERFORMANCE_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_PERFORMANCE_INSTANCE_PROVIDER = {\n  provide: Performance,\n  useFactory: defaultPerformanceInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_PERFORMANCE_INSTANCES ],\n    FirebaseApp,\n    PLATFORM_ID,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_PERFORMANCE_INSTANCE_PROVIDER,\n    PERFORMANCE_INSTANCES_PROVIDER,\n  ]\n})\nexport class PerformanceModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'perf');\n  }\n}\n\nexport function providePerformance(\n  fn: (injector: Injector) => FirebasePerformance, ...deps: any[]\n): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'perf');\n\n  return makeEnvironmentProviders([\n    DEFAULT_PERFORMANCE_INSTANCE_PROVIDER,\n    PERFORMANCE_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_PERFORMANCE_INSTANCES,\n      useFactory: performanceInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        PLATFORM_ID,\n        Injector,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/performance/performance.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { Performance, getPerformance, providePerformance } from '@angular/fire/performance';\nimport { COMMON_CONFIG } from '../test-config';\n\ndescribe('Performance', () => {\n  let app: FirebaseApp;\n  let performance: Performance;\n  let providedPerformance: Performance;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG)),\n                providePerformance(() => {\n                    providedPerformance = getPerformance();\n                    return providedPerformance;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        performance = TestBed.inject(Performance);\n    });\n\n    it('should be injectable', () => {\n        expect(providedPerformance).toBeTruthy();\n        expect(performance).toEqual(providedPerformance);\n        expect(performance.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/performance/performance.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { FirebasePerformance } from 'firebase/performance';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface Performance extends FirebasePerformance {}\n\nexport class Performance {\n  constructor(performance: FirebasePerformance) {\n    return performance;\n  }\n}\n\nexport const PERFORMANCE_PROVIDER_NAME = 'performance';\n\n \nexport interface PerformanceInstances extends Array<FirebasePerformance> {}\n\nexport class PerformanceInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebasePerformance>(PERFORMANCE_PROVIDER_NAME);\n  }\n}\n\nexport const performanceInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebasePerformance>(PERFORMANCE_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/performance/public_api.ts",
    "content": "export { Performance, PerformanceInstances, performanceInstance$ } from './performance';\nexport { providePerformance, PerformanceModule } from './performance.module';\nexport * from './rxfire';\nexport * from './firebase';\n"
  },
  {
    "path": "src/performance/rxfire.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  traceUntil as _traceUntil,\n  traceUntilComplete as _traceUntilComplete,\n  traceUntilFirst as _traceUntilFirst,\n  traceWhile as _traceWhile\n} from 'rxfire/performance';\n\nexport const traceUntil = ɵzoneWrap(_traceUntil, true);\nexport const traceUntilComplete = ɵzoneWrap(_traceUntilComplete, true);\nexport const traceUntilFirst = ɵzoneWrap(_traceUntilFirst, true);\nexport const traceWhile = ɵzoneWrap(_traceWhile, true);\n"
  },
  {
    "path": "src/public_api.ts",
    "content": "export * from './core';\nexport * from './zones';\n"
  },
  {
    "path": "src/remote-config/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/remote-config';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  activate as _activate,\n  ensureInitialized as _ensureInitialized,\n  fetchAndActivate as _fetchAndActivate,\n  fetchConfig as _fetchConfig,\n  getAll as _getAll,\n  getBoolean as _getBoolean,\n  getNumber as _getNumber,\n  getRemoteConfig as _getRemoteConfig,\n  getString as _getString,\n  getValue as _getValue,\n  isSupported as _isSupported,\n  onConfigUpdate as _onConfigUpdate,\n  setCustomSignals as _setCustomSignals,\n  setLogLevel as _setLogLevel\n} from 'firebase/remote-config';\n\nexport const activate = ɵzoneWrap(_activate, true);\nexport const ensureInitialized = ɵzoneWrap(_ensureInitialized, true);\nexport const fetchAndActivate = ɵzoneWrap(_fetchAndActivate, true);\nexport const fetchConfig = ɵzoneWrap(_fetchConfig, true);\nexport const getAll = ɵzoneWrap(_getAll, true);\nexport const getBoolean = ɵzoneWrap(_getBoolean, true);\nexport const getNumber = ɵzoneWrap(_getNumber, true);\nexport const getRemoteConfig = ɵzoneWrap(_getRemoteConfig, true);\nexport const getString = ɵzoneWrap(_getString, true);\nexport const getValue = ɵzoneWrap(_getValue, true);\nexport const isSupported = ɵzoneWrap(_isSupported, true);\nexport const onConfigUpdate = ɵzoneWrap(_onConfigUpdate, true);\nexport const setCustomSignals = ɵzoneWrap(_setCustomSignals, true);\nexport const setLogLevel = ɵzoneWrap(_setLogLevel, true);\n"
  },
  {
    "path": "src/remote-config/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/remote-config/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/remote-config/public_api.ts",
    "content": "export { RemoteConfigInstances, RemoteConfig, remoteConfigInstance$ } from './remote-config';\nexport { provideRemoteConfig, RemoteConfigModule } from './remote-config.module';\nexport * from './rxfire';\nexport * from './firebase';\n"
  },
  {
    "path": "src/remote-config/remote-config.module.ts",
    "content": "import { isPlatformServer } from '@angular/common';\nimport {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  PLATFORM_ID,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { registerVersion } from 'firebase/app';\nimport { RemoteConfig as FirebaseRemoteConfig } from 'firebase/remote-config';\nimport { REMOTE_CONFIG_PROVIDER_NAME, RemoteConfig, RemoteConfigInstances } from './remote-config';\n\nexport const PROVIDED_REMOTE_CONFIG_INSTANCES = new InjectionToken<RemoteConfig[]>('angularfire2.remote-config-instances');\n\nexport function defaultRemoteConfigInstanceFactory(\n  provided: FirebaseRemoteConfig[]|undefined,\n  defaultApp: FirebaseApp,\n  platformId: object,\n) {\n  if (isPlatformServer(platformId)) { return null; }\n  const defaultRemoteConfig = ɵgetDefaultInstanceOf<FirebaseRemoteConfig>(REMOTE_CONFIG_PROVIDER_NAME, provided, defaultApp);\n  return defaultRemoteConfig && new RemoteConfig(defaultRemoteConfig);\n}\n\nexport function remoteConfigInstanceFactory(fn: (injector: Injector) => FirebaseRemoteConfig) {\n  return (zone: NgZone, injector: Injector, platformId: object) => {\n    if (isPlatformServer(platformId)) { return null; }\n    const remoteConfig = zone.runOutsideAngular(() => fn(injector));\n    return new RemoteConfig(remoteConfig);\n  };\n}\n\nconst REMOTE_CONFIG_INSTANCES_PROVIDER = {\n  provide: RemoteConfigInstances,\n  deps: [\n    [new Optional(), PROVIDED_REMOTE_CONFIG_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_REMOTE_CONFIG_INSTANCE_PROVIDER = {\n  provide: RemoteConfig,\n  useFactory: defaultRemoteConfigInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_REMOTE_CONFIG_INSTANCES ],\n    FirebaseApp,\n    PLATFORM_ID,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_REMOTE_CONFIG_INSTANCE_PROVIDER,\n    REMOTE_CONFIG_INSTANCES_PROVIDER,\n  ]\n})\nexport class RemoteConfigModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'rc');\n  }\n}\n\nexport function provideRemoteConfig(\n  fn: (injector: Injector) => FirebaseRemoteConfig, ...deps: any[]\n): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'rc');\n\n  return makeEnvironmentProviders([\n    DEFAULT_REMOTE_CONFIG_INSTANCE_PROVIDER,\n    REMOTE_CONFIG_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_REMOTE_CONFIG_INSTANCES,\n      useFactory: remoteConfigInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        PLATFORM_ID,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/remote-config/remote-config.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { RemoteConfig, getRemoteConfig, provideRemoteConfig } from '@angular/fire/remote-config';\nimport { COMMON_CONFIG } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('RemoteConfig', () => {\n  let app: FirebaseApp;\n  let remoteConfig: RemoteConfig;\n  let providedRemoteConfig: RemoteConfig;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideRemoteConfig(() => {\n                    providedRemoteConfig = getRemoteConfig(getApp(appName));\n                    return providedRemoteConfig;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        remoteConfig = TestBed.inject(RemoteConfig);\n    });\n\n    it('should be injectable', () => {\n        expect(providedRemoteConfig).toBeTruthy();\n        expect(remoteConfig).toEqual(providedRemoteConfig);\n        expect(remoteConfig.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/remote-config/remote-config.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { RemoteConfig as FirebaseRemoteConfig } from 'firebase/remote-config';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface RemoteConfig extends FirebaseRemoteConfig {}\n\nexport class RemoteConfig {\n  constructor(remoteConfig: FirebaseRemoteConfig) {\n    return remoteConfig;\n  }\n}\n\nexport const REMOTE_CONFIG_PROVIDER_NAME = 'remote-config';\n\n \nexport interface RemoteConfigInstances extends Array<FirebaseRemoteConfig> {}\n\nexport class RemoteConfigInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseRemoteConfig>(REMOTE_CONFIG_PROVIDER_NAME);\n  }\n}\n\nexport const remoteConfigInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseRemoteConfig>(REMOTE_CONFIG_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/remote-config/rxfire.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  getAll as _getAll,\n  getBoolean as _getBoolean,\n  getNumber as _getNumber,\n  getString as _getString,\n  getValue as _getValue\n} from 'rxfire/remote-config';\n\nexport const getAllChanges = ɵzoneWrap(_getAll, true);\nexport const getBooleanChanges = ɵzoneWrap(_getBoolean, true);\nexport const getNumberChanges = ɵzoneWrap(_getNumber, true);\nexport const getStringChanges = ɵzoneWrap(_getString, true);\nexport const getValueChanges = ɵzoneWrap(_getValue, true);\n"
  },
  {
    "path": "src/schematics/add/index.ts",
    "content": "import { SchematicContext, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask, RunSchematicTask } from '@angular-devkit/schematics/tasks';\nimport { addDependencies } from '../common';\nimport { DeployOptions } from '../interfaces';\nimport { peerDependencies } from '../versions.json';\n\nexport const ngAdd = (options: DeployOptions) => (tree: Tree, context: SchematicContext) => {\n  addDependencies(\n    tree,\n    peerDependencies,\n    context\n  );\n  const npmInstallTaskId = context.addTask(new NodePackageInstallTask());\n  context.addTask(new RunSchematicTask('ng-add-setup-project', options), [npmInstallTaskId]);\n  return tree;\n};\n"
  },
  {
    "path": "src/schematics/add/schema.json",
    "content": "{\n    \"$schema\": \"http://json-schema.org/draft-07/schema\",\n    \"$id\": \"angular-fire-ng-add\",\n    \"title\": \"AngularFire ng-add\",\n    \"type\": \"object\",\n    \"properties\": {\n      \"project\": {\n        \"type\": \"string\",\n        \"description\": \"The name of the project.\",\n        \"$default\": {\n          \"$source\": \"projectName\"\n        }\n      }\n    },\n    \"required\": []\n  }\n"
  },
  {
    "path": "src/schematics/builders.json",
    "content": "{\n  \"$schema\": \"../../node_modules/@angular-devkit/schematics/collection-schema.json\",\n  \"builders\": {\n    \"deploy\": {\n      \"implementation\": \"./deploy/builder\",\n      \"schema\": \"./deploy/schema.json\",\n      \"description\": \"Deploy builder\"\n    }\n  }\n}"
  },
  {
    "path": "src/schematics/collection.json",
    "content": "{\n  \"$schema\": \"../../node_modules/@angular-devkit/schematics/collection-schema.json\",\n  \"schematics\": {\n    \"ng-add\": {\n      \"description\": \"Add firebase deploy schematic\",\n      \"factory\": \"./add#ngAdd\",\n      \"schema\": \"./add/schema.json\"\n    },\n    \"ng-add-setup-project\": {\n      \"description\": \"Setup ng deploy\",\n      \"factory\": \"./setup#ngAddSetupProject\",\n      \"schema\": \"./setup/schema.json\"\n    }\n  }\n}\n"
  },
  {
    "path": "src/schematics/common.ts",
    "content": "import { SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics';\nimport { intersects as semverIntersects } from 'semver';\nimport { FirebaseHostingSite } from './interfaces';\n\nexport const shortSiteName = (site?: FirebaseHostingSite) => site?.name?.split('/').pop();\n\nexport const stringifyFormatted = (obj: any) => JSON.stringify(obj, null, 2);\n\nexport const overwriteIfExists = (\n  tree: Tree,\n  path: string,\n  content: string\n) => {\n  if (tree.exists(path)) {\n    tree.overwrite(path, content);\n  } else {\n    tree.create(path, content);\n  }\n};\n\nexport function safeReadJSON(path: string, tree: Tree) {\n  try {\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    return JSON.parse(tree.read(path)!.toString());\n  } catch (e) {\n    throw new SchematicsException(`Error when parsing ${path}: ${e.message}`);\n  }\n}\n\nexport const addDependencies = (\n  host: Tree,\n  deps: Record<string, { dev?: boolean, version: string }>,\n  context: SchematicContext\n) => {\n  const packageJson =\n    host.exists('package.json') && safeReadJSON('package.json', host);\n\n  if (packageJson === undefined) {\n    throw new SchematicsException('Could not locate package.json');\n  }\n\n  packageJson.devDependencies ??= {};\n  packageJson.dependencies ??= {};\n\n  Object.keys(deps).forEach(depName => {\n    const dep = deps[depName];\n    const existingDeps = dep.dev ? packageJson.devDependencies : packageJson.dependencies;\n    const existingVersion = existingDeps[depName];\n    if (existingVersion) {\n      try {\n        if (!semverIntersects(existingVersion, dep.version)) {\n          context.logger.warn(`⚠️ The ${depName} devDependency specified in your package.json (${existingVersion}) does not fulfill AngularFire's dependency (${dep.version})`);\n          // TODO offer to fix\n        }\n      } catch (_) {\n        if (existingVersion !== dep.version) {\n          context.logger.warn(`⚠️ The ${depName} devDependency specified in your package.json (${existingVersion}) does not fulfill AngularFire's dependency (${dep.version})`);\n          // TODO offer to fix\n        }\n      }\n    } else {\n      existingDeps[depName] = dep.version;\n    }\n  });\n\n  overwriteIfExists(host, 'package.json', stringifyFormatted(packageJson));\n};\n"
  },
  {
    "path": "src/schematics/deploy/actions.jasmine.ts",
    "content": "/* eslint-disable @typescript-eslint/no-empty-function */\nimport { join } from 'path';\nimport { BuilderContext, BuilderRun, ScheduleOptions, Target } from '@angular-devkit/architect';\nimport { JsonObject, logging } from '@angular-devkit/core';\nimport { BuildTarget, FSHost, FirebaseDeployConfig, FirebaseTools } from '../interfaces';\nimport deploy, { deployToFunction } from './actions.js'\nimport 'jasmine';\n\nlet context: BuilderContext;\nlet firebaseMock: FirebaseTools;\nlet fsHost: FSHost;\n\nconst FIREBASE_PROJECT = 'ikachu-aa3ef';\nconst PROJECT = 'pirojok-project';\nconst STATIC_BUILD_TARGET: BuildTarget = {\n  name: `${PROJECT}:build:production`\n};\n\nconst FIREBASE_TOKEN = 'kkasllkascnkjnskjsdcskdckskdksdkjc';\n\nconst SERVER_BUILD_TARGET: BuildTarget = {\n  name: `${PROJECT}:server:production`\n};\n\nconst login = () => Promise.resolve({ user: { email: 'foo@bar.baz' }});\nlogin.list = () => Promise.resolve([{ user: { email: 'foo@bar.baz' }}]);\nlogin.add = () => Promise.resolve([{ user: { email: 'foo@bar.baz' }}]);\nlogin.use = () => Promise.resolve('foo@bar.baz');\n\nconst workspaceRoot = join('home', 'user');\n\nconst initMocks = () => {\n  fsHost = {\n    moveSync(_: string, __: string) {\n    },\n    renameSync(_: string, __: string) {\n    },\n    writeFileSync(_: string, __: string) {\n    },\n    copySync(_: string, __: string) {\n    },\n    removeSync(_: string) {\n    },\n    existsSync(_: string) {\n      return false;\n    },\n  };\n\n  firebaseMock = {\n    login,\n    projects: {\n      list: () => Promise.resolve([]),\n      create: () => Promise.reject(),\n    },\n    apps: {\n      list: () => Promise.resolve([]),\n      create: () => Promise.reject(),\n      sdkconfig: () => Promise.resolve({ fileName: '_', fileContents: '', sdkConfig: {}, }),\n    },\n    hosting: {\n      sites: {\n        list: () => Promise.resolve({sites: []}),\n        create: () => Promise.reject(),\n      }\n    },\n    init() {\n      return Promise.resolve()\n    },\n    deploy: (_: FirebaseDeployConfig) => Promise.resolve(),\n    use: () => Promise.resolve(),\n    logger: {\n      add: () => { },\n      logger: {\n        add: () => { }\n      }\n    },\n    cli: { version: () => '9.0.0' },\n    serve: () => Promise.resolve()\n  };\n\n  context = ({\n    target: {\n      configuration: 'production',\n      project: PROJECT,\n      target: 'foo'\n    },\n    builder: {\n      builderName: 'mock',\n      description: 'mock',\n      optionSchema: false\n    },\n    currentDirectory: 'cwd',\n    id: 1,\n    logger: new logging.NullLogger() as any,\n    workspaceRoot: 'cwd',\n    getTargetOptions: (target: Target) => {\n      if (target.target === 'build') {\n        return { outputPath: 'dist/browser' };\n      } else if (target.target === 'server') {\n        return { outputPath: 'dist/server' };\n      }\n    },\n    reportProgress: (_: number, __?: number, ___?: string) => {\n    },\n    reportStatus: (_: string) => {\n    },\n    reportRunning: () => {\n    },\n    scheduleBuilder: (_: string, __?: JsonObject, ___?: ScheduleOptions) => Promise.resolve({} as BuilderRun),\n    scheduleTarget: (_: Target, __?: JsonObject, ___?: ScheduleOptions) => Promise.resolve({} as BuilderRun)\n  } as any);\n};\n\ndescribe('Deploy Angular apps', () => {\n  beforeEach(() => initMocks());\n\n  it('should call login', async () => {\n    const spy = spyOn(firebaseMock, 'login').and.resolveTo({ email: 'foo@bar.baz' });\n    await deploy(\n      firebaseMock, context, STATIC_BUILD_TARGET, undefined,\n      undefined, undefined, { projectId: FIREBASE_PROJECT, preview: false }\n    );\n    expect(spy).toHaveBeenCalled();\n  });\n\n  it('should not call login', async () => {\n    const spy = spyOn(firebaseMock, 'login');\n    await deploy(firebaseMock, context, STATIC_BUILD_TARGET, undefined,  undefined, undefined, { preview: false }, FIREBASE_TOKEN);\n    expect(spy).not.toHaveBeenCalled();\n  });\n\n  it('should invoke the builder', async () => {\n    const spy = spyOn(context, 'scheduleTarget').and.callThrough();\n    await deploy(firebaseMock, context, STATIC_BUILD_TARGET, undefined,  undefined, undefined, { preview: false });\n    expect(spy).toHaveBeenCalled();\n    expect(spy).toHaveBeenCalledWith({\n      target: 'build',\n      configuration: 'production',\n      project: PROJECT\n    }, undefined);\n  });\n\n  it('should allow the buildTarget to be specified', async () => {\n    const buildTarget = {\n      name: `${PROJECT}:prerender`,\n      options: {}\n    };\n    const spy = spyOn(context, 'scheduleTarget').and.callThrough();\n    await deploy(firebaseMock, context, buildTarget, undefined,  undefined, undefined, { preview: false });\n    expect(spy).toHaveBeenCalled();\n    expect(spy).toHaveBeenCalledWith({ target: 'prerender', project: PROJECT }, {});\n  });\n\n  it('should invoke firebase.deploy', async () => {\n    const spy = spyOn(firebaseMock, 'deploy').and.callThrough();\n    await deploy(firebaseMock, context, STATIC_BUILD_TARGET, undefined,  undefined, undefined, { preview: false }, FIREBASE_TOKEN);\n    expect(spy).toHaveBeenCalled();\n    expect(spy).toHaveBeenCalledWith({\n      cwd: 'cwd',\n      only: 'hosting:' + PROJECT,\n      token: FIREBASE_TOKEN,\n      nonInteractive: true,\n      projectRoot: 'cwd',\n    });\n  });\n\n  describe('error handling', () => {\n    it('throws if there is no firebase project', async () => {\n      try {\n        await deploy(firebaseMock, context, STATIC_BUILD_TARGET, undefined, undefined, undefined, { preview: false  });\n      } catch (e) {\n        expect(e.message).toMatch(/Cannot find firebase project/);\n      }\n    });\n\n    it('throws if there is no target project', async () => {\n      context.target = undefined;\n      try {\n        await deploy(firebaseMock, context, STATIC_BUILD_TARGET, undefined, undefined, undefined, { preview: false });\n      } catch (e) {\n        expect(e.message).toMatch(/Cannot execute the build target/);\n      }\n    });\n  });\n});\n\ndescribe('universal deployment', () => {\n  beforeEach(() => initMocks());\n\n  it('should create a firebase function', async () => {\n    const spy = spyOn(fsHost, 'writeFileSync');\n    await deployToFunction(\n      firebaseMock,\n      context,\n      workspaceRoot,\n      STATIC_BUILD_TARGET,\n      SERVER_BUILD_TARGET,\n      { preview: false  },\n      undefined,\n      fsHost\n    );\n\n    expect(spy).toHaveBeenCalledTimes(2);\n\n    const packageArgs = spy.calls.argsFor(0);\n    const functionArgs = spy.calls.argsFor(1);\n\n    expect(packageArgs[0]).toBe(join(workspaceRoot, 'dist', 'package.json'));\n    expect(functionArgs[0]).toBe(join(workspaceRoot, 'dist', 'index.js'));\n  });\n\n  it('should create a firebase function (new)', async () => {\n    const spy = spyOn(fsHost, 'writeFileSync');\n    await deployToFunction(\n      firebaseMock,\n      context,\n      workspaceRoot,\n      STATIC_BUILD_TARGET,\n      SERVER_BUILD_TARGET,\n      { preview: false, outputPath: join('dist', 'functions') },\n      undefined,\n      fsHost\n    );\n\n    expect(spy).toHaveBeenCalledTimes(2);\n\n    const packageArgs = spy.calls.argsFor(0);\n    const functionArgs = spy.calls.argsFor(1);\n\n    expect(packageArgs[0]).toBe(join(workspaceRoot, 'dist', 'functions', 'package.json'));\n    expect(functionArgs[0]).toBe(join(workspaceRoot, 'dist', 'functions', 'index.js'));\n  });\n\n  it('should rename the index.html file in the nested dist', async () => {\n    const spy = spyOn(fsHost, 'renameSync');\n    await deployToFunction(\n      firebaseMock,\n      context,\n      workspaceRoot,\n      STATIC_BUILD_TARGET,\n      SERVER_BUILD_TARGET,\n      { preview: false  },\n      undefined,\n      fsHost\n    );\n\n    expect(spy).toHaveBeenCalledTimes(1);\n\n    const packageArgs = spy.calls.argsFor(0);\n\n    expect(packageArgs).toEqual([\n      join(workspaceRoot, 'dist', 'dist', 'browser', 'index.html'),\n      join(workspaceRoot, 'dist', 'dist', 'browser', 'index.original.html')\n    ]);\n  });\n\n  it('should rename the index.html file in the nested dist (new)', async () => {\n    const spy = spyOn(fsHost, 'renameSync');\n    await deployToFunction(\n      firebaseMock,\n      context,\n      workspaceRoot,\n      STATIC_BUILD_TARGET,\n      SERVER_BUILD_TARGET,\n      { preview: false, outputPath: join('dist', 'functions') },\n      undefined,\n      fsHost\n    );\n\n    expect(spy).toHaveBeenCalledTimes(1);\n\n    const packageArgs = spy.calls.argsFor(0);\n\n    expect(packageArgs).toEqual([\n      join(workspaceRoot, 'dist', 'functions', 'dist', 'browser', 'index.html'),\n      join(workspaceRoot, 'dist', 'functions', 'dist', 'browser', 'index.original.html')\n    ]);\n  });\n\n  it('should invoke firebase.deploy', async () => {\n    const spy = spyOn(firebaseMock, 'deploy');\n    await deployToFunction(\n      firebaseMock,\n      context,\n      workspaceRoot,\n      STATIC_BUILD_TARGET,\n      SERVER_BUILD_TARGET,\n      { preview: false },\n      undefined,\n      fsHost\n    );\n\n    expect(spy).toHaveBeenCalledTimes(1);\n  });\n\n  /* TODO figure out how to stub the prompt\n  it('should not deploy if the command is invoked with --preview', async () => {\n    const spy = spyOn(firebaseMock, 'deploy');\n    await deployToFunction(firebaseMock, context, '/home/user', projectTargets, true, fsHost);\n    expect(spy).not.toHaveBeenCalled();\n  });*/\n});\n"
  },
  {
    "path": "src/schematics/deploy/actions.ts",
    "content": "import { SpawnOptionsWithoutStdio, execSync, spawn } from 'child_process';\nimport { existsSync, readFileSync, renameSync, writeFileSync } from 'fs';\nimport { dirname, join } from 'path';\nimport { fileURLToPath } from 'url';\nimport { BuilderContext, targetFromTargetString } from '@angular-devkit/architect';\nimport { SchematicsException } from '@angular-devkit/schematics';\nimport fsExtra from 'fs-extra';\nimport * as inquirer from 'inquirer';\nimport open from 'open';\nimport { satisfies } from 'semver';\nimport tripleBeam from 'triple-beam';\nimport * as winston from 'winston';\nimport { BuildTarget, CloudRunOptions, DeployBuilderSchema, FSHost, FirebaseTools } from '../interfaces';\nimport { DEFAULT_FUNCTION_NAME, defaultFunction, defaultPackage, dockerfile, functionGen2 } from './functions-templates.js';\n\n// @ts-ignore\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nconst { copySync, removeSync, readJsonSync } = fsExtra;\n\nconst DEFAULT_EMULATOR_PORT = 5000;\nconst DEFAULT_EMULATOR_HOST = 'localhost';\n\nconst DEFAULT_CLOUD_RUN_OPTIONS: Partial<CloudRunOptions> = {\n  memory: '1Gi',\n  timeout: 60,\n  maxInstances: 'default',\n  maxConcurrency: 'default', // TODO tune concurrency for cloud run + angular\n  minInstances: 'default',\n  cpus: 1,\n};\n\nconst spawnAsync = async (\n  command: string,\n  options?: SpawnOptionsWithoutStdio\n) =>\n  new Promise<Buffer>((resolve, reject) => {\n    const [spawnCommand, ...args] = command.split(/\\s+/);\n    const spawnProcess = spawn(spawnCommand, args, options);\n    const chunks: Buffer[] = [];\n    const errorChunks: Buffer[] = [];\n    spawnProcess.stdout.on('data', (data) => {\n      process.stdout.write(data.toString());\n      chunks.push(data);\n    });\n    spawnProcess.stderr.on('data', (data) => {\n      process.stderr.write(data.toString());\n      errorChunks.push(data);\n    });\n    spawnProcess.on('error', (error) => {\n      reject(error);\n    });\n    spawnProcess.on('close', (code) => {\n      if (code === 1) {\n        reject(Buffer.concat(errorChunks).toString());\n        return;\n      }\n      resolve(Buffer.concat(chunks));\n    });\n  });\n\nexport type DeployBuilderOptions = DeployBuilderSchema & Record<string, any>;\n\nconst escapeRegExp = (str: string) => str.replace(/[-[\\]/{}()*+?.\\\\^$|]/g, '\\\\$&');\n\nconst moveSync = (src: string, dest: string) => {\n  copySync(src, dest);\n  removeSync(src);\n};\n\nconst deployToHosting = async (\n  firebaseTools: FirebaseTools,\n  context: BuilderContext,\n  workspaceRoot: string,\n  options: DeployBuilderOptions,\n  firebaseToken?: string,\n) => {\n\n  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n  const siteTarget = options.target ?? context.target!.project;\n\n  if (options.preview) {\n\n    await firebaseTools.serve({\n      port: DEFAULT_EMULATOR_PORT,\n      host: DEFAULT_EMULATOR_HOST,\n      only: `hosting:${siteTarget}`,\n      nonInteractive: true,\n      projectRoot: workspaceRoot,\n    });\n\n    const { deployProject } = await inquirer.prompt({\n      type: 'confirm',\n      name: 'deployProject',\n      message: 'Would you like to deploy your application to Firebase Hosting?'\n    }) as { deployProject: boolean };\n\n    if (!deployProject) { return; }\n\n    process.env.FIREBASE_FRAMEWORKS_SKIP_BUILD = 'true';\n\n  }\n\n  return await firebaseTools.deploy({\n    only: `hosting:${siteTarget}`,\n    cwd: workspaceRoot,\n    token: firebaseToken,\n    nonInteractive: true,\n    projectRoot: workspaceRoot,\n  });\n\n};\n\nconst defaultFsHost: FSHost = {\n  moveSync,\n  writeFileSync,\n  renameSync,\n  copySync,\n  removeSync,\n  existsSync,\n};\n\nconst findPackageVersion = (packageManager: string, name: string) => {\n  const match = execSync(`${packageManager} list ${name}`).toString().match(`[^|s]${escapeRegExp(name)}[@| ][^s]+(s.+)?$`);\n  return match ? match[0].split(new RegExp(`${escapeRegExp(name)}[@| ]`))[1].split(/\\s/)[0] : null;\n};\n\nconst getPackageJson = (context: BuilderContext, workspaceRoot: string, options: DeployBuilderOptions, main?: string) => {\n  const dependencies: Record<string, string> = {};\n  const devDependencies: Record<string, string> = {};\n  const { firebaseFunctionsDependencies } = readJsonSync(join(__dirname, '..', 'versions.json'));\n  if (options.ssr !== 'cloud-run') {\n    Object.keys(firebaseFunctionsDependencies).forEach(name => {\n      const { version, dev } = firebaseFunctionsDependencies[name];\n      (dev ? devDependencies : dependencies)[name] = version;\n    });\n  }\n  if (existsSync(join(workspaceRoot, 'angular.json'))) {\n    const angularJson = JSON.parse(readFileSync(join(workspaceRoot, 'angular.json')).toString());\n    const packageManager = angularJson.cli?.packageManager ?? 'npm';\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    const server = angularJson.projects[context.target!.project].architect.server;\n    const externalDependencies = server?.options?.externalDependencies || [];\n    const bundleDependencies = server?.options?.bundleDependencies ?? true;\n    if (bundleDependencies) {\n      externalDependencies.forEach(externalDependency => {\n        const packageVersion = findPackageVersion(packageManager, externalDependency);\n        if (packageVersion) { dependencies[externalDependency] = packageVersion; }\n      });\n    } else {\n      if (existsSync(join(workspaceRoot, 'package.json'))) {\n        const packageJson = JSON.parse(readFileSync(join(workspaceRoot, 'package.json')).toString());\n        Object.keys(packageJson.dependencies).forEach((dependency: string) => {\n          dependencies[dependency] = packageJson.dependencies[dependency];\n        });\n      } // TODO should we throw?\n    }\n  }\n  // TODO should we throw?\n  return defaultPackage(dependencies, devDependencies, options, main);\n};\n\nexport const deployToFunction = async (\n  firebaseTools: FirebaseTools,\n  context: BuilderContext,\n  workspaceRoot: string,\n  staticBuildTarget: BuildTarget,\n  serverBuildTarget: BuildTarget,\n  options: DeployBuilderOptions,\n  firebaseToken?: string,\n  fsHost: FSHost = defaultFsHost\n) => {\n\n  const staticBuildOptions = await context.getTargetOptions(targetFromTargetString(staticBuildTarget.name));\n  if (!staticBuildOptions.outputPath || typeof staticBuildOptions.outputPath !== 'string') {\n    throw new Error(\n      `Cannot read the output path option of the Angular project '${staticBuildTarget.name}' in angular.json`\n    );\n  }\n\n  const serverBuildOptions = await context.getTargetOptions(targetFromTargetString(serverBuildTarget.name));\n  if (!serverBuildOptions.outputPath || typeof serverBuildOptions.outputPath !== 'string') {\n    throw new Error(\n      `Cannot read the output path option of the Angular project '${serverBuildTarget.name}' in angular.json`\n    );\n  }\n\n  const staticOut = join(workspaceRoot, staticBuildOptions.outputPath);\n  const serverOut = join(workspaceRoot, serverBuildOptions.outputPath);\n\n  const functionsOut = options.outputPath ? join(workspaceRoot, options.outputPath) : dirname(serverOut);\n  const functionName = options.functionName || DEFAULT_FUNCTION_NAME;\n\n  const newStaticOut = join(functionsOut, staticBuildOptions.outputPath);\n  const newServerOut = join(functionsOut, serverBuildOptions.outputPath);\n\n  // New behavior vs. old\n  if (options.outputPath) {\n    fsHost.removeSync(functionsOut);\n    fsHost.copySync(staticOut, newStaticOut);\n    fsHost.copySync(serverOut, newServerOut);\n  } else {\n    fsHost.moveSync(staticOut, newStaticOut);\n    fsHost.moveSync(serverOut, newServerOut);\n  }\n\n  const packageJson = getPackageJson(context, workspaceRoot, options);\n  const nodeVersion = packageJson.engines.node;\n\n  if (!satisfies(process.versions.node, nodeVersion.toString())) {\n    context.logger.warn(\n      `⚠️ Your Node.js version (${process.versions.node}) does not match the Firebase Functions runtime (${nodeVersion}).`\n    );\n  }\n\n  const functionsPackageJsonPath = join(functionsOut, 'package.json');\n  fsHost.writeFileSync(\n    functionsPackageJsonPath,\n    JSON.stringify(packageJson, null, 2)\n  );\n\n  if (options.CF3v2) {\n    fsHost.writeFileSync(\n      join(functionsOut, 'index.js'),\n      functionGen2(serverBuildOptions.outputPath, options, functionName)\n    );\n  } else {\n    fsHost.writeFileSync(\n      join(functionsOut, 'index.js'),\n      defaultFunction(serverBuildOptions.outputPath, options, functionName)\n    );\n  }\n\n  if (!options.prerender) {\n    try {\n      fsHost.renameSync(\n        join(newStaticOut, 'index.html'),\n        join(newStaticOut, 'index.original.html')\n      );\n    } catch (_) { /* empty */ }\n  }\n\n  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n  const siteTarget = options.target ?? context.target!.project;\n\n  if (fsHost.existsSync(functionsPackageJsonPath)) {\n    execSync(`npm --prefix ${functionsOut} install`);\n  } else {\n    console.error(`No package.json exists at ${functionsOut}`);\n  }\n\n  if (options.preview) {\n\n    await firebaseTools.serve({\n      port: DEFAULT_EMULATOR_PORT,\n      host: DEFAULT_EMULATOR_HOST,\n      targets: [`hosting:${siteTarget}`, `functions:${functionName}`],\n      nonInteractive: true,\n      projectRoot: workspaceRoot,\n    });\n\n    const { deployProject } = await inquirer.prompt({\n      type: 'confirm',\n      name: 'deployProject',\n      message: 'Would you like to deploy your application to Firebase Hosting & Cloud Functions?'\n    }) as { deployProject: boolean };\n\n    if (!deployProject) { return; }\n  }\n\n  return await firebaseTools.deploy({\n    only: `hosting:${siteTarget},functions:${functionName}`,\n    cwd: workspaceRoot,\n    token: firebaseToken,\n    nonInteractive: true,\n    projectRoot: workspaceRoot,\n  });\n\n};\n\n\nexport const deployToCloudRun = async (\n  firebaseTools: FirebaseTools,\n  context: BuilderContext,\n  workspaceRoot: string,\n  staticBuildTarget: BuildTarget,\n  serverBuildTarget: BuildTarget,\n  options: DeployBuilderOptions,\n  firebaseToken?: string,\n  fsHost: FSHost = defaultFsHost\n) => {\n\n  const staticBuildOptions = await context.getTargetOptions(targetFromTargetString(staticBuildTarget.name));\n  if (!staticBuildOptions.outputPath || typeof staticBuildOptions.outputPath !== 'string') {\n    throw new Error(\n      `Cannot read the output path option of the Angular project '${staticBuildTarget.name}' in angular.json`\n    );\n  }\n\n  const serverBuildOptions = await context.getTargetOptions(targetFromTargetString(serverBuildTarget.name));\n  if (!serverBuildOptions.outputPath || typeof serverBuildOptions.outputPath !== 'string') {\n    throw new Error(\n      `Cannot read the output path option of the Angular project '${serverBuildTarget.name}' in angular.json`\n    );\n  }\n\n  const staticOut = join(workspaceRoot, staticBuildOptions.outputPath);\n  const serverOut = join(workspaceRoot, serverBuildOptions.outputPath);\n\n  const cloudRunOut = options.outputPath ? join(workspaceRoot, options.outputPath) : join(dirname(serverOut), 'run');\n  const serviceId = options.functionName || DEFAULT_FUNCTION_NAME;\n\n  const newStaticOut = join(cloudRunOut, staticBuildOptions.outputPath);\n  const newServerOut = join(cloudRunOut, serverBuildOptions.outputPath);\n\n  // This is needed because in the server output there's a hardcoded dependency on $cwd/dist/browser,\n  // This assumes that we've deployed our application dist directory and we're running the server\n  // in the parent directory. To have this precondition, we move dist/browser to dist/dist/browser\n  // since the firebase function runs the server from dist.\n  fsHost.removeSync(cloudRunOut);\n  fsHost.copySync(staticOut, newStaticOut);\n  fsHost.copySync(serverOut, newServerOut);\n\n  const packageJson = getPackageJson(context, workspaceRoot, options, join(serverBuildOptions.outputPath, 'main.js'));\n  const nodeVersion = packageJson.engines.node;\n\n  if (!satisfies(process.versions.node, nodeVersion.toString())) {\n    context.logger.warn(\n      `⚠️ Your Node.js version (${process.versions.node}) does not match the Cloud Run runtime (${nodeVersion}).`\n    );\n  }\n\n  fsHost.writeFileSync(\n    join(cloudRunOut, 'package.json'),\n    JSON.stringify(packageJson, null, 2),\n  );\n\n  fsHost.writeFileSync(\n    join(cloudRunOut, 'Dockerfile'),\n    dockerfile(options)\n  );\n\n  if (!options.prerender) {\n    try {\n      fsHost.renameSync(\n        join(newStaticOut, 'index.html'),\n        join(newStaticOut, 'index.original.html')\n      );\n    } catch (_) { /* empty */ }\n  }\n\n  if (options.preview) {\n    throw new SchematicsException('Cloud Run preview not supported.');\n  }\n\n  const deployArguments: any[] = [];\n  const cloudRunOptions = options.cloudRunOptions || {};\n  Object.entries(DEFAULT_CLOUD_RUN_OPTIONS).forEach(([k, v]) => {\n    cloudRunOptions[k] ||= v;\n  });\n  // lean on the schema for validation (rather than sanitize)\n  if (cloudRunOptions.cpus) { deployArguments.push('--cpu', cloudRunOptions.cpus); }\n  if (cloudRunOptions.maxConcurrency) { deployArguments.push('--concurrency', cloudRunOptions.maxConcurrency); }\n  if (cloudRunOptions.maxInstances) { deployArguments.push('--max-instances', cloudRunOptions.maxInstances); }\n  if (cloudRunOptions.memory) { deployArguments.push('--memory', cloudRunOptions.memory); }\n  if (cloudRunOptions.minInstances) { deployArguments.push('--min-instances', cloudRunOptions.minInstances); }\n  if (cloudRunOptions.timeout) { deployArguments.push('--timeout', cloudRunOptions.timeout); }\n  if (cloudRunOptions.vpcConnector) { deployArguments.push('--vpc-connector', cloudRunOptions.vpcConnector); }\n\n  // TODO validate serviceId, firebaseProject, and vpcConnector both to limit errors and opp for injection\n\n  context.logger.info(`📦 Deploying to Cloud Run`);\n  await spawnAsync(`gcloud builds submit ${cloudRunOut} --tag gcr.io/${options.firebaseProject}/${serviceId} --project ${options.firebaseProject} --quiet`);\n  await spawnAsync(`gcloud run deploy ${serviceId} --image gcr.io/${options.firebaseProject}/${serviceId} --project ${options.firebaseProject} ${deployArguments.join(' ')} --platform managed --allow-unauthenticated --region=${options.region} --quiet`);\n\n  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n  const siteTarget = options.target ?? context.target!.project;\n\n  // TODO deploy cloud run\n  return await firebaseTools.deploy({\n    only: `hosting:${siteTarget}`,\n    cwd: workspaceRoot,\n    token: firebaseToken,\n    nonInteractive: true,\n    projectRoot: workspaceRoot,\n  });\n};\n\nexport default async function deploy(\n  firebaseTools: FirebaseTools,\n  context: BuilderContext,\n  staticBuildTarget: BuildTarget,\n  serverBuildTarget: BuildTarget | undefined,\n  prerenderBuildTarget: BuildTarget | undefined,\n  firebaseProject: string,\n  options: DeployBuilderOptions,\n  firebaseToken?: string,\n) {\n  const legacyNgDeploy = !options.version || options.version < 2;\n\n  if (!firebaseToken && !process.env.GOOGLE_APPLICATION_CREDENTIALS) {\n    await firebaseTools.login();\n    const user = await firebaseTools.login({ projectRoot: context.workspaceRoot });\n    console.log(`Logged into Firebase as ${user.email}.`);\n  }\n\n  if (!firebaseToken && process.env.GOOGLE_APPLICATION_CREDENTIALS) {\n    await spawnAsync(`gcloud auth activate-service-account --key-file ${process.env.GOOGLE_APPLICATION_CREDENTIALS}`);\n    console.log(`Using Google Application Credentials.`);\n  }\n\n  if (legacyNgDeploy) {\n    console.error(`Legacy ng-deploy Firebase is deprecated.\nPlease migrate to Firebase Hosting's integration with Angular https://firebase.google.com/docs/hosting/frameworks/angular\nor the new Firebase App Hosting product https://firebase.google.com/docs/app-hosting`);\n  }\n\n  if (prerenderBuildTarget) {\n    const run = await context.scheduleTarget(\n      targetFromTargetString(prerenderBuildTarget.name),\n      prerenderBuildTarget.options\n    );\n    await run.result;\n\n  } else {\n\n    if (!context.target) {\n      throw new Error('Cannot execute the build target');\n    }\n\n    context.logger.info(`📦 Building \"${context.target.project}\"`);\n\n    const builders = [\n      context.scheduleTarget(\n        targetFromTargetString(staticBuildTarget.name),\n        staticBuildTarget.options\n      ).then(run => run.result)\n    ];\n\n    if (serverBuildTarget) {\n      builders.push(context.scheduleTarget(\n        targetFromTargetString(serverBuildTarget.name),\n        serverBuildTarget.options\n      ).then(run => run.result));\n    }\n\n    await Promise.all(builders);\n  }\n\n\n  try {\n    await firebaseTools.use(firebaseProject, {\n      project: firebaseProject,\n      projectRoot: context.workspaceRoot,\n    });\n  } catch (_) {\n    throw new Error(`Cannot select firebase project '${firebaseProject}'`);\n  }\n\n  options.firebaseProject = firebaseProject;\n\n  const logger = new winston.transports.Console({\n    level: 'info',\n    format: winston.format.printf((info) => {\n      const emulator = info[tripleBeam.SPLAT as any]?.[1]?.metadata?.emulator;\n      const text = info[tripleBeam.SPLAT as any]?.[0];\n      if (text?.replace) {\n        // eslint-disable-next-line no-control-regex\n        const plainText = text.replace(/\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]/g, '');\n        if (emulator?.name === 'hosting' && plainText.startsWith('Local server: ')) {\n          open(plainText.split(': ')[1]);\n        }\n      }\n      return [info.message, ...(info[tripleBeam.SPLAT as any] || []) as any]\n        .filter((chunk) => typeof chunk === 'string')\n        .join(' ');\n    })\n  });\n\n  firebaseTools.logger.logger.add(logger);\n\n  if (legacyNgDeploy && serverBuildTarget) {\n    if (options.ssr === 'cloud-run') {\n      await deployToCloudRun(\n        firebaseTools,\n        context,\n        context.workspaceRoot,\n        staticBuildTarget,\n        serverBuildTarget,\n        options,\n        firebaseToken,\n      );\n    } else {\n      await deployToFunction(\n        firebaseTools,\n        context,\n        context.workspaceRoot,\n        staticBuildTarget,\n        serverBuildTarget,\n        options,\n        firebaseToken,\n      );\n    }\n  } else {\n    await deployToHosting(\n      firebaseTools,\n      context,\n      context.workspaceRoot,\n      options,\n      firebaseToken,\n    );\n  }\n\n}\n"
  },
  {
    "path": "src/schematics/deploy/builder.ts",
    "content": "import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';\nimport { getFirebaseTools } from '../firebaseTools';\nimport { BuildTarget } from '../interfaces';\nimport { getFirebaseProjectNameFromFs } from '../utils';\nimport deploy, { DeployBuilderOptions } from './actions';\n\n// Call the createBuilder() function to create a builder. This mirrors\n// createJobHandler() but add typings specific to Architect Builders.\nexport default createBuilder(\n  async (options: DeployBuilderOptions, context: BuilderContext): Promise<BuilderOutput> => {\n    if (!context.target) {\n      throw new Error('Cannot deploy the application without a target');\n    }\n\n    const [defaultFirebaseProject, defulatFirebaseHostingSite] = getFirebaseProjectNameFromFs(\n      context.workspaceRoot,\n      context.target.project\n    );\n\n    const firebaseProject = options.firebaseProject || defaultFirebaseProject;\n    if (!firebaseProject) {\n      throw new Error('Cannot determine the Firebase Project from your angular.json or .firebaserc');\n    }\n    if (firebaseProject !== defaultFirebaseProject) {\n      throw new Error('The Firebase Project specified by your angular.json or .firebaserc is in conflict');\n    }\n\n    const firebaseHostingSite = options.firebaseHostingSite || defulatFirebaseHostingSite;\n    if (!firebaseHostingSite) {\n      throw new Error(`Cannot determine the Firebase Hosting Site from your angular.json or .firebaserc`);\n    }\n    if (firebaseHostingSite !== defulatFirebaseHostingSite) {\n      throw new Error('The Firebase Hosting Site specified by your angular.json or .firebaserc is in conflict');\n    }\n\n    const staticBuildTarget = { name: options.browserTarget || options.buildTarget || `${context.target.project}:build:production` };\n\n    let prerenderBuildTarget: BuildTarget | undefined;\n    if (options.prerender) {\n      prerenderBuildTarget = {\n        name: options.prerenderTarget || `${context.target.project}:prerender:production`\n      };\n    }\n\n    let serverBuildTarget: BuildTarget | undefined;\n    if (options.ssr) {\n      serverBuildTarget = {\n        name: options.serverTarget || options.universalBuildTarget || `${context.target.project}:server:production`\n      };\n    }\n\n    try {\n      process.env.FIREBASE_DEPLOY_AGENT = 'angularfire';\n      await deploy(\n        (await getFirebaseTools()),\n        context,\n        staticBuildTarget,\n        serverBuildTarget,\n        prerenderBuildTarget,\n        firebaseProject,\n        options,\n        process.env.FIREBASE_TOKEN,\n      );\n    } catch (e) {\n      console.error('Error when trying to deploy: ');\n      console.error(e.message);\n      return { success: false };\n    }\n\n    return { success: true };\n  }\n);\n"
  },
  {
    "path": "src/schematics/deploy/functions-templates.ts",
    "content": "import { DeployBuilderOptions } from './actions';\n\nexport const DEFAULT_NODE_VERSION = 14;\nexport const DEFAULT_FUNCTION_NAME = 'ssr';\n\nconst DEFAULT_FUNCTION_REGION = 'us-central1';\n\nconst DEFAULT_RUNTIME_OPTIONS = {\n  timeoutSeconds: 60,\n  memory: '1GB'\n};\n\nexport const defaultPackage = (\n  dependencies: Record<string, string>,\n  devDependencies: Record<string, string>,\n  options: DeployBuilderOptions,\n  main?: string,\n) => ({\n  name: 'functions',\n  description: 'Angular Universal Application',\n  main: main ?? 'index.js',\n  scripts: {\n    start: main ? `node ${main}` : 'firebase functions:shell',\n  },\n  engines: {\n    node: (options.functionsNodeVersion || DEFAULT_NODE_VERSION).toString()\n  },\n  dependencies,\n  devDependencies,\n  private: true\n});\n\nexport const defaultFunction = (\n  path: string,\n  options: DeployBuilderOptions,\n  functionName: string|undefined,\n) => `const functions = require('firebase-functions');\n\n// Increase readability in Cloud Logging\nrequire(\"firebase-functions/lib/logger/compat\");\n\nconst expressApp = require('./${path}/main').app();\n\nexports.${functionName || DEFAULT_FUNCTION_NAME} = functions\n  .region('${options.region || DEFAULT_FUNCTION_REGION}')\n  .runWith(${JSON.stringify(options.functionsRuntimeOptions || DEFAULT_RUNTIME_OPTIONS)})\n  .https\n  .onRequest(expressApp);\n`;\n\nexport const functionGen2 = (\n  path: string,\n  options: DeployBuilderOptions,\n  functionName: string|undefined,\n) => `const { onRequest } = require('firebase-functions/v2/https');\n\n// Increase readability in Cloud Logging\nrequire(\"firebase-functions/lib/logger/compat\");\n\nconst expressApp = require('./${path}/main').app();\n\nexports.${functionName || DEFAULT_FUNCTION_NAME} = onRequest(${JSON.stringify({\n  region: options.region || DEFAULT_FUNCTION_REGION,\n  ...(options.functionsRuntimeOptions || DEFAULT_RUNTIME_OPTIONS)\n})}, expressApp);\n`;\n\nexport const dockerfile = (\n  options: DeployBuilderOptions,\n) => `FROM node:${options.functionsNodeVersion || DEFAULT_NODE_VERSION}-slim\nWORKDIR /usr/src/app\nCOPY package*.json ./\nRUN npm install --only=production\nCOPY . ./\nCMD [ \"npm\", \"start\" ]\n`;\n"
  },
  {
    "path": "src/schematics/deploy/schema.json",
    "content": "{\n  \"$schema\": \"http://json-schema.org/draft-07/schema\",\n  \"$id\": \"FirebaseDeploySchema\",\n  \"title\": \"Firebase Deploy\",\n  \"description\": \"Ng Deploy target options for Firebase.\",\n  \"properties\": {\n    \"buildTarget\": {\n      \"type\": \"string\",\n      \"description\": \"Target to build.\",\n      \"pattern\": \"^[^:\\\\s]+:[^:\\\\s]+(:[^\\\\s]+)?$\"\n    },\n    \"browserTarget\": {\n      \"type\": \"string\",\n      \"description\": \"Target to build.\",\n      \"pattern\": \"^[^:\\\\s]+:[^:\\\\s]+(:[^\\\\s]+)?$\"\n    },\n    \"prerenderTarget\": {\n      \"type\": \"string\",\n      \"description\": \"Target to build.\",\n      \"pattern\": \"^[^:\\\\s]+:[^:\\\\s]+(:[^\\\\s]+)?$\"\n    },\n    \"serverTarget\": {\n      \"type\": \"string\",\n      \"description\": \"Target to build.\",\n      \"pattern\": \"^[^:\\\\s]+:[^:\\\\s]+(:[^\\\\s]+)?$\"\n    },\n    \"universalBuildTarget\": {\n      \"type\": \"string\",\n      \"description\": \"Target to build.\",\n      \"pattern\": \"^[^:\\\\s]+:[^:\\\\s]+(:[^\\\\s]+)?$\"\n    },\n    \"ssr\": {\n      \"oneOf\": [{ \"type\": \"boolean\" }, { \"type\": \"string\" }],\n      \"description\": \"Should we attempt to deploy the function to Cloud Functions (true or 'cloud-functions') / Cloud Run ('cloud-run') or just Hosting (false)\"\n    },\n    \"prerender\": {\n      \"type\": \"boolean\",\n      \"description\": \"Prerender before deploy?\"\n    },\n    \"firebaseProject\": {\n      \"type\": \"string\",\n      \"description\": \"The Firebase project name or project alias to use when deploying\"\n    },\n    \"target\": {\n      \"type\": \"string\",\n      \"description\": \"The Firebase hosting target in firebase.json for multi-site\"\n    },\n    \"firebaseHostingSite\": {\n      \"type\": \"string\",\n      \"description\": \"The Firebase Hosting site to deploy to\"\n    },\n    \"functionName\": {\n      \"type\": \"string\",\n      \"description\": \"The name of the Cloud Function or Cloud Run serviceId to deploy SSR to\"\n    },\n    \"functionsNodeVersion\": {\n      \"oneOf\": [{ \"type\": \"number\" }, { \"type\": \"string\" }],\n      \"description\": \"Version of Node.js to run Cloud Functions / Run on\"\n    },\n    \"CF3v2\": {\n      \"type\": \"boolean\",\n      \"description\": \"Generation of the Functions product to run on\"\n    },\n    \"region\": {\n      \"type\": \"string\",\n      \"description\": \"The region to deploy Cloud Functions or Cloud Run to\"\n    },\n    \"outputPath\": {\n      \"type\": \"string\",\n      \"description\": \"Where to output the deploy artifacts\"\n    },\n    \"functionsRuntimeOptions\": {\n      \"type\": \"object\",\n      \"description\": \"Runtime options for Cloud Functions, if deploying to Cloud Functions\"\n    },\n    \"preview\": {\n      \"type\": \"boolean\",\n      \"description\": \"Do not deploy the application, just set up the Firebase Function in the project output directory. Can be used for testing the Firebase Function with `firebase serve`.\"\n    },\n    \"cloudRunOptions\": {\n      \"type\": \"object\",\n      \"description\": \"Options passed to Cloud Run, if deploying to Cloud Run.\",\n      \"properties\": {\n        \"cpus\": {\n          \"type\": \"number\",\n          \"description\": \"Set a CPU limit in Kubernetes cpu units.\"\n        },\n        \"maxConcurrency\": {\n          \"oneOf\": [{ \"type\": \"number\" }, { \"type\": \"string\" }],\n          \"pattern\": \"^(\\\\d+|default)$\",\n          \"description\": \"Set the maximum number of concurrent requests allowed per container instance. If concurrency is unspecified, any number of concurrent requests are allowed. To unset this field, provide the special value default.\"\n        },\n        \"maxInstances\": {\n          \"oneOf\": [{ \"type\": \"number\" }, { \"type\": \"string\" }],\n          \"pattern\": \"^(\\\\d+|default)$\",\n          \"description\": \"The maximum number of container instances of the Service to run. Use 'default' to unset the limit and use the platform default.\"\n        },\n        \"memory\": {\n          \"type\": \"string\",\n          \"pattern\": \"^\\\\d+(G|M)i$\",\n          \"description\": \"Set a memory limit. Ex: 1Gi, 512Mi.\"\n        },\n        \"minInstances\": {\n          \"oneOf\": [{ \"type\": \"number\" }, { \"type\": \"string\" }],\n          \"pattern\": \"^(\\\\d+|default)$\",\n          \"description\": \"The minimum number of container instances of the Service to run or 'default' to remove any minimum.\"\n        },\n        \"timeout\": {\n          \"type\": \"number\",\n          \"description\": \"Set the maximum request execution time (timeout) in seconds.\"\n        },\n        \"vpcConnector\": {\n          \"type\": \"string\",\n          \"description\": \"Set a VPC connector for this resource.\"\n        }\n      }\n    }\n  }\n}\n"
  },
  {
    "path": "src/schematics/firebaseTools.ts",
    "content": " \nimport { execSync, spawn } from 'child_process';\nimport ora from 'ora';\nimport { compare as semverCompare } from 'semver';\nimport { FirebaseTools } from './interfaces';\n\ndeclare global {\n    var firebaseTools: FirebaseTools|undefined;\n}\n\nexport const getFirebaseTools = () => globalThis.firebaseTools ?\n    Promise.resolve(globalThis.firebaseTools) :\n    new Promise<FirebaseTools>((resolve, reject) => {\n        process.env.FIREBASE_CLI_EXPERIMENTS ||= 'webframeworks';\n        try {\n            resolve(require('firebase-tools'));\n        } catch (_) {\n            try {\n                const root = execSync('npm root --location=global').toString().trim();\n                resolve(require(`${root}/firebase-tools`));\n            } catch (_) {\n                const spinner = ora({\n                    text: `Installing firebase-tools...`,\n                    // Workaround for https://github.com/sindresorhus/ora/issues/136.\n                    discardStdin: process.platform !== 'win32',\n                }).start();\n                spawn('npm', ['i', '--location=global', 'firebase-tools'], {\n                    stdio: 'pipe',\n                    shell: true,\n                }).on('close', (code) => {\n                    if (code === 0) {\n                        spinner.succeed('firebase-tools installed globally.');\n                        spinner.stop();\n                        const root = execSync('npm root -g').toString().trim();\n                        resolve(require(`${root}/firebase-tools`));\n                    } else {\n                        spinner.fail('Package install failed.');\n                        reject();\n                    }\n                });\n            }\n        }\n    }).then(firebaseTools => {\n        globalThis.firebaseTools = firebaseTools;\n        const version = firebaseTools.cli.version();\n        console.log(`Using firebase-tools version ${version}`);\n        if (semverCompare(version, '14.0.0') === -1) {\n            console.error('firebase-tools version 13.0.0+ is required, please upgrade and run again');\n            return Promise.reject();\n        }\n        return firebaseTools;\n    });\n"
  },
  {
    "path": "src/schematics/interfaces.ts",
    "content": "import type { HttpsOptions } from 'firebase-functions/https';\n\nexport const enum FEATURES {\n  Authentication,\n  Analytics,\n  AppCheck,\n  Database,\n  DataConnect,\n  Functions,\n  Messaging,\n  Performance,\n  Firestore,\n  Storage,\n  RemoteConfig,\n  VertexAI,\n}\n\nexport const featureOptions = [\n  { name: 'Authentication', value: FEATURES.Authentication },\n  { name: 'Google Analytics', value: FEATURES.Analytics },\n  { name: 'App Check', value: FEATURES.AppCheck },\n  { name: 'Firestore', value: FEATURES.Firestore },\n  { name: 'Realtime Database', value: FEATURES.Database },\n  { name: 'Data Connect', value: FEATURES.DataConnect },\n  { name: 'Cloud Functions (callable)', value: FEATURES.Functions },\n  { name: 'Cloud Messaging', value: FEATURES.Messaging },\n  { name: 'Performance Monitoring', value: FEATURES.Performance },\n  { name: 'Cloud Storage', value: FEATURES.Storage },\n  { name: 'Remote Config', value: FEATURES.RemoteConfig },\n  { name: 'Vertex AI', value: FEATURES.VertexAI },\n];\n\nexport const enum PROJECT_TYPE { Static, CloudFunctions, CloudRun, WebFrameworks }\n\nexport interface NgAddOptions {\n  firebaseProject: string;\n  project?: string;\n}\n\nexport interface NgAddNormalizedOptions {\n  project: string;\n  firebaseProject: FirebaseProject;\n  firebaseApp: FirebaseApp|undefined;\n  firebaseHostingSite: FirebaseHostingSite|undefined;\n  sdkConfig: Record<string, string>|undefined;\n  buildTarget: [string,string]|undefined;\n  serveTarget: [string,string]|undefined;\n  ssrRegion: string|undefined;\n}\n\nexport interface DeployOptions {\n  project?: string;\n}\n\nexport interface FirebaseProject {\n  projectId: string;\n  projectNumber: string;\n  displayName: string;\n  name: string;\n  resources: Record<string, string>;\n  state: string;\n}\n\nexport interface FirebaseDeployConfig {\n  cwd: string;\n  only?: string;\n  token?: string;\n  [key: string]: any;\n}\n\nexport interface FirebaseApp {\n  name: string;\n  displayName: string;\n  platform: string;\n  appId: string;\n  namespace: string;\n}\n\nexport interface FirebaseHostingSite {\n  name: string;\n  defaultUrl: string;\n  type: string;\n  appId: string|undefined;\n}\n\nexport interface FirebaseSDKConfig {\n  fileName: string;\n  fileContents: string;\n  sdkConfig: Record<string, string>;\n}\n\nexport interface FirebaseTools {\n  projects: {\n    list(options: any): Promise<FirebaseProject[]>;\n    create(projectId: string|undefined, options: any): Promise<FirebaseProject>;\n  };\n\n  apps: {\n    list(platform: string|undefined, options: any): Promise<FirebaseApp[]>;\n    create(platform: string, displayName: string|undefined, options: any): Promise<FirebaseApp>;\n    sdkconfig(type: string, projectId: string, options: any): Promise<FirebaseSDKConfig>;\n  };\n\n  hosting: {\n    sites: {\n      list(options: any): Promise<{ sites: FirebaseHostingSite[]}>;\n      create(siteId: string, options: any): Promise<FirebaseHostingSite>;\n    }\n  };\n\n  logger: {\n    // firebase-tools v8\n    add: (...args: any[]) => any\n    // firebase-tools v9\n    logger: {\n      add: (...args: any[]) => any;\n    }\n  };\n\n  cli: {\n    version(): string;\n  };\n\n  login: {\n    list(): Promise<{user: Record<string, any>}[] | { users: undefined }>;\n    add(): Promise<Record<string, any>>;\n    use(email: string, options?: unknown): Promise<string>;\n  } & ((options?: unknown) => Promise<Record<string, any>>);\n\n  deploy(config: FirebaseDeployConfig): Promise<any>;\n\n  serve(options: any): Promise<any>;\n\n  use(options: any, lol: any): Promise<any>;\n\n  init(feature: string, options: any): Promise<any>;\n}\n\nexport interface FirebaseHostingRewrite {\n  source: string;\n  destination?: string;\n  function?: string;\n}\n\nexport interface FirebaseHostingConfig {\n  public?: string;\n  ignore?: string[];\n  target?: string;\n  rewrites?: FirebaseHostingRewrite[];\n}\n\nexport type FirebaseFunctionsConfig = Record<string, any>;\n\nexport interface DataConnectConfig {\n  source?: string;\n}\n\nexport interface FirebaseJSON {\n  hosting?: FirebaseHostingConfig[] | FirebaseHostingConfig;\n  functions?: FirebaseFunctionsConfig;\n  dataconnect?: DataConnectConfig;\n}\n\nexport interface FirebaseRcTarget {\n  hosting: Record<string, string[]>;\n}\n\nexport interface FirebaseRc {\n  targets?: Record<string, FirebaseRcTarget>;\n  projects?: Record<string, string>;\n}\n\nexport interface DeployBuilderSchema {\n  buildTarget?: string;\n  browserTarget?: string;\n  firebaseProject?: string;\n  firebaseHostingSite?: string;\n  preview?: boolean;\n  target?: boolean;\n  universalBuildTarget?: string;\n  serverTarget?: string;\n  prerenderTarget?: string;\n  ssr?: boolean | string;\n  region?: string;\n  prerender?: boolean;\n  functionName?: string;\n  functionsNodeVersion?: number|string;\n  functionsRuntimeOptions?: HttpsOptions;\n  cloudRunOptions?: Partial<CloudRunOptions>;\n  outputPath?: string;\n  CF3v2?: boolean;\n  version?: number;\n}\n\nexport interface CloudRunOptions {\n  cpus: number;\n  maxConcurrency: number | 'default';\n  maxInstances: number | 'default';\n  memory: string;\n  minInstances: number | 'default';\n  timeout: number;\n  vpcConnector: string;\n}\n\nexport interface BuildTarget {\n  name: string;\n  options?: Record<string, any>;\n}\n\nexport interface FSHost {\n  moveSync(src: string, dest: string): void;\n  writeFileSync(src: string, data: string): void;\n  renameSync(src: string, dest: string): void;\n  copySync(src: string, dest: string): void;\n  removeSync(src: string): void;\n  existsSync(src: string): boolean;\n}\n\nexport interface WorkspaceProject {\n  root: string;\n  sourceRoot?: string;\n  projectType?: string;\n  architect?: Record<string, {\n    builder: string;\n    options?: Record<string, any>,\n    configurations?: Record<string, Record<string, any>>,\n    defaultConfiguration?: string,\n  }>;\n}\n\nexport interface Workspace {\n  defaultProject?: string;\n  projects: Record<string, WorkspaceProject>;\n}\n\nexport interface ConnectorConfig {\n  location: string;\n  connector: string;\n  service: string;\n}\nexport interface ConnectorYaml {\n  connectorId: string;\n  generate?: {\n    javascriptSdk?: {\n      package: string;\n      outputDir: string;\n      packageJsonDir?: string;\n      angular?: boolean;\n    }\n  }\n}\nexport interface DataConnectYaml {\n  location: string;\n  serviceId: string;\n  connectorDirs: string[];\n}\nexport interface DataConnectConnectorConfig  {\n  connectorYaml: ConnectorYaml;\n  connectorConfig?: ConnectorConfig;\n  angular?: boolean;\n  package?: string;\n}\n\nexport interface PackageJson {\n  dependencies: Record<string, string>;\n  devDependencies: Record<string, string>;\n}\n"
  },
  {
    "path": "src/schematics/migration.json",
    "content": "{\n    \"$schema\": \"../../node_modules/@angular-devkit/schematics/collection-schema.json\",\n    \"schematics\": {\n        \"migration-v7\": {\n            \"version\": \"7.0.0\",\n            \"description\": \"Update @angular/fire to v7\",\n            \"factory\": \"./update/v7#ngUpdate\"\n        },\n        \"ng-post-upgate\": {\n            \"description\": \"Print out results after ng-update\",\n            \"factory\": \"./update#ngPostUpdate\",\n            \"private\": true\n        }\n    }\n}"
  },
  {
    "path": "src/schematics/setup/index.ts",
    "content": "import { readFileSync, writeFileSync } from 'fs';\nimport { join } from 'path';\nimport { asWindowsPath, normalize } from '@angular-devkit/core';\nimport { SchematicContext, Tree, chain } from '@angular-devkit/schematics';\nimport { addRootProvider } from '@schematics/angular/utility';\nimport { getFirebaseTools } from '../firebaseTools';\nimport {\n  DataConnectConnectorConfig,\n  DeployOptions, FEATURES, FirebaseApp, FirebaseJSON, FirebaseProject,\n} from '../interfaces';\nimport {\n  addIgnoreFiles,\n  featureToRules,\n  getFirebaseProjectNameFromHost,\n  getProject,\n  parseDataConnectConfig,\n  setupTanstackDependencies,\n} from '../utils';\nimport { appPrompt, featuresPrompt, projectPrompt, userPrompt } from './prompts';\n\nexport interface SetupConfig extends DeployOptions {\n  firebaseProject: FirebaseProject,\n  firebaseApp?: FirebaseApp,\n  sdkConfig?: Record<string, string>,\n  firebaseJsonConfig?: FirebaseJSON;\n  dataConnectConfig?: DataConnectConnectorConfig | null;\n  firebaseJsonPath: string;\n}\n\nexport const setupProject =\n  (tree: Tree, context: SchematicContext, features: FEATURES[], config: SetupConfig) => {\n    const { projectName } = getProject(config, tree);\n\n    addIgnoreFiles(tree);\n\n    if (features.length) {\n      return chain([\n        addRootProvider(projectName, ({code, external}) => {\n          external('initializeApp', '@angular/fire/app');\n          return code`${external('provideFirebaseApp', '@angular/fire/app')}(() => initializeApp(${\n            config.sdkConfig ? `{ ${Object.entries(config.sdkConfig).map(([k, v]) => `${k}: ${JSON.stringify(v)}`).join(\", \")} }` : \"\"\n          }))`;\n        }),\n        ...featureToRules(features, projectName, config.dataConnectConfig),\n      ]);\n    }\n};\n\nexport const ngAddSetupProject = (\n  options: DeployOptions\n) => async (host: Tree, context: SchematicContext) => {\n\n  // TODO is there a public API for this?\n  let projectRoot: string = (host as any)._backend._root;\n  if (process.platform.startsWith('win32')) { projectRoot = asWindowsPath(normalize(projectRoot)); }\n\n  const features = await featuresPrompt();\n\n  if (features.length > 0) {\n\n    const firebaseTools = await getFirebaseTools();\n\n    // Add the firebase files if they don't exist already so login.use works\n    if (!host.exists('/firebase.json')) { writeFileSync(join(projectRoot, 'firebase.json'), '{}'); }\n    \n    let firebaseJson: FirebaseJSON = JSON.parse(\n      readFileSync(join(projectRoot, \"firebase.json\")).toString()\n    );\n\n    const user = await userPrompt({ projectRoot });\n    const defaultUser = await firebaseTools.login(options);\n    if (user.email !== defaultUser?.email) {\n      await firebaseTools.login.use(user.email, { projectRoot });\n    }\n\n    const { projectName: ngProjectName } = getProject(options, host);\n\n    const [ defaultProjectName ] = getFirebaseProjectNameFromHost(host, ngProjectName);\n\n    const firebaseProject = await projectPrompt(defaultProjectName, { projectRoot, account: user.email });\n    \n    let firebaseApp: FirebaseApp|undefined;\n    let sdkConfig: Record<string, string>|undefined;\n\n    const setupConfig: SetupConfig = {\n      ...options, firebaseProject, firebaseApp, sdkConfig,\n      firebaseJsonConfig: firebaseJson,\n      firebaseJsonPath: projectRoot\n    };\n    if (features.length) {\n\n      firebaseApp = await appPrompt(firebaseProject, undefined, { projectRoot });\n\n      const result = await firebaseTools.apps.sdkconfig('web', firebaseApp.appId, { nonInteractive: true, projectRoot });\n      sdkConfig = result.sdkConfig;\n      delete sdkConfig.locationId;\n      setupConfig.sdkConfig = sdkConfig;\n      setupConfig.firebaseApp = firebaseApp;\n      // set up data connect locally if data connect hasn't already been initialized.\n      if(features.includes(FEATURES.DataConnect)) {\n        if (!firebaseJson.dataconnect) {\n          try {\n            await firebaseTools.init(\"dataconnect\", {\n              projectRoot,\n              project: firebaseProject.projectId,\n            });\n            // Update firebaseJson values to include newly added dataconnect field in firebase.json.\n            firebaseJson = JSON.parse(\n              readFileSync(join(projectRoot, \"firebase.json\")).toString()\n            );\n            setupConfig.firebaseJsonConfig = firebaseJson;\n          } catch (e) {\n            console.error(e);\n          }\n        }\n          let dataConnectConfig = parseDataConnectConfig(setupConfig);\n          if(!dataConnectConfig?.connectorYaml.generate?.javascriptSdk) {\n            await firebaseTools.init(\"dataconnect:sdk\", {\n              projectRoot,\n              project: firebaseProject.projectId,\n            });\n          }\n          // Parse through sdk again\n          dataConnectConfig = parseDataConnectConfig(setupConfig);\n          if(dataConnectConfig?.angular) {\n            context.logger.info('Generated Angular SDK Enabled.');\n          } else {\n            context.logger.info('Generated Angular SDK Disabled. Please add `angular: true` to your connector.yaml');\n          }\n          setupTanstackDependencies(host, context);\n          setupConfig.dataConnectConfig = dataConnectConfig;\n        }\n      \n    }\n\n    return setupProject(host, context, features, setupConfig);\n  }\n};\n"
  },
  {
    "path": "src/schematics/setup/prompts.ts",
    "content": "import { spawnSync } from 'child_process';\nimport * as fuzzy from 'fuzzy';\nimport * as inquirer from 'inquirer';\nimport { getFirebaseTools } from '../firebaseTools';\nimport { FEATURES, FirebaseApp, FirebaseProject, featureOptions } from '../interfaces';\nimport { shortAppId } from '../utils';\n\n \ninquirer.registerPrompt('autocomplete', require('inquirer-autocomplete-prompt'));\n\nconst NEW_OPTION = '~~angularfire-new~~';\n\n// `fuzzy` passes either the original list of projects or an internal object\n// which contains the project as a property.\nconst isProject = (elem: FirebaseProject | fuzzy.FilterResult<FirebaseProject>): elem is FirebaseProject => {\n    return (elem as { original: FirebaseProject }).original === undefined;\n};\n\nconst isApp = (elem: FirebaseApp | fuzzy.FilterResult<FirebaseApp>): elem is FirebaseApp => {\n    return (elem as { original: FirebaseApp }).original === undefined;\n};\n\nexport const searchProjects = (projects: FirebaseProject[]) =>\n  // eslint-disable-next-line @typescript-eslint/require-await\n    async (_: any, input: string) => {\n        projects.unshift({\n            projectId: NEW_OPTION,\n            displayName: '[CREATE NEW PROJECT]'\n        } as any);\n        return fuzzy.filter(input, projects, {\n            extract(el) {\n                return `${el.projectId} ${el.displayName}`;\n            }\n        }).map((result) => {\n            let original: FirebaseProject;\n            if (isProject(result)) {\n                original = result;\n            } else {\n                original = result.original;\n            }\n            return {\n                name: original.displayName,\n                title: original.displayName,\n                value: original.projectId\n            };\n        });\n    };\n\nexport const searchApps = (apps: FirebaseApp[]) =>\n  // eslint-disable-next-line @typescript-eslint/require-await\n  async (_: any, input: string) => {\n    apps.unshift({\n      appId: NEW_OPTION,\n      displayName: '[CREATE NEW APP]',\n    } as any);\n    return fuzzy.filter(input, apps, {\n      extract(el: FirebaseApp) {\n        return el.displayName;\n      }\n    }).map((result) => {\n      let original: FirebaseApp;\n      if (isApp(result)) {\n        original = result;\n      } else {\n        original = result.original;\n      }\n      return {\n        name: original.displayName,\n        title: original.displayName,\n        value: shortAppId(original),\n      };\n    });\n  };\n\ntype Prompt = <K extends string, U= unknown>(questions: { name: K, source: (...args) =>\n  Promise<{ value: U }[]>, default?: U | ((o: U[]) => U | Promise<U>), [key: string]: any }) =>\n    Promise<Record<K, U>>;\n\nconst autocomplete: Prompt = (questions) => inquirer.prompt(questions);\n\n\nexport const featuresPrompt = async (): Promise<FEATURES[]> => {\n  const { features } = await inquirer.prompt({\n    type: 'checkbox',\n    name: 'features',\n    choices: featureOptions,\n    message: 'What features would you like to setup?',\n    default: [],\n  }) as { features: FEATURES[] };\n  return features;\n};\n\nexport const userPrompt = async (options: { projectRoot: string }): Promise<Record<string, any>> => {\n  const firebaseTools = await getFirebaseTools();\n  let loginList = await firebaseTools.login.list();\n  if (!Array.isArray(loginList) || loginList.length === 0) {\n    spawnSync('firebase login', { shell: true, cwd: options.projectRoot, stdio: 'inherit' });\n    return await firebaseTools.login(options);\n  } else {\n    const defaultUser = await firebaseTools.login(options);\n    const choices = loginList.map(({user}) => ({ name: user.email, value: user }));\n    const newChoice = { name: '[Login in with another account]', value: NEW_OPTION };\n    const { user } = await inquirer.prompt({\n      type: 'list',\n      name: 'user',\n      choices: [newChoice].concat(choices as any), // TODO types\n      message: 'Which Firebase account would you like to use?',\n      default: choices.find(it => it.value.email === defaultUser.email)?.value,\n    }) as any;\n    if (user === NEW_OPTION) {\n      spawnSync('firebase login:add', { shell: true, cwd: options.projectRoot, stdio: 'inherit' });\n      loginList = await firebaseTools.login.list();\n      if (!Array.isArray(loginList)) {\n        throw new Error(\"firebase login:list did not respond as expected\");\n      }\n      const priorEmails = choices.map(it => it.name);\n      const newLogin = loginList.find(it => !priorEmails.includes(it.user.email));\n      if (!newLogin) {\n        throw new Error(\"Did not find a new user.\");\n      }\n      return newLogin.user;\n    }\n    return user;\n  }\n};\n\nexport const projectPrompt = async (defaultProject: string|undefined, options: unknown) => {\n  const firebaseTools = await getFirebaseTools();\n  const projects = await firebaseTools.projects.list(options);\n  const { projectId } = await autocomplete({\n    type: 'autocomplete',\n    name: 'projectId',\n    source: searchProjects(projects),\n    message: 'Please select a project:',\n    default: defaultProject,\n  });\n  if (projectId === NEW_OPTION) {\n    const { projectId } = await inquirer.prompt({\n      type: 'input',\n      name: 'projectId',\n      message: `Please specify a unique project id (cannot be modified afterward) [6-30 characters]:`,\n    }) as { projectId: string };\n    const { displayName } = await inquirer.prompt({\n      type: 'input',\n      name: 'displayName',\n      message: 'What would you like to call your project?',\n      default: projectId,\n    }) as { displayName: string };\n    return await firebaseTools.projects.create(projectId, { account: (options as any).account, displayName, nonInteractive: true });\n  }\n  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n  return (projects).find(it => it.projectId === projectId)!;\n};\n\nexport const appPrompt = async ({ projectId: project }: FirebaseProject, defaultAppId: string|undefined, options: any) => {\n  const firebaseTools = await getFirebaseTools();\n  const apps = await firebaseTools.apps.list('web', { ...options, project });\n  const { appId } = await autocomplete({\n    type: 'autocomplete',\n    name: 'appId',\n    source: searchApps(apps),\n    message: 'Please select an app:',\n    default: defaultAppId,\n  });\n  if (appId === NEW_OPTION) {\n    const { displayName } = await inquirer.prompt({\n      type: 'input',\n      name: 'displayName',\n      message: 'What would you like to call your app?',\n    }) as { displayName: string };\n    return await firebaseTools.apps.create('web', displayName, { ...options, nonInteractive: true, project });\n  }\n  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n  return (apps).find(it => shortAppId(it) === appId)!;\n};\n"
  },
  {
    "path": "src/schematics/setup/schema.json",
    "content": "{\n    \"$schema\": \"http://json-schema.org/draft-07/schema\",\n    \"$id\": \"angular-fire-ng-add\",\n    \"title\": \"AngularFire ng-add\",\n    \"type\": \"object\",\n    \"properties\": {\n      \"project\": {\n        \"type\": \"string\",\n        \"description\": \"The name of the project.\",\n        \"$default\": {\n          \"$source\": \"projectName\"\n        }\n      }\n    },\n    \"required\": []\n  }\n"
  },
  {
    "path": "src/schematics/tsconfig.json",
    "content": "{\n    \"compilerOptions\": {\n        \"rootDir\": \".\",\n        \"sourceMap\": false,\n        \"inlineSources\": false,\n        \"declaration\": false,\n        \"removeComments\": true,\n        \"strictNullChecks\": true,\n        \"resolveJsonModule\": true,\n        \"esModuleInterop\": true,\n        \"lib\": [\n            \"es2015\",\n            \"dom\",\n            \"es2015.promise\",\n            \"es2015.collection\",\n            \"es2015.iterable\"\n        ],\n        \"skipLibCheck\": true,\n        \"moduleResolution\": \"node\",\n        \"target\": \"es2018\",\n        \"module\": \"commonjs\",\n        \"outDir\": \"../../dist/packages-dist/schematics\"\n    },\n    \"files\": [\n        \"update/index.ts\",\n        \"deploy/actions.ts\",\n        \"deploy/builder.ts\",\n        \"add/index.ts\",\n        \"setup/index.ts\",\n        \"update/v7/index.ts\",\n    ]\n}"
  },
  {
    "path": "src/schematics/update/index.ts",
    "content": "import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\n\nexport const ngPostUpdate = (): Rule => (\n    host: Tree,\n    _context: SchematicContext\n) => {\n    return host;\n};\n"
  },
  {
    "path": "src/schematics/update/v7/index.ts",
    "content": "import { join } from 'path';\nimport { Rule, SchematicContext, SchematicsException, Tree } from '@angular-devkit/schematics';\nimport { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';\nimport { overwriteIfExists, safeReadJSON, stringifyFormatted } from '../../common';\nimport { firebaseFunctionsDependencies, peerDependencies } from '../../versions.json';\n\nconst IMPORT_REGEX = /(?<key>import|export)\\s+(?:(?<alias>[\\w,{}\\s*]+)\\s+from)?\\s*(?:(?<quote>[\"'])?(?<ref>[@\\w\\s\\\\/.-]+)\\3?)\\s*(?<term>[;\\n])/g;\ninterface ImportRegexMatch {\n    key: string;\n    alias: string;\n    ref: string;\n    quote: string;\n    term: string;\n}\n\nexport const ngUpdate = (): Rule => (\n    host: Tree,\n    context: SchematicContext\n) => {\n    const packageJson = host.exists('package.json') && safeReadJSON('package.json', host);\n\n    if (packageJson === undefined) {\n        throw new SchematicsException('Could not locate package.json');\n    }\n\n    Object.keys(peerDependencies).forEach(depName => {\n        const dep = peerDependencies[depName];\n        if (dep) {\n            packageJson[dep.dev ? 'devDependencies' : 'dependencies'][depName] = dep.version;\n        }\n    });\n\n    // TODO test if it's a SSR project in the JSON\n    Object.keys(firebaseFunctionsDependencies).forEach(depName => {\n        const dep = firebaseFunctionsDependencies[depName];\n        if (dep.dev && packageJson.devDependencies[depName]) {\n            packageJson.devDependencies[depName] = dep.version;\n        } else if (packageJson.dependencies[depName]) {\n            packageJson.dependencies[depName] = dep.version;\n        }\n    });\n\n    overwriteIfExists(host, 'package.json', stringifyFormatted(packageJson));\n    context.addTask(new NodePackageInstallTask());\n\n    const angularJson = host.exists('angular.json') && safeReadJSON('angular.json', host);\n    if (packageJson === undefined) {\n        throw new SchematicsException('Could not locate angular.json');\n    }\n\n    // TODO investigate if this is correct in Windows\n    const srcRoots: string[] = Object.values(angularJson.projects).map((it: any) =>\n        join(...['/', it.root, it.sourceRoot].filter(it => !!it))\n    );\n\n    host.visit(filePath => {\n        if (\n            !filePath.endsWith('.ts') ||\n            filePath.endsWith('.d.ts') ||\n            !srcRoots.find(root => filePath.startsWith(root))\n        ) {\n            return;\n        }\n        const content = host.read(filePath)?.toString();\n        if (!content) {\n            return;\n        }\n        const newContent = content.replace(IMPORT_REGEX, (substring, ...args) => {\n            const { alias, key, ref, quote, term }: ImportRegexMatch = args.pop();\n            if (ref.startsWith('@angular/fire') && !ref.startsWith('@angular/fire/compat')) {\n                return `${key} ${alias} from ${quote}${ref.replace('@angular/fire', '@angular/fire/compat')}${quote}${term}`;\n            }\n            if (ref.startsWith('firebase') && !ref.startsWith('firebase/compat')) {\n                return `${key} ${alias} from ${quote}${ref.replace('firebase', 'firebase/compat')}${quote}${term}`;\n            }\n            if (ref.startsWith('@firebase')) {\n                return `${key} ${alias} from ${quote}${ref.replace('@firebase', 'firebase')}${quote}${term}`;\n            }\n            return substring;\n        });\n        if (content !== newContent) {\n            overwriteIfExists(host, filePath, newContent);\n        }\n    });\n\n    return host;\n};\n"
  },
  {
    "path": "src/schematics/utils.ts",
    "content": "import { readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport {\n  Rule,\n  SchematicContext,\n  SchematicsException,\n  Tree,\n  chain,\n} from \"@angular-devkit/schematics\";\nimport { NodePackageInstallTask } from \"@angular-devkit/schematics/tasks\";\nimport { addRootProvider } from \"@schematics/angular/utility\";\nimport { parse } from \"yaml\";\nimport { overwriteIfExists, safeReadJSON, stringifyFormatted } from \"./common\";\nimport {\n  ConnectorConfig,\n  ConnectorYaml,\n  DataConnectConnectorConfig,\n  DataConnectYaml,\n  DeployOptions,\n  FEATURES,\n  FirebaseApp,\n  FirebaseRc,\n  PackageJson,\n  Workspace,\n} from \"./interfaces\";\nimport { SetupConfig } from \"./setup\";\n\nexport const shortAppId = (app?: FirebaseApp) => app?.appId?.split(\"/\").pop();\n\nexport function getWorkspace(host: Tree): {\n  path: string;\n  workspace: Workspace;\n} {\n  const path = \"/angular.json\";\n\n  const configBuffer = path && host.read(path);\n  if (!configBuffer) {\n    throw new SchematicsException(`Could not find angular.json`);\n  }\n\n   \n  const { parse } = require(\"jsonc-parser\");\n\n  const workspace = parse(configBuffer.toString()) as Workspace | undefined;\n  if (!workspace) {\n    throw new SchematicsException(\"Could not parse angular.json\");\n  }\n\n  return {\n    path,\n    workspace,\n  };\n}\n\nexport const getProject = (options: DeployOptions, host: Tree) => {\n  const { workspace } = getWorkspace(host);\n  const projectName = options.project || workspace.defaultProject;\n\n  if (!projectName) {\n    throw new SchematicsException(\n      \"No Angular project selected and no default project in the workspace\"\n    );\n  }\n\n  const project = workspace.projects[projectName];\n  if (!project) {\n    throw new SchematicsException(\n      \"The specified Angular project is not defined in this workspace\"\n    );\n  }\n\n  if (project.projectType !== \"application\") {\n    throw new SchematicsException(\n      `Deploy requires an Angular project type of \"application\" in angular.json`\n    );\n  }\n\n  return { project, projectName };\n};\n\nexport function getFirebaseProjectNameFromHost(\n  host: Tree,\n  target: string\n): [string | undefined, string | undefined] {\n  const buffer = host.read(\"/.firebaserc\");\n  if (!buffer) {\n    return [undefined, undefined];\n  }\n  const rc: FirebaseRc = JSON.parse(buffer.toString());\n  return projectFromRc(rc, target);\n}\n\nexport function getFirebaseProjectNameFromFs(\n  root: string,\n  target: string\n): [string | undefined, string | undefined] {\n  const path = join(root, \".firebaserc\");\n  try {\n    const buffer = readFileSync(path);\n    const rc: FirebaseRc = JSON.parse(buffer.toString());\n    return projectFromRc(rc, target);\n  } catch (_) {\n    return [undefined, undefined];\n  }\n}\n\nconst projectFromRc = (\n  rc: FirebaseRc,\n  target: string\n): [string | undefined, string | undefined] => {\n  const defaultProject = rc.projects?.default;\n  const project = Object.keys(rc.targets || {}).find(\n    (project) => !!rc.targets?.[project]?.hosting?.[target]\n  );\n  const site = project && rc.targets?.[project]?.hosting?.[target]?.[0];\n  return [project || defaultProject, site];\n};\n\n// TODO rewrite using typescript\nexport function addFixesToServer(host: Tree) {\n  const serverPath = `/server.ts`;\n\n  if (!host.exists(serverPath)) {\n    return host;\n  }\n\n  const text = host.read(serverPath);\n  if (text === null) {\n    throw new SchematicsException(`File ${serverPath} does not exist.`);\n  }\n  const sourceText = text.toString(\"utf-8\");\n  const addZonePatch = !sourceText.includes(\n    \"import 'zone.js/dist/zone-patch-rxjs';\"\n  );\n\n  if (addZonePatch) {\n    overwriteIfExists(\n      host,\n      serverPath,\n      sourceText.replace(\n        \"import 'zone.js/dist/zone-node';\",\n        `import 'zone.js/dist/zone-node';\n${addZonePatch ? \"import 'zone.js/dist/zone-patch-rxjs';\" : \"\"}`\n      )\n    );\n  }\n\n  return host;\n}\n\nexport function featureToRules(\n  features: FEATURES[],\n  projectName: string,\n  dataConnectConfig?: DataConnectConnectorConfig | null\n) {\n  return features\n    .map((feature) => {\n      switch (feature) {\n        case FEATURES.AppCheck:\n          // TODO make this smarter in Angular Universal\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"initializeAppCheck\", \"@angular/fire/app-check\");\n            external(\"ReCaptchaEnterpriseProvider\", \"@angular/fire/app-check\");\n            return code`${external(\n              \"provideAppCheck\",\n              \"@angular/fire/app-check\"\n            )}(() => {\n  // TODO get a reCAPTCHA Enterprise here https://console.cloud.google.com/security/recaptcha?project=_\n  const provider = new ReCaptchaEnterpriseProvider(/* reCAPTCHA Enterprise site key */);\n  return initializeAppCheck(undefined, { provider, isTokenAutoRefreshEnabled: true });\n})`;\n          });\n        case FEATURES.Analytics:\n          return chain([\n            addRootProvider(projectName, ({ code, external }) => {\n              external(\"getAnalytics\", \"@angular/fire/analytics\");\n              return code`${external(\n                \"provideAnalytics\",\n                \"@angular/fire/analytics\"\n              )}(() => getAnalytics())`;\n            }),\n            // TODO if using Angular router\n            addRootProvider(projectName, ({ code, external }) => {\n              return code`${external(\n                \"ScreenTrackingService\",\n                \"@angular/fire/analytics\"\n              )}`;\n            }),\n            ...(features.includes(FEATURES.Authentication)\n              ? [\n                  addRootProvider(projectName, ({ code, external }) => {\n                    return code`${external(\n                      \"UserTrackingService\",\n                      \"@angular/fire/analytics\"\n                    )}`;\n                  }),\n                ]\n              : []),\n          ]);\n        case FEATURES.Authentication:\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getAuth\", \"@angular/fire/auth\");\n            return code`${external(\n              \"provideAuth\",\n              \"@angular/fire/auth\"\n            )}(() => getAuth())`;\n          });\n        case FEATURES.Database:\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getDatabase\", \"@angular/fire/database\");\n            return code`${external(\n              \"provideDatabase\",\n              \"@angular/fire/database\"\n            )}(() => getDatabase())`;\n          });\n        case FEATURES.DataConnect:\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getDataConnect\", \"@angular/fire/data-connect\");\n            let configAsStr = \"{}\";\n\n            const config = dataConnectConfig;\n            let angularConfig: undefined | string;\n            if (config) {\n              if (config.package) {\n                configAsStr = external(\"connectorConfig\", config.package);\n              } else {\n                configAsStr = `{${Object.keys(config.connectorConfig as ConnectorConfig).map(\n                  (key) => `${key}: \"${(config.connectorConfig as ConnectorConfig)[key]}\"`\n                ).join(',')}}`;\n              }\n              if (config.angular) {\n                angularConfig = `, ${external(\n                  \"provideTanStackQuery\",\n                  \"@tanstack/angular-query-experimental\"\n                )}(new ${external(\n                  \"QueryClient\",\n                  \"@tanstack/angular-query-experimental\"\n                )}())`;\n              }\n            }\n            return code`${external(\n              \"provideDataConnect\",\n              \"@angular/fire/data-connect\"\n            )}(() => getDataConnect(${configAsStr}))${angularConfig ?? \"\"}`;\n          });\n        case FEATURES.Firestore:\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getFirestore\", \"@angular/fire/firestore\");\n            return code`${external(\n              \"provideFirestore\",\n              \"@angular/fire/firestore\"\n            )}(() => getFirestore())`;\n          });\n        case FEATURES.Functions:\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getFunctions\", \"@angular/fire/functions\");\n            return code`${external(\n              \"provideFunctions\",\n              \"@angular/fire/functions\"\n            )}(() => getFunctions())`;\n          });\n        case FEATURES.Messaging:\n          // TODO add the service worker\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getMessaging\", \"@angular/fire/messaging\");\n            return code`${external(\n              \"provideMessaging\",\n              \"@angular/fire/messaging\"\n            )}(() => getMessaging())`;\n          });\n        case FEATURES.Performance:\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getPerformance\", \"@angular/fire/performance\");\n            return code`${external(\n              \"providePerformance\",\n              \"@angular/fire/performance\"\n            )}(() => getPerformance())`;\n          });\n        case FEATURES.Storage:\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getStorage\", \"@angular/fire/storage\");\n            return code`${external(\n              \"provideStorage\",\n              \"@angular/fire/storage\"\n            )}(() => getStorage())`;\n          });\n        case FEATURES.RemoteConfig:\n          // TODO consider downloading the defaults\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getRemoteConfig\", \"@angular/fire/remote-config\");\n            return code`${external(\n              \"provideRemoteConfig\",\n              \"@angular/fire/remote-config\"\n            )}(() => getRemoteConfig())`;\n          });\n        case FEATURES.VertexAI:\n          return addRootProvider(projectName, ({ code, external }) => {\n            external(\"getVertexAI\", \"@angular/fire/vertexai\");\n            return code`${external(\n              \"provideVertexAI\",\n              \"@angular/fire/vertexai\"\n            )}(() => getVertexAI())`;\n          });\n        default:\n          return undefined;\n      }\n    })\n    .filter((it): it is Rule => !!it);\n}\n\nexport const addIgnoreFiles = (host: Tree) => {\n  const path = \"/.gitignore\";\n  if (!host.exists(path)) {\n    return host;\n  }\n\n  const buffer = host.read(path);\n  if (!buffer) {\n    return host;\n  }\n\n  const content = buffer.toString();\n  if (!content.includes(\"# Firebase\")) {\n    overwriteIfExists(\n      host,\n      path,\n      content.concat(`\n# Firebase\n.firebase\n*-debug.log\n.runtimeconfig.json\n`)\n    );\n  }\n\n  return host;\n};\n\nexport function parseDataConnectConfig(\n  config: SetupConfig\n): DataConnectConnectorConfig | null {\n  if (!config.firebaseJsonConfig) {\n    throw new Error(\"No firebase json\");\n  }\n  if (!config.firebaseJsonConfig.dataconnect?.source) {\n    throw new Error(\n      \"Couldn't find data connect configuration. Running `firebase init dataconnect`\"\n    );\n  }\n  const dataConnectFolder = join(\n    config.firebaseJsonPath,\n    config.firebaseJsonConfig.dataconnect?.source\n  );\n  const sourcePath = join(dataConnectFolder, \"dataconnect.yaml\");\n  try {\n    const fileAsStr = readFileSync(sourcePath).toString();\n    const dataConnectYaml: DataConnectYaml = parse(fileAsStr);\n    const connectorPath = join(\n      dataConnectFolder,\n      dataConnectYaml.connectorDirs[0],\n      \"connector.yaml\"\n    );\n    const connectorAsStr = readFileSync(connectorPath).toString();\n    const connectorJson: ConnectorYaml = parse(connectorAsStr);\n    if (!connectorJson?.generate?.javascriptSdk) {\n      return { connectorYaml: connectorJson };\n    }\n    return {\n      connectorYaml: connectorJson,\n      connectorConfig: {\n        connector: connectorJson.connectorId,\n        location: dataConnectYaml.location,\n        service: dataConnectYaml.serviceId,\n      },\n      package: connectorJson.generate.javascriptSdk.package,\n      angular: connectorJson.generate.javascriptSdk.angular,\n    };\n  } catch (_) {\n    console.error(\"Couldn't parse dataconnect.yaml\", e);\n    return null;\n  }\n}\n\nexport function setupTanstackDependencies(\n  host: Tree,\n  context: SchematicContext\n) {\n  const packageJson: PackageJson = safeReadJSON(\"package.json\", host);\n  const tanstackFirebasePackage = \"@tanstack-query-firebase/angular\";\n  if (\n    !packageJson.dependencies[tanstackFirebasePackage] &&\n    !packageJson.devDependencies[tanstackFirebasePackage]\n  ) {\n    packageJson.dependencies[tanstackFirebasePackage] =\n      \"^1.0.0\";\n    packageJson.dependencies[\"@tanstack/angular-query-experimental\"] = \"5.66.4\";\n    overwriteIfExists(host, \"package.json\", stringifyFormatted(packageJson));\n    context.addTask(new NodePackageInstallTask());\n  }\n}\n"
  },
  {
    "path": "src/schematics/versions.json",
    "content": "{\n    \"peerDependencies\": {\n    },\n    \"firebaseFunctionsDependencies\": {\n        \"firebase-admin\": { \"dev\": false, \"version\": \"0.0.0\" },\n        \"firebase-functions\": { \"dev\": false, \"version\":  \"0.0.0\" }\n    }\n}\n"
  },
  {
    "path": "src/storage/firebase.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nexport * from 'firebase/storage';\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  connectStorageEmulator as _connectStorageEmulator,\n  deleteObject as _deleteObject,\n  getBlob as _getBlob,\n  getBytes as _getBytes,\n  getDownloadURL as _getDownloadURL,\n  getMetadata as _getMetadata,\n  getStorage as _getStorage,\n  getStream as _getStream,\n  list as _list,\n  listAll as _listAll,\n  ref as _ref,\n  updateMetadata as _updateMetadata,\n  uploadBytes as _uploadBytes,\n  uploadBytesResumable as _uploadBytesResumable,\n  uploadString as _uploadString\n} from 'firebase/storage';\n\nexport const connectStorageEmulator = ɵzoneWrap(_connectStorageEmulator, true);\nexport const deleteObject = ɵzoneWrap(_deleteObject, true, 2);\nexport const getBlob = ɵzoneWrap(_getBlob, true);\nexport const getBytes = ɵzoneWrap(_getBytes, true);\nexport const getDownloadURL = ɵzoneWrap(_getDownloadURL, true);\nexport const getMetadata = ɵzoneWrap(_getMetadata, true);\nexport const getStorage = ɵzoneWrap(_getStorage, true);\nexport const getStream = ɵzoneWrap(_getStream, true);\nexport const list = ɵzoneWrap(_list, true);\nexport const listAll = ɵzoneWrap(_listAll, true);\nexport const ref = ɵzoneWrap(_ref, true, 2);\nexport const updateMetadata = ɵzoneWrap(_updateMetadata, true, 2);\nexport const uploadBytes = ɵzoneWrap(_uploadBytes, true);\nexport const uploadBytesResumable = ɵzoneWrap(_uploadBytesResumable, true);\nexport const uploadString = ɵzoneWrap(_uploadString, true);\n"
  },
  {
    "path": "src/storage/ng-package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/ng-package.schema.json\",\n  \"lib\": {\n    \"entryFile\": \"public_api.ts\"\n  }\n}\n"
  },
  {
    "path": "src/storage/package.json",
    "content": "{\n  \"$schema\": \"../../node_modules/ng-packagr/package.schema.json\"\n}\n"
  },
  {
    "path": "src/storage/public_api.ts",
    "content": "export { Storage, StorageInstances, storageInstance$ } from './storage';\nexport { provideStorage, StorageModule } from './storage.module';\nexport * from './rxfire';\nexport * from './firebase';\n"
  },
  {
    "path": "src/storage/rxfire.ts",
    "content": "// DO NOT MODIFY, this file is autogenerated by tools/build.ts\nimport { ɵzoneWrap } from '@angular/fire';\nimport {\n  fromTask as _fromTask,\n  percentage as _percentage\n} from 'rxfire/storage';\n\nexport const fromTask = ɵzoneWrap(_fromTask, true);\nexport const percentage = ɵzoneWrap(_percentage, true);\n"
  },
  {
    "path": "src/storage/storage.module.ts",
    "content": "import {\n  EnvironmentProviders,\n  InjectionToken,\n  Injector,\n  NgModule,\n  NgZone,\n  Optional,\n  makeEnvironmentProviders,\n} from '@angular/core';\nimport { VERSION, ɵAngularFireSchedulers, ɵgetDefaultInstanceOf } from '@angular/fire';\nimport { FirebaseApp, FirebaseApps } from '@angular/fire/app';\nimport { AppCheckInstances } from '@angular/fire/app-check';\nimport { AuthInstances } from '@angular/fire/auth';\nimport { registerVersion } from 'firebase/app';\nimport { FirebaseStorage } from 'firebase/storage';\nimport { STORAGE_PROVIDER_NAME, Storage, StorageInstances } from './storage';\n\nexport const PROVIDED_STORAGE_INSTANCES = new InjectionToken<Storage[]>('angularfire2.storage-instances');\n\nexport function defaultStorageInstanceFactory(provided: FirebaseStorage[]|undefined, defaultApp: FirebaseApp) {\n  const defaultStorage = ɵgetDefaultInstanceOf<FirebaseStorage>(STORAGE_PROVIDER_NAME, provided, defaultApp);\n  return defaultStorage && new Storage(defaultStorage);\n}\n\nexport function storageInstanceFactory(fn: (injector: Injector) => FirebaseStorage) {\n  return (zone: NgZone, injector: Injector) => {\n    const storage = zone.runOutsideAngular(() => fn(injector));\n    return new Storage(storage);\n  };\n}\n\nconst STORAGE_INSTANCES_PROVIDER = {\n  provide: StorageInstances,\n  deps: [\n    [new Optional(), PROVIDED_STORAGE_INSTANCES ],\n  ]\n};\n\nconst DEFAULT_STORAGE_INSTANCE_PROVIDER = {\n  provide: Storage,\n  useFactory: defaultStorageInstanceFactory,\n  deps: [\n    [new Optional(), PROVIDED_STORAGE_INSTANCES ],\n    FirebaseApp,\n  ]\n};\n\n@NgModule({\n  providers: [\n    DEFAULT_STORAGE_INSTANCE_PROVIDER,\n    STORAGE_INSTANCES_PROVIDER,\n  ]\n})\nexport class StorageModule {\n  constructor() {\n    registerVersion('angularfire', VERSION.full, 'gcs');\n  }\n}\n\nexport function provideStorage(fn: (injector: Injector) => FirebaseStorage, ...deps: any[]): EnvironmentProviders {\n  registerVersion('angularfire', VERSION.full, 'gcs');\n\n  return makeEnvironmentProviders([\n    DEFAULT_STORAGE_INSTANCE_PROVIDER,\n    STORAGE_INSTANCES_PROVIDER,\n    {\n      provide: PROVIDED_STORAGE_INSTANCES,\n      useFactory: storageInstanceFactory(fn),\n      multi: true,\n      deps: [\n        NgZone,\n        Injector,\n        ɵAngularFireSchedulers,\n        FirebaseApps,\n        // Defensively load Auth first, if provided\n        [new Optional(), AuthInstances ],\n        [new Optional(), AppCheckInstances ],\n        ...deps,\n      ]\n    }\n  ]);\n}\n"
  },
  {
    "path": "src/storage/storage.spec.ts",
    "content": "import { TestBed } from '@angular/core/testing';\nimport { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';\nimport { Storage, connectStorageEmulator, getStorage, provideStorage } from '@angular/fire/storage';\nimport { COMMON_CONFIG } from '../test-config';\nimport { rando } from '../utils';\n\ndescribe('Storage', () => {\n  let app: FirebaseApp;\n  let storage: Storage;\n  let providedStorage: Storage;\n  let appName: string;\n\n  describe('single injection', () => {\n\n    beforeEach(() => {\n        appName = rando();\n        TestBed.configureTestingModule({\n            providers: [\n                provideFirebaseApp(() => initializeApp(COMMON_CONFIG, appName)),\n                provideStorage(() => {\n                    providedStorage = getStorage(getApp(appName));\n                    connectStorageEmulator(providedStorage, 'localhost', 9199);\n                    return providedStorage;\n                }),\n            ],\n        });\n        app = TestBed.inject(FirebaseApp);\n        storage = TestBed.inject(Storage);\n    });\n\n    it('should be injectable', () => {\n        expect(providedStorage).toBeTruthy();\n        expect(storage).toEqual(providedStorage);\n        expect(storage.app).toEqual(app);\n    });\n\n  });\n\n});\n"
  },
  {
    "path": "src/storage/storage.ts",
    "content": "import { ɵgetAllInstancesOf } from '@angular/fire';\nimport { FirebaseStorage } from 'firebase/storage';\nimport { from, timer } from 'rxjs';\nimport { concatMap, distinct } from 'rxjs/operators';\n\n// see notes in core/firebase.app.module.ts for why we're building the class like this\n \nexport interface Storage extends FirebaseStorage {}\n\nexport class Storage {\n  constructor(auth: FirebaseStorage) {\n    return auth;\n  }\n}\n\nexport const STORAGE_PROVIDER_NAME = 'storage';\n\n \nexport interface StorageInstances extends Array<FirebaseStorage> {}\n\nexport class StorageInstances {\n  constructor() {\n    return ɵgetAllInstancesOf<FirebaseStorage>(STORAGE_PROVIDER_NAME);\n  }\n}\n\nexport const storageInstance$ = timer(0, 300).pipe(\n  concatMap(() => from(ɵgetAllInstancesOf<FirebaseStorage>(STORAGE_PROVIDER_NAME))),\n  distinct(),\n);\n"
  },
  {
    "path": "src/test-config.ts",
    "content": "export const COMMON_CONFIG = {\n    apiKey: 'AIzaSyBVSy3YpkVGiKXbbxeK0qBnu3-MNZ9UIjA',\n    authDomain: 'angularfire2-test.firebaseapp.com',\n    databaseURL: 'https://angularfire2-test.firebaseio.com',\n    projectId: 'angularfire2-test',\n    storageBucket: 'angularfire2-test.appspot.com',\n    messagingSenderId: '920323787688',\n    appId: '1:920323787688:web:2253a0e5eb5b9a8b',\n    databaseName: 'angularfire2-test',\n    measurementId: 'G-W20QDV5CZP'\n};\n\nexport const COMMON_CONFIG_TOO = {\n    apiKey: 'AIzaSyBVSy3YpkVGiKXbbxeK0qBnu3-MNZ9UIjA',\n    authDomain: 'angularfire2-test.firebaseapp.com',\n    databaseURL: 'https://angularfire2-test.firebaseio.com',\n    projectId: 'angularfire2-test',\n    storageBucket: 'angularfire2-test.appspot.com',\n    messagingSenderId: '920323787688',\n    appId: '1:920323787688:web:2253a0e5eb5b9a8d',\n    databaseName: 'angularfire2-test',\n    measurementId: 'G-W20QDV5CZZ'\n};\n\ndeclare global {\n  interface Window {\n    __karma__ : {\n        config: {\n            args: any[]\n        }\n    };\n  }\n}\n\nexport const firestoreEmulatorPort: number = window.__karma__.config.args.find((it) => it[0] === \"FIRESTORE_EMULATOR_PORT\")[1];\nexport const storageEmulatorPort: number = window.__karma__.config.args.find((it) => it[0] === \"STORAGE_EMULATOR_PORT\")[1];\nexport const authEmulatorPort: number = window.__karma__.config.args.find((it) => it[0] === \"AUTH_EMULATOR_PORT\")[1];\nexport const databaseEmulatorPort: number = window.__karma__.config.args.find((it) => it[0] === \"DATABASE_EMULATOR_PORT\")[1];\nexport const functionsEmulatorPort: number = window.__karma__.config.args.find((it) => it[0] === \"FUNCTIONS_EMULATOR_PORT\")[1];\n"
  },
  {
    "path": "src/test.ts",
    "content": "// This file is required by karma.conf.js and loads recursively all the .spec and framework files\n\nimport 'zone.js/dist/zone';\nimport 'zone.js/dist/zone-testing';\nimport 'zone.js/dist/task-tracking';\n\nimport { getTestBed } from '@angular/core/testing';\nimport { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';\n\ndeclare const require: any;\n\n// First, initialize the Angular testing environment.\ngetTestBed().initTestEnvironment(\n  BrowserDynamicTestingModule,\n  platformBrowserDynamicTesting()\n);\n// Then we find all the tests.\nconst context = require.context('./', true, /^\\.\\/.+\\.spec\\.ts$/);\n\n// And load the modules.\ncontext.keys().map(context);\n"
  },
  {
    "path": "src/utils.ts",
    "content": "const randomString = () => (Math.random() + 1).toString(36).split('.')[1];\n\nexport const rando = () => [randomString(), randomString(), randomString()].join('');\n"
  },
  {
    "path": "src/zones.ts",
    "content": " \nimport {\n  EnvironmentInjector,\n  Injectable,\n  NgZone,\n  PendingTasks,\n  inject,\n  isDevMode,\n  runInInjectionContext\n} from '@angular/core';\nimport { pendingUntilEvent } from '@angular/core/rxjs-interop';\nimport {\n  Observable,\n  SchedulerAction,\n  SchedulerLike,\n  Subscription,\n  asyncScheduler,\n  queueScheduler\n} from 'rxjs';\nimport { observeOn, subscribeOn } from 'rxjs/operators';\n\ndeclare const Zone: {current: unknown} | undefined;\n\nexport enum LogLevel {\n  \"SILENT\" = 0, \n  \"WARN\" = 1,\n  \"VERBOSE\" = 2,\n}\n\n\nvar currentLogLevel = (isDevMode() && typeof Zone !== \"undefined\") ? LogLevel.WARN : LogLevel.SILENT;\n\nexport const setLogLevel = (logLevel: LogLevel) => currentLogLevel = logLevel;\n\n/**\n * Schedules tasks so that they are invoked inside the Zone that is passed in the constructor.\n */\nexport class ɵZoneScheduler implements SchedulerLike {\n  constructor(private zone: any, private delegate: any = queueScheduler) {\n  }\n\n  now() {\n    return this.delegate.now();\n  }\n\n  schedule(work: (this: SchedulerAction<any>, state?: any) => void, delay?: number, state?: any): Subscription {\n    const targetZone = this.zone;\n    // Wrap the specified work function to make sure that if nested scheduling takes place the\n    // work is executed in the correct zone\n    const workInZone = function(this: SchedulerAction<any>, state: any) {\n      if (targetZone) {\n        targetZone.runGuarded(() => {\n          work.apply(this, [state]);\n        });\n      } else {\n        work.apply(this, [state]);\n      }\n    };\n\n    // Scheduling itself needs to be run in zone to ensure setInterval calls for async scheduling are done\n    // inside the correct zone. This scheduler needs to schedule asynchronously always to ensure that\n    // firebase emissions are never synchronous. Specifying a delay causes issues with the queueScheduler delegate.\n    return this.delegate.schedule(workInZone, delay, state);\n  }\n}\n\n@Injectable({\n  providedIn: 'root',\n})\nexport class ɵAngularFireSchedulers {\n  public readonly outsideAngular: ɵZoneScheduler;\n  public readonly insideAngular: ɵZoneScheduler;\n\n  constructor() {\n    const ngZone = inject(NgZone);\n    this.outsideAngular = ngZone.runOutsideAngular(\n      () => new ɵZoneScheduler(typeof Zone === 'undefined' ? undefined : Zone.current)\n    );\n    this.insideAngular = ngZone.run(\n      () => new ɵZoneScheduler(\n        typeof Zone === 'undefined' ? undefined : Zone.current,\n        asyncScheduler\n      )\n    );\n  }\n}\n\nvar alreadyWarned = false;\nfunction warnOutsideInjectionContext(original: any, logLevel: LogLevel) {\n  if (!alreadyWarned && (currentLogLevel > LogLevel.SILENT || isDevMode())) {\n    alreadyWarned = true;\n    console.warn(\"Calling Firebase APIs outside of an Injection context may destabilize your application leading to subtle change-detection and hydration bugs. Find more at https://github.com/angular/angularfire/blob/main/docs/zones.md\");\n  }\n  if (currentLogLevel >= logLevel) {\n    console.warn(`Firebase API called outside injection context: ${original.name}`);\n  }\n}\n\nfunction runOutsideAngular<T>(fn: (...args: any[]) => T): T {\n  const ngZone = inject(NgZone, { optional: true });\n  if (!ngZone) {return fn();}\n  return ngZone.runOutsideAngular(() => fn());\n}\n\nfunction run<T>(fn: (...args: any[]) => T): T {\n  const ngZone = inject(NgZone, { optional: true });\n  if (!ngZone) {return fn();}\n  return ngZone.run(() => fn());\n}\n\nconst zoneWrapFn = (\n  it: (...args: any[]) => any,\n  taskDone: VoidFunction | undefined,\n  injector: EnvironmentInjector,\n) => {\n  return (...args: any[]) => {\n    if (taskDone) {\n      setTimeout(taskDone, 0);\n    }\n    return runInInjectionContext(injector, () => run(() => it.apply(this, args)));\n  };\n};\n\nexport const ɵzoneWrap = <T= unknown>(it: T, blockUntilFirst: boolean, logLevel?: LogLevel): T => {\n  logLevel ||= blockUntilFirst ? LogLevel.WARN : LogLevel.VERBOSE;\n  // function() is needed for the arguments object\n  return function () {\n    let taskDone: VoidFunction | undefined;\n    const _arguments = arguments;\n    let schedulers: ɵAngularFireSchedulers;\n    let pendingTasks: PendingTasks;\n    let injector: EnvironmentInjector;\n    try {\n      schedulers = inject(ɵAngularFireSchedulers);\n      pendingTasks = inject(PendingTasks);\n      injector = inject(EnvironmentInjector);\n    } catch (_) {\n      warnOutsideInjectionContext(it, logLevel);\n      return (it as any).apply(this, _arguments);\n    }\n    // if this is a callback function, e.g, onSnapshot, we should create a pending task and complete it\n    // only once one of the callback functions is tripped.\n    for (let i = 0; i < arguments.length; i++) {\n      if (typeof _arguments[i] === 'function') {\n        if (blockUntilFirst) {\n          taskDone ||= run(() => pendingTasks.add());\n        }\n        // TODO create a microtask to track callback functions\n        _arguments[i] = zoneWrapFn(_arguments[i], taskDone, injector);\n      }\n    }\n    const ret = runOutsideAngular(() => (it as any).apply(this, _arguments));\n    if (!blockUntilFirst) {\n      if (ret instanceof Observable) {\n        return ret.pipe(\n          subscribeOn(schedulers.outsideAngular),\n          observeOn(schedulers.insideAngular),\n        );\n      } else {\n        return run(() => ret);\n      }\n    }\n    if (ret instanceof Observable) {\n      return ret.pipe(\n        subscribeOn(schedulers.outsideAngular),\n        observeOn(schedulers.insideAngular),\n        pendingUntilEvent(injector),\n      );\n    } else if (ret instanceof Promise) {\n       \n      return run(\n        () => {\n          const removeTask = pendingTasks.add();\n          return new Promise((resolve, reject) => {\n            ret.then(\n              (it) => runInInjectionContext(injector, () => run(() => resolve(it))),\n              (reason) => runInInjectionContext(injector, () => run(() => reject(reason)))\n            ).finally(removeTask);\n        });\n      });\n    } else if (typeof ret === 'function' && taskDone) {\n      // Handle unsubscribe\n      // function() is needed for the arguments object\n      return function () {\n        setTimeout(taskDone, 0);\n        return ret.apply(this, arguments);\n      };\n    } else {\n      // TODO how do we handle storage uploads in Zone? and other stuff with cancel() etc?\n      return run(() => ret);\n    }\n  } as any;\n};\n"
  },
  {
    "path": "test/database.rules.json",
    "content": "{\n  \"rules\": {\n    \".read\": true,\n    \".write\": true,\n    \".indexOn\": [\n      \"height\",\n      \".value\"\n    ]\n  }\n}\n"
  },
  {
    "path": "test/firestore.indexes.json",
    "content": "{\n  \"indexes\": [],\n  \"fieldOverrides\": []\n}\n"
  },
  {
    "path": "test/firestore.rules",
    "content": "service cloud.firestore {\n  match /databases/{database}/documents {\n    match /{document=**} {\n      allow read, write: if true;\n    }\n  }\n}"
  },
  {
    "path": "test/functions/.gitignore",
    "content": "# Compiled JavaScript files\nlib/**/*.js\nlib/**/*.js.map\n\n# TypeScript v1 declaration files\ntypings/\n\n# Node.js dependency directory\nnode_modules/\n*.local"
  },
  {
    "path": "test/functions/package.json",
    "content": "{\n  \"name\": \"functions\",\n  \"scripts\": {\n    \"build\": \"tsc\",\n    \"build:watch\": \"tsc --watch\",\n    \"serve\": \"npm run build && firebase emulators:start --only functions\",\n    \"shell\": \"npm run build && firebase functions:shell\",\n    \"start\": \"npm run shell\",\n    \"deploy\": \"firebase deploy --only functions\",\n    \"logs\": \"firebase functions:log\"\n  },\n  \"engines\": {\n    \"node\": \"18\"\n  },\n  \"main\": \"lib/index.js\",\n  \"dependencies\": {\n    \"firebase-admin\": \"^12.6.0\",\n    \"firebase-functions\": \"^6.0.1\"\n  },\n  \"devDependencies\": {\n    \"typescript\": \"^4.9.0\",\n    \"firebase-functions-test\": \"^3.1.0\"\n  },\n  \"private\": true\n}"
  },
  {
    "path": "test/functions/src/index.ts",
    "content": "import { onCall } from \"firebase-functions/v2/https\";\n\nexport const foo = onCall(() => {\n    return { bar: \"baz\" };\n});\n"
  },
  {
    "path": "test/functions/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"module\": \"commonjs\",\n    \"noImplicitReturns\": true,\n    \"noUnusedLocals\": true,\n    \"outDir\": \"lib\",\n    \"sourceMap\": true,\n    \"strict\": true,\n    \"target\": \"es2017\"\n  },\n  \"compileOnSave\": true,\n  \"include\": [\n    \"src\"\n  ]\n}\n"
  },
  {
    "path": "test/storage.rules",
    "content": "rules_version = '2';\nservice firebase.storage {\n  match /b/{bucket}/o {\n    match /{allPaths=**} {\n      allow read, write: if true;\n    }\n  }\n}\n"
  },
  {
    "path": "tools/build.sh",
    "content": "SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)\nTAG_TEST=\"^refs/tags/.+$\"\nLATEST_TEST=\"^[^-]*$\"\n\nif [[ $GITHUB_REF =~ $TAG_TEST ]]; then\n    OVERRIDE_VERSION=${GITHUB_REF/refs\\/tags\\//}\n    if [[ $OVERRIDE_VERSION =~ $LATEST_TEST ]]; then\n        NPM_TAG=latest\n    else\n        NPM_TAG=next\n    fi;\nelse\n    OVERRIDE_VERSION=$(node -e \"console.log(require('./package.json').version)\")-canary.$SHORT_SHA\n    NPM_TAG=canary\nfi;\n\nnpm --no-git-tag-version --allow-same-version -f version $OVERRIDE_VERSION\n\nnpm run build &&\n    echo \"npm publish . --tag $NPM_TAG\" > ./dist/packages-dist/publish.sh &&\n    chmod +x ./dist/packages-dist/publish.sh\n"
  },
  {
    "path": "tools/build.ts",
    "content": "import { spawn } from 'cross-spawn';\nimport { copy, writeFile } from 'fs-extra';\nimport { join } from 'path';\nimport { keys as tsKeys } from 'ts-transformer-keys';\nimport * as esbuild from \"esbuild\";\n\nenum LogLevel {\n  \"WARN\" = 1,\n  \"VERBOSE\" = 2,\n};\n\ninterface OverrideOptions {\n  exportName?: string;\n  zoneWrap?: boolean;\n  blockUntilFirst?: boolean;\n  override?: boolean;\n  logLevel?: LogLevel;\n}\n\nconst firestoreOverrides = {\n  addDoc: { logLevel: LogLevel.VERBOSE },\n  aggregateFieldEqual: { logLevel: LogLevel.VERBOSE },\n  aggregateQuerySnapshotEqual: { logLevel: LogLevel.VERBOSE },\n  and: { logLevel: LogLevel.VERBOSE },\n  arrayRemove: null,\n  arrayUnion: null,\n  average: null,\n  collection: { logLevel: LogLevel.VERBOSE },\n  collectionGroup: { logLevel: LogLevel.VERBOSE },\n  count: null,\n  deleteDoc: { logLevel: LogLevel.VERBOSE },\n  deleteField: { logLevel: LogLevel.VERBOSE },\n  doc: { logLevel: LogLevel.VERBOSE },\n  documentId: { logLevel: LogLevel.VERBOSE },\n  endAt: { logLevel: LogLevel.VERBOSE },\n  endBefore: { logLevel: LogLevel.VERBOSE },\n  increment: { logLevel: LogLevel.VERBOSE },\n  limit: { logLevel: LogLevel.VERBOSE },\n  limitToLast: { logLevel: LogLevel.VERBOSE },\n  memoryEagerGarbageCollector: null,\n  memoryLocalCache: null,\n  memoryLruGarbageCollector: null,\n  namedQuery: { logLevel: LogLevel.VERBOSE },\n  or: { logLevel: LogLevel.VERBOSE },\n  orderBy: { logLevel: LogLevel.VERBOSE },\n  persistentLocalCache: null,\n  persistentMultipleTabManager: null,\n  persistentSingleTabManager: null,\n  query: { logLevel: LogLevel.VERBOSE },\n  queryEqual: { logLevel: LogLevel.VERBOSE },\n  refEqual: { logLevel: LogLevel.VERBOSE },\n  serverTimestamp: null,\n  setDoc: { logLevel: LogLevel.VERBOSE },\n  snapshotEqual: { logLevel: LogLevel.VERBOSE },\n  startAfter: { logLevel: LogLevel.VERBOSE },\n  startAt: { logLevel: LogLevel.VERBOSE },\n  sum: { logLevel: LogLevel.VERBOSE },\n  updateDoc: { logLevel: LogLevel.VERBOSE },\n  vector: { logLevel: LogLevel.VERBOSE },\n  where: { logLevel: LogLevel.VERBOSE },\n  writeBatch: { logLevel: LogLevel.VERBOSE },\n};\n\nfunction zoneWrapExports() {\n  const reexport = async (\n    module: string,\n    name: string,\n    path: string,\n    exports: string[],\n    overrides: Record<string, OverrideOptions | null> = {}\n  ) => {\n    const imported = await import(path);\n    const toBeExported: [string, string, boolean][] = exports.sort().\n      filter(it => !it.startsWith('_') && overrides[it] !== null && overrides[it]?.override !== true).\n      map(importName => {\n        const zoneWrap = typeof imported[importName] === 'function' &&\n          // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with\n          (overrides[importName]?.zoneWrap ?? importName[0] !== importName[0].toUpperCase());\n        const exportName = overrides[importName]?.exportName ?? importName;\n        return [importName, exportName, zoneWrap];\n      });\n    const zoneWrapped = toBeExported.filter(([, , zoneWrap]) => zoneWrap);\n    const rawExport = toBeExported.filter(([, , zoneWrap]) => !zoneWrap);\n    const overridden = Object.keys(overrides).filter(key => overrides[key]?.override);\n    const isFirebaseSDK = path.startsWith('firebase/');\n    const hasZoneWrappedFns = zoneWrapped.length > 0;\n    const hasRawExportedFns = rawExport.length > 0;\n    const hasOverridedFns = overridden.length > 0;\n    const zoneWrappedImports = zoneWrapped.map(([importName]) => `${importName} as _${importName}`).join(',\\n  ');\n    const rawExportedFns = rawExport.map(([importName, exportName]) =>\n      `${importName}${exportName === importName ? '' : `as ${exportName}`}`).join(',\\n  ');\n    const overriddenFns = overridden.join(',\\n  ');\n    const exportedZoneWrappedFns = zoneWrapped.map(([importName, exportName]) =>\n      `export const ${exportName} = ɵzoneWrap(_${importName}, ${overrides[importName]?.blockUntilFirst ?? true}${overrides[importName]?.logLevel ? `, ${overrides[importName].logLevel}` : \"\"});`)\n        .join('\\n');\n    const filePath = join(process.cwd(), 'src', `${module}/${name}.ts`);\n    // TODO(davideast): Create a builder pattern for this file for readability\n    const fileOutput = `// DO NOT MODIFY, this file is autogenerated by tools/build.ts\n${isFirebaseSDK ? `export * from '${path}';\\n` : ''}${hasZoneWrappedFns ? `import { ɵzoneWrap } from '@angular/fire';\nimport {\n  ${zoneWrappedImports}\n} from '${path}';\n` : ''}${!isFirebaseSDK && hasRawExportedFns ? `\nexport {\n  ${rawExportedFns}\n} from '${path}';\n` : ''}${hasOverridedFns ? `\nexport {\n  ${overriddenFns}\n} from './overrides';\n` : ''}\n${exportedZoneWrappedFns}\n`;\n    await writeFile(filePath, fileOutput);\n  };\n  return Promise.all([\n    reexport('ai', 'firebase', 'firebase/ai', tsKeys<typeof import('firebase/ai')>()),\n    reexport('analytics', 'firebase', 'firebase/analytics', tsKeys<typeof import('firebase/analytics')>(), {\n      isSupported: { blockUntilFirst: false },\n      logEvent: { blockUntilFirst: false, logLevel: LogLevel.VERBOSE },\n      setAnalyticsCollectionEnabled: { logLevel: LogLevel.VERBOSE },\n      setConsent: { logLevel: LogLevel.VERBOSE },\n      setCurrentScreen: { logLevel: LogLevel.VERBOSE },\n      setDefaultEventParameters: { logLevel: LogLevel.VERBOSE },\n      setUserId: { logLevel: LogLevel.VERBOSE },\n      setUserProperties: { logLevel: LogLevel.VERBOSE },\n    }),\n    reexport('app', 'firebase', 'firebase/app', tsKeys<typeof import('firebase/app')>()),\n    reexport('app-check', 'firebase', 'firebase/app-check', tsKeys<typeof import('firebase/app-check')>(), {\n      getLimitedUseToken: { logLevel: LogLevel.VERBOSE },\n    }),\n    reexport('auth', 'rxfire', 'rxfire/auth', tsKeys<typeof import('rxfire/auth')>()),\n    reexport('auth', 'firebase', 'firebase/auth', tsKeys<typeof import('firebase/auth')>(), {\n      debugErrorMap: null,\n      inMemoryPersistence: null,\n      browserLocalPersistence: null,\n      browserSessionPersistence: null,\n      indexedDBLocalPersistence: null,\n      prodErrorMap: null,\n      multiFactor: null,\n      linkWithCredential: { logLevel: LogLevel.VERBOSE },\n      linkWithPhoneNumber: { logLevel: LogLevel.VERBOSE },\n      linkWithPopup: { logLevel: LogLevel.VERBOSE },\n      linkWithRedirect: { logLevel: LogLevel.VERBOSE },\n      signInAnonymously: { logLevel: LogLevel.VERBOSE },\n      signInWithCredential: { logLevel: LogLevel.VERBOSE },\n      signInWithCustomToken: { logLevel: LogLevel.VERBOSE },\n      signInWithEmailAndPassword: { logLevel: LogLevel.VERBOSE },\n      signInWithEmailLink: { logLevel: LogLevel.VERBOSE },\n      signInWithPhoneNumber: { logLevel: LogLevel.VERBOSE },\n      signInWithPopup: { logLevel: LogLevel.VERBOSE },\n      signInWithRedirect: { logLevel: LogLevel.VERBOSE },\n      signOut: { logLevel: LogLevel.VERBOSE },\n      confirmPasswordReset: { logLevel: LogLevel.VERBOSE },\n      deleteUser: { logLevel: LogLevel.VERBOSE },\n      createUserWithEmailAndPassword: { logLevel: LogLevel.VERBOSE },\n      fetchSignInMethodsForEmail: { logLevel: LogLevel.VERBOSE },\n      getAdditionalUserInfo: { logLevel: LogLevel.VERBOSE },\n      reauthenticateWithCredential: { logLevel: LogLevel.VERBOSE },\n      reauthenticateWithPhoneNumber: { logLevel: LogLevel.VERBOSE },\n      reauthenticateWithPopup: { logLevel: LogLevel.VERBOSE },\n      reauthenticateWithRedirect: { logLevel: LogLevel.VERBOSE },\n      reload : { logLevel: LogLevel.VERBOSE },\n      revokeAccessToken: { logLevel: LogLevel.VERBOSE },\n      sendEmailVerification: { logLevel: LogLevel.VERBOSE },\n      sendPasswordResetEmail: { logLevel: LogLevel.VERBOSE },\n      sendSignInLinkToEmail: { logLevel: LogLevel.VERBOSE },\n      unlink: { logLevel: LogLevel.VERBOSE },\n      updateCurrentUser: { logLevel: LogLevel.VERBOSE },\n      updateEmail: { logLevel: LogLevel.VERBOSE },\n      updatePassword: { logLevel: LogLevel.VERBOSE },\n      updatePhoneNumber: { logLevel: LogLevel.VERBOSE },\n      updateProfile: { logLevel: LogLevel.VERBOSE },\n      useDeviceLanguage: { logLevel: LogLevel.VERBOSE },\n      validatePassword: { logLevel: LogLevel.VERBOSE },\n      verifyBeforeUpdateEmail: { logLevel: LogLevel.VERBOSE },\n      verifyPasswordResetCode: { logLevel: LogLevel.VERBOSE },\n    }),\n    reexport('database', 'rxfire', 'rxfire/database', tsKeys<typeof import('rxfire/database')>()),\n    reexport('database', 'firebase', 'firebase/database', tsKeys<typeof import('firebase/database')>(), {\n      child: { logLevel: LogLevel.VERBOSE },\n      endAt: { logLevel: LogLevel.VERBOSE },\n      endBefore: { logLevel: LogLevel.VERBOSE },\n      equalTo: { logLevel: LogLevel.VERBOSE },\n      increment: { logLevel: LogLevel.VERBOSE },\n      limitToFirst: { logLevel: LogLevel.VERBOSE },\n      limitToLast: { logLevel: LogLevel.VERBOSE },\n      orderByChild: { logLevel: LogLevel.VERBOSE },\n      orderByKey: { logLevel: LogLevel.VERBOSE },\n      orderByPriority: { logLevel: LogLevel.VERBOSE },\n      orderByValue: { logLevel: LogLevel.VERBOSE },\n      push: { logLevel: LogLevel.VERBOSE },\n      query: { logLevel: LogLevel.VERBOSE },\n      ref: { logLevel: LogLevel.VERBOSE },\n      refFromURL: { logLevel: LogLevel.VERBOSE },\n      remove: { logLevel: LogLevel.VERBOSE },\n      serverTimestamp: null,\n      set: { logLevel: LogLevel.VERBOSE },\n      setPriority: { logLevel: LogLevel.VERBOSE },\n      setWithPriority: { logLevel: LogLevel.VERBOSE },\n      startAfter: { logLevel: LogLevel.VERBOSE },\n      startAt: { logLevel: LogLevel.VERBOSE },\n      update: { logLevel: LogLevel.VERBOSE },\n    }),\n    reexport('data-connect', 'firebase', 'firebase/data-connect', tsKeys<typeof import('firebase/data-connect')>(), {\n      mutationRef: { logLevel: LogLevel.VERBOSE },\n      queryRef: { logLevel: LogLevel.VERBOSE },\n      toQueryRef: { logLevel: LogLevel.VERBOSE },\n    }),\n    reexport('firestore', 'rxfire', 'rxfire/firestore', tsKeys<typeof import('rxfire/firestore')>(), {\n      doc: { exportName: 'docSnapshots' },\n      collection: { exportName: 'collectionSnapshots' },\n    }),\n    reexport('firestore', 'firebase', 'firebase/firestore', tsKeys<typeof import('firebase/firestore')>(), firestoreOverrides),\n    reexport('functions', 'rxfire', 'rxfire/functions', [\"httpsCallable\"], {\n      httpsCallable: { exportName: 'httpsCallableData' },\n    }),\n    reexport('functions', 'firebase', 'firebase/functions', tsKeys<typeof import('firebase/functions')>()),\n    reexport('messaging', 'firebase', 'firebase/messaging', tsKeys<typeof import('firebase/messaging')>(), {\n      isSupported: { blockUntilFirst: false },\n      onMessage: { blockUntilFirst: false },\n      deleteToken: { logLevel: LogLevel.VERBOSE },\n    }),\n    reexport('remote-config', 'rxfire', 'rxfire/remote-config', tsKeys<typeof import('rxfire/remote-config')>(), {\n      isSupported: { blockUntilFirst: false },\n      getValue: { exportName: 'getValueChanges' },\n      getString: { exportName: 'getStringChanges' },\n      getNumber: { exportName: 'getNumberChanges' },\n      getBoolean: { exportName: 'getBooleanChanges' },\n      getAll: { exportName: 'getAllChanges' },\n    }),\n    reexport('remote-config', 'firebase', 'firebase/remote-config', tsKeys<typeof import('firebase/remote-config')>()),\n    reexport('storage', 'rxfire', 'rxfire/storage', tsKeys<typeof import('rxfire/storage')>(), {\n      getDownloadURL: null,\n      getMetadata: null,\n      uploadBytesResumable: null,\n      uploadString: null,\n    }),\n    reexport('storage', 'firebase', 'firebase/storage', tsKeys<typeof import('firebase/storage')>(), {\n      deleteObject: { logLevel: LogLevel.VERBOSE },\n      ref: { logLevel: LogLevel.VERBOSE },\n      updateMetadata: { logLevel: LogLevel.VERBOSE },\n    }),\n    reexport('performance', 'rxfire', 'rxfire/performance', tsKeys<typeof import('rxfire/performance')>(), {\n      getPerformance$: null,\n      trace: null,\n    }),\n    reexport('performance', 'firebase', 'firebase/performance', tsKeys<typeof import('firebase/performance')>(), {\n      trace: { logLevel: LogLevel.VERBOSE },\n    }),\n    reexport('firestore/lite', 'rxfire', 'rxfire/firestore/lite', tsKeys<typeof import('rxfire/firestore/lite')>(), {\n      doc: { exportName: 'docSnapshots' },\n      collection: { exportName: 'collectionSnapshots' },\n    }),\n    reexport('firestore/lite', 'firebase', 'firebase/firestore/lite', tsKeys<typeof import('firebase/firestore/lite')>(), firestoreOverrides),\n  ]);\n}\n\nconst src = (...args: string[]) => join(process.cwd(), 'src', ...args);\nconst dest = (...args: string[]) => join(process.cwd(), 'dist', 'packages-dist', ...args);\n\nconst rootPackage = import(join(process.cwd(), 'package.json'));\n\nasync function replacePackageCoreVersion() {\n  const root = await rootPackage;\n  // eslint-disable-next-line @typescript-eslint/no-var-requires\n  const replace = require('replace-in-file');\n  const files = dest('package.json');\n  return replace({\n    files,\n    from: 'ANGULARFIRE2_VERSION',\n    to: root.version\n  });\n}\n\nasync function replaceSchematicVersions() {\n  const root = await rootPackage;\n  const packagesPath = dest('schematics', 'versions.json');\n  const dependencies = await import(packagesPath);\n  Object.keys(dependencies.peerDependencies).forEach(name => {\n    dependencies.peerDependencies[name].version = root.dependencies[name] || root.devDependencies[name];\n  });\n  Object.keys(dependencies.firebaseFunctionsDependencies).forEach(name => {\n    dependencies.firebaseFunctionsDependencies[name].version = root.dependencies[name] || root.devDependencies[name];\n  });\n  return writeFile(packagesPath, JSON.stringify(dependencies, null, 2));\n}\n\nfunction spawnPromise(command: string, args: string[]) {\n  return new Promise<void>((resolve, reject) => spawn(command, args, { stdio: 'inherit' }).on('close', code => {\n    if (code === 0) {\n      resolve()\n    } else {\n      reject('Build failed.');\n    }\n  })\n  .on('error', reject));\n}\n\nasync function compileSchematics() {\n  await esbuild.build({\n    entryPoints: [\n      src('schematics', \"update\", \"index.ts\"),\n      src('schematics', \"deploy\", \"actions.ts\"),\n      src('schematics', \"deploy\", \"builder.ts\"),\n      src('schematics', \"add\", \"index.ts\"),\n      src('schematics', \"setup\", \"index.ts\"),\n      src('schematics', \"update\", \"v7\", \"index.ts\"),\n    ],\n    format: \"cjs\",\n    // turns out schematics don't support ESM, need to use webpack or shim these\n    // format: \"esm\",\n    // splitting: true,\n    // outExtension: {\".js\": \".mjs\"},\n    bundle: true,\n    minify: true,\n    platform: \"node\",\n    target: \"es2016\",\n    external: [\n      \"@angular-devkit/schematics\",\n      \"@angular-devkit/architect\",\n      \"@angular-devkit/core\",\n      \"rxjs\",\n      \"@schematics/angular\",\n      \"jsonc-parser\",\n      \"firebase-tools\"\n    ],\n    outdir: dest('schematics'),\n  });\n  await Promise.all([\n    copy(src('schematics', 'versions.json'), dest('schematics', 'versions.json')),\n    copy(src('schematics', 'builders.json'), dest('schematics', 'builders.json')),\n    copy(src('schematics', 'collection.json'), dest('schematics', 'collection.json')),\n    copy(src('schematics', 'migration.json'), dest('schematics', 'migration.json')),\n    copy(src('schematics', 'deploy', 'schema.json'), dest('schematics', 'deploy', 'schema.json')),\n    copy(src('schematics', 'add', 'schema.json'), dest('schematics', 'add', 'schema.json')),\n    copy(src('schematics', 'setup', 'schema.json'), dest('schematics', 'setup', 'schema.json')),\n  ]);\n  await replaceSchematicVersions();\n}\n\nasync function buildLibrary() {\n  await zoneWrapExports();\n  await spawnPromise('npx', ['ng', 'build']);\n  await Promise.all([\n    copy(join(process.cwd(), '.npmignore'), dest('.npmignore')),\n    copy(join(process.cwd(), 'README.md'), dest('README.md')),\n    copy(join(process.cwd(), 'docs'), dest('docs')),\n    compileSchematics(),\n    replacePackageCoreVersion(),\n  ]);\n}\n\nbuildLibrary().catch(err => {\n  console.error(err);\n  process.exit(1);\n})\n"
  },
  {
    "path": "tools/jasmine.ts",
    "content": "// @ts-ignore\nimport Jasmine from 'jasmine';\n\nimport 'reflect-metadata';\nimport 'zone.js';\n\nimport { getTestBed } from '@angular/core/testing';\nimport { platformServerTesting, ServerTestingModule } from '@angular/platform-server/testing';\n\n// First, initialize the Angular testing environment.\ngetTestBed().initTestEnvironment(\n    ServerTestingModule,\n    platformServerTesting()\n);\n\nconst tests = new Jasmine({});\ntests.loadConfig({\n    spec_dir: '.',\n    spec_files: [\n        'dist/out-tsc/jasmine/**/*.jasmine.js',\n        'dist/out-tsc/jasmine/**/*.spec.js',\n    ]\n});\n\ntests.execute();\n"
  },
  {
    "path": "tsconfig.base.json",
    "content": "{\n    \"compileOnSave\": false,\n    \"compilerOptions\": {\n      \"allowSyntheticDefaultImports\": true,\n      \"baseUrl\": \"./\",\n      \"outDir\": \"./dist\",\n      \"sourceMap\": true,\n      \"declaration\": false,\n      \"downlevelIteration\": true,\n      \"emitDecoratorMetadata\": true,\n      \"experimentalDecorators\": true,\n      \"module\": \"preserve\",\n      \"moduleResolution\": \"bundler\",\n      \"importHelpers\": true,\n      \"target\": \"es2020\",\n      \"skipLibCheck\": true,\n      \"typeRoots\": [\n        \"node_modules/@types\"\n      ],\n      \"lib\": [\n        \"es2018\",\n        \"dom\"\n      ],\n      \"paths\": {\n        \"@angular/fire\": [\"dist/packages-dist\"],\n        \"@angular/fire/*\": [\"dist/packages-dist/*\"]\n      }\n    }\n  }\n"
  },
  {
    "path": "tsconfig.build.json",
    "content": "{\n    \"files\": [\n        \"tools/build.ts\"\n    ],\n    \"compilerOptions\": {\n        \"outDir\": \"tools\",\n        \"skipLibCheck\": true,\n        \"lib\": [\"es2019\", \"dom\"],\n        \"module\": \"commonjs\",\n        \"target\": \"ES2020\",\n        \"plugins\": [\n            { \"transform\": \"ts-transformer-keys/transformer\" }\n        ],\n        \"baseUrl\": \"./\"\n    }\n}"
  },
  {
    "path": "tsconfig.jasmine.json",
    "content": "{\n    \"extends\": \"./tsconfig.base.json\",\n    \"compilerOptions\": {\n      \"outDir\": \"dist/out-tsc/jasmine\",\n      \"module\": \"preserve\",\n      \"target\": \"es2015\",\n      \"allowJs\": true,\n      \"resolveJsonModule\": true,\n      \"esModuleInterop\": true,\n      \"types\": [\n        \"jasmine\",\n        \"node\"\n      ]\n    },\n    \"include\": [\n        \"tools/jasmine.ts\",\n        \"src/**/*.jasmine.ts\",\n        // Not sure what is wrong here, but since upgrading karma it's fallen apart\n        // \"src/**/*.spec.ts\",\n        \"src/**/*.d.ts\",\n        \"node_modules/zone.js/zone.d.ts\"\n    ]\n  }\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"extends\": \"./tsconfig.base.json\",\n  \"compilerOptions\": {\n    \"outDir\": \"dist/out-tsc/lib\",\n    \"target\": \"es2015\",\n    \"declaration\": true,\n    \"inlineSources\": true,\n    \"declarationMap\": false,\n    \"types\": [\n      \"node\"\n    ],\n    \"lib\": [\n      \"dom\",\n      \"es2018\"\n    ]\n  },\n  \"angularCompilerOptions\": {\n    \"compilationMode\": \"partial\"\n  },\n  \"exclude\": [\n    \"src/test.ts\",\n    \"src/**/*.spec.ts\"\n  ]\n}\n"
  },
  {
    "path": "tsconfig.spec.json",
    "content": "{\n    \"extends\": \"./tsconfig.base.json\",\n    \"compilerOptions\": {\n      \"outDir\": \"dist/out-tsc/spec\",\n      \"module\": \"preserve\",\n      \"types\": [\n        \"jasmine\",\n        \"node\"\n      ]\n    },\n    \"files\": [\n      \"src/test.ts\"\n    ],\n    \"include\": [\n      \"src/**/*.spec.ts\",\n      \"src/**/*.d.ts\",\n      \"node_modules/zone.js/zone.d.ts\"\n    ]\n  }\n  "
  },
  {
    "path": "typedoc.json",
    "content": "{\n    \"tsconfig\": \"./tsconfig.json\",\n    \"ignoreCompilerErrors\": true,\n    \"mode\": \"modules\",\n    \"excludeExternals\": true,\n    \"excludeNotExported\": true,\n    \"excludePrivate\": true,\n    \"excludeProtected\": true,\n    \"includeDeclarations\": true,\n    \"disableOutputCheck\": true\n}"
  }
]