From 293a17c437675f9aa8591a40b43d395f7da31713 Mon Sep 17 00:00:00 2001 From: Vadym Parakonnyi Date: Fri, 15 Mar 2024 13:44:45 +0100 Subject: [PATCH] fix: react lint warnings, build --- examples/demo/src/app/todos/todos.module.ts | 4 +- examples/demo/src/app/todos/todos.service.ts | 6 +- package-lock.json | 342 ------------------ package.json | 2 - .../src/lib/collection.service.spec.ts | 6 +- packages/rxdb/core/src/index.ts | 1 + .../src/with-collection-service.spec.ts | 4 +- .../signals/src/with-collection-service.ts | 4 +- packages/rxdb/src/lib/rxdb.module.puml | 10 +- packages/rxdb/src/lib/rxdb.module.spec.ts | 10 +- packages/rxdb/src/lib/rxdb.module.ts | 6 +- packages/rxdb/src/lib/rxdb.providers.ts | 6 +- packages/rxdb/testing/src/lib/mocks.ts | 3 +- .../rxdb_dataframe/frontend/build/index.js | 44 +-- .../frontend/src/lib/RxDBDataframe.tsx | 8 +- .../frontend/src/lib/useEditingState.ts | 16 +- .../frontend/src/lib/useNullableRenderData.ts | 11 +- 17 files changed, 72 insertions(+), 411 deletions(-) diff --git a/examples/demo/src/app/todos/todos.module.ts b/examples/demo/src/app/todos/todos.module.ts index 7919b44..d46bc60 100644 --- a/examples/demo/src/app/todos/todos.module.ts +++ b/examples/demo/src/app/todos/todos.module.ts @@ -3,7 +3,7 @@ import { Inject, NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; import { LetDirective, PushPipe } from '@ngrx/component'; -import { NgxRxdbCollectionService, NgxRxdbModule } from '@ngx-odm/rxdb'; +import { NgxRxdbModule, RXDB_COLLECTION } from '@ngx-odm/rxdb'; import { RxDBCollectionService } from '@ngx-odm/rxdb/collection'; import { TODOS_COLLECTION_CONFIG, Todo } from '@shared'; import { TodosComponent } from './todos.component'; @@ -24,7 +24,7 @@ import { TodosService } from './todos.service'; }) export class TodosModule { constructor( - @Inject(NgxRxdbCollectionService) private collectionService: RxDBCollectionService + @Inject(RXDB_COLLECTION) private collectionService: RxDBCollectionService ) { this.collectionService.sync(); } diff --git a/examples/demo/src/app/todos/todos.service.ts b/examples/demo/src/app/todos/todos.service.ts index 655e6f3..139d7d8 100755 --- a/examples/demo/src/app/todos/todos.service.ts +++ b/examples/demo/src/app/todos/todos.service.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { Injectable, inject } from '@angular/core'; -import { NgxRxdbCollectionService } from '@ngx-odm/rxdb'; +import { RXDB_COLLECTION } from '@ngx-odm/rxdb'; import { RxDBCollectionService } from '@ngx-odm/rxdb/collection'; import { DEFAULT_LOCAL_DOCUMENT_ID } from '@ngx-odm/rxdb/config'; import { Todo, TodosFilter, TodosLocalState } from '@shared'; @@ -11,9 +11,7 @@ const withAttachments = true; @Injectable() export class TodosService { - private collectionService: RxDBCollectionService = inject< - RxDBCollectionService - >(NgxRxdbCollectionService); + private collectionService: RxDBCollectionService = inject< RxDBCollectionService>(RXDB_COLLECTION); newTodo = ''; current: Todo = undefined; diff --git a/package-lock.json b/package-lock.json index d02e050..38c9998 100644 --- a/package-lock.json +++ b/package-lock.json @@ -131,8 +131,6 @@ "typescript": "5.2.2", "vite": "~5.0.0", "vite-plugin-dts": "~2.3.0", - "vite-plugin-json-server": "^0.1.1", - "vite-plugin-static": "^0.0.3", "vitest": "~0.34.6" }, "engines": { @@ -18901,15 +18899,6 @@ "node": ">=0.8" } }, - "node_modules/connect-pause": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/connect-pause/-/connect-pause-0.1.1.tgz", - "integrity": "sha512-a1gSWQBQD73krFXdUEYJom2RTFrWUL3YvXDCRkyv//GVXc79cdW9MngtRuN9ih4FDKBtfJAJId+BbDuX+1rh2w==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/connect/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -21369,19 +21358,6 @@ "is-arrayish": "^0.2.1" } }, - "node_modules/errorhandler": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/errorhandler/-/errorhandler-1.5.1.tgz", - "integrity": "sha512-rcOwbfvP1WTViVoUjcfZicVzjhjTuhSMntHh6mW3IrEiyE6mJyXvsToJUJGlGlw/2xU9P5whlWNGlIDVeCiT4A==", - "dev": true, - "dependencies": { - "accepts": "~1.3.7", - "escape-html": "~1.0.3" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/es-abstract": { "version": "1.22.5", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.22.5.tgz", @@ -22665,31 +22641,6 @@ "node": ">= 0.10.0" } }, - "node_modules/express-urlrewrite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/express-urlrewrite/-/express-urlrewrite-1.4.0.tgz", - "integrity": "sha512-PI5h8JuzoweS26vFizwQl6UTF25CAHSggNv0J25Dn/IKZscJHWZzPrI5z2Y2jgOzIaw2qh8l6+/jUcig23Z2SA==", - "dev": true, - "dependencies": { - "debug": "*", - "path-to-regexp": "^1.0.3" - } - }, - "node_modules/express-urlrewrite/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", - "dev": true - }, - "node_modules/express-urlrewrite/node_modules/path-to-regexp": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", - "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", - "dev": true, - "dependencies": { - "isarray": "0.0.1" - } - }, "node_modules/express/node_modules/cookie": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", @@ -25766,12 +25717,6 @@ "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", "dev": true }, - "node_modules/is-promise": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", - "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==", - "dev": true - }, "node_modules/is-property": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", @@ -28333,123 +28278,11 @@ "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==" }, - "node_modules/json-parse-helpfulerror": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/json-parse-helpfulerror/-/json-parse-helpfulerror-1.0.3.tgz", - "integrity": "sha512-XgP0FGR77+QhUxjXkwOMkC94k3WtqEBfcnjWqhRd82qTat4SWKRE+9kUnynz/shm3I4ea2+qISvTIeGTNU7kJg==", - "dev": true, - "dependencies": { - "jju": "^1.1.0" - } - }, "node_modules/json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" }, - "node_modules/json-server": { - "version": "0.17.4", - "resolved": "https://registry.npmjs.org/json-server/-/json-server-0.17.4.tgz", - "integrity": "sha512-bGBb0WtFuAKbgI7JV3A864irWnMZSvBYRJbohaOuatHwKSRFUfqtQlrYMrB6WbalXy/cJabyjlb7JkHli6dYjQ==", - "dev": true, - "dependencies": { - "body-parser": "^1.19.0", - "chalk": "^4.1.2", - "compression": "^1.7.4", - "connect-pause": "^0.1.1", - "cors": "^2.8.5", - "errorhandler": "^1.5.1", - "express": "^4.17.1", - "express-urlrewrite": "^1.4.0", - "json-parse-helpfulerror": "^1.0.3", - "lodash": "^4.17.21", - "lodash-id": "^0.14.1", - "lowdb": "^1.0.0", - "method-override": "^3.0.0", - "morgan": "^1.10.0", - "nanoid": "^3.1.23", - "please-upgrade-node": "^3.2.0", - "pluralize": "^8.0.0", - "server-destroy": "^1.0.1", - "yargs": "^17.0.1" - }, - "bin": { - "json-server": "lib/cli/bin.js" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/json-server/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/json-server/node_modules/chalk": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", - "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/chalk?sponsor=1" - } - }, - "node_modules/json-server/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/json-server/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/json-server/node_modules/has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/json-server/node_modules/supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "dependencies": { - "has-flag": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", @@ -29339,15 +29172,6 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, - "node_modules/lodash-id": { - "version": "0.14.1", - "resolved": "https://registry.npmjs.org/lodash-id/-/lodash-id-0.14.1.tgz", - "integrity": "sha512-ikQPBTiq/d5m6dfKQlFdIXFzvThPi2Be9/AHxktOnDSfSxE1j9ICbBT5Elk1ke7HSTgM38LHTpmJovo9/klnLg==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, "node_modules/lodash.camelcase": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz", @@ -29763,31 +29587,6 @@ "get-func-name": "^2.0.1" } }, - "node_modules/lowdb": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lowdb/-/lowdb-1.0.0.tgz", - "integrity": "sha512-2+x8esE/Wb9SQ1F9IHaYWfsC9FIecLOPrK4g17FGEayjUWH172H6nwicRovGvSE2CPZouc2MCIqCI7h9d+GftQ==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.3", - "is-promise": "^2.1.0", - "lodash": "4", - "pify": "^3.0.0", - "steno": "^0.4.1" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/lowdb/node_modules/pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/lower-case": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", @@ -30052,36 +29851,6 @@ "node": ">= 8" } }, - "node_modules/method-override": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/method-override/-/method-override-3.0.0.tgz", - "integrity": "sha512-IJ2NNN/mSl9w3kzWB92rcdHpz+HjkxhDJWNDBqSlas+zQdP8wBiJzITPg08M/k2uVvMow7Sk41atndNtt/PHSA==", - "dev": true, - "dependencies": { - "debug": "3.1.0", - "methods": "~1.1.2", - "parseurl": "~1.3.2", - "vary": "~1.1.2" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/method-override/node_modules/debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/method-override/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "dev": true - }, "node_modules/methods": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", @@ -32952,24 +32721,6 @@ "pathe": "^1.1.0" } }, - "node_modules/please-upgrade-node": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", - "integrity": "sha512-gQR3WpIgNIKwBMVLkpMUeR3e1/E1y42bqDQZfql+kDeXd8COYfM8PQA4X6y7a8u9Ua9FHmsrrmirW2vHs45hWg==", - "dev": true, - "dependencies": { - "semver-compare": "^1.0.0" - } - }, - "node_modules/pluralize": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", - "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/png-js": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/png-js/-/png-js-1.0.0.tgz", @@ -36026,12 +35777,6 @@ "node": ">=10" } }, - "node_modules/semver-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", - "integrity": "sha512-YM3/ITh2MJ5MtzaM429anh+x2jiLVjqILF4m4oyQB18W7Ggea7BfqdH/wGMK7dDiMghv/6WG7znWMwUDzJiXow==", - "dev": true - }, "node_modules/semver-regex": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/semver-regex/-/semver-regex-4.0.5.tgz", @@ -37374,15 +37119,6 @@ "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", "dev": true }, - "node_modules/steno": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/steno/-/steno-0.4.4.tgz", - "integrity": "sha512-EEHMVYHNXFHfGtgjNITnka0aHhiAlo93F7z2/Pwd+g0teG9CnM3JIINM7hVVB5/rhw9voufD7Wukwgtw2uqh6w==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.1.3" - } - }, "node_modules/stop-iteration-iterator": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz", @@ -39880,84 +39616,6 @@ "code-block-writer": "^12.0.0" } }, - "node_modules/vite-plugin-json-server": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/vite-plugin-json-server/-/vite-plugin-json-server-0.1.1.tgz", - "integrity": "sha512-bMr96f71FmfemQuW8ta5vsXtCVGyZR11q+YU4FTnoSiEdjcayimBPsWiTBlySvAV9xVbiUiPIAM6Hep38UerGg==", - "dev": true, - "dependencies": { - "json-server": "^0.17.3" - }, - "peerDependencies": { - "vite": "^4.0.0" - } - }, - "node_modules/vite-plugin-static": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/vite-plugin-static/-/vite-plugin-static-0.0.3.tgz", - "integrity": "sha512-j9Pnya2VGX3mQhbcbgJmMIToXjEMHQfIP1QiS0kmE+cBPdbqdwi5+YjgQ8RC9rHs+Pcdt8hNaYa0dLHwupN5Rg==", - "dev": true, - "dependencies": { - "glob": "^8.0.3", - "typescript": "^4.8.2" - }, - "peerDependencies": { - "vite": "^2.5.10" - } - }, - "node_modules/vite-plugin-static/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/vite-plugin-static/node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "dev": true, - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/vite-plugin-static/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/vite-plugin-static/node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "dev": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/vite/node_modules/postcss": { "version": "8.4.35", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz", diff --git a/package.json b/package.json index 1775b13..ddd653e 100644 --- a/package.json +++ b/package.json @@ -186,8 +186,6 @@ "typescript": "5.2.2", "vite": "~5.0.0", "vite-plugin-dts": "~2.3.0", - "vite-plugin-json-server": "^0.1.1", - "vite-plugin-static": "^0.0.3", "vitest": "~0.34.6" }, "engines": { diff --git a/packages/rxdb/collection/src/lib/collection.service.spec.ts b/packages/rxdb/collection/src/lib/collection.service.spec.ts index 37ff9aa..4f49058 100644 --- a/packages/rxdb/collection/src/lib/collection.service.spec.ts +++ b/packages/rxdb/collection/src/lib/collection.service.spec.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-var-requires */ import { TestBed } from '@angular/core/testing'; -import { NgxRxdbCollectionService, RXDB, provideRxCollection } from '@ngx-odm/rxdb'; +import { RXDB_COLLECTION, RXDB, provideRxCollection } from '@ngx-odm/rxdb'; import { RxDBService } from '@ngx-odm/rxdb/core'; import { TEST_FEATURE_CONFIG_1, @@ -21,7 +21,7 @@ const getMockReplicationState = (obj: Partial>) => return obj as RxReplicationState; }; -describe(`NgxRxdbCollectionService`, () => { +describe(`RXDB_COLLECTION`, () => { describe(`test methods using mock NgxRxdbService`, () => { let dbService: RxDBService; let service: RxDBCollectionService; @@ -34,7 +34,7 @@ describe(`NgxRxdbCollectionService`, () => { provideRxCollection(TEST_FEATURE_CONFIG_1), ], }); - service = TestBed.inject(NgxRxdbCollectionService) as any; + service = TestBed.inject(RXDB_COLLECTION) as any; }); afterEach(() => { diff --git a/packages/rxdb/core/src/index.ts b/packages/rxdb/core/src/index.ts index 485d68b..0404db6 100644 --- a/packages/rxdb/core/src/index.ts +++ b/packages/rxdb/core/src/index.ts @@ -1 +1,2 @@ export * from './lib/service'; +export * from './lib/plugin.loader'; diff --git a/packages/rxdb/signals/src/with-collection-service.spec.ts b/packages/rxdb/signals/src/with-collection-service.spec.ts index d160c31..4179930 100644 --- a/packages/rxdb/signals/src/with-collection-service.spec.ts +++ b/packages/rxdb/signals/src/with-collection-service.spec.ts @@ -3,7 +3,7 @@ import { TestBed } from '@angular/core/testing'; import { getState, signalStore } from '@ngrx/signals'; import { withEntities } from '@ngrx/signals/entities'; import { EntitySignals } from '@ngrx/signals/entities/src/models'; -import { NgxRxdbCollectionService, RXDB, provideRxCollection } from '@ngx-odm/rxdb'; +import { RXDB_COLLECTION, RXDB, provideRxCollection } from '@ngx-odm/rxdb'; import { RxDBCollectionService } from '@ngx-odm/rxdb/collection'; import { RxDBService } from '@ngx-odm/rxdb/core'; import { @@ -107,7 +107,7 @@ describe('withCollectionService', () => { }, }); store = TestBed.inject(TestStore) as any; - colService = TestBed.inject(NgxRxdbCollectionService) as any; + colService = TestBed.inject(RXDB_COLLECTION) as any; rxCollection = dbService.collections['test']; spyFind = jest.spyOn(rxCollection, 'find'); }); diff --git a/packages/rxdb/signals/src/with-collection-service.ts b/packages/rxdb/signals/src/with-collection-service.ts index 9073c24..1695567 100644 --- a/packages/rxdb/signals/src/with-collection-service.ts +++ b/packages/rxdb/signals/src/with-collection-service.ts @@ -19,7 +19,7 @@ import { setAllEntities } from '@ngrx/signals/entities'; import { NamedEntitySignals } from '@ngrx/signals/entities/src/models'; import { SignalStoreFeatureResult } from '@ngrx/signals/src/signal-store-models'; import { StateSignal } from '@ngrx/signals/src/state-signal'; -import { NgxRxdbCollectionService } from '@ngx-odm/rxdb'; +import { RXDB_COLLECTION } from '@ngx-odm/rxdb'; import { RxDBCollectionService } from '@ngx-odm/rxdb/collection'; import { DEFAULT_LOCAL_DOCUMENT_ID } from '@ngx-odm/rxdb/config'; import { Entity, EntityId, NgxRxdbUtils } from '@ngx-odm/rxdb/utils'; @@ -295,7 +295,7 @@ export function withCollectionService< if (colService instanceof RxDBCollectionService) return; const injector = inject(Injector); // eslint-disable-next-line @typescript-eslint/no-explicit-any - colService = injector.get(NgxRxdbCollectionService) as RxDBCollectionService; + colService = injector.get(RXDB_COLLECTION) as RxDBCollectionService; }; return signalStoreFeature( diff --git a/packages/rxdb/src/lib/rxdb.module.puml b/packages/rxdb/src/lib/rxdb.module.puml index 20d2861..60a4ca5 100644 --- a/packages/rxdb/src/lib/rxdb.module.puml +++ b/packages/rxdb/src/lib/rxdb.module.puml @@ -4,7 +4,7 @@ actor User participant ApplicationInitStatus participant NgxRxdbModule participant NgxRxdbService -participant NgxRxdbCollectionService +participant RXDB_COLLECTION participant RXDB_CONFIG User -> ApplicationInitStatus: Start Application @@ -22,10 +22,10 @@ NgxRxdbService -> ApplicationInitStatus: Done with Initialization deactivate NgxRxdbService -User -> NgxRxdbCollectionService: Use NgxRxdbCollectionService -NgxRxdbCollectionService -> NgxRxdbService: Use NgxRxdbService -NgxRxdbService --> NgxRxdbCollectionService: Provide NgxRxdbService -NgxRxdbCollectionService -> RXDB_CONFIG: Use RXDB_CONFIG +User -> RXDB_COLLECTION: Use RXDB_COLLECTION +RXDB_COLLECTION -> NgxRxdbService: Use NgxRxdbService +NgxRxdbService --> RXDB_COLLECTION: Provide NgxRxdbService +RXDB_COLLECTION -> RXDB_CONFIG: Use RXDB_CONFIG NgxRxdbService --> RXDB_CONFIG: Provide RXDB_CONFIG @enduml diff --git a/packages/rxdb/src/lib/rxdb.module.spec.ts b/packages/rxdb/src/lib/rxdb.module.spec.ts index 37be6aa..cc5d41c 100644 --- a/packages/rxdb/src/lib/rxdb.module.spec.ts +++ b/packages/rxdb/src/lib/rxdb.module.spec.ts @@ -4,13 +4,13 @@ import { TestBed, inject } from '@angular/core/testing'; import { RxDBCollectionService } from '@ngx-odm/rxdb/collection'; import { RxDBService } from '@ngx-odm/rxdb/core'; import { - setupNavigationWarnStub, - getMockRxdbService, TEST_DB_CONFIG_1, TEST_FEATURE_CONFIG_1, + getMockRxdbService, + setupNavigationWarnStub, } from '@ngx-odm/rxdb/testing'; import { NgxRxdbModule } from './rxdb.module'; -import { NgxRxdbCollectionService, RXDB, RXDB_CONFIG } from './rxdb.providers'; +import { RXDB, RXDB_COLLECTION, RXDB_CONFIG } from './rxdb.providers'; describe('NgxRxdbModule', () => { beforeAll(() => { @@ -69,7 +69,7 @@ describe('NgxRxdbModule', () => { }); it(`should not provide feature config token & collection service`, () => { expect(dbService.initCollections).not.toHaveBeenCalled(); - expect(() => TestBed.inject(NgxRxdbCollectionService)).toThrowError( + expect(() => TestBed.inject(RXDB_COLLECTION)).toThrowError( /No provider for/ ); }); @@ -92,7 +92,7 @@ describe('NgxRxdbModule', () => { }); it(`should init db via dbService`, inject( - [NgxRxdbCollectionService], + [RXDB_COLLECTION], async (colService: RxDBCollectionService) => { expect(dbService.initDb).toHaveBeenCalledWith(TEST_DB_CONFIG_1); expect(dbService.initCollections).toHaveBeenCalledWith({ diff --git a/packages/rxdb/src/lib/rxdb.module.ts b/packages/rxdb/src/lib/rxdb.module.ts index 2d1bedb..bbed794 100644 --- a/packages/rxdb/src/lib/rxdb.module.ts +++ b/packages/rxdb/src/lib/rxdb.module.ts @@ -14,8 +14,8 @@ import { RxDBService } from '@ngx-odm/rxdb/core'; import { NgxRxdbUtils } from '@ngx-odm/rxdb/utils'; import type { RxDatabaseCreator } from 'rxdb'; import { - NgxRxdbCollectionService, RXDB, + RXDB_COLLECTION, RXDB_CONFIG, provideRxCollection, provideRxDatabase, @@ -140,13 +140,13 @@ export class NgxRxdbModule { * (Fake) Feature module for NgxRxdbModule * * By being provided with `forChild` method of *root* NgxRxdbModule, - * and by injecting `NgxRxdbCollectionService` in its constructor, + * and by injecting `RXDB_COLLECTION` in its constructor, * this module actually creates a collection with collectionService and provided config */ @NgModule() export class NgxRxdbFeatureModule { constructor( @Inject(RXDB) private dbService: RxDBService, - @Inject(NgxRxdbCollectionService) private collectionService: RxDBCollectionService + @Inject(RXDB_COLLECTION) private collectionService: RxDBCollectionService ) {} } diff --git a/packages/rxdb/src/lib/rxdb.providers.ts b/packages/rxdb/src/lib/rxdb.providers.ts index 3a7d991..b6fb38a 100644 --- a/packages/rxdb/src/lib/rxdb.providers.ts +++ b/packages/rxdb/src/lib/rxdb.providers.ts @@ -31,7 +31,7 @@ export const RXDB_CONFIG_COLLECTION = new InjectionToken( +export const RXDB_COLLECTION = new InjectionToken( 'RxDBCollectionService' ); @@ -106,9 +106,9 @@ export function provideRxCollection( return [ { provide: RXDB_CONFIG_COLLECTION, useValue: collectionConfig }, { - provide: NgxRxdbCollectionService, + provide: RXDB_COLLECTION, // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore + // @ts-ignore // INFO: no need for typings here, nothing's exposed, but ts complains // NOSONAR useFactory: (config, dbService, ngZone, currentUrl, updateQueryParamsFn) => new RxDBCollectionService( config, diff --git a/packages/rxdb/testing/src/lib/mocks.ts b/packages/rxdb/testing/src/lib/mocks.ts index 94329c7..75797c2 100644 --- a/packages/rxdb/testing/src/lib/mocks.ts +++ b/packages/rxdb/testing/src/lib/mocks.ts @@ -2,7 +2,7 @@ /// import { RxCollectionCreatorExtended } from '@ngx-odm/rxdb/config'; -import { RxDBService } from '@ngx-odm/rxdb/core'; +import { RxDBService, loadRxDBPlugins } from '@ngx-odm/rxdb/core'; import { RxCollectionCreator, RxDatabaseCreator, @@ -11,7 +11,6 @@ import { randomCouchString, } from 'rxdb'; import { getRxStorageMemory } from 'rxdb/plugins/storage-memory'; -import { loadRxDBPlugins } from '../../../core/src/lib/plugin.loader'; export type TestDocType = { id: string; diff --git a/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/build/index.js b/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/build/index.js index 14bd02d..a497c71 100644 --- a/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/build/index.js +++ b/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/build/index.js @@ -1,4 +1,4 @@ -var Jx=Object.defineProperty;var Xx=(t,e,n)=>e in t?Jx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var jc=(t,e,n)=>(Xx(t,typeof e!="symbol"?e+"":e,n),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var yw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var N1={exports:{}},ih={},B1={exports:{}},Me={};/** +var Xx=Object.defineProperty;var Zx=(t,e,n)=>e in t?Xx(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var jc=(t,e,n)=>(Zx(t,typeof e!="symbol"?e+"":e,n),n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var vw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rh(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var B1={exports:{}},ih={},F1={exports:{}},Me={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ var Jx=Object.defineProperty;var Xx=(t,e,n)=>e in t?Jx(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var zl=Symbol.for("react.element"),Zx=Symbol.for("react.portal"),eA=Symbol.for("react.fragment"),tA=Symbol.for("react.strict_mode"),nA=Symbol.for("react.profiler"),rA=Symbol.for("react.provider"),iA=Symbol.for("react.context"),sA=Symbol.for("react.forward_ref"),oA=Symbol.for("react.suspense"),aA=Symbol.for("react.memo"),uA=Symbol.for("react.lazy"),vw=Symbol.iterator;function lA(t){return t===null||typeof t!="object"?null:(t=vw&&t[vw]||t["@@iterator"],typeof t=="function"?t:null)}var F1={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},L1=Object.assign,$1={};function tu(t,e,n){this.props=t,this.context=e,this.refs=$1,this.updater=n||F1}tu.prototype.isReactComponent={};tu.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};tu.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function j1(){}j1.prototype=tu.prototype;function wv(t,e,n){this.props=t,this.context=e,this.refs=$1,this.updater=n||F1}var _v=wv.prototype=new j1;_v.constructor=wv;L1(_v,tu.prototype);_v.isPureReactComponent=!0;var gw=Array.isArray,U1=Object.prototype.hasOwnProperty,bv={current:null},z1={key:!0,ref:!0,__self:!0,__source:!0};function V1(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)U1.call(e,r)&&!z1.hasOwnProperty(r)&&(i[r]=e[r]);var a=arguments.length-2;if(a===1)i.children=n;else if(1e in t?Jx(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var pA=oi,mA=Symbol.for("react.element"),yA=Symbol.for("react.fragment"),vA=Object.prototype.hasOwnProperty,gA=pA.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,wA={key:!0,ref:!0,__self:!0,__source:!0};function K1(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)vA.call(e,r)&&!wA.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:mA,type:t,key:s,ref:o,props:i,_owner:gA.current}}ih.Fragment=yA;ih.jsx=K1;ih.jsxs=K1;N1.exports=ih;var _A=N1.exports,W1={exports:{}},nr={},q1={exports:{}},H1={};/** + */var mC=qn,yC=Symbol.for("react.element"),vC=Symbol.for("react.fragment"),gC=Object.prototype.hasOwnProperty,wC=mC.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,_C={key:!0,ref:!0,__self:!0,__source:!0};function W1(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)gC.call(e,r)&&!_C.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:yC,type:t,key:s,ref:o,props:i,_owner:wC.current}}ih.Fragment=vC;ih.jsx=W1;ih.jsxs=W1;B1.exports=ih;var bC=B1.exports,q1={exports:{}},rr={},H1={exports:{}},Q1={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var Jx=Object.defineProperty;var Xx=(t,e,n)=>e in t?Jx(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(t){function e(G,oe){var ue=G.length;G.push(oe);e:for(;0>>1,xt=G[Re];if(0>>1;Rei(Un,ue))tni(Xi,Un)?(G[Re]=Xi,G[tn]=ue,Re=tn):(G[Re]=Un,G[At]=ue,Re=At);else if(tni(Xi,ue))G[Re]=Xi,G[tn]=ue,Re=tn;else break e}}return oe}function i(G,oe){var ue=G.sortIndex-oe.sortIndex;return ue!==0?ue:G.id-oe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var l=[],f=[],h=1,m=null,y=3,w=!1,I=!1,E=!1,F=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(G){for(var oe=n(f);oe!==null;){if(oe.callback===null)r(f);else if(oe.startTime<=G)r(f),oe.sortIndex=oe.expirationTime,e(l,oe);else break;oe=n(f)}}function z(G){if(E=!1,k(G),!I)if(n(l)!==null)I=!0,Te(W);else{var oe=n(f);oe!==null&&Dt(z,oe.startTime-G)}}function W(G,oe){I=!1,E&&(E=!1,S(X),X=-1),w=!0;var ue=y;try{for(k(oe),m=n(l);m!==null&&(!(m.expirationTime>oe)||G&&!ce());){var Re=m.callback;if(typeof Re=="function"){m.callback=null,y=m.priorityLevel;var xt=Re(m.expirationTime<=oe);oe=t.unstable_now(),typeof xt=="function"?m.callback=xt:m===n(l)&&r(l),k(oe)}else r(l);m=n(l)}if(m!==null)var ft=!0;else{var At=n(f);At!==null&&Dt(z,At.startTime-oe),ft=!1}return ft}finally{m=null,y=ue,w=!1}}var Q=!1,H=null,X=-1,U=5,ee=-1;function ce(){return!(t.unstable_now()-eeG||125Re?(G.sortIndex=ue,e(f,G),n(l)===null&&G===n(f)&&(E?(S(X),X=-1):E=!0,Dt(z,ue-Re))):(G.sortIndex=xt,e(l,G),I||w||(I=!0,Te(W))),G},t.unstable_shouldYield=ce,t.unstable_wrapCallback=function(G){var oe=y;return function(){var ue=y;y=oe;try{return G.apply(this,arguments)}finally{y=ue}}}})(H1);q1.exports=H1;var bA=q1.exports;/** + */(function(t){function e(G,oe){var ue=G.length;G.push(oe);e:for(;0>>1,xt=G[Re];if(0>>1;Rei(Un,ue))tni(Xi,Un)?(G[Re]=Xi,G[tn]=ue,Re=tn):(G[Re]=Un,G[Ct]=ue,Re=Ct);else if(tni(Xi,ue))G[Re]=Xi,G[tn]=ue,Re=tn;else break e}}return oe}function i(G,oe){var ue=G.sortIndex-oe.sortIndex;return ue!==0?ue:G.id-oe.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var l=[],f=[],h=1,m=null,y=3,w=!1,I=!1,E=!1,$=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function O(G){for(var oe=n(f);oe!==null;){if(oe.callback===null)r(f);else if(oe.startTime<=G)r(f),oe.sortIndex=oe.expirationTime,e(l,oe);else break;oe=n(f)}}function z(G){if(E=!1,O(G),!I)if(n(l)!==null)I=!0,Te(W);else{var oe=n(f);oe!==null&&Dt(z,oe.startTime-G)}}function W(G,oe){I=!1,E&&(E=!1,S(X),X=-1),w=!0;var ue=y;try{for(O(oe),m=n(l);m!==null&&(!(m.expirationTime>oe)||G&&!ce());){var Re=m.callback;if(typeof Re=="function"){m.callback=null,y=m.priorityLevel;var xt=Re(m.expirationTime<=oe);oe=t.unstable_now(),typeof xt=="function"?m.callback=xt:m===n(l)&&r(l),O(oe)}else r(l);m=n(l)}if(m!==null)var ft=!0;else{var Ct=n(f);Ct!==null&&Dt(z,Ct.startTime-oe),ft=!1}return ft}finally{m=null,y=ue,w=!1}}var Q=!1,H=null,X=-1,U=5,ee=-1;function ce(){return!(t.unstable_now()-eeG||125Re?(G.sortIndex=ue,e(f,G),n(l)===null&&G===n(f)&&(E?(S(X),X=-1):E=!0,Dt(z,ue-Re))):(G.sortIndex=xt,e(l,G),I||w||(I=!0,Te(W))),G},t.unstable_shouldYield=ce,t.unstable_wrapCallback=function(G){var oe=y;return function(){var ue=y;y=oe;try{return G.apply(this,arguments)}finally{y=ue}}}})(Q1);H1.exports=Q1;var SC=H1.exports;/** * @license React * react-dom.production.min.js * @@ -30,52 +30,52 @@ var Jx=Object.defineProperty;var Xx=(t,e,n)=>e in t?Jx(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Q1=oi,Zn=bA;function Z(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Cm=Object.prototype.hasOwnProperty,SA=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,_w={},bw={};function IA(t){return Cm.call(bw,t)?!0:Cm.call(_w,t)?!1:SA.test(t)?bw[t]=!0:(_w[t]=!0,!1)}function EA(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function OA(t,e,n,r){if(e===null||typeof e>"u"||EA(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function gn(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var en={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){en[t]=new gn(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];en[e]=new gn(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){en[t]=new gn(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){en[t]=new gn(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){en[t]=new gn(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){en[t]=new gn(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){en[t]=new gn(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){en[t]=new gn(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){en[t]=new gn(t,5,!1,t.toLowerCase(),null,!1,!1)});var Iv=/[\-:]([a-z])/g;function Ev(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Iv,Ev);en[e]=new gn(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Iv,Ev);en[e]=new gn(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Iv,Ev);en[e]=new gn(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){en[t]=new gn(t,1,!1,t.toLowerCase(),null,!1,!1)});en.xlinkHref=new gn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){en[t]=new gn(t,1,!1,t.toLowerCase(),null,!0,!0)});function Ov(t,e,n,r){var i=en.hasOwnProperty(e)?en[e]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Pm=Object.prototype.hasOwnProperty,IC=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,bw={},Sw={};function EC(t){return Pm.call(Sw,t)?!0:Pm.call(bw,t)?!1:IC.test(t)?Sw[t]=!0:(bw[t]=!0,!1)}function OC(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function kC(t,e,n,r){if(e===null||typeof e>"u"||OC(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function gn(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var en={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){en[t]=new gn(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];en[e]=new gn(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){en[t]=new gn(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){en[t]=new gn(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){en[t]=new gn(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){en[t]=new gn(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){en[t]=new gn(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){en[t]=new gn(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){en[t]=new gn(t,5,!1,t.toLowerCase(),null,!1,!1)});var Ev=/[\-:]([a-z])/g;function Ov(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Ev,Ov);en[e]=new gn(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Ev,Ov);en[e]=new gn(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Ev,Ov);en[e]=new gn(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){en[t]=new gn(t,1,!1,t.toLowerCase(),null,!1,!1)});en.xlinkHref=new gn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){en[t]=new gn(t,1,!1,t.toLowerCase(),null,!0,!0)});function kv(t,e,n,r){var i=en.hasOwnProperty(e)?en[e]:null;(i!==null?i.type!==0:r||!(2a||i[o]!==s[a]){var l=` -`+i[o].replace(" at new "," at ");return t.displayName&&l.includes("")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{xp=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Lu(t):""}function kA(t){switch(t.tag){case 5:return Lu(t.type);case 16:return Lu("Lazy");case 13:return Lu("Suspense");case 19:return Lu("SuspenseList");case 0:case 2:case 15:return t=Ap(t.type,!1),t;case 11:return t=Ap(t.type.render,!1),t;case 1:return t=Ap(t.type,!0),t;default:return""}}function Mm(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case la:return"Fragment";case ua:return"Portal";case Pm:return"Profiler";case kv:return"StrictMode";case Rm:return"Suspense";case Tm:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case J1:return(t.displayName||"Context")+".Consumer";case G1:return(t._context.displayName||"Context")+".Provider";case Dv:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case xv:return e=t.displayName||null,e!==null?e:Mm(t.type)||"Memo";case us:e=t._payload,t=t._init;try{return Mm(t(e))}catch{}}return null}function DA(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Mm(e);case 8:return e===kv?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Ps(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Z1(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function xA(t){var e=Z1(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Vc(t){t._valueTracker||(t._valueTracker=xA(t))}function eS(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=Z1(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Uf(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Nm(t,e){var n=e.checked;return Et({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Iw(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Ps(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function tS(t,e){e=e.checked,e!=null&&Ov(t,"checked",e,!1)}function Bm(t,e){tS(t,e);var n=Ps(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Fm(t,e.type,n):e.hasOwnProperty("defaultValue")&&Fm(t,e.type,Ps(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Ew(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Fm(t,e,n){(e!=="number"||Uf(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var $u=Array.isArray;function ba(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Kc.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function cl(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Wu={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},AA=["Webkit","ms","Moz","O"];Object.keys(Wu).forEach(function(t){AA.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Wu[e]=Wu[t]})});function sS(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Wu.hasOwnProperty(t)&&Wu[t]?(""+e).trim():e+"px"}function oS(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=sS(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var CA=Et({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function jm(t,e){if(e){if(CA[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Z(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Z(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Z(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Z(62))}}function Um(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var zm=null;function Av(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Vm=null,Sa=null,Ia=null;function Dw(t){if(t=Wl(t)){if(typeof Vm!="function")throw Error(Z(280));var e=t.stateNode;e&&(e=lh(e),Vm(t.stateNode,t.type,e))}}function aS(t){Sa?Ia?Ia.push(t):Ia=[t]:Sa=t}function uS(){if(Sa){var t=Sa,e=Ia;if(Ia=Sa=null,Dw(t),e)for(t=0;t>>=0,t===0?32:31-(UA(t)/zA|0)|0}var Wc=64,qc=4194304;function ju(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Wf(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=ju(a):(s&=o,s!==0&&(r=ju(s)))}else o=n&~i,o!==0?r=ju(o):s!==0&&(r=ju(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Vl(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Dr(e),t[e]=n}function qA(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Hu),Bw=String.fromCharCode(32),Fw=!1;function xS(t,e){switch(t){case"keyup":return _C.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function AS(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ca=!1;function SC(t,e){switch(t){case"compositionend":return AS(e);case"keypress":return e.which!==32?null:(Fw=!0,Bw);case"textInput":return t=e.data,t===Bw&&Fw?null:t;default:return null}}function IC(t,e){if(ca)return t==="compositionend"||!Fv&&xS(t,e)?(t=kS(),gf=Mv=ms=null,ca=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Uw(n)}}function TS(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?TS(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function MS(){for(var t=window,e=Uf();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Uf(t.document)}return e}function Lv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function RC(t){var e=MS(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&TS(n.ownerDocument.documentElement,n)){if(r!==null&&Lv(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=zw(n,s);var o=zw(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,fa=null,Ym=null,Yu=null,Gm=!1;function Vw(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Gm||fa==null||fa!==Uf(r)||(r=fa,"selectionStart"in r&&Lv(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Yu&&yl(Yu,r)||(Yu=r,r=Qf(Ym,"onSelect"),0pa||(t.current=ny[pa],ny[pa]=null,pa--)}function ut(t,e){pa++,ny[pa]=t.current,t.current=e}var Rs={},ln=Us(Rs),Dn=Us(!1),Ao=Rs;function Ta(t,e){var n=t.type.contextTypes;if(!n)return Rs;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function xn(t){return t=t.childContextTypes,t!=null}function Gf(){mt(Dn),mt(ln)}function Gw(t,e,n){if(ln.current!==Rs)throw Error(Z(168));ut(ln,e),ut(Dn,n)}function VS(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(Z(108,DA(t)||"Unknown",i));return Et({},n,r)}function Jf(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Rs,Ao=ln.current,ut(ln,t),ut(Dn,Dn.current),!0}function Jw(t,e,n){var r=t.stateNode;if(!r)throw Error(Z(169));n?(t=VS(t,e,Ao),r.__reactInternalMemoizedMergedChildContext=t,mt(Dn),mt(ln),ut(ln,t)):mt(Dn),ut(Dn,n)}var Ei=null,ch=!1,Vp=!1;function KS(t){Ei===null?Ei=[t]:Ei.push(t)}function KC(t){ch=!0,KS(t)}function zs(){if(!Vp&&Ei!==null){Vp=!0;var t=0,e=Ge;try{var n=Ei;for(Ge=1;t>=o,i-=o,xi=1<<32-Dr(e)+i|n<X?(U=H,H=null):U=H.sibling;var ee=y(S,H,k[X],z);if(ee===null){H===null&&(H=U);break}t&&H&&ee.alternate===null&&e(S,H),_=s(ee,_,X),Q===null?W=ee:Q.sibling=ee,Q=ee,H=U}if(X===k.length)return n(S,H),gt&&uo(S,X),W;if(H===null){for(;XX?(U=H,H=null):U=H.sibling;var ce=y(S,H,ee.value,z);if(ce===null){H===null&&(H=U);break}t&&H&&ce.alternate===null&&e(S,H),_=s(ce,_,X),Q===null?W=ce:Q.sibling=ce,Q=ce,H=U}if(ee.done)return n(S,H),gt&&uo(S,X),W;if(H===null){for(;!ee.done;X++,ee=k.next())ee=m(S,ee.value,z),ee!==null&&(_=s(ee,_,X),Q===null?W=ee:Q.sibling=ee,Q=ee);return gt&&uo(S,X),W}for(H=r(S,H);!ee.done;X++,ee=k.next())ee=w(H,S,X,ee.value,z),ee!==null&&(t&&ee.alternate!==null&&H.delete(ee.key===null?X:ee.key),_=s(ee,_,X),Q===null?W=ee:Q.sibling=ee,Q=ee);return t&&H.forEach(function(de){return e(S,de)}),gt&&uo(S,X),W}function F(S,_,k,z){if(typeof k=="object"&&k!==null&&k.type===la&&k.key===null&&(k=k.props.children),typeof k=="object"&&k!==null){switch(k.$$typeof){case zc:e:{for(var W=k.key,Q=_;Q!==null;){if(Q.key===W){if(W=k.type,W===la){if(Q.tag===7){n(S,Q.sibling),_=i(Q,k.props.children),_.return=S,S=_;break e}}else if(Q.elementType===W||typeof W=="object"&&W!==null&&W.$$typeof===us&&i_(W)===Q.type){n(S,Q.sibling),_=i(Q,k.props),_.ref=Ru(S,Q,k),_.return=S,S=_;break e}n(S,Q);break}else e(S,Q);Q=Q.sibling}k.type===la?(_=Io(k.props.children,S.mode,z,k.key),_.return=S,S=_):(z=kf(k.type,k.key,k.props,null,S.mode,z),z.ref=Ru(S,_,k),z.return=S,S=z)}return o(S);case ua:e:{for(Q=k.key;_!==null;){if(_.key===Q)if(_.tag===4&&_.stateNode.containerInfo===k.containerInfo&&_.stateNode.implementation===k.implementation){n(S,_.sibling),_=i(_,k.children||[]),_.return=S,S=_;break e}else{n(S,_);break}else e(S,_);_=_.sibling}_=Jp(k,S.mode,z),_.return=S,S=_}return o(S);case us:return Q=k._init,F(S,_,Q(k._payload),z)}if($u(k))return I(S,_,k,z);if(Du(k))return E(S,_,k,z);Zc(S,k)}return typeof k=="string"&&k!==""||typeof k=="number"?(k=""+k,_!==null&&_.tag===6?(n(S,_.sibling),_=i(_,k),_.return=S,S=_):(n(S,_),_=Gp(k,S.mode,z),_.return=S,S=_),o(S)):n(S,_)}return F}var Na=XS(!0),ZS=XS(!1),ql={},ui=Us(ql),_l=Us(ql),bl=Us(ql);function po(t){if(t===ql)throw Error(Z(174));return t}function Hv(t,e){switch(ut(bl,e),ut(_l,t),ut(ui,ql),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:$m(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=$m(e,t)}mt(ui),ut(ui,e)}function Ba(){mt(ui),mt(_l),mt(bl)}function eI(t){po(bl.current);var e=po(ui.current),n=$m(e,t.type);e!==n&&(ut(_l,t),ut(ui,n))}function Qv(t){_l.current===t&&(mt(ui),mt(_l))}var bt=Us(0);function rd(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var Kp=[];function Yv(){for(var t=0;tn?n:4,t(!0);var r=Wp.transition;Wp.transition={};try{t(!1),e()}finally{Ge=n,Wp.transition=r}}function yI(){return gr().memoizedState}function QC(t,e,n){var r=Os(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},vI(t))gI(e,n);else if(n=QS(t,e,n,r),n!==null){var i=yn();xr(n,t,r,i),wI(n,e,r)}}function YC(t,e,n){var r=Os(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(vI(t))gI(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,Pr(a,o)){var l=e.interleaved;l===null?(i.next=i,Wv(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}finally{}n=QS(t,e,i,r),n!==null&&(i=yn(),xr(n,t,r,i),wI(n,e,r))}}function vI(t){var e=t.alternate;return t===It||e!==null&&e===It}function gI(t,e){Gu=id=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function wI(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Pv(t,n)}}var sd={readContext:vr,useCallback:sn,useContext:sn,useEffect:sn,useImperativeHandle:sn,useInsertionEffect:sn,useLayoutEffect:sn,useMemo:sn,useReducer:sn,useRef:sn,useState:sn,useDebugValue:sn,useDeferredValue:sn,useTransition:sn,useMutableSource:sn,useSyncExternalStore:sn,useId:sn,unstable_isNewReconciler:!1},GC={readContext:vr,useCallback:function(t,e){return Wr().memoizedState=[t,e===void 0?null:e],t},useContext:vr,useEffect:o_,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Sf(4194308,4,fI.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Sf(4194308,4,t,e)},useInsertionEffect:function(t,e){return Sf(4,2,t,e)},useMemo:function(t,e){var n=Wr();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=Wr();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=QC.bind(null,It,t),[r.memoizedState,t]},useRef:function(t){var e=Wr();return t={current:t},e.memoizedState=t},useState:s_,useDebugValue:eg,useDeferredValue:function(t){return Wr().memoizedState=t},useTransition:function(){var t=s_(!1),e=t[0];return t=HC.bind(null,t[1]),Wr().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=It,i=Wr();if(gt){if(n===void 0)throw Error(Z(407));n=n()}else{if(n=e(),Qt===null)throw Error(Z(349));Po&30||rI(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,o_(sI.bind(null,r,s,t),[t]),r.flags|=2048,El(9,iI.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=Wr(),e=Qt.identifierPrefix;if(gt){var n=Ai,r=xi;n=(r&~(1<<32-Dr(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Sl++,0")&&(l=l.replace("",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{xp=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Lu(t):""}function DC(t){switch(t.tag){case 5:return Lu(t.type);case 16:return Lu("Lazy");case 13:return Lu("Suspense");case 19:return Lu("SuspenseList");case 0:case 2:case 15:return t=Cp(t.type,!1),t;case 11:return t=Cp(t.type.render,!1),t;case 1:return t=Cp(t.type,!0),t;default:return""}}function Nm(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case ca:return"Fragment";case la:return"Portal";case Rm:return"Profiler";case Dv:return"StrictMode";case Tm:return"Suspense";case Mm:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case X1:return(t.displayName||"Context")+".Consumer";case J1:return(t._context.displayName||"Context")+".Provider";case xv:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Cv:return e=t.displayName||null,e!==null?e:Nm(t.type)||"Memo";case us:e=t._payload,t=t._init;try{return Nm(t(e))}catch{}}return null}function xC(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Nm(e);case 8:return e===Dv?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Ps(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function eS(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function CC(t){var e=eS(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Vc(t){t._valueTracker||(t._valueTracker=CC(t))}function tS(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=eS(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Uf(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Bm(t,e){var n=e.checked;return Et({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Ew(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Ps(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function nS(t,e){e=e.checked,e!=null&&kv(t,"checked",e,!1)}function Fm(t,e){nS(t,e);var n=Ps(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Lm(t,e.type,n):e.hasOwnProperty("defaultValue")&&Lm(t,e.type,Ps(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Ow(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Lm(t,e,n){(e!=="number"||Uf(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var $u=Array.isArray;function Sa(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Kc.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function cl(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Wu={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},AC=["Webkit","ms","Moz","O"];Object.keys(Wu).forEach(function(t){AC.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Wu[e]=Wu[t]})});function oS(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Wu.hasOwnProperty(t)&&Wu[t]?(""+e).trim():e+"px"}function aS(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=oS(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var PC=Et({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Um(t,e){if(e){if(PC[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(Z(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(Z(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(Z(61))}if(e.style!=null&&typeof e.style!="object")throw Error(Z(62))}}function zm(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Vm=null;function Av(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Km=null,Ia=null,Ea=null;function xw(t){if(t=Wl(t)){if(typeof Km!="function")throw Error(Z(280));var e=t.stateNode;e&&(e=lh(e),Km(t.stateNode,t.type,e))}}function uS(t){Ia?Ea?Ea.push(t):Ea=[t]:Ia=t}function lS(){if(Ia){var t=Ia,e=Ea;if(Ea=Ia=null,xw(t),e)for(t=0;t>>=0,t===0?32:31-(zC(t)/VC|0)|0}var Wc=64,qc=4194304;function ju(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Wf(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~i;a!==0?r=ju(a):(s&=o,s!==0&&(r=ju(s)))}else o=n&~i,o!==0?r=ju(o):s!==0&&(r=ju(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Vl(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-xr(e),t[e]=n}function HC(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Hu),Fw=String.fromCharCode(32),Lw=!1;function CS(t,e){switch(t){case"keyup":return bA.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function AS(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var fa=!1;function IA(t,e){switch(t){case"compositionend":return AS(e);case"keypress":return e.which!==32?null:(Lw=!0,Fw);case"textInput":return t=e.data,t===Fw&&Lw?null:t;default:return null}}function EA(t,e){if(fa)return t==="compositionend"||!Lv&&CS(t,e)?(t=DS(),gf=Nv=ms=null,fa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=zw(n)}}function MS(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?MS(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function NS(){for(var t=window,e=Uf();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Uf(t.document)}return e}function $v(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function TA(t){var e=NS(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&MS(n.ownerDocument.documentElement,n)){if(r!==null&&$v(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=Vw(n,s);var o=Vw(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,da=null,Gm=null,Yu=null,Jm=!1;function Kw(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Jm||da==null||da!==Uf(r)||(r=da,"selectionStart"in r&&$v(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Yu&&yl(Yu,r)||(Yu=r,r=Qf(Gm,"onSelect"),0ma||(t.current=ry[ma],ry[ma]=null,ma--)}function ut(t,e){ma++,ry[ma]=t.current,t.current=e}var Rs={},ln=Us(Rs),Dn=Us(!1),Co=Rs;function Ma(t,e){var n=t.type.contextTypes;if(!n)return Rs;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function xn(t){return t=t.childContextTypes,t!=null}function Gf(){mt(Dn),mt(ln)}function Jw(t,e,n){if(ln.current!==Rs)throw Error(Z(168));ut(ln,e),ut(Dn,n)}function KS(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(Z(108,xC(t)||"Unknown",i));return Et({},n,r)}function Jf(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Rs,Co=ln.current,ut(ln,t),ut(Dn,Dn.current),!0}function Xw(t,e,n){var r=t.stateNode;if(!r)throw Error(Z(169));n?(t=KS(t,e,Co),r.__reactInternalMemoizedMergedChildContext=t,mt(Dn),mt(ln),ut(ln,t)):mt(Dn),ut(Dn,n)}var Ei=null,ch=!1,Vp=!1;function WS(t){Ei===null?Ei=[t]:Ei.push(t)}function WA(t){ch=!0,WS(t)}function zs(){if(!Vp&&Ei!==null){Vp=!0;var t=0,e=Ge;try{var n=Ei;for(Ge=1;t>=o,i-=o,xi=1<<32-xr(e)+i|n<X?(U=H,H=null):U=H.sibling;var ee=y(S,H,O[X],z);if(ee===null){H===null&&(H=U);break}t&&H&&ee.alternate===null&&e(S,H),_=s(ee,_,X),Q===null?W=ee:Q.sibling=ee,Q=ee,H=U}if(X===O.length)return n(S,H),gt&&uo(S,X),W;if(H===null){for(;XX?(U=H,H=null):U=H.sibling;var ce=y(S,H,ee.value,z);if(ce===null){H===null&&(H=U);break}t&&H&&ce.alternate===null&&e(S,H),_=s(ce,_,X),Q===null?W=ce:Q.sibling=ce,Q=ce,H=U}if(ee.done)return n(S,H),gt&&uo(S,X),W;if(H===null){for(;!ee.done;X++,ee=O.next())ee=m(S,ee.value,z),ee!==null&&(_=s(ee,_,X),Q===null?W=ee:Q.sibling=ee,Q=ee);return gt&&uo(S,X),W}for(H=r(S,H);!ee.done;X++,ee=O.next())ee=w(H,S,X,ee.value,z),ee!==null&&(t&&ee.alternate!==null&&H.delete(ee.key===null?X:ee.key),_=s(ee,_,X),Q===null?W=ee:Q.sibling=ee,Q=ee);return t&&H.forEach(function(de){return e(S,de)}),gt&&uo(S,X),W}function $(S,_,O,z){if(typeof O=="object"&&O!==null&&O.type===ca&&O.key===null&&(O=O.props.children),typeof O=="object"&&O!==null){switch(O.$$typeof){case zc:e:{for(var W=O.key,Q=_;Q!==null;){if(Q.key===W){if(W=O.type,W===ca){if(Q.tag===7){n(S,Q.sibling),_=i(Q,O.props.children),_.return=S,S=_;break e}}else if(Q.elementType===W||typeof W=="object"&&W!==null&&W.$$typeof===us&&s_(W)===Q.type){n(S,Q.sibling),_=i(Q,O.props),_.ref=Ru(S,Q,O),_.return=S,S=_;break e}n(S,Q);break}else e(S,Q);Q=Q.sibling}O.type===ca?(_=Io(O.props.children,S.mode,z,O.key),_.return=S,S=_):(z=kf(O.type,O.key,O.props,null,S.mode,z),z.ref=Ru(S,_,O),z.return=S,S=z)}return o(S);case la:e:{for(Q=O.key;_!==null;){if(_.key===Q)if(_.tag===4&&_.stateNode.containerInfo===O.containerInfo&&_.stateNode.implementation===O.implementation){n(S,_.sibling),_=i(_,O.children||[]),_.return=S,S=_;break e}else{n(S,_);break}else e(S,_);_=_.sibling}_=Jp(O,S.mode,z),_.return=S,S=_}return o(S);case us:return Q=O._init,$(S,_,Q(O._payload),z)}if($u(O))return I(S,_,O,z);if(Du(O))return E(S,_,O,z);Zc(S,O)}return typeof O=="string"&&O!==""||typeof O=="number"?(O=""+O,_!==null&&_.tag===6?(n(S,_.sibling),_=i(_,O),_.return=S,S=_):(n(S,_),_=Gp(O,S.mode,z),_.return=S,S=_),o(S)):n(S,_)}return $}var Ba=ZS(!0),eI=ZS(!1),ql={},ui=Us(ql),_l=Us(ql),bl=Us(ql);function po(t){if(t===ql)throw Error(Z(174));return t}function Qv(t,e){switch(ut(bl,e),ut(_l,t),ut(ui,ql),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:jm(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=jm(e,t)}mt(ui),ut(ui,e)}function Fa(){mt(ui),mt(_l),mt(bl)}function tI(t){po(bl.current);var e=po(ui.current),n=jm(e,t.type);e!==n&&(ut(_l,t),ut(ui,n))}function Yv(t){_l.current===t&&(mt(ui),mt(_l))}var bt=Us(0);function rd(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var Kp=[];function Gv(){for(var t=0;tn?n:4,t(!0);var r=Wp.transition;Wp.transition={};try{t(!1),e()}finally{Ge=n,Wp.transition=r}}function vI(){return wr().memoizedState}function YA(t,e,n){var r=Os(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},gI(t))wI(e,n);else if(n=YS(t,e,n,r),n!==null){var i=yn();Cr(n,t,r,i),_I(n,e,r)}}function GA(t,e,n){var r=Os(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(gI(t))wI(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,a=s(o,n);if(i.hasEagerState=!0,i.eagerState=a,Rr(a,o)){var l=e.interleaved;l===null?(i.next=i,qv(e)):(i.next=l.next,l.next=i),e.interleaved=i;return}}catch{}finally{}n=YS(t,e,i,r),n!==null&&(i=yn(),Cr(n,t,r,i),_I(n,e,r))}}function gI(t){var e=t.alternate;return t===It||e!==null&&e===It}function wI(t,e){Gu=id=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function _I(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Rv(t,n)}}var sd={readContext:gr,useCallback:sn,useContext:sn,useEffect:sn,useImperativeHandle:sn,useInsertionEffect:sn,useLayoutEffect:sn,useMemo:sn,useReducer:sn,useRef:sn,useState:sn,useDebugValue:sn,useDeferredValue:sn,useTransition:sn,useMutableSource:sn,useSyncExternalStore:sn,useId:sn,unstable_isNewReconciler:!1},JA={readContext:gr,useCallback:function(t,e){return qr().memoizedState=[t,e===void 0?null:e],t},useContext:gr,useEffect:a_,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Sf(4194308,4,dI.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Sf(4194308,4,t,e)},useInsertionEffect:function(t,e){return Sf(4,2,t,e)},useMemo:function(t,e){var n=qr();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=qr();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=YA.bind(null,It,t),[r.memoizedState,t]},useRef:function(t){var e=qr();return t={current:t},e.memoizedState=t},useState:o_,useDebugValue:tg,useDeferredValue:function(t){return qr().memoizedState=t},useTransition:function(){var t=o_(!1),e=t[0];return t=QA.bind(null,t[1]),qr().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=It,i=qr();if(gt){if(n===void 0)throw Error(Z(407));n=n()}else{if(n=e(),Qt===null)throw Error(Z(349));Po&30||iI(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,a_(oI.bind(null,r,s,t),[t]),r.flags|=2048,El(9,sI.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=qr(),e=Qt.identifierPrefix;if(gt){var n=Ci,r=xi;n=(r&~(1<<32-xr(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Sl++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Yr]=e,t[wl]=r,xI(t,e,!1,!1),e.stateNode=t;e:{switch(o=Um(n,r),n){case"dialog":ht("cancel",t),ht("close",t),i=r;break;case"iframe":case"object":case"embed":ht("load",t),i=r;break;case"video":case"audio":for(i=0;iLa&&(e.flags|=128,r=!0,Tu(s,!1),e.lanes=4194304)}else{if(!r)if(t=rd(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Tu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!gt)return on(e),null}else 2*Tt()-s.renderingStartTime>La&&n!==1073741824&&(e.flags|=128,r=!0,Tu(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Tt(),e.sibling=null,n=bt.current,ut(bt,r?n&1|2:n&1),e):(on(e),null);case 22:case 23:return og(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Wn&1073741824&&(on(e),e.subtreeFlags&6&&(e.flags|=8192)):on(e),null;case 24:return null;case 25:return null}throw Error(Z(156,e.tag))}function iP(t,e){switch(jv(e),e.tag){case 1:return xn(e.type)&&Gf(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ba(),mt(Dn),mt(ln),Yv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Qv(e),null;case 13:if(mt(bt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Z(340));Ma()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return mt(bt),null;case 4:return Ba(),null;case 10:return Kv(e.type._context),null;case 22:case 23:return og(),null;case 24:return null;default:return null}}var tf=!1,an=!1,sP=typeof WeakSet=="function"?WeakSet:Set,ae=null;function ga(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ct(t,e,r)}else n.current=null}function py(t,e,n){try{n()}catch(r){Ct(t,e,r)}}var m_=!1;function oP(t,e){if(Jm=qf,t=MS(),Lv(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,f=0,h=0,m=t,y=null;t:for(;;){for(var w;m!==n||i!==0&&m.nodeType!==3||(a=o+i),m!==s||r!==0&&m.nodeType!==3||(l=o+r),m.nodeType===3&&(o+=m.nodeValue.length),(w=m.firstChild)!==null;)y=m,m=w;for(;;){if(m===t)break t;if(y===n&&++f===i&&(a=o),y===s&&++h===r&&(l=o),(w=m.nextSibling)!==null)break;m=y,y=m.parentNode}m=w}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(Xm={focusedElem:t,selectionRange:n},qf=!1,ae=e;ae!==null;)if(e=ae,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,ae=t;else for(;ae!==null;){e=ae;try{var I=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(I!==null){var E=I.memoizedProps,F=I.memoizedState,S=e.stateNode,_=S.getSnapshotBeforeUpdate(e.elementType===e.type?E:Sr(e.type,E),F);S.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var k=e.stateNode.containerInfo;k.nodeType===1?k.textContent="":k.nodeType===9&&k.documentElement&&k.removeChild(k.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Z(163))}}catch(z){Ct(e,e.return,z)}if(t=e.sibling,t!==null){t.return=e.return,ae=t;break}ae=e.return}return I=m_,m_=!1,I}function Ju(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&py(e,n,s)}i=i.next}while(i!==r)}}function hh(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function my(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function PI(t){var e=t.alternate;e!==null&&(t.alternate=null,PI(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Yr],delete e[wl],delete e[ty],delete e[zC],delete e[VC])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function RI(t){return t.tag===5||t.tag===3||t.tag===4}function y_(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||RI(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function yy(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Yf));else if(r!==4&&(t=t.child,t!==null))for(yy(t,e,n),t=t.sibling;t!==null;)yy(t,e,n),t=t.sibling}function vy(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(vy(t,e,n),t=t.sibling;t!==null;)vy(t,e,n),t=t.sibling}var Xt=null,Ir=!1;function os(t,e,n){for(n=n.child;n!==null;)TI(t,e,n),n=n.sibling}function TI(t,e,n){if(ai&&typeof ai.onCommitFiberUnmount=="function")try{ai.onCommitFiberUnmount(sh,n)}catch{}switch(n.tag){case 5:an||ga(n,e);case 6:var r=Xt,i=Ir;Xt=null,os(t,e,n),Xt=r,Ir=i,Xt!==null&&(Ir?(t=Xt,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Xt.removeChild(n.stateNode));break;case 18:Xt!==null&&(Ir?(t=Xt,n=n.stateNode,t.nodeType===8?zp(t.parentNode,n):t.nodeType===1&&zp(t,n),pl(t)):zp(Xt,n.stateNode));break;case 4:r=Xt,i=Ir,Xt=n.stateNode.containerInfo,Ir=!0,os(t,e,n),Xt=r,Ir=i;break;case 0:case 11:case 14:case 15:if(!an&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&py(n,e,o),i=i.next}while(i!==r)}os(t,e,n);break;case 1:if(!an&&(ga(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Ct(n,e,a)}os(t,e,n);break;case 21:os(t,e,n);break;case 22:n.mode&1?(an=(r=an)||n.memoizedState!==null,os(t,e,n),an=r):os(t,e,n);break;default:os(t,e,n)}}function v_(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new sP),e.forEach(function(r){var i=mP.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function _r(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Tt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*uP(r/1960))-r,10t?16:t,ys===null)var r=!1;else{if(t=ys,ys=null,ud=0,Fe&6)throw Error(Z(331));var i=Fe;for(Fe|=4,ae=t.current;ae!==null;){var s=ae,o=s.child;if(ae.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lTt()-ig?So(t,0):rg|=n),An(t,e)}function UI(t,e){e===0&&(t.mode&1?(e=qc,qc<<=1,!(qc&130023424)&&(qc=4194304)):e=1);var n=yn();t=$i(t,e),t!==null&&(Vl(t,e,n),An(t,n))}function pP(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),UI(t,n)}function mP(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(Z(314))}r!==null&&r.delete(e),UI(t,n)}var zI;zI=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Dn.current)kn=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return kn=!1,nP(t,e,n);kn=!!(t.flags&131072)}else kn=!1,gt&&e.flags&1048576&&WS(e,Zf,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;If(t,e),t=e.pendingProps;var i=Ta(e,ln.current);Oa(e,n),i=Jv(null,e,r,t,i,n);var s=Xv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,xn(r)?(s=!0,Jf(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,qv(e),i.updater=fh,e.stateNode=i,i._reactInternals=e,ay(e,r,t,n),e=cy(null,e,r,!0,s,n)):(e.tag=0,gt&&s&&$v(e),dn(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(If(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=vP(r),t=Sr(r,t),i){case 0:e=ly(null,e,r,t,n);break e;case 1:e=d_(null,e,r,t,n);break e;case 11:e=c_(null,e,r,t,n);break e;case 14:e=f_(null,e,r,Sr(r.type,t),n);break e}throw Error(Z(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Sr(r,i),ly(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Sr(r,i),d_(t,e,r,i,n);case 3:e:{if(OI(e),t===null)throw Error(Z(387));r=e.pendingProps,s=e.memoizedState,i=s.element,YS(t,e),nd(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=Fa(Error(Z(423)),e),e=h_(t,e,r,n,i);break e}else if(r!==i){i=Fa(Error(Z(424)),e),e=h_(t,e,r,n,i);break e}else for(Yn=Ss(e.stateNode.containerInfo.firstChild),Jn=e,gt=!0,Or=null,n=ZS(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ma(),r===i){e=ji(t,e,n);break e}dn(t,e,r,n)}e=e.child}return e;case 5:return eI(e),t===null&&iy(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,Zm(r,i)?o=null:s!==null&&Zm(r,s)&&(e.flags|=32),EI(t,e),dn(t,e,o,n),e.child;case 6:return t===null&&iy(e),null;case 13:return kI(t,e,n);case 4:return Hv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Na(e,null,r,n):dn(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Sr(r,i),c_(t,e,r,i,n);case 7:return dn(t,e,e.pendingProps,n),e.child;case 8:return dn(t,e,e.pendingProps.children,n),e.child;case 12:return dn(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,ut(ed,r._currentValue),r._currentValue=o,s!==null)if(Pr(s.value,o)){if(s.children===i.children&&!Dn.current){e=ji(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=Ri(-1,n&-n),l.tag=2;var f=s.updateQueue;if(f!==null){f=f.shared;var h=f.pending;h===null?l.next=l:(l.next=h.next,h.next=l),f.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),sy(s.return,n,e),a.lanes|=n;break}l=l.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(Z(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),sy(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}dn(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Oa(e,n),i=vr(i),r=r(i),e.flags|=1,dn(t,e,r,n),e.child;case 14:return r=e.type,i=Sr(r,e.pendingProps),i=Sr(r.type,i),f_(t,e,r,i,n);case 15:return SI(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Sr(r,i),If(t,e),e.tag=1,xn(r)?(t=!0,Jf(e)):t=!1,Oa(e,n),JS(e,r,i),ay(e,r,i,n),cy(null,e,r,!0,t,n);case 19:return DI(t,e,n);case 22:return II(t,e,n)}throw Error(Z(156,e.tag))};function VI(t,e){return mS(t,e)}function yP(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function mr(t,e,n,r){return new yP(t,e,n,r)}function ug(t){return t=t.prototype,!(!t||!t.isReactComponent)}function vP(t){if(typeof t=="function")return ug(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Dv)return 11;if(t===xv)return 14}return 2}function ks(t,e){var n=t.alternate;return n===null?(n=mr(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function kf(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")ug(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case la:return Io(n.children,i,s,e);case kv:o=8,i|=8;break;case Pm:return t=mr(12,n,e,i|2),t.elementType=Pm,t.lanes=s,t;case Rm:return t=mr(13,n,e,i),t.elementType=Rm,t.lanes=s,t;case Tm:return t=mr(19,n,e,i),t.elementType=Tm,t.lanes=s,t;case X1:return mh(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case G1:o=10;break e;case J1:o=9;break e;case Dv:o=11;break e;case xv:o=14;break e;case us:o=16,r=null;break e}throw Error(Z(130,t==null?t:typeof t,""))}return e=mr(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Io(t,e,n,r){return t=mr(7,t,r,e),t.lanes=n,t}function mh(t,e,n,r){return t=mr(22,t,r,e),t.elementType=X1,t.lanes=n,t.stateNode={isHidden:!1},t}function Gp(t,e,n){return t=mr(6,t,null,e),t.lanes=n,t}function Jp(t,e,n){return e=mr(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function gP(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pp(0),this.expirationTimes=Pp(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pp(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function lg(t,e,n,r,i,s,o,a,l){return t=new gP(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=mr(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},qv(s),t}function wP(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(HI)}catch(t){console.error(t)}}HI(),W1.exports=nr;var EP=W1.exports,QI,O_=EP;QI=O_.createRoot,O_.hydrateRoot;var Sy=function(t,e){return Sy=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},Sy(t,e)};function pi(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Sy(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function tt(t,e,n,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,n):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}function re(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ve(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(h){try{f(r.next(h))}catch(m){o(m)}}function l(h){try{f(r.throw(h))}catch(m){o(m)}}function f(h){h.done?s(h.value):i(h.value).then(a,l)}f((r=r.apply(t,e||[])).next())})}function YI(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(f){return function(h){return l([f,h])}}function l(f){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,f[0]&&(n=0)),n;)try{if(r=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,i=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Rr(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function ci(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r1||a(y,w)})})}function a(y,w){try{l(r[y](w))}catch(I){m(s[0][3],I)}}function l(y){y.value instanceof ge?Promise.resolve(y.value.v).then(f,h):m(s[0][2],y)}function f(y){a("next",y)}function h(y){a("throw",y)}function m(y,w){y(w),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Df(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(o){return(n=!n)?{value:ge(t[i](o)),done:!1}:s?s(o):o}:s}}function Ds(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof $a=="function"?$a(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(o){return new Promise(function(a,l){o=t[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(f){s({value:f,done:a})},o)}}function kl(t){"@babel/helpers - typeof";return kl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},kl(t)}function OP(t,e){if(kl(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(kl(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function kP(t){var e=OP(t,"string");return kl(e)=="symbol"?e:String(e)}function k_(t,e){for(var n=0;nr[t]:r=>{for(var i=r,s=0;s"u")return i}return i}}function $e(t){return Object.assign({},t)}function CP(t){return Object.keys(t)[0]}function fd(t,e=!1){if(!t)return t;if(!e&&Array.isArray(t))return t.sort((r,i)=>typeof r=="string"&&typeof i=="string"?r.localeCompare(i):typeof r=="object"?1:-1).map(r=>fd(r,e));if(typeof t=="object"&&!Array.isArray(t)){var n={};return Object.keys(t).sort((r,i)=>r.localeCompare(i)).forEach(r=>{n[r]=fd(t[r],e)}),n}return t}function Iy(t){if(!t||t===null||typeof t!="object")return t;if(Array.isArray(t)){for(var e=new Array(t.length),n=e.length;n--;)e[n]=Iy(t[n]);return e}var r={};for(var i in t)r[i]=Iy(t[i]);return r}var Pn=Iy;function xs(t,e,n){return Object.defineProperty(t,e,{get:function(){return n}}),n}var pg=1;function Ks(){return{lwt:pg}}function Rn(){return""}function PP(t){return Object.assign({},t,{_meta:void 0,_deleted:void 0,_rev:void 0})}function RP(t,e,n){if(e.length!==n.length)return!1;for(var r=0,i=e.length;r>>2]>>>24-n%4*8&255;this.words[this.sigBytes+n>>>2]|=r<<24-(this.sigBytes+n)%4*8}else for(let n=0;n>>2]=e.words[n>>>2];return this.sigBytes+=e.sigBytes,this}clamp(){this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4)}clone(){return new As([...this.words])}}const TP={stringify(t){const e=[];for(let n=0;n>>2]>>>24-n%4*8&255;e.push((r>>>4).toString(16),(r&15).toString(16))}return e.join("")}},MP={parse(t){const e=t.length,n=[];for(let r=0;r>>2]|=(t.charCodeAt(r)&255)<<24-r%4*8;return new As(n,e)}},NP={parse(t){return MP.parse(unescape(encodeURIComponent(t)))}};class BP{constructor(){this._data=new As,this._nDataBytes=0,this._minBufferSize=0,this.blockSize=512/32}reset(){this._data=new As,this._nDataBytes=0}_append(e){typeof e=="string"&&(e=NP.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes}_doProcessBlock(e,n){}_process(e){let n,r=this._data.sigBytes/(this.blockSize*4);e?r=Math.ceil(r):r=Math.max((r|0)-this._minBufferSize,0);const i=r*this.blockSize,s=Math.min(i*4,this._data.sigBytes);if(i){for(let o=0;o>>7)^(k<<14|k>>>18)^k>>>3,W=so[y-2],Q=(W<<15|W>>>17)^(W<<13|W>>>19)^W>>>10;so[y]=z+so[y-7]+Q+so[y-16]}const w=l&f^~l&h,I=i&s^i&o^s&o,E=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),F=(l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25),S=m+F+w+LP[y]+so[y],_=E+I;m=h,h=f,f=l,l=a+S|0,a=o,o=s,s=i,i=S+_|0}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+l|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+m|0}finalize(e){super.finalize(e);const n=this._nDataBytes*8,r=this._data.sigBytes*8;return this._data.words[r>>>5]|=128<<24-r%32,this._data.words[(r+64>>>9<<4)+14]=Math.floor(n/4294967296),this._data.words[(r+64>>>9<<4)+15]=n,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}}function jP(t){return new $P().finalize(t).toString()}function UP(t){return Promise.resolve(jP(t))}async function zP(t){var e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),r=Array.prototype.map.call(new Uint8Array(n),i=>("00"+i.toString(16)).slice(-2)).join("");return r}var VP=typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function",KP=VP?zP:UP;function WP(){return new Promise(t=>setTimeout(t,0))}function qP(t=0){return new Promise(e=>setTimeout(e,t))}function XI(t){return t&&typeof t.then=="function"?t:Promise.resolve(t)}var dd=Promise.resolve(!0),Gn=Promise.resolve(!1),mg=Promise.resolve(null),un=Promise.resolve();function yg(t=1e4){return typeof requestIdleCallback=="function"?new Promise(e=>{requestIdleCallback(()=>e(),{timeout:t})}):qP(0)}var Zp=un;function HP(t=void 0){return Zp=Zp.then(()=>yg(t)),Zp}function QP(t,e){return t.reduce((n,r)=>n.then(r),Promise.resolve(e))}var YP=/\./g,A_="abcdefghijklmnopqrstuvwxyz";function iu(t=10){for(var e="",n=0;n{var e=typeof t;return t!==null&&(e==="object"||e==="function")},em=new Set(["__proto__","prototype","constructor"]),GP=new Set("0123456789");function eE(t){var e=[],n="",r="start",i=!1;for(var s of t)switch(s){case"\\":{if(r==="index")throw new Error("Invalid character in an index");if(r==="indexEnd")throw new Error("Invalid character after an index");i&&(n+=s),r="property",i=!i;break}case".":{if(r==="index")throw new Error("Invalid character in an index");if(r==="indexEnd"){r="property";break}if(i){i=!1,n+=s;break}if(em.has(n))return[];e.push(n),n="",r="property";break}case"[":{if(r==="index")throw new Error("Invalid character in an index");if(r==="indexEnd"){r="index";break}if(i){i=!1,n+=s;break}if(r==="property"){if(em.has(n))return[];e.push(n),n=""}r="index";break}case"]":{if(r==="index"){e.push(Number.parseInt(n,10)),n="",r="indexEnd";break}if(r==="indexEnd")throw new Error("Invalid character after an index")}default:{if(r==="index"&&!GP.has(s))throw new Error("Invalid character in an index");if(r==="indexEnd")throw new Error("Invalid character after an index");r==="start"&&(r="property"),i&&(i=!1,n+="\\"),n+=s}}switch(i&&(n+="\\"),r){case"property":{if(em.has(n))return[];e.push(n);break}case"index":throw new Error("Index was not closed");case"start":{e.push("");break}}return e}function tE(t,e){if(typeof e!="number"&&Array.isArray(t)){var n=Number.parseInt(e,10);return Number.isInteger(n)&&t[n]===t[e]}return!1}function JP(t,e){if(tE(t,e))throw new Error("Cannot use string index")}function Ts(t,e,n){if(Array.isArray(e)&&(e=e.join(".")),!e.includes(".")&&!e.includes("["))return t[e];if(!Ey(t)||typeof e!="string")return n===void 0?t:n;var r=eE(e);if(r.length===0)return n;for(var i=0;i"u")throw new Error("missing value from map "+e);return n}function Tr(t,e,n,r){var i=t.get(e);return typeof i>"u"?(i=n(),t.set(e,i)):r&&r(i),i}function pt(t){var e=t.split("-"),n="RxDB";return e.forEach(r=>{n+=ZI(r)}),n+="Plugin",new Error(`You are using a function which must be overwritten by a plugin. +`+s.stack}return{value:t,source:e,stack:i,digest:null}}function Qp(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function ly(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var eP=typeof WeakMap=="function"?WeakMap:Map;function bI(t,e,n){n=Ri(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){ad||(ad=!0,wy=r),ly(t,e)},n}function SI(t,e,n){n=Ri(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;n.payload=function(){return r(i)},n.callback=function(){ly(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){ly(t,e),typeof r!="function"&&(Es===null?Es=new Set([this]):Es.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function u_(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new eP;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(n)||(i.add(n),t=pP.bind(null,t,e,n),e.then(t,t))}function l_(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function c_(t,e,n,r,i){return t.mode&1?(t.flags|=65536,t.lanes=i,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Ri(-1,1),e.tag=2,Is(n,e,1))),n.lanes|=1),t)}var tP=Qi.ReactCurrentOwner,kn=!1;function dn(t,e,n,r){e.child=t===null?eI(e,null,n,r):Ba(e,t.child,n,r)}function f_(t,e,n,r,i){n=n.render;var s=e.ref;return ka(e,i),r=Xv(t,e,n,r,s,i),n=Zv(),t!==null&&!kn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,ji(t,e,i)):(gt&&n&&jv(e),e.flags|=1,dn(t,e,r,i),e.child)}function d_(t,e,n,r,i){if(t===null){var s=n.type;return typeof s=="function"&&!lg(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,II(t,e,s,r,i)):(t=kf(n.type,null,r,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,!(t.lanes&i)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:yl,n(o,r)&&t.ref===e.ref)return ji(t,e,i)}return e.flags|=1,t=ks(s,r),t.ref=e.ref,t.return=e,e.child=t}function II(t,e,n,r,i){if(t!==null){var s=t.memoizedProps;if(yl(s,r)&&t.ref===e.ref)if(kn=!1,e.pendingProps=r=s,(t.lanes&i)!==0)t.flags&131072&&(kn=!0);else return e.lanes=t.lanes,ji(t,e,i)}return cy(t,e,n,r,i)}function EI(t,e,n){var r=e.pendingProps,i=r.children,s=t!==null?t.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},ut(_a,Wn),Wn|=n;else{if(!(n&1073741824))return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,ut(_a,Wn),Wn|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,ut(_a,Wn),Wn|=r}else s!==null?(r=s.baseLanes|n,e.memoizedState=null):r=n,ut(_a,Wn),Wn|=r;return dn(t,e,i,n),e.child}function OI(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function cy(t,e,n,r,i){var s=xn(n)?Co:ln.current;return s=Ma(e,s),ka(e,i),n=Xv(t,e,n,r,s,i),r=Zv(),t!==null&&!kn?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,ji(t,e,i)):(gt&&r&&jv(e),e.flags|=1,dn(t,e,n,i),e.child)}function h_(t,e,n,r,i){if(xn(n)){var s=!0;Jf(e)}else s=!1;if(ka(e,i),e.stateNode===null)If(t,e),XS(e,n,r),uy(e,n,r,i),r=!0;else if(t===null){var o=e.stateNode,a=e.memoizedProps;o.props=a;var l=o.context,f=n.contextType;typeof f=="object"&&f!==null?f=gr(f):(f=xn(n)?Co:ln.current,f=Ma(e,f));var h=n.getDerivedStateFromProps,m=typeof h=="function"||typeof o.getSnapshotBeforeUpdate=="function";m||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==f)&&i_(e,o,r,f),ls=!1;var y=e.memoizedState;o.state=y,nd(e,r,o,i),l=e.memoizedState,a!==r||y!==l||Dn.current||ls?(typeof h=="function"&&(ay(e,n,h,r),l=e.memoizedState),(a=ls||r_(e,n,a,r,y,l,f))?(m||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=l),o.props=r,o.state=l,o.context=f,r=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,GS(t,e),a=e.memoizedProps,f=e.type===e.elementType?a:Ir(e.type,a),o.props=f,m=e.pendingProps,y=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=gr(l):(l=xn(n)?Co:ln.current,l=Ma(e,l));var w=n.getDerivedStateFromProps;(h=typeof w=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==m||y!==l)&&i_(e,o,r,l),ls=!1,y=e.memoizedState,o.state=y,nd(e,r,o,i);var I=e.memoizedState;a!==m||y!==I||Dn.current||ls?(typeof w=="function"&&(ay(e,n,w,r),I=e.memoizedState),(f=ls||r_(e,n,f,r,y,I,l)||!1)?(h||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,I,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,I,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=I),o.props=r,o.state=I,o.context=l,r=f):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&y===t.memoizedState||(e.flags|=1024),r=!1)}return fy(t,e,n,r,s,i)}function fy(t,e,n,r,i,s){OI(t,e);var o=(e.flags&128)!==0;if(!r&&!o)return i&&Xw(e,n,!1),ji(t,e,s);r=e.stateNode,tP.current=e;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&o?(e.child=Ba(e,t.child,null,s),e.child=Ba(e,null,a,s)):dn(t,e,a,s),e.memoizedState=r.state,i&&Xw(e,n,!0),e.child}function kI(t){var e=t.stateNode;e.pendingContext?Jw(t,e.pendingContext,e.pendingContext!==e.context):e.context&&Jw(t,e.context,!1),Qv(t,e.containerInfo)}function p_(t,e,n,r,i){return Na(),zv(i),e.flags|=256,dn(t,e,n,r),e.child}var dy={dehydrated:null,treeContext:null,retryLane:0};function hy(t){return{baseLanes:t,cachePool:null,transitions:null}}function DI(t,e,n){var r=e.pendingProps,i=bt.current,s=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=t!==null&&t.memoizedState===null?!1:(i&2)!==0),a?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),ut(bt,i&1),t===null)return sy(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=r.children,t=r.fallback,s?(r=e.mode,s=e.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=mh(o,r,0,null),t=Io(t,r,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=hy(n),e.memoizedState=dy,t):ng(e,o));if(i=t.memoizedState,i!==null&&(a=i.dehydrated,a!==null))return nP(t,e,o,r,a,i,n);if(s){s=r.fallback,o=e.mode,i=t.child,a=i.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=l,e.deletions=null):(r=ks(i,l),r.subtreeFlags=i.subtreeFlags&14680064),a!==null?s=ks(a,s):(s=Io(s,o,n,null),s.flags|=2),s.return=e,r.return=e,r.sibling=s,e.child=r,r=s,s=e.child,o=t.child.memoizedState,o=o===null?hy(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=t.childLanes&~n,e.memoizedState=dy,r}return s=t.child,t=s.sibling,r=ks(s,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function ng(t,e){return e=mh({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function ef(t,e,n,r){return r!==null&&zv(r),Ba(e,t.child,null,n),t=ng(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function nP(t,e,n,r,i,s,o){if(n)return e.flags&256?(e.flags&=-257,r=Qp(Error(Z(422))),ef(t,e,o,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=r.fallback,i=e.mode,r=mh({mode:"visible",children:r.children},i,0,null),s=Io(s,i,o,null),s.flags|=2,r.return=e,s.return=e,r.sibling=s,e.child=r,e.mode&1&&Ba(e,t.child,null,o),e.child.memoizedState=hy(o),e.memoizedState=dy,s);if(!(e.mode&1))return ef(t,e,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var a=r.dgst;return r=a,s=Error(Z(419)),r=Qp(s,r,void 0),ef(t,e,o,r)}if(a=(o&t.childLanes)!==0,kn||a){if(r=Qt,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,$i(t,i),Cr(r,t,i,-1))}return ug(),r=Qp(Error(Z(421))),ef(t,e,o,r)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=mP.bind(null,t),i._reactRetry=e,null):(t=s.treeContext,Gn=Ss(i.nextSibling),Xn=e,gt=!0,kr=null,t!==null&&(dr[hr++]=xi,dr[hr++]=Ci,dr[hr++]=Ao,xi=t.id,Ci=t.overflow,Ao=e),e=ng(e,r.children),e.flags|=4096,e)}function m_(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),oy(t.return,e,n)}function Yp(t,e,n,r,i){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function xI(t,e,n){var r=e.pendingProps,i=r.revealOrder,s=r.tail;if(dn(t,e,r.children,n),r=bt.current,r&2)r=r&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&m_(t,n,e);else if(t.tag===19)m_(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(ut(bt,r),!(e.mode&1))e.memoizedState=null;else switch(i){case"forwards":for(n=e.child,i=null;n!==null;)t=n.alternate,t!==null&&rd(t)===null&&(i=n),n=n.sibling;n=i,n===null?(i=e.child,e.child=null):(i=n.sibling,n.sibling=null),Yp(e,!1,i,n,s);break;case"backwards":for(n=null,i=e.child,e.child=null;i!==null;){if(t=i.alternate,t!==null&&rd(t)===null){e.child=i;break}t=i.sibling,i.sibling=n,n=i,i=t}Yp(e,!0,n,null,s);break;case"together":Yp(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function If(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function ji(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),Ro|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(Z(153));if(e.child!==null){for(t=e.child,n=ks(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=ks(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function rP(t,e,n){switch(e.tag){case 3:kI(e),Na();break;case 5:tI(e);break;case 1:xn(e.type)&&Jf(e);break;case 4:Qv(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;ut(ed,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(ut(bt,bt.current&1),e.flags|=128,null):n&e.child.childLanes?DI(t,e,n):(ut(bt,bt.current&1),t=ji(t,e,n),t!==null?t.sibling:null);ut(bt,bt.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return xI(t,e,n);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ut(bt,bt.current),r)break;return null;case 22:case 23:return e.lanes=0,EI(t,e,n)}return ji(t,e,n)}var CI,py,AI,PI;CI=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};py=function(){};AI=function(t,e,n,r){var i=t.memoizedProps;if(i!==r){t=e.stateNode,po(ui.current);var s=null;switch(n){case"input":i=Bm(t,i),r=Bm(t,r),s=[];break;case"select":i=Et({},i,{value:void 0}),r=Et({},r,{value:void 0}),s=[];break;case"textarea":i=$m(t,i),r=$m(t,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=Yf)}Um(n,r);var o;n=null;for(f in i)if(!r.hasOwnProperty(f)&&i.hasOwnProperty(f)&&i[f]!=null)if(f==="style"){var a=i[f];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else f!=="dangerouslySetInnerHTML"&&f!=="children"&&f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&f!=="autoFocus"&&(ll.hasOwnProperty(f)?s||(s=[]):(s=s||[]).push(f,null));for(f in r){var l=r[f];if(a=i!=null?i[f]:void 0,r.hasOwnProperty(f)&&l!==a&&(l!=null||a!=null))if(f==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(n||(n={}),n[o]=l[o])}else n||(s||(s=[]),s.push(f,n)),n=l;else f==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(s=s||[]).push(f,l)):f==="children"?typeof l!="string"&&typeof l!="number"||(s=s||[]).push(f,""+l):f!=="suppressContentEditableWarning"&&f!=="suppressHydrationWarning"&&(ll.hasOwnProperty(f)?(l!=null&&f==="onScroll"&&ht("scroll",t),s||a===l||(s=[])):(s=s||[]).push(f,l))}n&&(s=s||[]).push("style",n);var f=s;(e.updateQueue=f)&&(e.flags|=4)}};PI=function(t,e,n,r){n!==r&&(e.flags|=4)};function Tu(t,e){if(!gt)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function on(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=t,i=i.sibling;else for(i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=t,i=i.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function iP(t,e,n){var r=e.pendingProps;switch(Uv(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return on(e),null;case 1:return xn(e.type)&&Gf(),on(e),null;case 3:return r=e.stateNode,Fa(),mt(Dn),mt(ln),Gv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Xc(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,kr!==null&&(Sy(kr),kr=null))),py(t,e),on(e),null;case 5:Yv(e);var i=po(bl.current);if(n=e.type,t!==null&&e.stateNode!=null)AI(t,e,n,r,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(Z(166));return on(e),null}if(t=po(ui.current),Xc(e)){r=e.stateNode,n=e.type;var s=e.memoizedProps;switch(r[Gr]=e,r[wl]=s,t=(e.mode&1)!==0,n){case"dialog":ht("cancel",r),ht("close",r);break;case"iframe":case"object":case"embed":ht("load",r);break;case"video":case"audio":for(i=0;i<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Gr]=e,t[wl]=r,CI(t,e,!1,!1),e.stateNode=t;e:{switch(o=zm(n,r),n){case"dialog":ht("cancel",t),ht("close",t),i=r;break;case"iframe":case"object":case"embed":ht("load",t),i=r;break;case"video":case"audio":for(i=0;i$a&&(e.flags|=128,r=!0,Tu(s,!1),e.lanes=4194304)}else{if(!r)if(t=rd(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Tu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!gt)return on(e),null}else 2*Tt()-s.renderingStartTime>$a&&n!==1073741824&&(e.flags|=128,r=!0,Tu(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Tt(),e.sibling=null,n=bt.current,ut(bt,r?n&1|2:n&1),e):(on(e),null);case 22:case 23:return ag(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Wn&1073741824&&(on(e),e.subtreeFlags&6&&(e.flags|=8192)):on(e),null;case 24:return null;case 25:return null}throw Error(Z(156,e.tag))}function sP(t,e){switch(Uv(e),e.tag){case 1:return xn(e.type)&&Gf(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Fa(),mt(Dn),mt(ln),Gv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Yv(e),null;case 13:if(mt(bt),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(Z(340));Na()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return mt(bt),null;case 4:return Fa(),null;case 10:return Wv(e.type._context),null;case 22:case 23:return ag(),null;case 24:return null;default:return null}}var tf=!1,an=!1,oP=typeof WeakSet=="function"?WeakSet:Set,ae=null;function wa(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){At(t,e,r)}else n.current=null}function my(t,e,n){try{n()}catch(r){At(t,e,r)}}var y_=!1;function aP(t,e){if(Xm=qf,t=NS(),$v(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,f=0,h=0,m=t,y=null;t:for(;;){for(var w;m!==n||i!==0&&m.nodeType!==3||(a=o+i),m!==s||r!==0&&m.nodeType!==3||(l=o+r),m.nodeType===3&&(o+=m.nodeValue.length),(w=m.firstChild)!==null;)y=m,m=w;for(;;){if(m===t)break t;if(y===n&&++f===i&&(a=o),y===s&&++h===r&&(l=o),(w=m.nextSibling)!==null)break;m=y,y=m.parentNode}m=w}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(Zm={focusedElem:t,selectionRange:n},qf=!1,ae=e;ae!==null;)if(e=ae,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,ae=t;else for(;ae!==null;){e=ae;try{var I=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(I!==null){var E=I.memoizedProps,$=I.memoizedState,S=e.stateNode,_=S.getSnapshotBeforeUpdate(e.elementType===e.type?E:Ir(e.type,E),$);S.__reactInternalSnapshotBeforeUpdate=_}break;case 3:var O=e.stateNode.containerInfo;O.nodeType===1?O.textContent="":O.nodeType===9&&O.documentElement&&O.removeChild(O.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Z(163))}}catch(z){At(e,e.return,z)}if(t=e.sibling,t!==null){t.return=e.return,ae=t;break}ae=e.return}return I=y_,y_=!1,I}function Ju(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&my(e,n,s)}i=i.next}while(i!==r)}}function hh(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function yy(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function RI(t){var e=t.alternate;e!==null&&(t.alternate=null,RI(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Gr],delete e[wl],delete e[ny],delete e[VA],delete e[KA])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function TI(t){return t.tag===5||t.tag===3||t.tag===4}function v_(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||TI(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function vy(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Yf));else if(r!==4&&(t=t.child,t!==null))for(vy(t,e,n),t=t.sibling;t!==null;)vy(t,e,n),t=t.sibling}function gy(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(gy(t,e,n),t=t.sibling;t!==null;)gy(t,e,n),t=t.sibling}var Xt=null,Er=!1;function os(t,e,n){for(n=n.child;n!==null;)MI(t,e,n),n=n.sibling}function MI(t,e,n){if(ai&&typeof ai.onCommitFiberUnmount=="function")try{ai.onCommitFiberUnmount(sh,n)}catch{}switch(n.tag){case 5:an||wa(n,e);case 6:var r=Xt,i=Er;Xt=null,os(t,e,n),Xt=r,Er=i,Xt!==null&&(Er?(t=Xt,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Xt.removeChild(n.stateNode));break;case 18:Xt!==null&&(Er?(t=Xt,n=n.stateNode,t.nodeType===8?zp(t.parentNode,n):t.nodeType===1&&zp(t,n),pl(t)):zp(Xt,n.stateNode));break;case 4:r=Xt,i=Er,Xt=n.stateNode.containerInfo,Er=!0,os(t,e,n),Xt=r,Er=i;break;case 0:case 11:case 14:case 15:if(!an&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&my(n,e,o),i=i.next}while(i!==r)}os(t,e,n);break;case 1:if(!an&&(wa(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){At(n,e,a)}os(t,e,n);break;case 21:os(t,e,n);break;case 22:n.mode&1?(an=(r=an)||n.memoizedState!==null,os(t,e,n),an=r):os(t,e,n);break;default:os(t,e,n)}}function g_(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new oP),e.forEach(function(r){var i=yP.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function br(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Tt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*lP(r/1960))-r,10t?16:t,ys===null)var r=!1;else{if(t=ys,ys=null,ud=0,Fe&6)throw Error(Z(331));var i=Fe;for(Fe|=4,ae=t.current;ae!==null;){var s=ae,o=s.child;if(ae.flags&16){var a=s.deletions;if(a!==null){for(var l=0;lTt()-sg?So(t,0):ig|=n),Cn(t,e)}function zI(t,e){e===0&&(t.mode&1?(e=qc,qc<<=1,!(qc&130023424)&&(qc=4194304)):e=1);var n=yn();t=$i(t,e),t!==null&&(Vl(t,e,n),Cn(t,n))}function mP(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),zI(t,n)}function yP(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(Z(314))}r!==null&&r.delete(e),zI(t,n)}var VI;VI=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Dn.current)kn=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return kn=!1,rP(t,e,n);kn=!!(t.flags&131072)}else kn=!1,gt&&e.flags&1048576&&qS(e,Zf,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;If(t,e),t=e.pendingProps;var i=Ma(e,ln.current);ka(e,n),i=Xv(null,e,r,t,i,n);var s=Zv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,xn(r)?(s=!0,Jf(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Hv(e),i.updater=fh,e.stateNode=i,i._reactInternals=e,uy(e,r,t,n),e=fy(null,e,r,!0,s,n)):(e.tag=0,gt&&s&&jv(e),dn(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(If(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=gP(r),t=Ir(r,t),i){case 0:e=cy(null,e,r,t,n);break e;case 1:e=h_(null,e,r,t,n);break e;case 11:e=f_(null,e,r,t,n);break e;case 14:e=d_(null,e,r,Ir(r.type,t),n);break e}throw Error(Z(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ir(r,i),cy(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ir(r,i),h_(t,e,r,i,n);case 3:e:{if(kI(e),t===null)throw Error(Z(387));r=e.pendingProps,s=e.memoizedState,i=s.element,GS(t,e),nd(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=La(Error(Z(423)),e),e=p_(t,e,r,n,i);break e}else if(r!==i){i=La(Error(Z(424)),e),e=p_(t,e,r,n,i);break e}else for(Gn=Ss(e.stateNode.containerInfo.firstChild),Xn=e,gt=!0,kr=null,n=eI(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Na(),r===i){e=ji(t,e,n);break e}dn(t,e,r,n)}e=e.child}return e;case 5:return tI(e),t===null&&sy(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,ey(r,i)?o=null:s!==null&&ey(r,s)&&(e.flags|=32),OI(t,e),dn(t,e,o,n),e.child;case 6:return t===null&&sy(e),null;case 13:return DI(t,e,n);case 4:return Qv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Ba(e,null,r,n):dn(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ir(r,i),f_(t,e,r,i,n);case 7:return dn(t,e,e.pendingProps,n),e.child;case 8:return dn(t,e,e.pendingProps.children,n),e.child;case 12:return dn(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,ut(ed,r._currentValue),r._currentValue=o,s!==null)if(Rr(s.value,o)){if(s.children===i.children&&!Dn.current){e=ji(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var a=s.dependencies;if(a!==null){o=s.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(s.tag===1){l=Ri(-1,n&-n),l.tag=2;var f=s.updateQueue;if(f!==null){f=f.shared;var h=f.pending;h===null?l.next=l:(l.next=h.next,h.next=l),f.pending=l}}s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),oy(s.return,n,e),a.lanes|=n;break}l=l.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(Z(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),oy(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}dn(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,ka(e,n),i=gr(i),r=r(i),e.flags|=1,dn(t,e,r,n),e.child;case 14:return r=e.type,i=Ir(r,e.pendingProps),i=Ir(r.type,i),d_(t,e,r,i,n);case 15:return II(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ir(r,i),If(t,e),e.tag=1,xn(r)?(t=!0,Jf(e)):t=!1,ka(e,n),XS(e,r,i),uy(e,r,i,n),fy(null,e,r,!0,t,n);case 19:return xI(t,e,n);case 22:return EI(t,e,n)}throw Error(Z(156,e.tag))};function KI(t,e){return yS(t,e)}function vP(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function yr(t,e,n,r){return new vP(t,e,n,r)}function lg(t){return t=t.prototype,!(!t||!t.isReactComponent)}function gP(t){if(typeof t=="function")return lg(t)?1:0;if(t!=null){if(t=t.$$typeof,t===xv)return 11;if(t===Cv)return 14}return 2}function ks(t,e){var n=t.alternate;return n===null?(n=yr(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function kf(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")lg(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ca:return Io(n.children,i,s,e);case Dv:o=8,i|=8;break;case Rm:return t=yr(12,n,e,i|2),t.elementType=Rm,t.lanes=s,t;case Tm:return t=yr(13,n,e,i),t.elementType=Tm,t.lanes=s,t;case Mm:return t=yr(19,n,e,i),t.elementType=Mm,t.lanes=s,t;case Z1:return mh(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case J1:o=10;break e;case X1:o=9;break e;case xv:o=11;break e;case Cv:o=14;break e;case us:o=16,r=null;break e}throw Error(Z(130,t==null?t:typeof t,""))}return e=yr(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function Io(t,e,n,r){return t=yr(7,t,r,e),t.lanes=n,t}function mh(t,e,n,r){return t=yr(22,t,r,e),t.elementType=Z1,t.lanes=n,t.stateNode={isHidden:!1},t}function Gp(t,e,n){return t=yr(6,t,null,e),t.lanes=n,t}function Jp(t,e,n){return e=yr(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function wP(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Pp(0),this.expirationTimes=Pp(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Pp(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function cg(t,e,n,r,i,s,o,a,l){return t=new wP(t,e,n,a,l),e===1?(e=1,s===!0&&(e|=8)):e=0,s=yr(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Hv(s),t}function _P(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(QI)}catch(t){console.error(t)}}QI(),q1.exports=rr;var OP=q1.exports,YI,k_=OP;YI=k_.createRoot,k_.hydrateRoot;var Iy=function(t,e){return Iy=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(n[i]=r[i])},Iy(t,e)};function pi(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Iy(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function tt(t,e,n,r){var i=arguments.length,s=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,n):r,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}function re(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ve(t,e,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function a(h){try{f(r.next(h))}catch(m){o(m)}}function l(h){try{f(r.throw(h))}catch(m){o(m)}}function f(h){h.done?s(h.value):i(h.value).then(a,l)}f((r=r.apply(t,e||[])).next())})}function GI(t,e){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(f){return function(h){return l([f,h])}}function l(f){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,f[0]&&(n=0)),n;)try{if(r=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return n.label++,{value:f[1],done:!1};case 5:n.label++,i=f[1],f=[0];continue;case 7:f=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){n=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Tr(t,e){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var r=n.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=r.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return s}function ci(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r1||a(y,w)})})}function a(y,w){try{l(r[y](w))}catch(I){m(s[0][3],I)}}function l(y){y.value instanceof ge?Promise.resolve(y.value.v).then(f,h):m(s[0][2],y)}function f(y){a("next",y)}function h(y){a("throw",y)}function m(y,w){y(w),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Df(t){var e,n;return e={},r("next"),r("throw",function(i){throw i}),r("return"),e[Symbol.iterator]=function(){return this},e;function r(i,s){e[i]=t[i]?function(o){return(n=!n)?{value:ge(t[i](o)),done:!1}:s?s(o):o}:s}}function Ds(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],n;return e?e.call(t):(t=typeof ja=="function"?ja(t):t[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(s){n[s]=t[s]&&function(o){return new Promise(function(a,l){o=t[s](o),i(a,l,o.done,o.value)})}}function i(s,o,a,l){Promise.resolve(l).then(function(f){s({value:f,done:a})},o)}}function kl(t){"@babel/helpers - typeof";return kl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},kl(t)}function kP(t,e){if(kl(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e||"default");if(kl(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function DP(t){var e=kP(t,"string");return kl(e)=="symbol"?e:String(e)}function D_(t,e){for(var n=0;nr[t]:r=>{for(var i=r,s=0;s"u")return i}return i}}function $e(t){return Object.assign({},t)}function PP(t){return Object.keys(t)[0]}function fd(t,e=!1){if(!t)return t;if(!e&&Array.isArray(t))return t.sort((r,i)=>typeof r=="string"&&typeof i=="string"?r.localeCompare(i):typeof r=="object"?1:-1).map(r=>fd(r,e));if(typeof t=="object"&&!Array.isArray(t)){var n={};return Object.keys(t).sort((r,i)=>r.localeCompare(i)).forEach(r=>{n[r]=fd(t[r],e)}),n}return t}function Ey(t){if(!t||t===null||typeof t!="object")return t;if(Array.isArray(t)){for(var e=new Array(t.length),n=e.length;n--;)e[n]=Ey(t[n]);return e}var r={};for(var i in t)r[i]=Ey(t[i]);return r}var Pn=Ey;function xs(t,e,n){return Object.defineProperty(t,e,{get:function(){return n}}),n}var mg=1;function Ks(){return{lwt:mg}}function Rn(){return""}function RP(t){return Object.assign({},t,{_meta:void 0,_deleted:void 0,_rev:void 0})}function TP(t,e,n){if(e.length!==n.length)return!1;for(var r=0,i=e.length;r>>2]>>>24-n%4*8&255;this.words[this.sigBytes+n>>>2]|=r<<24-(this.sigBytes+n)%4*8}else for(let n=0;n>>2]=e.words[n>>>2];return this.sigBytes+=e.sigBytes,this}clamp(){this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4)}clone(){return new Cs([...this.words])}}const MP={stringify(t){const e=[];for(let n=0;n>>2]>>>24-n%4*8&255;e.push((r>>>4).toString(16),(r&15).toString(16))}return e.join("")}},NP={parse(t){const e=t.length,n=[];for(let r=0;r>>2]|=(t.charCodeAt(r)&255)<<24-r%4*8;return new Cs(n,e)}},BP={parse(t){return NP.parse(unescape(encodeURIComponent(t)))}};class FP{constructor(){this._data=new Cs,this._nDataBytes=0,this._minBufferSize=0,this.blockSize=512/32}reset(){this._data=new Cs,this._nDataBytes=0}_append(e){typeof e=="string"&&(e=BP.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes}_doProcessBlock(e,n){}_process(e){let n,r=this._data.sigBytes/(this.blockSize*4);e?r=Math.ceil(r):r=Math.max((r|0)-this._minBufferSize,0);const i=r*this.blockSize,s=Math.min(i*4,this._data.sigBytes);if(i){for(let o=0;o>>7)^(O<<14|O>>>18)^O>>>3,W=so[y-2],Q=(W<<15|W>>>17)^(W<<13|W>>>19)^W>>>10;so[y]=z+so[y-7]+Q+so[y-16]}const w=l&f^~l&h,I=i&s^i&o^s&o,E=(i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22),$=(l<<26|l>>>6)^(l<<21|l>>>11)^(l<<7|l>>>25),S=m+$+w+$P[y]+so[y],_=E+I;m=h,h=f,f=l,l=a+S|0,a=o,o=s,s=i,i=S+_|0}r[0]=r[0]+i|0,r[1]=r[1]+s|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+l|0,r[5]=r[5]+f|0,r[6]=r[6]+h|0,r[7]=r[7]+m|0}finalize(e){super.finalize(e);const n=this._nDataBytes*8,r=this._data.sigBytes*8;return this._data.words[r>>>5]|=128<<24-r%32,this._data.words[(r+64>>>9<<4)+14]=Math.floor(n/4294967296),this._data.words[(r+64>>>9<<4)+15]=n,this._data.sigBytes=this._data.words.length*4,this._process(),this._hash}}function UP(t){return new jP().finalize(t).toString()}function zP(t){return Promise.resolve(UP(t))}async function VP(t){var e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),r=Array.prototype.map.call(new Uint8Array(n),i=>("00"+i.toString(16)).slice(-2)).join("");return r}var KP=typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof crypto.subtle.digest=="function",WP=KP?VP:zP;function qP(){return new Promise(t=>setTimeout(t,0))}function HP(t=0){return new Promise(e=>setTimeout(e,t))}function ZI(t){return t&&typeof t.then=="function"?t:Promise.resolve(t)}var dd=Promise.resolve(!0),Jn=Promise.resolve(!1),yg=Promise.resolve(null),un=Promise.resolve();function vg(t=1e4){return typeof requestIdleCallback=="function"?new Promise(e=>{requestIdleCallback(()=>e(),{timeout:t})}):HP(0)}var Zp=un;function QP(t=void 0){return Zp=Zp.then(()=>vg(t)),Zp}function YP(t,e){return t.reduce((n,r)=>n.then(r),Promise.resolve(e))}var GP=/\./g,A_="abcdefghijklmnopqrstuvwxyz";function su(t=10){for(var e="",n=0;n{var e=typeof t;return t!==null&&(e==="object"||e==="function")},em=new Set(["__proto__","prototype","constructor"]),JP=new Set("0123456789");function tE(t){var e=[],n="",r="start",i=!1;for(var s of t)switch(s){case"\\":{if(r==="index")throw new Error("Invalid character in an index");if(r==="indexEnd")throw new Error("Invalid character after an index");i&&(n+=s),r="property",i=!i;break}case".":{if(r==="index")throw new Error("Invalid character in an index");if(r==="indexEnd"){r="property";break}if(i){i=!1,n+=s;break}if(em.has(n))return[];e.push(n),n="",r="property";break}case"[":{if(r==="index")throw new Error("Invalid character in an index");if(r==="indexEnd"){r="index";break}if(i){i=!1,n+=s;break}if(r==="property"){if(em.has(n))return[];e.push(n),n=""}r="index";break}case"]":{if(r==="index"){e.push(Number.parseInt(n,10)),n="",r="indexEnd";break}if(r==="indexEnd")throw new Error("Invalid character after an index")}default:{if(r==="index"&&!JP.has(s))throw new Error("Invalid character in an index");if(r==="indexEnd")throw new Error("Invalid character after an index");r==="start"&&(r="property"),i&&(i=!1,n+="\\"),n+=s}}switch(i&&(n+="\\"),r){case"property":{if(em.has(n))return[];e.push(n);break}case"index":throw new Error("Index was not closed");case"start":{e.push("");break}}return e}function nE(t,e){if(typeof e!="number"&&Array.isArray(t)){var n=Number.parseInt(e,10);return Number.isInteger(n)&&t[n]===t[e]}return!1}function XP(t,e){if(nE(t,e))throw new Error("Cannot use string index")}function Ts(t,e,n){if(Array.isArray(e)&&(e=e.join(".")),!e.includes(".")&&!e.includes("["))return t[e];if(!Oy(t)||typeof e!="string")return n===void 0?t:n;var r=tE(e);if(r.length===0)return n;for(var i=0;i"u")throw new Error("missing value from map "+e);return n}function Mr(t,e,n,r){var i=t.get(e);return typeof i>"u"?(i=n(),t.set(e,i)):r&&r(i),i}function pt(t){var e=t.split("-"),n="RxDB";return e.forEach(r=>{n+=eE(r)}),n+="Plugin",new Error(`You are using a function which must be overwritten by a plugin. You should either prevent the usage of this function or add the plugin via: import { `+n+" } from 'rxdb/plugins/"+t+`'; addRxPlugin(`+n+`); - `)}function Oy(t){var e={name:t.name,message:t.message,rxdb:t.rxdb,parameters:t.parameters,code:t.code,stack:t.stack?t.stack.replace(/\n/g,` - `):void 0};return e}var tm=0;function Ft(){var t=Date.now();t=t+.01,t<=tm&&(t=tm+.01);var e=parseFloat(t.toFixed(2));return tm=e,e}function ye(t,e){if(!t)throw e||(e=""),new Error("ensureNotFalsy() is falsy: "+e);return t}var Ci={bufferSize:1,refCount:!0},vg="15.9.1";function Dl(t,e){return Dl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Dl(t,e)}function gg(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,Dl(t,e)}function ky(t){return ky=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ky(t)}function XP(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch{return typeof t=="function"}}function rE(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(rE=function(){return!!t})()}function ZP(t,e,n){if(rE())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&Dl(i,n.prototype),i}function hd(t){var e=typeof Map=="function"?new Map:void 0;return hd=function(r){if(r===null||!XP(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return ZP(r,arguments,ky(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Dl(i,r)},hd(t)}var it={isDevMode(){return!1},deepFreezeWhenDevMode(t){return t},tunnelErrorMessage(t){return"RxDB Error-Code "+t+`. + `)}function ky(t){var e={name:t.name,message:t.message,rxdb:t.rxdb,parameters:t.parameters,code:t.code,stack:t.stack?t.stack.replace(/\n/g,` + `):void 0};return e}var tm=0;function Ft(){var t=Date.now();t=t+.01,t<=tm&&(t=tm+.01);var e=parseFloat(t.toFixed(2));return tm=e,e}function ye(t,e){if(!t)throw e||(e=""),new Error("ensureNotFalsy() is falsy: "+e);return t}var Ai={bufferSize:1,refCount:!0},gg="15.9.1";function Dl(t,e){return Dl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Dl(t,e)}function wg(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,Dl(t,e)}function Dy(t){return Dy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Dy(t)}function ZP(t){try{return Function.toString.call(t).indexOf("[native code]")!==-1}catch{return typeof t=="function"}}function iE(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(iE=function(){return!!t})()}function eR(t,e,n){if(iE())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&Dl(i,n.prototype),i}function hd(t){var e=typeof Map=="function"?new Map:void 0;return hd=function(r){if(r===null||!ZP(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(typeof e<"u"){if(e.has(r))return e.get(r);e.set(r,i)}function i(){return eR(r,arguments,Dy(this).constructor)}return i.prototype=Object.create(r.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),Dl(i,r)},hd(t)}var it={isDevMode(){return!1},deepFreezeWhenDevMode(t){return t},tunnelErrorMessage(t){return"RxDB Error-Code "+t+`. Error messages are not included in RxDB core to reduce build size. - To find out what this error means, either use the dev-mode-plugin https://rxdb.info/dev-mode.html - or search for the error code here: https://github.com/pubkey/rxdb/search?q=`+t+` - `}};function eR(t){var e="";return Object.keys(t).length===0||(e+=`Given parameters: { + `}};function tR(t){var e="";return Object.keys(t).length===0||(e+=`Given parameters: { `,e+=Object.keys(t).map(n=>{var r="[object Object]";try{n==="errors"?r=t[n].map(i=>JSON.stringify(i,Object.getOwnPropertyNames(i))):r=JSON.stringify(t[n],function(i,s){return s===void 0?null:s},2)}catch{}return n+":"+r}).join(` -`),e+="}"),e}function iE(t,e,n){return"RxError ("+e+`): +`),e+="}"),e}function sE(t,e,n){return"RxError ("+e+`): `+t+` -`+eR(n)}var tR=function(t){gg(e,t);function e(r,i,s={}){var o,a=iE(i,r,s);return o=t.call(this,a)||this,o.code=r,o.message=a,o.parameters=s,o.rxdb=!0,o}var n=e.prototype;return n.toString=function(){return this.message},Vs(e,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),e}(hd(Error)),nR=function(t){gg(e,t);function e(r,i,s={}){var o,a=iE(i,r,s);return o=t.call(this,a)||this,o.code=r,o.message=a,o.parameters=s,o.rxdb=!0,o}var n=e.prototype;return n.toString=function(){return this.message},Vs(e,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),e}(hd(TypeError));function le(t,e){return new tR(t,it.tunnelErrorMessage(t),e)}function el(t,e){return new nR(t,it.tunnelErrorMessage(t),e)}function _h(t){return t&&t.status===409?t:!1}var rR={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};function iR(t){return le("COL20",{name:rR[t.status],document:t.documentId,writeError:t})}var xl={preAddRxPlugin:[],preCreateRxDatabase:[],createRxDatabase:[],preCreateRxCollection:[],createRxCollection:[],postDestroyRxCollection:[],postRemoveRxCollection:[],preCreateRxSchema:[],createRxSchema:[],preCreateRxQuery:[],prePrepareQuery:[],createRxDocument:[],postCreateRxDocument:[],preCreateRxStorageInstance:[],preMigrateDocument:[],postMigrateDocument:[],preDestroyRxDatabase:[],postRemoveRxDatabase:[],preReplicationMasterWrite:[],preReplicationMasterWriteDocumentsHandle:[]};function Mr(t,e){xl[t]&&xl[t].forEach(n=>n(e))}function No(t,e){return Promise.all(xl[t].map(n=>n(e)))}function zi(t,e){var n=e;n=n.replace(YP,".properties."),n="properties."+n,n=zu(n);var r=Ts(t,n);return r}function sE(t,e,n){if(typeof e.primaryKey=="string")return n;var r=Ws(e,n),i=n[t];if(i&&i!==r)throw le("DOC19",{args:{documentData:n,existingPrimary:i,newPrimary:r},schema:e});return n[t]=r,n}function Fn(t){return typeof t=="string"?t:t.key}function sR(t){var e=Fn(t.primaryKey),n=zi(t,e);return ye(n.maxLength)}function Ws(t,e){if(typeof t.primaryKey=="string")return e[t.primaryKey];var n=t.primaryKey;return n.fields.map(r=>{var i=Ts(e,r);if(typeof i>"u")throw le("DOC18",{args:{field:r,documentData:e}});return i}).join(n.separator)}function oR(t){var e=fd(t,!0);return e}function aR(t){return["_deleted",t]}function bh(t){t=$e(t);var e=Fn(t.primaryKey);t.properties=$e(t.properties),t.additionalProperties=!1,Object.prototype.hasOwnProperty.call(t,"keyCompression")||(t.keyCompression=!1),t.indexes=t.indexes?t.indexes.slice(0):[],t.required=t.required?t.required.slice(0):[],t.encrypted=t.encrypted?t.encrypted.slice(0):[],t.properties._rev={type:"string",minLength:1},t.properties._attachments={type:"object"},t.properties._deleted={type:"boolean"},t.properties._meta=uR,t.required=t.required?t.required.slice(0):[],t.required.push("_deleted"),t.required.push("_rev"),t.required.push("_meta"),t.required.push("_attachments");var n=oE(t);Ua(t.required,n),t.required=t.required.filter(s=>!s.includes(".")).filter((s,o,a)=>a.indexOf(s)===o),t.version=t.version||0;var r=t.indexes.map(s=>{var o=hg(s)?s.slice(0):[s];return o.includes(e)||o.push(e),o[0]!=="_deleted"&&o.unshift("_deleted"),o});r.length===0&&r.push(aR(e)),r.push(["_meta.lwt",e]),t.internalIndexes&&t.internalIndexes.map(s=>{r.push(s)});var i=new Set;return r.filter(s=>{var o=s.join(",");return i.has(o)?!1:(i.add(o),!0)}),t.indexes=r,t}var uR={type:"object",properties:{lwt:{type:"number",minimum:pg,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function oE(t){var e=Object.keys(t.properties).filter(r=>t.properties[r].final),n=Fn(t.primaryKey);return e.push(n),typeof t.primaryKey!="string"&&t.primaryKey.fields.forEach(r=>e.push(r)),e}function lR(t,e){for(var n=Object.keys(t.defaultValues),r=0;r"u")&&(e[i]=t.defaultValues[i])}return e}var aE=function(){function t(n,r){this.jsonSchema=n,this.hashFunction=r,this.indexes=cR(this.jsonSchema),this.primaryPath=Fn(this.jsonSchema.primaryKey),this.finalFields=oE(this.jsonSchema)}var e=t.prototype;return e.validateChange=function(r,i){this.finalFields.forEach(s=>{if(!Va(r[s],i[s]))throw le("DOC9",{dataBefore:r,dataAfter:i,fieldName:s,schema:this.jsonSchema})})},e.getDocumentPrototype=function(){var r={},i=zi(this.jsonSchema,"");return Object.keys(i).forEach(s=>{var o=s;r.__defineGetter__(s,function(){if(!(!this.get||typeof this.get!="function")){var a=this.get(o);return a}}),Object.defineProperty(r,s+"$",{get:function(){return this.get$(o)},enumerable:!1,configurable:!1}),Object.defineProperty(r,s+"$$",{get:function(){return this.get$$(o)},enumerable:!1,configurable:!1}),Object.defineProperty(r,s+"_",{get:function(){return this.populate(o)},enumerable:!1,configurable:!1})}),xs(this,"getDocumentPrototype",()=>r),r},e.getPrimaryOfDocumentData=function(r){return Ws(this.jsonSchema,r)},Vs(t,[{key:"version",get:function(){return this.jsonSchema.version}},{key:"defaultValues",get:function(){var n={};return Object.entries(this.jsonSchema.properties).filter(([,r])=>Object.prototype.hasOwnProperty.call(r,"default")).forEach(([r,i])=>n[r]=i.default),xs(this,"defaultValues",n)}},{key:"hash",get:function(){return xs(this,"hash",this.hashFunction(JSON.stringify(this.jsonSchema)))}}]),t}();function cR(t){return(t.indexes||[]).map(e=>hg(e)?e:[e])}function fR(t){var e=t.version?t.version:0,n=0;return new Array(e).fill(0).map(()=>n++)}function dR(t,e,n=!0){n&&Mr("preCreateRxSchema",t);var r=bh(t);r=oR(r),it.deepFreezeWhenDevMode(r);var i=new aE(r,e);return Mr("createRxSchema",i),i}function qe(t){return typeof t=="function"}function hR(t){return qe(t==null?void 0:t.lift)}function Ln(t){return function(e){if(hR(e))return e.lift(function(n){try{return t(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}var wg=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function uE(t){return qe(t==null?void 0:t.then)}function _g(t){var e=function(r){Error.call(r),r.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var nm=_g(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription: +`+tR(n)}var nR=function(t){wg(e,t);function e(r,i,s={}){var o,a=sE(i,r,s);return o=t.call(this,a)||this,o.code=r,o.message=a,o.parameters=s,o.rxdb=!0,o}var n=e.prototype;return n.toString=function(){return this.message},Vs(e,[{key:"name",get:function(){return"RxError ("+this.code+")"}},{key:"typeError",get:function(){return!1}}]),e}(hd(Error)),rR=function(t){wg(e,t);function e(r,i,s={}){var o,a=sE(i,r,s);return o=t.call(this,a)||this,o.code=r,o.message=a,o.parameters=s,o.rxdb=!0,o}var n=e.prototype;return n.toString=function(){return this.message},Vs(e,[{key:"name",get:function(){return"RxTypeError ("+this.code+")"}},{key:"typeError",get:function(){return!0}}]),e}(hd(TypeError));function le(t,e){return new nR(t,it.tunnelErrorMessage(t),e)}function el(t,e){return new rR(t,it.tunnelErrorMessage(t),e)}function _h(t){return t&&t.status===409?t:!1}var iR={409:"document write conflict",422:"schema validation error",510:"attachment data missing"};function sR(t){return le("COL20",{name:iR[t.status],document:t.documentId,writeError:t})}var xl={preAddRxPlugin:[],preCreateRxDatabase:[],createRxDatabase:[],preCreateRxCollection:[],createRxCollection:[],postDestroyRxCollection:[],postRemoveRxCollection:[],preCreateRxSchema:[],createRxSchema:[],preCreateRxQuery:[],prePrepareQuery:[],createRxDocument:[],postCreateRxDocument:[],preCreateRxStorageInstance:[],preMigrateDocument:[],postMigrateDocument:[],preDestroyRxDatabase:[],postRemoveRxDatabase:[],preReplicationMasterWrite:[],preReplicationMasterWriteDocumentsHandle:[]};function Nr(t,e){xl[t]&&xl[t].forEach(n=>n(e))}function No(t,e){return Promise.all(xl[t].map(n=>n(e)))}function zi(t,e){var n=e;n=n.replace(GP,".properties."),n="properties."+n,n=zu(n);var r=Ts(t,n);return r}function oE(t,e,n){if(typeof e.primaryKey=="string")return n;var r=Ws(e,n),i=n[t];if(i&&i!==r)throw le("DOC19",{args:{documentData:n,existingPrimary:i,newPrimary:r},schema:e});return n[t]=r,n}function Fn(t){return typeof t=="string"?t:t.key}function oR(t){var e=Fn(t.primaryKey),n=zi(t,e);return ye(n.maxLength)}function Ws(t,e){if(typeof t.primaryKey=="string")return e[t.primaryKey];var n=t.primaryKey;return n.fields.map(r=>{var i=Ts(e,r);if(typeof i>"u")throw le("DOC18",{args:{field:r,documentData:e}});return i}).join(n.separator)}function aR(t){var e=fd(t,!0);return e}function uR(t){return["_deleted",t]}function bh(t){t=$e(t);var e=Fn(t.primaryKey);t.properties=$e(t.properties),t.additionalProperties=!1,Object.prototype.hasOwnProperty.call(t,"keyCompression")||(t.keyCompression=!1),t.indexes=t.indexes?t.indexes.slice(0):[],t.required=t.required?t.required.slice(0):[],t.encrypted=t.encrypted?t.encrypted.slice(0):[],t.properties._rev={type:"string",minLength:1},t.properties._attachments={type:"object"},t.properties._deleted={type:"boolean"},t.properties._meta=lR,t.required=t.required?t.required.slice(0):[],t.required.push("_deleted"),t.required.push("_rev"),t.required.push("_meta"),t.required.push("_attachments");var n=aE(t);za(t.required,n),t.required=t.required.filter(s=>!s.includes(".")).filter((s,o,a)=>a.indexOf(s)===o),t.version=t.version||0;var r=t.indexes.map(s=>{var o=pg(s)?s.slice(0):[s];return o.includes(e)||o.push(e),o[0]!=="_deleted"&&o.unshift("_deleted"),o});r.length===0&&r.push(uR(e)),r.push(["_meta.lwt",e]),t.internalIndexes&&t.internalIndexes.map(s=>{r.push(s)});var i=new Set;return r.filter(s=>{var o=s.join(",");return i.has(o)?!1:(i.add(o),!0)}),t.indexes=r,t}var lR={type:"object",properties:{lwt:{type:"number",minimum:mg,maximum:1e15,multipleOf:.01}},additionalProperties:!0,required:["lwt"]};function aE(t){var e=Object.keys(t.properties).filter(r=>t.properties[r].final),n=Fn(t.primaryKey);return e.push(n),typeof t.primaryKey!="string"&&t.primaryKey.fields.forEach(r=>e.push(r)),e}function cR(t,e){for(var n=Object.keys(t.defaultValues),r=0;r"u")&&(e[i]=t.defaultValues[i])}return e}var uE=function(){function t(n,r){this.jsonSchema=n,this.hashFunction=r,this.indexes=fR(this.jsonSchema),this.primaryPath=Fn(this.jsonSchema.primaryKey),this.finalFields=aE(this.jsonSchema)}var e=t.prototype;return e.validateChange=function(r,i){this.finalFields.forEach(s=>{if(!Ka(r[s],i[s]))throw le("DOC9",{dataBefore:r,dataAfter:i,fieldName:s,schema:this.jsonSchema})})},e.getDocumentPrototype=function(){var r={},i=zi(this.jsonSchema,"");return Object.keys(i).forEach(s=>{var o=s;r.__defineGetter__(s,function(){if(!(!this.get||typeof this.get!="function")){var a=this.get(o);return a}}),Object.defineProperty(r,s+"$",{get:function(){return this.get$(o)},enumerable:!1,configurable:!1}),Object.defineProperty(r,s+"$$",{get:function(){return this.get$$(o)},enumerable:!1,configurable:!1}),Object.defineProperty(r,s+"_",{get:function(){return this.populate(o)},enumerable:!1,configurable:!1})}),xs(this,"getDocumentPrototype",()=>r),r},e.getPrimaryOfDocumentData=function(r){return Ws(this.jsonSchema,r)},Vs(t,[{key:"version",get:function(){return this.jsonSchema.version}},{key:"defaultValues",get:function(){var n={};return Object.entries(this.jsonSchema.properties).filter(([,r])=>Object.prototype.hasOwnProperty.call(r,"default")).forEach(([r,i])=>n[r]=i.default),xs(this,"defaultValues",n)}},{key:"hash",get:function(){return xs(this,"hash",this.hashFunction(JSON.stringify(this.jsonSchema)))}}]),t}();function fR(t){return(t.indexes||[]).map(e=>pg(e)?e:[e])}function dR(t){var e=t.version?t.version:0,n=0;return new Array(e).fill(0).map(()=>n++)}function hR(t,e,n=!0){n&&Nr("preCreateRxSchema",t);var r=bh(t);r=aR(r),it.deepFreezeWhenDevMode(r);var i=new uE(r,e);return Nr("createRxSchema",i),i}function qe(t){return typeof t=="function"}function pR(t){return qe(t==null?void 0:t.lift)}function Ln(t){return function(e){if(pR(e))return e.lift(function(n){try{return t(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}var _g=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function lE(t){return qe(t==null?void 0:t.then)}function bg(t){var e=function(r){Error.call(r),r.stack=new Error().stack},n=t(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var nm=bg(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription: `+n.map(function(r,i){return i+1+") "+r.toString()}).join(` - `):"",this.name="UnsubscriptionError",this.errors=n}});function pd(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var su=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=$a(o),l=a.next();!l.done;l=a.next()){var f=l.value;f.remove(this)}}catch(E){e={error:E}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else o.remove(this);var h=this.initialTeardown;if(qe(h))try{h()}catch(E){s=E instanceof nm?E.errors:[E]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var y=$a(m),w=y.next();!w.done;w=y.next()){var I=w.value;try{C_(I)}catch(E){s=s??[],E instanceof nm?s=ci(ci([],Rr(s)),Rr(E.errors)):s.push(E)}}}catch(E){r={error:E}}finally{try{w&&!w.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}}if(s)throw new nm(s)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)C_(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&pd(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&pd(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),lE=su.EMPTY;function cE(t){return t instanceof su||t&&"closed"in t&&qe(t.remove)&&qe(t.add)&&qe(t.unsubscribe)}function C_(t){qe(t)?t():t.unsubscribe()}var fE={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Dy={setTimeout:function(t,e){for(var n=[],r=2;r0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var r=this,i=this,s=i.hasError,o=i.isStopped,a=i.observers;return s||o?lE:(this.currentObservers=null,a.push(n),new su(function(){r.currentObservers=null,pd(a,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},e.prototype.asObservable=function(){var n=new Ot;return n.source=this,n},e.create=function(n,r){return new N_(n,r)},e}(Ot),N_=function(t){pi(e,t);function e(n,r){var i=t.call(this)||this;return i.destination=n,i.source=r,i}return e.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},e.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,n)},e.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},e.prototype._subscribe=function(n){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:lE},e}(Kt);function B_(){for(var t=[],e=0;e0&&(h=new Ka({next:function(Q){return W.next(Q)},error:function(Q){E=!0,F(),m=sm(S,i,Q),W.error(Q)},complete:function(){I=!0,F(),m=sm(S,o),W.complete()}}),ir(k).subscribe(h))})(f)}}function sm(t,e){for(var n=[],r=2;r!!t.queryParams.limit,_T=t=>t.queryParams.limit===1,bT=t=>!!(t.queryParams.skip&&t.queryParams.skip>0),ST=t=>t.changeEvent.operation==="DELETE",IT=t=>t.changeEvent.operation==="INSERT",ET=t=>t.changeEvent.operation==="UPDATE",OT=t=>ME(t)&&t.previousResults.length>=t.queryParams.limit,kT=t=>{const e=t.queryParams.sortFields,n=t.changeEvent.previous,r=t.changeEvent.doc;if(!r)return!1;if(!n)return!0;for(let i=0;i{const e=t.changeEvent.id;if(t.keyDocumentMap)return t.keyDocumentMap.has(e);{const n=t.queryParams.primaryKey,r=t.previousResults;for(let i=0;i{const e=t.previousResults[0];return!!(e&&e[t.queryParams.primaryKey]===t.changeEvent.id)},AT=t=>{const e=Dg(t.previousResults);return!!(e&&e[t.queryParams.primaryKey]===t.changeEvent.id)},CT=t=>{const e=t.changeEvent.previous;if(!e)return!1;const n=t.previousResults[0];return n?n[t.queryParams.primaryKey]===t.changeEvent.id?!0:t.queryParams.sortComparator(e,n)<0:!1},PT=t=>{const e=t.changeEvent.previous;if(!e)return!1;const n=Dg(t.previousResults);return n?n[t.queryParams.primaryKey]===t.changeEvent.id?!0:t.queryParams.sortComparator(e,n)>0:!1},RT=t=>{const e=t.changeEvent.doc;if(!e)return!1;const n=t.previousResults[0];return n?n[t.queryParams.primaryKey]===t.changeEvent.id?!0:t.queryParams.sortComparator(e,n)<0:!1},TT=t=>{const e=t.changeEvent.doc;if(!e)return!1;const n=Dg(t.previousResults);return n?n[t.queryParams.primaryKey]===t.changeEvent.id?!0:t.queryParams.sortComparator(e,n)>0:!1},MT=t=>{const e=t.changeEvent.previous;return e?t.queryParams.queryMatcher(e):!1},NT=t=>{const e=t.changeEvent.doc;return e?t.queryParams.queryMatcher(e):!1},BT=t=>t.previousResults.length===0,FT={0:IT,1:ET,2:ST,3:ME,4:_T,5:bT,6:BT,7:OT,8:xT,9:AT,10:kT,11:DT,12:CT,13:PT,14:RT,15:TT,16:MT,17:NT};function NE(t,e,n,r){var i=t.length,s=i-1,o=0;if(i===0)return t.push(e),0;for(var a;r<=s;)o=r+(s-r>>1),a=t[o],n(a,e)<=0?r=o+1:s=o-1;return n(a,e)<=0&&o++,t.splice(o,0,e),o}const LT=t=>{},xg=t=>{t.previousResults.unshift(t.changeEvent.doc),t.keyDocumentMap&&t.keyDocumentMap.set(t.changeEvent.id,t.changeEvent.doc)},Ag=t=>{t.previousResults.push(t.changeEvent.doc),t.keyDocumentMap&&t.keyDocumentMap.set(t.changeEvent.id,t.changeEvent.doc)},Cg=t=>{const e=t.previousResults.shift();t.keyDocumentMap&&e&&t.keyDocumentMap.delete(e[t.queryParams.primaryKey])},Pg=t=>{const e=t.previousResults.pop();t.keyDocumentMap&&e&&t.keyDocumentMap.delete(e[t.queryParams.primaryKey])},$T=t=>{Cg(t),Ag(t)},jT=t=>{Pg(t),xg(t)},UT=t=>{Cg(t),xg(t)},zT=t=>{Pg(t),Ag(t)},BE=t=>{t.keyDocumentMap&&t.keyDocumentMap.delete(t.changeEvent.id);const e=t.queryParams.primaryKey,n=t.previousResults;for(let r=0;r{const e=t.changeEvent.doc,n=t.queryParams.primaryKey,r=t.previousResults;for(let i=0;i{const e={_id:"wrongHuman"+new Date().getTime()};t.previousResults.length=0,t.previousResults.push(e),t.keyDocumentMap&&(t.keyDocumentMap.clear(),t.keyDocumentMap.set(e._id,e))},FE=t=>{const e=t.changeEvent.id,n=t.changeEvent.doc;if(t.keyDocumentMap){if(t.keyDocumentMap.has(e))return;t.keyDocumentMap.set(e,n)}else if(t.previousResults.find(i=>i[t.queryParams.primaryKey]===e))return;NE(t.previousResults,n,t.queryParams.sortComparator,0)},WT=t=>{BE(t),FE(t)},qT=t=>{throw new Error("Action runFullQueryAgain must be implemented by yourself")},HT=t=>{throw new Error("Action unknownAction should never be called")},QT=["doNothing","insertFirst","insertLast","removeFirstItem","removeLastItem","removeFirstInsertLast","removeLastInsertFirst","removeFirstInsertFirst","removeLastInsertLast","removeExisting","replaceExisting","alwaysWrong","insertAtSortPosition","removeExistingAndInsertAtSortPosition","runFullQueryAgain","unknownAction"],YT={doNothing:LT,insertFirst:xg,insertLast:Ag,removeFirstItem:Cg,removeLastItem:Pg,removeFirstInsertLast:$T,removeLastInsertFirst:jT,removeFirstInsertFirst:UT,removeLastInsertLast:zT,removeExisting:BE,replaceExisting:VT,alwaysWrong:KT,insertAtSortPosition:FE,removeExistingAndInsertAtSortPosition:WT,runFullQueryAgain:qT,unknownAction:HT},GT=40;function om(t){return t.charCodeAt(0)-GT}function JT(t){return t?"1":"0"}function $_(t,e){const n=[];for(let r=0,i=t.length;rZT(tM(),FT,t);function rM(t){const e=nM(t);return QT[e]}function iM(t,e,n,r,i){const s=YT[t];return s({queryParams:e,changeEvent:n,previousResults:r,keyDocumentMap:i}),r}var Ar=String.fromCharCode(65535),li=Number.MIN_SAFE_INTEGER;function sM(t,e){var n=e.selector,r=t.indexes?t.indexes.slice(0):[];e.index&&(r=[e.index]);var i=!!e.sort.find(h=>Object.values(h)[0]==="desc"),s=new Set;Object.keys(n).forEach(h=>{var m=zi(t,h);m&&m.type==="boolean"&&Object.prototype.hasOwnProperty.call(n[h],"$eq")&&s.add(h)});var o=e.sort.map(h=>Object.keys(h)[0]),a=o.filter(h=>!s.has(h)).join(","),l=-1,f;if(r.forEach(h=>{var m=!0,y=!0,w=h.map(_=>{var k=n[_],z=k?Object.keys(k):[],W={};if(!k||!z.length){var Q=y?li:Ar;W={startKey:Q,endKey:m?Ar:li,inclusiveStart:!0,inclusiveEnd:!0}}else z.forEach(H=>{if(Rg.has(H)){var X=k[H],U=lM(H,X);W=Object.assign(W,U)}});return typeof W.startKey>"u"&&(W.startKey=li),typeof W.endKey>"u"&&(W.endKey=Ar),typeof W.inclusiveStart>"u"&&(W.inclusiveStart=!0),typeof W.inclusiveEnd>"u"&&(W.inclusiveEnd=!0),y&&!W.inclusiveStart&&(y=!1),m&&!W.inclusiveEnd&&(m=!1),W}),I=w.map(_=>_.startKey),E=w.map(_=>_.endKey),F={index:h,startKeys:I,endKeys:E,inclusiveEnd:m,inclusiveStart:y,sortSatisfiedByIndex:!i&&a===h.filter(_=>!s.has(_)).join(","),selectorSatisfiedByIndex:uM(h,e.selector,I,E)},S=cM(t,e,F);(S>=l||e.index)&&(l=S,f=F)}),!f)throw le("SNH",{query:e});return f}var Rg=new Set(["$eq","$gt","$gte","$lt","$lte"]),oM=new Set(["$eq","$gt","$gte"]),aM=new Set(["$eq","$lt","$lte"]);function uM(t,e,n,r){var i=Object.entries(e),s=i.find(([H,X])=>{if(!t.includes(H))return!0;var U=Object.entries(X).find(([ee,ce])=>!Rg.has(ee));return U});if(s||e.$and||e.$or)return!1;var o=[],a=new Set;for(var[l,f]of Object.entries(e)){if(!t.includes(l))return!1;var h=Object.keys(f).filter(H=>oM.has(H));if(h.length>1)return!1;var m=h[0];if(m&&a.add(l),m!=="$eq"){if(o.length>0)return!1;o.push(m)}}var y=[],w=new Set;for(var[I,E]of Object.entries(e)){if(!t.includes(I))return!1;var F=Object.keys(E).filter(H=>aM.has(H));if(F.length>1)return!1;var S=F[0];if(S&&w.add(I),S!=="$eq"){if(y.length>0)return!1;y.push(S)}}var _=0;for(var k of t){for(var z of[a,w]){if(!z.has(k)&&z.size>0)return!1;z.delete(k)}var W=n[_],Q=r[_];if(W!==Q&&a.size>0&&w.size>0)return!1;_++}return!0}function lM(t,e){switch(t){case"$eq":return{startKey:e,endKey:e,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:e,inclusiveEnd:!0};case"$gte":return{startKey:e,inclusiveStart:!0};case"$lt":return{endKey:e,inclusiveEnd:!1};case"$gt":return{startKey:e,inclusiveStart:!1};default:throw new Error("SNH")}}function cM(t,e,n){var r=0,i=h=>{h>0&&(r=r+h)},s=10,o=Xp(n.startKeys,h=>h!==li&&h!==Ar);i(o*s);var a=Xp(n.startKeys,h=>h!==Ar&&h!==li);i(a*s);var l=Xp(n.startKeys,(h,m)=>h===n.endKeys[m]);i(l*s*1.5);var f=n.sortSatisfiedByIndex?5:0;return i(f),r}const fM=2147483647,dM=-2147483648,hM=Number.MAX_SAFE_INTEGER,pM=Number.MIN_SAFE_INTEGER,Vi=Symbol("missing"),LE=Object.freeze(new Error("mingo: cycle detected while processing object/array")),mM=Object.getPrototypeOf([]),$E=Object.getPrototypeOf({}),yM="[object Object]",vM=/^\[object ([a-zA-Z0-9]+)\]$/;let Tg=class{};class Mg{}const Fo=t=>t===null?Tg:t===void 0?Mg:t.constructor,Ql=t=>{const e=EM(t);let n=0,r=e.length;for(;r;)n=(n<<5)-n^e.charCodeAt(--r);return n>>>0},jE=new Set(["null","undefined","boolean","number","string","date","regexp"]),j_=new Set([Mg,Tg,Boolean,String,Number]),Nu=t=>t.toString(),br=t=>`${Fo(t).name}[${t.toString()}]`,Lo=new Map([[Number,Nu],[Boolean,Nu],[RegExp,Nu],[Function,Nu],[Symbol,Nu],[Date,t=>t.toISOString()],[String,JSON.stringify],[Tg,t=>"null"],[Mg,t=>"undefined"],[Int8Array,br],[Uint8Array,br],[Uint8ClampedArray,br],[Int16Array,br],[Uint16Array,br],[Int32Array,br],[Uint32Array,br],[Float32Array,br],[Float64Array,br]]);typeof BigInt<"u"&&Lo.set(BigInt,t=>"0x"+t.toString(16));typeof BigInt64Array<"u"&&Lo.set(BigInt64Array,br);typeof BigUint64Array<"u"&&Lo.set(BigUint64Array,br);const gM={null:0,undefined:0,number:1,string:2,object:3,array:4,boolean:5,date:6,regexp:7,function:8},Mn=(t,e)=>{t===Vi&&(t=void 0),e===Vi&&(e=void 0);const[n,r]=[t,e].map(i=>gM[Cl(i).toLowerCase()]);return n!==r?n-r:n===1||n===2||n===6?te?1:0:Wi(t,e)?0:te?1:0};function Yt(t,e){if(!t)throw new Error(e)}const wM=t=>{const e=Object.getPrototypeOf(Fo(t));return e&&e.name==="TypedArray"},Py=t=>{if(j_.has(Fo(t)))return t;const e=new Set,n=r=>{if(e.has(r))throw LE;const i=Fo(r);if(j_.has(i))return r;try{if(Lt(r))return e.add(r),r.map(n);if(wt(r)){e.add(r);const s={};for(const o in r)s[o]=n(r[o]);return s}}finally{e.delete(r)}return i===Date||i===RegExp||wM(r)?new i(r):r};return n(t)},Cl=t=>vM.exec(Object.prototype.toString.call(t))[1],um=t=>typeof t=="boolean",Ki=t=>typeof t=="string",Hn=t=>!isNaN(t)&&typeof t=="number",Lt=Array.isArray,wt=t=>{if(!t)return!1;const e=Object.getPrototypeOf(t);return(e===$E||e===null)&&yM===Object.prototype.toString.call(t)},Sh=t=>t===Object(t),Ry=t=>t instanceof Date,Af=t=>t instanceof RegExp,Ih=t=>typeof t=="function",cn=t=>t==null,Wa=(t,e)=>t.includes(e),UE=(t,e)=>!Wa(t,e),_M=(t,e=!0)=>!!t||e&&t==="",uu=t=>cn(t)||Ki(t)&&!t||t instanceof Array&&t.length===0||wt(t)&&Object.keys(t).length===0,U_=t=>t===Vi,Yl=t=>t instanceof Array?t:[t],Xn=(t,e)=>!!t&&Object.prototype.hasOwnProperty.call(t,e),bM=(t,e)=>wt(t)&&wt(e)||Lt(t)&&Lt(e);function Ty(t,e,n){if(n=n||{flatten:!1},U_(t)||cn(t))return e;if(U_(e)||cn(e))return t;if(!bM(t,e)){if(n.skipValidation)return e||t;throw Error("mismatched types. must both be array or object")}if(n.skipValidation=!0,Lt(t)){const r=t,i=e;if(n.flatten){let s=0,o=0;for(;s{const s=VE(r,e);n.has(s)?n.get(s).some(o=>Wi(t[o],r))||n.get(s).push(i):n.set(s,[i])}),n}function Ng(t,e=Ql){if(t.some(a=>a.length==0))return[];if(t.length===1)return Array.from(t);const n=OM(t.map((a,l)=>[l,a.length]),a=>a[1]),r=t[n[0][0]],i=My(r,e),s=new Map,o=new Array;return i.forEach((a,l)=>{const f=a.map(w=>r[w]),h=f.map(w=>0),m=f.map(w=>[n[0][0],0]);let y=!1;for(let w=1;wF[_]);y=f.map((_,k)=>S.some((z,W)=>{const Q=h[k];return Wi(_,z)&&(h[k]++,Iw===t.length-1?[f[I],m[I]]:Vi).filter(w=>w!==Vi))}),o.sort((a,l)=>{const[f,[h,m]]=a,[y,[w,I]]=l,E=Mn(h,w);return E!==0?E:Mn(m,I)}).map(a=>a[0])}function zE(t,e=0){const n=new Array;function r(i,s){for(let o=0,a=i.length;o0||s<0)?r(i[o],Math.max(-1,s-1)):n.push(i[o])}return r(t,e),n}const SM=t=>{let[e,n]=[Object.getPrototypeOf(t),Object.getOwnPropertyNames(t)],r=e;for(;!n.length&&e!==$E&&e!==mM;)r=e,n=Object.getOwnPropertyNames(e),e=Object.getPrototypeOf(e);const i={};return n.forEach(s=>i[s]=t[s]),[i,r]};function Wi(t,e){const n=[[t,e]];for(;n.length>0;){if([t,e]=n.pop(),t===e)continue;const r=Fo(t);if(r!==Fo(e)||Ih(t))return!1;if(Lo.has(r)){const i=Lo.get(r);if(i(t)!==i(e))return!1;continue}if(r===Array||r===Object){const i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length||new Set(i.concat(s)).size!=i.length)return!1;for(const o of i)n.push([t[o],e[o]]);continue}return!1}return!n.length}function IM(t,e=Ql){const n=t.map(r=>Vi);return My(t,e).forEach((r,i)=>{r.forEach(s=>n[s]=t[s])}),n.filter(r=>r!==Vi)}function EM(t){const e=new Set,n=r=>{const i=Fo(r);if(Lo.has(i))return Lo.get(i)(r);const s=i===Object?"":i.name;if(Ih(r.toJSON))return`${s}(${JSON.stringify(r)})`;if(e.has(r))throw LE;e.add(r);try{if(i===Array)return"["+r.map(n).join(",")+"]";if(i!==Object){const[a,l]=SM(r);if(Lt(r))return`${s}${n([...r,a])}`;r=a}const o=Object.keys(r);return o.sort(),`${s}{`+o.map(a=>`${a}:${n(r[a])}`).join(",")+"}"}finally{e.delete(r)}};return n(t)}function VE(t,e){return e=e||Ql,cn(t)?null:e(t).toString()}function OM(t,e,n=Mn){if(uu(t))return t;const r=new Array,i=new Array;for(let s=0;sn(s[0],o[0])),Gl(i,r.map(s=>s[1]))}function kM(t,e,n=Ql){if(t.length<1)return new Map;const r=new Map,i=new Map;for(let s=0;sWi(h,a)):null;cn(f)?(i.set(a,[o]),r.has(l)?r.get(l).push(a):r.set(l,[a])):i.get(f).push(o)}}return i}const lm=5e4;function Gl(t,...e){return t instanceof Array?e.reduce((n,r)=>{let i=Math.ceil(r.length/lm),s=0;for(;i-- >0;)Array.prototype.push.apply(n,r.slice(s,s+lm)),s+=lm;return n},t):e.filter(Sh).reduce((n,r)=>(Object.assign(n,r),n),t)}function Ny(t,e){return Sh(t)?t[e]:void 0}function DM(t,e){if(e<1)return t;for(;e--&&t.length===1;)t=t[0];return t}function lu(t,e,n){let r=0;function i(o,a){let l=o;for(let f=0;f0)break;r+=1;const y=a.slice(f);l=l.reduce((w,I)=>{const E=i(I,y);return E!==void 0&&w.push(E),w},[]);break}else l=Ny(l,h);if(l===void 0)break}return l}const s=jE.has(Cl(t).toLowerCase())?t:i(t,e.split("."));return s instanceof Array&&(n!=null&&n.unwrapArray)?DM(s,r):s}function Cf(t,e,n){const r=e.split("."),i=r[0],s=r.slice(1).join("."),o=/^\d+$/.exec(i)!==null,a=r.length>1;let l,f;if(t instanceof Array)if(o)l=Ny(t,Number(i)),a&&(l=Cf(l,s,n)),l=[l];else{l=[];for(const h of t)f=Cf(h,e,n),n!=null&&n.preserveMissing?(f===void 0&&(f=Vi),l.push(f)):f!==void 0&&l.push(f)}else{if(f=Ny(t,i),a&&(f=Cf(f,s,n)),f===void 0)return;l=n!=null&&n.preserveKeys?Object.assign({},t):{},l[i]=f}return l}function By(t){if(t instanceof Array)for(let e=t.length-1;e>=0;e--)t[e]===Vi?t.splice(e,1):By(t[e]);else if(wt(t))for(const e in t)Xn(t,e)&&By(t[e])}const z_=/^\d+$/;function Pl(t,e,n,r){const i=e.split("."),s=i[0],o=i.slice(1).join(".");if(i.length===1)(wt(t)||Lt(t)&&z_.test(s))&&n(t,s);else{r!=null&&r.buildGraph&&cn(t[s])&&(t[s]={});const a=t[s];if(!a)return;const l=!!(i.length>1&&z_.test(i[1]));a instanceof Array&&(r!=null&&r.descendArray)&&!l?a.forEach(f=>Pl(f,o,n,r)):Pl(a,o,n,r)}}function xM(t,e,n){Pl(t,e,(r,i)=>{r[i]=Ih(n)?n(r[i]):n},{buildGraph:!0})}function V_(t,e,n){Pl(t,e,(r,i)=>{if(r instanceof Array){if(/^\d+$/.test(i))r.splice(parseInt(i),1);else if(n&&n.descendArray)for(const s of r)wt(s)&&delete s[i]}else wt(r)&&delete r[i]},n)}const AM=/^\$[a-zA-Z0-9_]+$/;function Ko(t){return AM.test(t)}function KE(t){if(jE.has(Cl(t).toLowerCase()))return Af(t)?{$regex:t}:{$eq:t};if(Sh(t)){if(!Object.keys(t).some(Ko))return{$eq:t};if(Xn(t,"$regex")){const n=Object.assign({},t);return n.$regex=new RegExp(t.$regex,t.$options),delete n.$options,n}}return t}var vs;(function(t){t.CLONE_ALL="CLONE_ALL",t.CLONE_INPUT="CLONE_INPUT",t.CLONE_OUTPUT="CLONE_OUTPUT",t.CLONE_OFF="CLONE_OFF"})(vs||(vs={}));class Eo{constructor(e,n,r,i=Date.now()){this._opts=e,this._root=n,this._local=r,this.timestamp=i,this.update(n,r)}static init(e,n,r){return e instanceof Eo?new Eo(e._opts,cn(e.root)?n:e.root,Object.assign({},e.local,r)):new Eo(e,n,r)}update(e,n){var r;return this._root=e,this._local=n&&Object.assign({},n,{variables:Object.assign({},(r=this._local)===null||r===void 0?void 0:r.variables,n==null?void 0:n.variables)}),this}getOptions(){return Object.freeze(Object.assign(Object.assign({},this._opts),{context:$o.from(this._opts.context)}))}get root(){return this._root}get local(){return this._local}get idKey(){return this._opts.idKey}get collation(){var e;return(e=this._opts)===null||e===void 0?void 0:e.collation}get processingMode(){var e;return((e=this._opts)===null||e===void 0?void 0:e.processingMode)||vs.CLONE_OFF}get useStrictMode(){var e;return(e=this._opts)===null||e===void 0?void 0:e.useStrictMode}get scriptEnabled(){var e;return(e=this._opts)===null||e===void 0?void 0:e.scriptEnabled}get useGlobalContext(){var e;return(e=this._opts)===null||e===void 0?void 0:e.useGlobalContext}get hashFunction(){var e;return(e=this._opts)===null||e===void 0?void 0:e.hashFunction}get collectionResolver(){var e;return(e=this._opts)===null||e===void 0?void 0:e.collectionResolver}get jsonSchemaValidator(){var e;return(e=this._opts)===null||e===void 0?void 0:e.jsonSchemaValidator}get variables(){var e;return(e=this._opts)===null||e===void 0?void 0:e.variables}get context(){var e;return(e=this._opts)===null||e===void 0?void 0:e.context}}function Bg(t){return t instanceof Eo?t.getOptions():Object.freeze(Object.assign(Object.assign({idKey:"_id",scriptEnabled:!0,useStrictMode:!0,useGlobalContext:!0,processingMode:vs.CLONE_OFF},t),{context:t!=null&&t.context?$o.from(t==null?void 0:t.context):$o.init({})}))}var Ye;(function(t){t.ACCUMULATOR="accumulator",t.EXPRESSION="expression",t.PIPELINE="pipeline",t.PROJECTION="projection",t.QUERY="query",t.WINDOW="window"})(Ye||(Ye={}));class $o{constructor(e){this.operators={[Ye.ACCUMULATOR]:{},[Ye.EXPRESSION]:{},[Ye.PIPELINE]:{},[Ye.PROJECTION]:{},[Ye.QUERY]:{},[Ye.WINDOW]:{}};for(const[n,r]of Object.entries(e))this.addOperators(n,r)}static init(e={}){return new $o(e)}static from(e){return new $o(e.operators)}addOperators(e,n){for(const[r,i]of Object.entries(n))this.getOperator(e,r)||(this.operators[e][r]=i);return this}addAccumulatorOps(e){return this.addOperators(Ye.ACCUMULATOR,e)}addExpressionOps(e){return this.addOperators(Ye.EXPRESSION,e)}addQueryOps(e){return this.addOperators(Ye.QUERY,e)}addPipelineOps(e){return this.addOperators(Ye.PIPELINE,e)}addProjectionOps(e){return this.addOperators(Ye.PROJECTION,e)}addWindowOps(e){return this.addOperators(Ye.WINDOW,e)}getOperator(e,n){return e in this.operators&&this.operators[e][n]||null}}const co=$o.init();function K_(t,e){for(const[n,r]of Object.entries(e)){Yt(Ih(r)&&Ko(n),`'${n}' is not a valid operator`);const i=Oo(t,n,null);Yt(!i||r===i,`${n} already exists for '${t}' operators. Cannot change operator function once registered.`)}switch(t){case Ye.ACCUMULATOR:co.addAccumulatorOps(e);break;case Ye.EXPRESSION:co.addExpressionOps(e);break;case Ye.PIPELINE:co.addPipelineOps(e);break;case Ye.PROJECTION:co.addProjectionOps(e);break;case Ye.QUERY:co.addQueryOps(e);break;case Ye.WINDOW:co.addWindowOps(e);break}}function Oo(t,e,n){const{context:r,useGlobalContext:i}=n||{},s=r?r.getOperator(t,e):null;return!s&&i?co.getOperator(t,e):s}const W_={$$ROOT(t,e,n){return n.root},$$CURRENT(t,e,n){return t},$$REMOVE(t,e,n){},$$NOW(t,e,n){return new Date(n.timestamp)}},Fy={$$KEEP(t,e,n){return t},$$PRUNE(t,e,n){},$$DESCEND(t,e,n){if(!Xn(e,"$cond"))return t;let r;for(const[i,s]of Object.entries(t))if(Sh(s)){if(s instanceof Array){const o=[];for(let a of s)wt(a)&&(a=q_(a,e,n.update(a))),cn(a)||o.push(a);r=o}else r=q_(s,e,n.update(s));cn(r)?delete t[i]:t[i]=r}return t}};function Jr(t,e,n,r){var i;const s=Eo.init(r,t);if(n=n||"",Ko(n)){const o=Oo(Ye.EXPRESSION,n,r);if(o)return o(t,e,s);const a=Oo(Ye.ACCUMULATOR,n,r);if(a)return t instanceof Array||(t=Jr(t,e,null,s),e=null),Yt(t instanceof Array,`'${n}' target must be an array.`),a(t,e,s.update(null,s.local));throw new Error(`operator '${n}' is not registered`)}if(Ki(e)&&e.length>0&&e[0]==="$"){if(Xn(Fy,e))return e;let o=s.root;const a=e.split(".");if(Xn(W_,a[0]))o=W_[a[0]](t,null,s),e=e.slice(a[0].length+1);else if(a[0].slice(0,2)==="$$"){o=Object.assign({},s.variables,{this:t},(i=s.local)===null||i===void 0?void 0:i.variables);const l=a[0].slice(2);Yt(Xn(o,l),`Use of undefined variable: ${l}`),e=e.slice(2)}else e=e.slice(1);return e===""?o:lu(o,e)}if(Lt(e))return e.map(o=>Jr(t,o,null,s));if(wt(e)){const o={};for(const[a,l]of Object.entries(e))if(o[a]=Jr(t,l,a,s),[Ye.EXPRESSION,Ye.ACCUMULATOR].some(f=>!!Oo(f,a,r)))return Yt(Object.keys(e).length===1,"Invalid aggregation expression '"+JSON.stringify(e)+"'"),o[a];return o}return e}function q_(t,e,n){const r=Jr(t,e,null,n);return Xn(Fy,r)?Fy[r](t,e,n):r}function qa(t){return t instanceof H_?t:new H_(t)}function CM(...t){let e=0;return qa(()=>{for(;e{const i=r.next();if(i.done)throw Ly;return i.value}}else if(e instanceof Array){const r=e,i=r.length;let s=0;n=()=>{if(s0?this.push(ii.TAKE,e):this}drop(e){return e>0?this.push(ii.DROP,e):this}transform(e){const n=this;let r;return qa(()=>(r||(r=qa(e(n.value()))),r.next()))}value(){return this.isDone||(this.isDone=this.getNext(!0).done),this.yieldedValues}each(e){for(;;){const n=this.next();if(n.done)break;if(e(n.value)===!1)return!1}return!0}reduce(e,n){let r=this.next();for(n===void 0&&!r.done&&(n=r.value,r=this.next());!r.done;)n=e(n,r.value),r=this.next();return n}size(){return this.reduce((e,n)=>++e,0)}[Symbol.iterator](){return this}}class MM{constructor(e,n){this.pipeline=e,this.options=Bg(n)}stream(e){let n=qa(e);const r=this.options.processingMode;(r==vs.CLONE_ALL||r==vs.CLONE_INPUT)&&n.map(Py);const i=new Array;if(!uu(this.pipeline))for(const s of this.pipeline){const o=Object.keys(s),a=o[0],l=Oo(Ye.PIPELINE,a,this.options);Yt(o.length===1&&!!l,`invalid pipeline operator ${a}`),i.push(a),n=l(n,s[a],this.options)}return(r==vs.CLONE_OUTPUT||r==vs.CLONE_ALL&&Ng([["$group","$unwind"],i]).length)&&n.map(Py),n}run(e){return this.stream(e).value()}}class NM{constructor(e,n,r,i){this.source=e,this.predicate=n,this.projection=r,this.options=i,this.operators=[],this.result=null,this.buffer=[]}fetch(){return this.result?this.result:(wt(this.projection)&&this.operators.push({$project:this.projection}),this.result=qa(this.source).filter(this.predicate),this.operators.length>0&&(this.result=new MM(this.operators,this.options).stream(this.result)),this.result)}fetchAll(){const e=qa([...this.buffer]);return this.buffer=[],CM(e,this.fetch())}all(){return this.fetchAll().value()}count(){return this.all().length}skip(e){return this.operators.push({$skip:e}),this}limit(e){return this.operators.push({$limit:e}),this}sort(e){return this.operators.push({$sort:e}),this}collation(e){return this.options=Object.assign(Object.assign({},this.options),{collation:e}),this}next(){if(this.buffer.length>0)return this.buffer.pop();const e=this.fetch().next();if(!e.done)return e.value}hasNext(){if(this.buffer.length>0)return!0;const e=this.fetch().next();return e.done?!1:(this.buffer.push(e.value),!0)}map(e){return this.all().map(e)}forEach(e){this.all().forEach(e)}[Symbol.iterator](){return this.fetchAll()}}class qs{constructor(e,n){this.condition=e,this.options=Bg(n),this.compiled=[],this.compile()}compile(){Yt(wt(this.condition),`query criteria must be an object: ${JSON.stringify(this.condition)}`);const e={};for(const[n,r]of Object.entries(this.condition)){if(n==="$where")Object.assign(e,{field:n,expr:r});else if(Wa(["$and","$or","$nor","$expr","$jsonSchema"],n))this.processOperator(n,n,r);else{Yt(!Ko(n),`unknown top level operator: ${n}`);for(const[i,s]of Object.entries(KE(r)))this.processOperator(n,i,s)}e.field&&this.processOperator(e.field,e.field,e.expr)}}processOperator(e,n,r){const i=Oo(Ye.QUERY,n,this.options);if(!i)throw new Error(`unknown operator ${n}`);const s=i(e,r,this.options);this.compiled.push(s)}test(e){for(let n=0,r=this.compiled.length;nthis.test(r),n||{},this.options)}remove(e){return e.reduce((n,r)=>(this.test(r)||n.push(r),n),[])}}const BM=(t,e,n)=>{if(uu(e)||!wt(e))return t;let r=Mn;const i=n.collation;return wt(i)&&Ki(i.locale)&&(r=LM(i)),t.transform(s=>{const o=Object.keys(e);for(const a of o.reverse()){const l=kM(s,h=>lu(h,a),n.hashFunction),f=Array.from(l.keys()).sort(r);e[a]===-1&&f.reverse(),s=[],f.reduce((h,m)=>Gl(h,l.get(m)),s)}return s})},FM={1:"base",2:"accent",3:"variant"};function LM(t){const e={sensitivity:FM[t.strength||3],caseFirst:t.caseFirst==="off"?"false":t.caseFirst||"false",numeric:t.numericOrdering||!1,ignorePunctuation:t.alternate==="shifted"};(t.caseLevel||!1)===!0&&(e.sensitivity==="base"&&(e.sensitivity="case"),e.sensitivity==="accent"&&(e.sensitivity="variant"));const n=new Intl.Collator(t.locale,e);return(r,i)=>{if(!Ki(r)||!Ki(i))return Mn(r,i);const s=n.compare(r,i);return s<0?-1:s>0?1:0}}function wn(t){const e=(n,r,i)=>{const s={unwrapArray:!0},o=Math.max(1,n.split(".").length-1);return a=>{const l=lu(a,n,s);return t(l,r,Object.assign(Object.assign({},i),{depth:o}))}};return e.op="query",e}function WE(t,e,n){if(Wi(t,e)||cn(t)&&cn(e))return!0;if(t instanceof Array){const r=Wi.bind(null,e);return t.some(r)||zE(t,n==null?void 0:n.depth).some(r)}return!1}function $M(t,e,n){return!WE(t,e,n)}function qE(t,e,n){return cn(t)?e.some(r=>r===null):Ng([Yl(t),e],n==null?void 0:n.hashFunction).length>0}function jM(t,e,n){return!qE(t,e,n)}function UM(t,e,n){return Eh(t,e,(r,i)=>Mn(r,i)<0)}function zM(t,e,n){return Eh(t,e,(r,i)=>Mn(r,i)<=0)}function VM(t,e,n){return Eh(t,e,(r,i)=>Mn(r,i)>0)}function KM(t,e,n){return Eh(t,e,(r,i)=>Mn(r,i)>=0)}function WM(t,e,n){return Yl(t).some(r=>e.length===2&&r%e[0]===e[1])}function qM(t,e,n){const r=Yl(t),i=s=>Ki(s)&&_M(e.exec(s),n==null?void 0:n.useStrictMode);return r.some(i)||zE(r,1).some(i)}function HM(t,e,n){return(e===!1||e===0)&&t===void 0||(e===!0||e===1)&&t!==void 0}function QM(t,e,n){if(!Lt(t)||!Lt(e)||!t.length||!e.length)return!1;let r=!0;for(const i of e){if(!r)break;wt(i)&&Wa(Object.keys(i),"$elemMatch")?r=HE(t,i.$elemMatch,n):i instanceof RegExp?r=t.some(s=>typeof s=="string"&&i.test(s)):r=t.some(s=>Wi(i,s))}return r}function YM(t,e,n){return Array.isArray(t)&&t.length===e}function GM(t){return Ko(t)&&["$and","$or","$nor"].indexOf(t)===-1}function HE(t,e,n){if(Lt(t)&&!uu(t)){let r=o=>o,i=e;Object.keys(e).every(GM)&&(i={temp:e},r=o=>({temp:o}));const s=new qs(i,n);for(let o=0,a=t.length;ot===null,Y_=t=>Hn(t)&&t>=dM&&t<=fM&&t.toString().indexOf(".")===-1,G_=t=>Hn(t)&&t>=pM&&t<=hM&&t.toString().indexOf(".")===-1,JM={array:Lt,bool:um,boolean:um,date:Ry,decimal:Hn,double:Hn,int:Y_,long:G_,number:Hn,null:Q_,object:wt,regex:Af,regexp:Af,string:Ki,undefined:cn,function:t=>{throw new Error("unsupported type key `function`.")},1:Hn,2:Ki,3:wt,4:Lt,6:cn,8:um,9:Ry,10:Q_,11:Af,16:Y_,18:G_,19:Hn};function J_(t,e,n){const r=JM[e];return r?r(t):!1}function XM(t,e,n){return Array.isArray(e)?e.findIndex(r=>J_(t,r))>=0:J_(t,e)}function Eh(t,e,n){return Yl(t).some(r=>Cl(r)===Cl(e)&&n(r,e))}const X_=(t,e)=>{const n={};return t.split("").forEach((r,i)=>n[r]=e*(i+1)),n};Object.assign(Object.assign(Object.assign({},X_("ABCDEFGHIKLM",1)),X_("NOPQRSTUVWXY",-1)),{Z:0});const Z_={undefined:null,null:null,NaN:NaN,Infinity:new Error,"-Infinity":new Error};function sr(t,e=Z_){const n=Object.assign({},Z_,e),r=new Set(Object.keys(n));return(i,s,o)=>{const a=Jr(i,s,null,o);if(r.has(`${a}`)){const l=n[`${a}`];if(l instanceof Error)throw new Error(`cannot apply $${t.name} to -inf, value must in (-inf,inf)`);return l}return t(a)}}sr(Math.acos,{Infinity:1/0,0:new Error});sr(Math.acosh,{Infinity:1/0,0:new Error});sr(Math.asin);sr(Math.asinh,{Infinity:1/0,"-Infinity":-1/0});sr(Math.atan);sr(Math.atanh,{1:1/0,"-1":-1/0});sr(Math.cos);sr(Math.cosh,{"-Infinity":1/0,Infinity:1/0});const ZM=Math.PI/180;sr(t=>t*ZM,{Infinity:1/0,"-Infinity":1/0});const e2=180/Math.PI;sr(t=>t*e2,{Infinity:1/0,"-Infinity":-1/0});sr(Math.sin);sr(Math.sinh,{"-Infinity":-1/0,Infinity:1/0});sr(Math.tan);const t2=(t,e,n)=>{if(uu(e))return t;let r=Object.keys(e),i=!1;QE(e,n);const s=n.idKey;if(Wa(r,s)){const a=e[s];(a===0||a===!1)&&(r=r.filter(UE.bind(null,[s])),i=r.length==0)}else r.push(s);const o=Eo.init(n);return t.map(a=>$y(a,e,o.update(a),r,i))};function $y(t,e,n,r,i){let s={},o=!1,a=!1;const l=[];i&&l.push(n.idKey);for(const f of r){let h;const m=e[f];if(f!==n.idKey&&Wa([0,!1],m)&&(a=!0),f===n.idKey&&uu(m))h=t[f];else if(Ki(m))h=Jr(t,m,f,n);else if(!Wa([1,!0],m))if(m instanceof Array)h=m.map(w=>{const I=Jr(t,w,null,n);return cn(I)?null:I});else if(wt(m)){const w=m,I=Object.keys(m),E=I.length==1?I[0]:"",F=Oo(Ye.PROJECTION,E,n);if(F)E==="$slice"?Yl(w[E]).every(Hn)?(h=F(t,w[E],f,n),o=!0):h=Jr(t,w,f,n):h=F(t,w[E],f,n);else if(Ko(E))h=Jr(t,w[E],E,n);else if(Xn(t,f)){QE(w,n);let S=t[f];S instanceof Array?h=S.map(_=>$y(_,w,n,I,!1)):(S=wt(S)?S:t,h=$y(S,w,n,I,!1))}else h=Jr(t,m,null,n)}else{l.push(f);continue}const y=Cf(t,f,{preserveMissing:!0});y!==void 0&&Ty(s,y,{flatten:!0}),UE([0,1,!1,!0],m)&&(h===void 0?V_(s,f,{descendArray:!0}):xM(s,f,h))}if(By(s),(o||a||i)&&(s=Gl({},t,s),l.length>0))for(const f of l)V_(s,f,{descendArray:!0});return s}function QE(t,e){const n=[!1,!1];for(const[r,i]of Object.entries(t)){if(r===(e==null?void 0:e.idKey))return;i===0||i===!1?n[0]=!0:(i===1||i===!0)&&(n[1]=!0),Yt(!(n[0]&&n[1]),"Projection cannot have a mix of inclusion and exclusion.")}}const n2=(t,e,n)=>{Yt(Lt(e),"Invalid expression: $and expects value to be an Array.");const r=e.map(i=>new qs(i,n));return i=>r.every(s=>s.test(i))},YE=(t,e,n)=>{Yt(Lt(e),"Invalid expression. $or expects value to be an Array");const r=e.map(i=>new qs(i,n));return i=>r.some(s=>s.test(i))},r2=(t,e,n)=>{Yt(Lt(e),"Invalid expression. $nor expects value to be an array.");const r=YE("$or",e,n);return i=>!r(i)},i2=(t,e,n)=>{const r={};r[t]=KE(e);const i=new qs(r,n);return s=>!i.test(s)},s2=wn(WE),o2=wn(VM),a2=wn(KM),u2=wn(qE),l2=wn(UM),c2=wn(zM),f2=wn($M),d2=wn(jM),h2=wn(WM),p2=wn(qM);wn(QM);const m2=wn(HE),y2=wn(YM),v2=wn(HM),g2=wn(XM);var eb=!1;function w2(t){return eb||(K_(Ye.PIPELINE,{$sort:BM,$project:t2}),K_(Ye.QUERY,{$and:n2,$eq:s2,$elemMatch:m2,$exists:v2,$gt:o2,$gte:a2,$in:u2,$lt:l2,$lte:c2,$ne:f2,$nin:d2,$mod:h2,$nor:r2,$not:i2,$or:YE,$regex:p2,$size:y2,$type:g2}),eb=!0),new qs(t)}function Rl(t,e){var n=Fn(t.primaryKey);e=$e(e);var r=Pn(e);if(typeof r.skip!="number"&&(r.skip=0),r.selector?(r.selector=r.selector,Object.entries(r.selector).forEach(([f,h])=>{(typeof h!="object"||h===null)&&(r.selector[f]={$eq:h})})):r.selector={},r.index){var i=ja(r.index);i.includes(n)||i.push(n),r.index=i}if(r.sort){var l=r.sort.find(f=>CP(f)===n);l||(r.sort=r.sort.slice(0),r.sort.push({[n]:"asc"}))}else if(r.index)r.sort=r.index.map(f=>({[f]:"asc"}));else{if(t.indexes){var s=new Set;Object.entries(r.selector).forEach(([f,h])=>{var m=!1;typeof h=="object"&&h!==null?m=!!Object.keys(h).find(y=>Rg.has(y)):m=!0,m&&s.add(f)});var o=-1,a;t.indexes.forEach(f=>{var h=hg(f)?f:[f],m=h.findIndex(y=>!s.has(y));m>0&&m>o&&(o=m,a=h)}),a&&(r.sort=a.map(f=>({[f]:"asc"})))}r.sort||(r.sort=[{[n]:"asc"}])}return r}function Fg(t,e){if(!e.sort)throw le("SNH",{query:e});var n=[];e.sort.forEach(i=>{var s=Object.keys(i)[0],o=Object.values(i)[0];n.push({key:s,direction:o,getValueFn:JI(s)})});var r=(i,s)=>{for(var o=0;on.test(i);return r}function _2(t,e){return!e.sort||e.sort.length===0?[t]:e.sort.map(n=>Object.keys(n)[0])}var b2=new WeakMap;function S2(t){return Tr(b2,t,()=>{var e=t.collection,n=Rl(e.storageInstance.schema,Pn(t.mangoQuery)),r=e.schema.primaryPath,i=Fg(e.schema.jsonSchema,n),s=(f,h)=>{var m={docA:f,docB:h,rxQuery:t};return i(m.docA,m.docB)},o=Oh(e.schema.jsonSchema,n),a=f=>{var h={doc:f,rxQuery:t};return o(h.doc)},l={primaryKey:t.collection.schema.primaryPath,skip:n.skip,limit:n.limit,sortFields:_2(r,n),sortComparator:s,queryMatcher:a};return l})}function I2(t,e){if(!t.collection.database.eventReduce)return{runFullQueryAgain:!0};var n=S2(t),r=ye(t._result).docsData.slice(0),i=ye(t._result).docsDataMap,s=!1,o=e.map(l=>uT(l)).filter(GI),a=o.find(l=>{var f={queryParams:n,changeEvent:l,previousResults:r,keyDocumentMap:i},h=rM(f);if(h==="runFullQueryAgain")return!0;if(h!=="doNothing")return s=!0,iM(h,n,l,r,i),!1});return a?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:r}}var E2=function(){function t(){this._map=new Map}var e=t.prototype;return e.getByQuery=function(r){var i=r.toString();return Tr(this._map,i,()=>r)},t}();function O2(){return new E2}function tb(t,e){e.uncached=!0;var n=e.toString();t._map.delete(n)}function k2(t){return t.refCount$.observers.length}var D2=100,x2=30*1e3,A2=(t,e)=>(n,r)=>{if(!(r._map.size0)){if(a._lastEnsureEqual===0&&a._creationTimem._lastEnsureEqual-y._lastEnsureEqual),h=f.slice(0,l);h.forEach(m=>tb(r,m))}}},GE=A2(D2,x2),cm=new WeakSet;function C2(t){cm.has(t)||(cm.add(t),WP().then(()=>HP(200)).then(()=>{t.destroyed||t.cacheReplacementPolicy(t,t._queryCache),cm.delete(t)}))}var JE=function(){function t(n,r,i){this.cacheItemByDocId=new Map,this.registry=typeof FinalizationRegistry=="function"?new FinalizationRegistry(s=>{var o=s.docId,a=this.cacheItemByDocId.get(o);a&&(a.byRev.delete(s.revisionHeight),a.byRev.size===0&&this.cacheItemByDocId.delete(o))}):void 0,this.registerIdleTasks=[],this.primaryPath=n,this.changes$=r,this.documentCreator=i,r.subscribe(s=>{var o=s.documentId,a=this.cacheItemByDocId.get(o);if(a){var l=kg(s);a.last=l}})}var e=t.prototype;return e.getLatestDocumentData=function(r){var i=Mo(this.cacheItemByDocId,r);return i.last},e.getLatestDocumentDataIfExists=function(r){var i=this.cacheItemByDocId.get(r);if(i)return i.last},Vs(t,[{key:"getCachedRxDocument",get:function(){var n=P2(this);return xs(this,"getCachedRxDocument",n)}}]),t}();function P2(t){var e=t.primaryPath,n=t.cacheItemByDocId,r=t.registry,i=it.deepFreezeWhenDevMode,s=t.documentCreator,o=a=>{var l=a[e],f=D_(a._rev),h=Tr(n,l,()=>R2(a)),m=h.byRev,y=m.get(f),w=y?y.deref():void 0;return w||(a=i(a),w=s(a),m.set(f,M2(w)),r&&(t.registerIdleTasks.push(w),t.registerIdlePromise||(t.registerIdlePromise=yg().then(()=>{t.registerIdlePromise=void 0;var I=t.registerIdleTasks;I.length!==0&&(t.registerIdleTasks=[],I.forEach(E=>{r.register(E,{docId:E.primary,revisionHeight:D_(E.revision)})}))})))),w};return o}function XE(t,e){for(var n=t.getCachedRxDocument,r=[],i=0;ie._data))}},{key:"docsDataMap",get:function(){var e=new Map;return this.documents.forEach(n=>{e.set(n.primary,n._data)}),xs(this,"docsDataMap",e)}},{key:"docsMap",get:function(){for(var e=new Map,n=this.documents,r=0;r{var m=this.collection._docCache.getLatestDocumentDataIfExists(h);if(m){if(!m._deleted){var y=this.collection._docCache.getCachedRxDocument(m);o.set(h,y)}}else a.push(h)}),a.length>0){var l=await this.collection.storageInstance.findDocumentsById(a,!1);l.forEach(h=>{var m=this.collection._docCache.getCachedRxDocument(h);o.set(m.primary,m)})}return o}var f=tO(this);return f.then(h=>(this._lastExecEnd=Ft(),h))},e.exec=function(r){if(r&&this.op!=="findOne")throw le("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return rb(this).then(()=>Cs(this.$)).then(i=>{if(!i&&r)throw le("QU10",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return i})},e.toString=function(){var r=fd({op:this.op,query:this.mangoQuery,other:this.other},!0),i=JSON.stringify(r);return this.toString=()=>i,i},e.getPreparedQuery=function(){var r={rxQuery:this,mangoQuery:Rl(this.collection.schema.jsonSchema,this.mangoQuery)};r.mangoQuery.selector._deleted={$eq:!1},r.mangoQuery.index&&r.mangoQuery.index.unshift("_deleted"),Mr("prePrepareQuery",r);var i=Jl(this.collection.schema.jsonSchema,r.mangoQuery);return this.getPreparedQuery=()=>i,i},e.doesDocumentDataMatch=function(r){return r._deleted?!1:this.queryMatcher(r)},e.remove=function(){return this.exec().then(r=>Array.isArray(r)?Promise.all(r.map(i=>i.remove())):r.remove())},e.update=function(r){throw pt("update")},e.where=function(r){throw pt("query-builder")},e.sort=function(r){throw pt("query-builder")},e.skip=function(r){throw pt("query-builder")},e.limit=function(r){throw pt("query-builder")},Vs(t,[{key:"$",get:function(){if(!this._$){var n=this.collection.$.pipe(lt(r=>!r.isLocal),Hl(null),Nr(()=>rb(this)),Mt(()=>this._result),Pi(Ci),Bo((r,i)=>!!(r&&r.time===ye(i).time)),lt(r=>!!r),Mt(r=>{var i=ye(r);return this.op==="count"?i.count:this.op==="findOne"?i.documents.length===0?null:i.documents[0]:this.op==="findByIds"?i.docsMap:i.documents.slice(0)}));this._$=vT(n,this.refCount$.pipe(lt(()=>!1)))}return this._$}},{key:"$$",get:function(){var n=this.collection.database.getReactivityFactory();return n.fromObservable(this.$,void 0)}},{key:"queryMatcher",get:function(){var n=this.collection.schema.jsonSchema,r=Rl(this.collection.schema.jsonSchema,this.mangoQuery);return xs(this,"queryMatcher",Oh(n,r))}},{key:"asRxQuery",get:function(){return this}}]),t}();function tl(){return{selector:{}}}function $2(t){return t.collection._queryCache.getByQuery(t)}function na(t,e,n,r){Mr("preCreateRxQuery",{op:t,queryObj:e,collection:n,other:r});var i=new ZE(t,e,n,r);return i=$2(i),C2(n),i}function eO(t){var e=t.asRxQuery.collection._changeEventBuffer.counter;return t._latestChangeEvent>=e}function rb(t){return t.collection.database.destroyed||eO(t)?Gn:(t._ensureEqualQueue=t._ensureEqualQueue.then(()=>j2(t)),t._ensureEqualQueue)}function j2(t){if(t._lastEnsureEqual=Ft(),t.collection.database.destroyed||eO(t))return Gn;var e=!1,n=!1;if(t._latestChangeEvent===-1&&(n=!0),!n){var r=t.asRxQuery.collection._changeEventBuffer.getFrom(t._latestChangeEvent+1);if(r===null)n=!0;else{t._latestChangeEvent=t.asRxQuery.collection._changeEventBuffer.counter;var i=t.asRxQuery.collection._changeEventBuffer.reduceByLastOfDoc(r);if(t.op==="count"){var s=ye(t._result).count,o=s;i.forEach(l=>{var f=l.previousDocumentData&&t.doesDocumentDataMatch(l.previousDocumentData),h=t.doesDocumentDataMatch(l.documentData);!f&&h&&o++,f&&!h&&o--}),o!==s&&(e=!0,t._setResultData(o))}else{var a=I2(t,i);a.runFullQueryAgain?n=!0:a.changed&&(e=!0,t._setResultData(a.newResults))}}}return n?t._execOverDatabase().then(l=>(t._latestChangeEvent=t.collection._changeEventBuffer.counter,typeof l=="number"?((!t._result||l!==t._result.count)&&(e=!0,t._setResultData(l)),e):((!t._result||!RP(t.collection.schema.primaryPath,l,t._result.docsData))&&(e=!0,t._setResultData(l)),e))):Promise.resolve(e)}function Jl(t,e){if(!e.sort)throw le("SNH",{query:e});var n=sM(t,e);return{query:e,queryPlan:n}}async function tO(t){var e=[],n=t.collection;if(t.isFindOneByIdQuery)if(Array.isArray(t.isFindOneByIdQuery)){var r=t.isFindOneByIdQuery;if(r=r.filter(h=>{var m=t.collection._docCache.getLatestDocumentDataIfExists(h);return m?(m._deleted||e.push(m),!1):!0}),r.length>0){var i=await n.storageInstance.findDocumentsById(r,!1);Ua(e,i)}}else{var s=t.isFindOneByIdQuery,o=t.collection._docCache.getLatestDocumentDataIfExists(s);if(!o){var a=await n.storageInstance.findDocumentsById([s],!1);a[0]&&(o=a[0])}o&&!o._deleted&&e.push(o)}else{var l=t.getPreparedQuery(),f=await n.storageInstance.query(l);e=f.documents}return e}function U2(t,e){if(!e.skip&&e.selector&&Object.keys(e.selector).length===1&&e.selector[t]){var n=e.selector[t];if(typeof n=="string")return n;if(Object.keys(n).length===1&&typeof n.$eq=="string"||Object.keys(n).length===1&&Array.isArray(n.$eq)&&!n.$eq.find(r=>typeof r!="string"))return n.$eq}return!1}var z2="_rxdb_internal";async function Xl(t,e){var n=await t.findDocumentsById([e],!1),r=n[0];if(r)return r}async function Tl(t,e,n){var r=await t.bulkWrite([e],n);if(r.error.length>0){var i=r.error[0];throw i}else{var s=r.success[0];return s}}function V2(t,e){var n=Xl(t,e),r=t.changeStream().pipe(Mt(i=>i.events.find(s=>s.documentId===e)),lt(i=>!!i),Mt(i=>Promise.resolve(ye(i).documentData)),Hl(n),Al(i=>i),lt(i=>!!i));return r}function Ml(t){return Object.assign({},...t)}function nO(t,e,n){var r=e.documentData,i=e.previousDocumentData,s={documentId:e.documentId,collectionName:n?n.name:void 0,isLocal:t,operation:e.operation,documentData:it.deepFreezeWhenDevMode(r),previousDocumentData:it.deepFreezeWhenDevMode(i)};return s}function yd(t,e,n,r){if(r)throw r.status===409?le("CONFLICT",{collection:t.name,id:e,writeError:r,data:n}):r.status===422?le("VD2",{collection:t.name,id:e,writeError:r,data:n}):r}function rO(t,e,n,r,i,s,o){for(var a=!!t.schema.attachments,l=[],f=[],h=[],m=iu(10),y={id:m,events:[],checkpoint:null,context:i,startTime:Ft(),endTime:0},w=y.events,I=[],E=[],F=[],S=n.size>0,_,k=r.length,z=function(){var Q=r[W],H=Q.document,X=Q.previous,U=H[e],ee=H._deleted,ce=X&&X._deleted,de=void 0;S&&(de=n.get(U));var Pe;if(de){var Te=de._rev;if(!X||X&&Te!==X._rev){var Dt={isError:!0,status:409,documentId:U,writeRow:Q,documentInDb:de};return h.push(Dt),1}var G=a?fm(Q):Q;a&&(ee?X&&Object.keys(X._attachments).forEach(ft=>{E.push({documentId:U,attachmentId:ft,digest:ye(X)._attachments[ft].digest})}):(Object.entries(H._attachments).find(([ft,At])=>{var Un=X?X._attachments[ft]:void 0;return!Un&&!At.data&&(Pe={documentId:U,documentInDb:de,isError:!0,status:510,writeRow:Q,attachmentId:ft}),!0}),Pe||Object.entries(H._attachments).forEach(([ft,At])=>{var Un=X?X._attachments[ft]:void 0;if(!Un)I.push({documentId:U,attachmentId:ft,attachmentData:At,digest:At.digest});else{var tn=G.document._attachments[ft].digest;At.data&&Un.digest!==tn&&F.push({documentId:U,attachmentId:ft,attachmentData:At,digest:At.digest})}}))),Pe?h.push(Pe):(a?(f.push(fm(G)),o&&o(H)):(f.push(G),o&&o(H)),_=G);var oe=null,ue=null,Re=null;if(ce&&!ee)Re="INSERT",oe=a?gs(H):H;else if(X&&!ce&&!ee)Re="UPDATE",oe=a?gs(H):H,ue=X;else if(ee)Re="DELETE",oe=ye(H),ue=X;else throw le("SNH",{args:{writeRow:Q}});var xt={documentId:U,documentData:oe,previousDocumentData:ue,operation:Re};w.push(xt)}else{var ot=!!ee;if(a&&Object.entries(H._attachments).forEach(([ft,At])=>{At.data?I.push({documentId:U,attachmentId:ft,attachmentData:At,digest:At.digest}):(Pe={documentId:U,isError:!0,status:510,writeRow:Q,attachmentId:ft},h.push(Pe))}),Pe||(a?(l.push(fm(Q)),s&&s(H)):(l.push(Q),s&&s(H)),_=Q),!ot){var ct={documentId:U,operation:"INSERT",documentData:a?gs(H):H,previousDocumentData:a&&X?gs(X):X};w.push(ct)}}},W=0;W{e._attachments[n]=W2(r)}),e}function Lg(t){var e=$e(t);return e._meta=$e(t._meta),e}function $g(t,e,n){it.deepFreezeWhenDevMode(n);var r=Fn(n.primaryKey);function i(o){var a=$e(o.document);if(a._meta=$e(a._meta),it.isDevMode()){a=sE(r,n,a);try{typeof structuredClone=="function"?structuredClone(o):JSON.parse(JSON.stringify(o))}catch{throw le("DOC24",{collection:e.collectionName,document:o.document})}o.previous,o.previous&&Object.keys(o.previous._meta).forEach(l=>{if(!Object.prototype.hasOwnProperty.call(o.document._meta,l))throw le("SNH",{dataBefore:o.previous,dataAfter:o.document})})}return a._meta.lwt=Ft(),a._rev=Ui(t.token,o.previous),{document:a,previous:o.previous}}var s={originalStorageInstance:e,schema:e.schema,internals:e.internals,collectionName:e.collectionName,databaseName:e.databaseName,options:e.options,bulkWrite(o,a){var l=o.map(f=>i(f));return t.lockedRun(()=>e.bulkWrite(l,a)).then(f=>{var h={error:[],success:f.success.slice(0)},m=f.error.filter(w=>w.status===409&&!w.writeRow.previous&&!w.writeRow.document._deleted&&ye(w.documentInDb)._deleted?!0:(h.error.push(w),!1));if(m.length>0){var y=m.map(w=>({previous:w.documentInDb,document:Object.assign({},w.writeRow.document,{_rev:Ui(t.token,w.documentInDb)})}));return t.lockedRun(()=>e.bulkWrite(y,a)).then(w=>(Ua(h.error,w.error),Ua(h.success,w.success),h))}return f})},query(o){return t.lockedRun(()=>e.query(o))},count(o){return t.lockedRun(()=>e.count(o))},findDocumentsById(o,a){return t.lockedRun(()=>e.findDocumentsById(o,a))},getAttachmentData(o,a,l){return t.lockedRun(()=>e.getAttachmentData(o,a,l))},getChangedDocumentsSince:e.getChangedDocumentsSince?(o,a)=>t.lockedRun(()=>e.getChangedDocumentsSince(ye(o),a)):void 0,cleanup(o){return t.lockedRun(()=>e.cleanup(o))},remove(){return t.storageInstances.delete(s),t.lockedRun(()=>e.remove())},close(){return t.storageInstances.delete(s),t.lockedRun(()=>e.close())},changeStream(){return e.changeStream()},conflictResultionTasks(){return e.conflictResultionTasks()},resolveConflictResultionTask(o){if(o.output.isEqual)return e.resolveConflictResultionTask(o);var a=Object.assign({},o.output.documentData,{_meta:Ks(),_rev:Rn(),_attachments:{}}),l=$e(a);return delete l._meta,delete l._rev,delete l._attachments,e.resolveConflictResultionTask({id:o.id,output:{isEqual:!1,documentData:l}})}};return t.storageInstances.add(s),s}function iO(t){if(t.schema.keyCompression)throw le("UT5",{args:{params:t}});if(vd(t.schema))throw le("UT6",{args:{params:t}});if(t.schema.attachments&&t.schema.attachments.compression)throw le("UT7",{args:{params:t}})}function vd(t){return!!(t.encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)}function q2(t,e,n){var r=Fn(t.schema.primaryKey),i=n?n.lwt:pg,s=n?n.id:"";return Rl(t.schema,{selector:{$or:[{"_meta.lwt":{$gt:i}},{"_meta.lwt":{$eq:i},[r]:{$gt:n?s:""}}],"_meta.lwt":{$gte:i}},sort:[{"_meta.lwt":"asc"},{[r]:"asc"}],skip:0,limit:e})}async function sO(t,e,n){if(t.getChangedDocumentsSince)return t.getChangedDocumentsSince(e,n);var r=Fn(t.schema.primaryKey),i=Jl(t.schema,q2(t,e,n)),s=await t.query(i),o=s.documents,a=DP(o);return{documents:o,checkpoint:a?{id:a[r],lwt:a._meta.lwt}:n||{id:"",lwt:0}}}var oO=function(){function t(n,r,i,s){this.queueByDocId=new Map,this.isRunning=!1,this.storageInstance=n,this.primaryPath=r,this.preWrite=i,this.postWrite=s}var e=t.prototype;return e.addWrite=function(r,i){var s=r[this.primaryPath],o=Tr(this.queueByDocId,s,()=>[]),a=new Promise((l,f)=>{var h={lastKnownDocumentState:r,modifier:i,resolve:l,reject:f};ye(o).push(h),this.triggerRun()});return a},e.triggerRun=async function(){if(!(this.isRunning===!0||this.queueByDocId.size===0)){this.isRunning=!0;var r=[],i=this.queueByDocId;this.queueByDocId=new Map,await Promise.all(Array.from(i.entries()).map(async([o,a])=>{var l=H2(a.map(m=>m.lastKnownDocumentState)),f=l;for(var h of a)try{f=await h.modifier(Pn(f))}catch(m){h.reject(m),h.reject=()=>{},h.resolve=()=>{}}try{await this.preWrite(f,l)}catch(m){a.forEach(y=>y.reject(m));return}r.push({previous:l,document:f})}));var s=r.length>0?await this.storageInstance.bulkWrite(r,"incremental-write"):{error:[],success:[]};return await Promise.all(s.success.map(o=>{var a=o[this.primaryPath];this.postWrite(o);var l=Mo(i,a);l.forEach(f=>f.resolve(o))})),s.error.forEach(o=>{var a=o.documentId,l=Mo(i,a),f=_h(o);if(f){var h=Tr(this.queueByDocId,a,()=>[]);l.reverse().forEach(y=>{y.lastKnownDocumentState=ye(f.documentInDb),ye(h).unshift(y)})}else{var m=iR(o);l.forEach(y=>y.reject(m))}}),this.isRunning=!1,this.triggerRun()}},t}();function ib(t){var e=async n=>{var r=PP(n);r._deleted=n._deleted;var i=await t(r),s=Object.assign({},i,{_meta:n._meta,_attachments:n._attachments,_rev:n._rev,_deleted:typeof i._deleted<"u"?i._deleted:n._deleted});return typeof s._deleted>"u"&&(s._deleted=!1),s};return e}function H2(t){var e=t[0],n=za(e._rev).height;return t.forEach(r=>{var i=za(r._rev).height;i>n&&(e=r,n=i)}),e}var kh={get primaryPath(){var t=this;if(t.isInstanceOfRxDocument)return t.collection.schema.primaryPath},get primary(){var t=this;if(t.isInstanceOfRxDocument)return t._data[t.primaryPath]},get revision(){var t=this;if(t.isInstanceOfRxDocument)return t._data._rev},get deleted$(){var t=this;if(t.isInstanceOfRxDocument)return t.$.pipe(Mt(e=>e._data._deleted))},get deleted$$(){var t=this,e=t.collection.database.getReactivityFactory();return e.fromObservable(t.deleted$,t.getLatest().deleted)},get deleted(){var t=this;if(t.isInstanceOfRxDocument)return t._data._deleted},getLatest(){var t=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(t)},get $(){var t=this;return t.collection.$.pipe(lt(e=>!e.isLocal),lt(e=>e.documentId===this.primary),Mt(e=>kg(e)),Hl(t.collection._docCache.getLatestDocumentData(this.primary)),Bo((e,n)=>e._rev===n._rev),Mt(e=>this.collection._docCache.getCachedRxDocument(e)),Pi(Ci))},get $$(){var t=this,e=t.collection.database.getReactivityFactory();return e.fromObservable(t.$,t.getLatest()._data)},get$(t){if(it.isDevMode()){if(t.includes(".item."))throw le("DOC1",{path:t});if(t===this.primaryPath)throw le("DOC2");if(this.collection.schema.finalFields.includes(t))throw le("DOC3",{path:t});var e=zi(this.collection.schema.jsonSchema,t);if(!e)throw le("DOC4",{path:t})}return this.$.pipe(Mt(n=>Ts(n,t)),Bo())},get$$(t){var e=this.get$(t),n=this.collection.database.getReactivityFactory();return n.fromObservable(e,this.getLatest().get(t))},populate(t){var e=zi(this.collection.schema.jsonSchema,t),n=this.get(t);if(!n)return mg;if(!e)throw le("DOC5",{path:t});if(!e.ref)throw le("DOC6",{path:t,schemaObj:e});var r=this.collection.database.collections[e.ref];if(!r)throw le("DOC7",{ref:e.ref,path:t,schemaObj:e});return e.type==="array"?r.findByIds(n).exec().then(i=>{var s=i.values();return Array.from(s)}):r.findOne(n).exec()},get(t){return Tr(this._propertyCache,t,()=>{var e=Ts(this._data,t);if(typeof e!="object"||e===null||Array.isArray(e))return it.deepFreezeWhenDevMode(e);var n=this,r=new Proxy($e(e),{get(i,s){if(typeof s!="string")return i[s];var o=s.charAt(s.length-1);if(s.endsWith("$$")){var a=s.slice(0,-2);return n.get$$(zu(t+"."+a))}else if(o==="$"){var l=s.slice(0,-1);return n.get$(zu(t+"."+l))}else if(o==="_"){var f=s.slice(0,-1);return n.populate(zu(t+"."+f))}else return n.get(zu(t+"."+s))}});return r})},toJSON(t=!1){if(t)return it.deepFreezeWhenDevMode(this._data);var e=$e(this._data);return delete e._rev,delete e._attachments,delete e._deleted,delete e._meta,it.deepFreezeWhenDevMode(e)},toMutableJSON(t=!1){return Pn(this.toJSON(t))},update(t){throw pt("update")},incrementalUpdate(t){throw pt("update")},updateCRDT(t){throw pt("crdt")},putAttachment(){throw pt("attachments")},getAttachment(){throw pt("attachments")},allAttachments(){throw pt("attachments")},get allAttachments$(){throw pt("attachments")},async modify(t,e){var n=this._data,r=await ib(t)(n);return this._saveData(r,n)},incrementalModify(t,e){return this.collection.incrementalWriteQueue.addWrite(this._data,ib(t)).then(n=>this.collection._docCache.getCachedRxDocument(n))},patch(t){var e=this._data,n=Pn(e);return Object.entries(t).forEach(([r,i])=>{n[r]=i}),this._saveData(n,e)},incrementalPatch(t){return this.incrementalModify(e=>(Object.entries(t).forEach(([n,r])=>{e[n]=r}),e))},async _saveData(t,e){if(t=$e(t),this._data._deleted)throw le("DOC11",{id:this.primary,document:this});await uO(this.collection,t,e);var n=await this.collection.storageInstance.bulkWrite([{previous:e,document:t}],"rx-document-save-data"),r=n.error[0];return yd(this.collection,this.primary,t,r),await this.collection._runHooks("post","save",t,this),this.collection._docCache.getCachedRxDocument(n.success[0])},remove(){var t=this.collection;if(this.deleted)return Promise.reject(le("DOC13",{document:this,id:this.primary}));var e=$e(this._data),n;return t._runHooks("pre","remove",e,this).then(async()=>{e._deleted=!0;var r=await t.storageInstance.bulkWrite([{previous:this._data,document:e}],"rx-document-remove"),i=r.error[0];return yd(t,this.primary,e,i),r.success[0]}).then(r=>(n=r,this.collection._runHooks("post","remove",e,this))).then(()=>this.collection._docCache.getCachedRxDocument(n))},incrementalRemove(){return this.incrementalModify(async t=>(await this.collection._runHooks("pre","remove",t,this),t._deleted=!0,t)).then(async t=>(await this.collection._runHooks("post","remove",t._data,t),t))},destroy(){throw le("DOC14")}};function aO(t=kh){var e=function(r,i){this.collection=r,this._data=i,this._propertyCache=new Map,this.isInstanceOfRxDocument=!0};return e.prototype=t,e}function Q2(t,e,n){var r=new t(e,n);return Mr("createRxDocument",r),r}function uO(t,e,n){return e._meta=Object.assign({},n._meta,e._meta),it.isDevMode()&&t.schema.validateChange(n,e),t._runHooks("pre","save",e,n)}var ko="collection",jg="storage-token",Pf="rx-migration-status",Y2="RxInternalDocument",Ug=bh({version:0,title:Y2,primaryKey:{key:"id",fields:["context","key"],separator:"|"},type:"object",properties:{id:{type:"string",maxLength:200},key:{type:"string"},context:{type:"string",enum:[ko,jg,Pf,"OTHER"]},data:{type:"object",additionalProperties:!0}},indexes:[],required:["key","context","data"],additionalProperties:!1,sharding:{shards:1,mode:"collection"}});function Ha(t,e){return Ws(Ug,{key:t,context:e})}async function zg(t){var e=Jl(t.schema,{selector:{context:ko,_deleted:{$eq:!1}},sort:[{id:"asc"}],skip:0}),n=await t.query(e),r=n.documents;return r}var lO="storageToken",G2=Ha(lO,jg);async function J2(t){var e=iu(10),n=t.password?await t.hashFunction(JSON.stringify(t.password)):void 0,r={id:G2,context:jg,key:lO,data:{rxdbVersion:t.rxdbVersion,token:e,instanceToken:t.token,passwordHash:n},_deleted:!1,_meta:Ks(),_rev:Rn(),_attachments:{}},i=await t.internalStore.bulkWrite([{document:r}],"internal-add-storage-token");if(i.success[0])return i.success[0];var s=ye(i.error[0]);if(s.isError&&_h(s)){var o=s;if(!X2(o.documentInDb.data.rxdbVersion,t.rxdbVersion))throw le("DM5",{args:{database:t.name,databaseStateVersion:o.documentInDb.data.rxdbVersion,codeVersion:t.rxdbVersion}});if(n&&n!==o.documentInDb.data.passwordHash)throw le("DB1",{passwordHash:n,existingPasswordHash:o.documentInDb.data.passwordHash});var a=o.documentInDb;return ye(a)}throw s}function X2(t,e){if(!t||e.includes("beta")&&e!==t)return!1;var n=t.split(".")[0],r=e.split(".")[0];return n===r}async function cO(t,e,n){if(t.schema.version!==n.version)throw le("SNH",{schema:n,version:t.schema.version,name:t.name,collection:t,args:{storageCollectionName:e}});for(var r=jy(t.name,t.schema.jsonSchema),i=Ha(r,ko);;){var s=await Xl(t.database.internalStore,i),o=Pn(ye(s)),a=o.data.connectedStorages.find(l=>l.collectionName===e&&l.schema.version===n.version);if(a)return;o.data.connectedStorages.push({collectionName:e,schema:n});try{await Tl(t.database.internalStore,{previous:ye(s),document:o},"add-connected-storage-to-collection")}catch(l){if(!_h(l))throw l}}}function jy(t,e){return t+"-"+e.version}function dm(t,e){return e=$e(e),e=lR(t,e),e=sE(t.primaryPath,t.jsonSchema,e),e._meta=Ks(),Object.prototype.hasOwnProperty.call(e,"_deleted")||(e._deleted=!1),Object.prototype.hasOwnProperty.call(e,"_attachments")||(e._attachments={}),Object.prototype.hasOwnProperty.call(e,"_rev")||(e._rev=Rn()),e}async function Z2(t,e){e.multiInstance=t.multiInstance;var n=await t.storage.createStorageInstance(e);return n}async function fO(t,e,n,r,i,s,o){var a=await zg(e),l=a.filter(y=>y.data.name===i),f=[];l.forEach(y=>{f.push({collectionName:y.data.name,schema:y.data.schema,isCollection:!0}),y.data.connectedStorages.forEach(w=>f.push({collectionName:w.collectionName,isCollection:!1,schema:w.schema}))});var h=new Set;if(f=f.filter(y=>{var w=y.collectionName+"||"+y.schema.version;return h.has(w)?!1:(h.add(w),!0)}),await Promise.all(f.map(async y=>{var w=await t.createStorageInstance({collectionName:y.collectionName,databaseInstanceToken:n,databaseName:r,multiInstance:!1,options:{},schema:y.schema,password:s,devMode:it.isDevMode()});await w.remove(),y.isCollection&&await No("postRemoveRxCollection",{storage:t,databaseName:r,collectionName:i})})),o){var m=l.map(y=>{var w=Lg(y);return w._deleted=!0,w._meta.lwt=Ft(),w._rev=Ui(n,y),{previous:y,document:w}});await e.bulkWrite(m,"rx-database-remove-collection-all")}}var eN=function(){function t(n){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=n,this.subs.push(this.collection.$.pipe(lt(r=>!r.isLocal)).subscribe(r=>this._handleChangeEvent(r)))}var e=t.prototype;return e._handleChangeEvent=function(r){for(this.counter++,this.buffer.push(r),this.eventCounterMap.set(r,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},e.getArrayIndexByPointer=function(r){var i=this.buffer[0],s=this.eventCounterMap.get(i);if(ri(o))},e.reduceByLastOfDoc=function(r){return r.slice(0)},e.destroy=function(){this.subs.forEach(r=>r.unsubscribe())},t}();function tN(t){return new eN(t)}var nN=new WeakMap;function rN(t){var e=t.schema.getDocumentPrototype(),n=oN(t),r=kh,i={};return[e,n,r].forEach(s=>{var o=Object.getOwnPropertyNames(s);o.forEach(a=>{var l=Object.getOwnPropertyDescriptor(s,a),f=!0;(a.startsWith("_")||a.endsWith("_")||a.startsWith("$")||a.endsWith("$"))&&(f=!1),typeof l.value=="function"?Object.defineProperty(i,a,{get(){return l.value.bind(this)},enumerable:f,configurable:!1}):(l.enumerable=f,l.configurable=!1,l.writable&&(l.writable=!1),Object.defineProperty(i,a,l))})}),i}function iN(t){return Tr(nN,t,()=>aO(rN(t)))}function sN(t,e){var n=Q2(iN(t),t,it.deepFreezeWhenDevMode(e));return t._runHooksSync("post","create",e,n),Mr("postCreateRxDocument",n),n}function oN(t){var e={};return Object.entries(t.methods).forEach(([n,r])=>{e[n]=r}),e}async function gd(t,e){var n=Ws(t.input.metaInstance.schema,{isCheckpoint:"1",itemId:e}),r=await t.input.metaInstance.findDocumentsById([n],!1),i=r[0];if(t.lastCheckpointDoc[e]=i,i)return i.checkpointData}async function wd(t,e,n){t.checkpointQueue=t.checkpointQueue.then(async()=>{var r=t.lastCheckpointDoc[e];if(n&&!t.events.canceled.getValue()&&(!r||JSON.stringify(r.checkpointData)!==JSON.stringify(n))){var i={id:"",isCheckpoint:"1",itemId:e,_deleted:!1,_attachments:{},checkpointData:n,_meta:Ks(),_rev:Rn()};for(i.id=Ws(t.input.metaInstance.schema,i);!t.events.canceled.getValue();){if(r&&(i.checkpointData=Ml([r.checkpointData,i.checkpointData])),i._meta.lwt=Ft(),i._rev=Ui(await t.checkpointKey,r),t.events.canceled.getValue())return;var s=await t.input.metaInstance.bulkWrite([{previous:r,document:i}],"replication-set-checkpoint"),o=s.success[0];if(o){t.lastCheckpointDoc[e]=o;return}else{var a=s.error[0];if(a.status!==409)throw a;r=ye(a.documentInDb),i._rev=Ui(await t.checkpointKey,r)}}}}),await t.checkpointQueue}async function aN(t){var e=await t.hashFunction([t.identifier,t.forkInstance.databaseName,t.forkInstance.collectionName].join("||"));return"rx_storage_replication_"+e}function sb(t,e,n,r,i){var s=Object.assign({},r,{_attachments:e&&r._attachments?r._attachments:{},_meta:n?r._meta:{lwt:Ft()},_rev:n?r._rev:Rn()});return s._rev||(s._rev=Ui(t,i)),s}function cs(t,e,n){var r=$e(t);return e||delete r._attachments,n||(delete r._meta,delete r._rev),r}function Uy(t,e){return t.hasAttachments?e.map(n=>{var r=Pn(n.document);return r.docData=gs(r.docData),{document:r,previous:n.previous}}):e}function zy(t){for(;;)if(t.underlyingPersistentStorage)t=t.underlyingPersistentStorage;else return t}var Rf="RxReplicationProtocolMetaData";function Vy(t,e){var n=sR(t),r={title:Rf,primaryKey:{key:"id",fields:["itemId","isCheckpoint"],separator:"|"},type:"object",version:t.version,additionalProperties:!1,properties:{id:{type:"string",minLength:1,maxLength:n+2},isCheckpoint:{type:"string",enum:["0","1"],minLength:1,maxLength:1},itemId:{type:"string",maxLength:n>4?n:4},checkpointData:{type:"object",additionalProperties:!0},docData:{type:"object",properties:t.properties},isResolvedConflict:{type:"string"}},keyCompression:t.keyCompression,required:["id","isCheckpoint","itemId"]};e&&(r.encrypted=["docData"]);var i=bh(r);return i}function dO(t,e){return t.input.metaInstance.findDocumentsById(e.map(n=>{var r=Ws(t.input.metaInstance.schema,{itemId:n,isCheckpoint:"0"});return r}),!0).then(n=>{var r={};return Object.values(n).forEach(i=>{r[i.itemId]={docData:i.docData,metaDocument:i}}),r})}async function _d(t,e,n,r){var i=e[t.primaryPath],s=n?Lg(n):{id:"",isCheckpoint:"0",itemId:i,docData:e,_attachments:{},_deleted:!1,_rev:Rn(),_meta:{lwt:0}};s.docData=e,r&&(s.isResolvedConflict=r),s._meta.lwt=Ft(),s.id=Ws(t.input.metaInstance.schema,s),s._rev=Ui(await t.checkpointKey,n);var o={previous:n,document:s};return o}async function uN(t){if(t.input.initialCheckpoint&&t.input.initialCheckpoint.downstream){var e=await gd(t,"down");e||await wd(t,"down",t.input.initialCheckpoint.downstream)}var n=await t.input.hashFunction(t.input.identifier),r=t.input.replicationHandler,i=0,s=[];function o(I){t.stats.down.addNewTask=t.stats.down.addNewTask+1;var E={time:i++,task:I};s.push(E),t.streamQueue.down=t.streamQueue.down.then(()=>{for(var F=[];s.length>0;){t.events.active.down.next(!0);var S=ye(s.shift());if(!(S.time{t.events.active.down.next(!1),!t.firstSyncDone.down.getValue()&&!t.events.canceled.getValue()&&t.firstSyncDone.down.next(!0)})}if(o("RESYNC"),!t.events.canceled.getValue()){var a=r.masterChangeStream$.pipe(Nr(async I=>(await Cs(t.events.active.up.pipe(lt(E=>!E))),I))).subscribe(I=>{t.stats.down.masterChangeStreamEmit=t.stats.down.masterChangeStreamEmit+1,o(I)});Cs(t.events.canceled.pipe(lt(I=>!!I))).then(()=>a.unsubscribe())}var l=-1;async function f(){if(t.stats.down.downstreamResyncOnce=t.stats.down.downstreamResyncOnce+1,!t.events.canceled.getValue()){t.checkpointQueue=t.checkpointQueue.then(()=>gd(t,"down"));for(var I=await t.checkpointQueue,E=[];!t.events.canceled.getValue();){l=i++;var F=await r.masterChangesSince(I,t.input.pullBatchSize);if(F.documents.length===0||(I=Ml([I,F.checkpoint]),E.push(w(F.documents,I)),F.documents.length{if(S==="RESYNC")throw new Error("SNH");Ua(E,S.documents),F=Ml([F,S.checkpoint])}),w(E,ye(F))}var m=un,y={docs:{}};function w(I,E){var F=t.primaryPath;return t.stats.down.persistFromMaster=t.stats.down.persistFromMaster+1,I.forEach(S=>{var _=S[F];y.docs[_]=S}),y.checkpoint=E,m=m.then(()=>{var S=y.docs;y.docs={};var _=y.checkpoint,k=Object.keys(S);if(t.events.canceled.getValue()||k.length===0)return un;var z=[],W={},Q={},H=[];return Promise.all([t.input.forkInstance.findDocumentsById(k,!0),dO(t,k)]).then(([X,U])=>{var ee=new Map;return X.forEach(ce=>ee.set(ce[F],ce)),Promise.all(k.map(async ce=>{var de=ee.get(ce),Pe=de?cs(de,t.hasAttachments,!1):void 0,ot=S[ce],ct=U[ce];if(ct&&de&&ct.metaDocument.isResolvedConflict===de._rev)return un;var Te=!ct||!Pe?!1:await t.input.conflictHandler({realMasterState:ct.docData,newDocumentState:Pe},"downstream-check-if-equal-0").then(Re=>Re.isEqual);if(!Te&&ct&&ct.docData._rev&&de&&de._meta[t.input.identifier]&&za(de._rev).height===de._meta[t.input.identifier]&&(Te=!0),de&&ct&&Te===!1||de&&!ct)return un;var Dt=Pe?await t.input.conflictHandler({realMasterState:ot,newDocumentState:Pe},"downstream-check-if-equal-1").then(Re=>Re.isEqual):!1;if(Pe&&Dt)return(!ct||Te===!1)&&H.push(await _d(t,Pe,ct?ct.metaDocument:void 0)),un;var G=Object.assign({},ot,de?{_meta:$e(de._meta),_attachments:t.hasAttachments&&ot._attachments?ot._attachments:{},_rev:Rn()}:{_meta:{lwt:Ft()},_rev:Rn(),_attachments:t.hasAttachments&&ot._attachments?ot._attachments:{}});if(ot._rev){var oe=de?za(de._rev).height+1:1;G._meta[t.input.identifier]=oe,t.input.keepMeta&&(G._rev=ot._rev)}t.input.keepMeta&&ot._meta&&(G._meta=ot._meta);var ue={previous:de,document:G};ue.document._rev=ue.document._rev?ue.document._rev:Ui(n,ue.previous),z.push(ue),W[ce]=ue,Q[ce]=await _d(t,ot,ct?ct.metaDocument:void 0)}))}).then(async()=>{if(z.length>0)return t.input.forkInstance.bulkWrite(z,await t.downstreamBulkWriteFlag).then(X=>{X.success.forEach(U=>{var ee=U[F];t.events.processed.down.next(W[ee]),H.push(Q[ee])}),X.error.forEach(U=>{U.status!==409&&t.events.error.next(le("RC_PULL",{writeError:U}))})})}).then(()=>{if(H.length>0)return t.input.metaInstance.bulkWrite(Uy(t,H),"replication-down-write-meta").then(X=>{X.error.forEach(U=>{t.events.error.next(le("RC_PULL",{id:U.documentId,writeError:U}))})})}).then(()=>{wd(t,"down",_)})}).catch(S=>t.events.error.next(S)),m}}var bd=function(t,e){var n=gs(t.newDocumentState),r=gs(t.realMasterState);return Va(n,r)?Promise.resolve({isEqual:!0}):Promise.resolve({isEqual:!1,documentData:t.realMasterState})};async function lN(t,e,n){var r=t.input.conflictHandler,i=await r(e,"replication-resolve-conflict");if(!i.isEqual){var s=Object.assign({},i.documentData,{_meta:$e(n._meta),_rev:Rn(),_attachments:$e(n._attachments)});return s._meta.lwt=Ft(),s._rev=Ui(await t.checkpointKey,n),{resolvedDoc:s,output:i}}}async function Ky(t,e,n,r){if(!n._attachments||r&&!r._attachments)throw new Error("_attachments missing");var i=n[t],s=new Set(r&&r._attachments?Object.keys(r._attachments):[]);return await Promise.all(Object.entries(n._attachments).map(async([o,a])=>{if((!s.has(o)||r&&ye(r._attachments)[o].digest!==a.digest)&&!a.data){var l=await e.getAttachmentData(i,o,a.digest);a.data=l}})),n}async function cN(t){if(t.input.initialCheckpoint&&t.input.initialCheckpoint.upstream){var e=await gd(t,"up");e||await wd(t,"up",t.input.initialCheckpoint.upstream)}var n=t.input.replicationHandler;t.streamQueue.up=t.streamQueue.up.then(()=>f().then(()=>{h()}));var r=0,i=-1,s=[],o=Gn,a={docs:{}},l=t.input.forkInstance.changeStream().subscribe(async y=>{if(y.context!==await t.downstreamBulkWriteFlag)return t.stats.up.forkChangeStreamEmit=t.stats.up.forkChangeStreamEmit+1,s.push({task:y,time:r++}),t.events.active.up.getValue()||t.events.active.up.next(!0),t.input.waitBeforePersist?t.input.waitBeforePersist().then(()=>h()):h()});Cs(t.events.canceled.pipe(lt(y=>!!y))).then(()=>l.unsubscribe());async function f(){if(t.stats.up.upstreamInitialSync=t.stats.up.upstreamInitialSync+1,!t.events.canceled.getValue()){t.checkpointQueue=t.checkpointQueue.then(()=>gd(t,"up"));for(var y=await t.checkpointQueue,w=new Set,I=async function(){i=r++,w.size>3&&await Promise.race(Array.from(w));var S=await sO(t.input.forkInstance,t.input.pushBatchSize,y);if(S.documents.length===0)return 1;y=Ml([y,S.checkpoint]);var _=m(S.documents,ye(y));w.add(_),_.catch().then(()=>w.delete(_))};!t.events.canceled.getValue()&&!await I(););var E=await Promise.all(w),F=E.find(S=>!!S);F?await f():!t.firstSyncDone.up.getValue()&&!t.events.canceled.getValue()&&t.firstSyncDone.up.next(!0)}}function h(){if(t.events.canceled.getValue()||s.length===0){t.events.active.up.next(!1);return}t.stats.up.processTasks=t.stats.up.processTasks+1,t.events.active.up.next(!0),t.streamQueue.up=t.streamQueue.up.then(()=>{for(var y=[],w={};s.length>0;){var I=ye(s.shift());I.timeF.documentData)),w=Ml([w,I.task.checkpoint]))}var E=y.length===0?Gn:m(y,w);return E.then(()=>{s.length===0?t.events.active.up.next(!1):h()})})}function m(y,w){return t.stats.up.persistToMaster=t.stats.up.persistToMaster+1,y.forEach(I=>{var E=I[t.primaryPath];a.docs[E]=I}),a.checkpoint=w,o=o.then(async()=>{if(t.events.canceled.getValue())return!1;var I=a.docs;a.docs={};var E=a.checkpoint,F=Object.keys(I);if(F.length===0)return!1;var S=await dO(t,F),_={},k=[],z={},W={};if(await Promise.all(F.map(async Te=>{var Dt=I[Te];W[Te]=Dt;var G=cs(Dt,t.hasAttachments,!!t.input.keepMeta),oe=S[Te];oe&&oe.metaDocument.isResolvedConflict!==Dt._rev&&(await t.input.conflictHandler({realMasterState:oe.docData,newDocumentState:G},"upstream-check-if-equal")).isEqual||oe&&oe.docData._rev&&za(Dt._rev).height===Dt._meta[t.input.identifier]||(k.push(Te),_[Te]={assumedMasterState:oe?oe.docData:void 0,newDocumentState:G},z[Te]=await _d(t,G,oe?oe.metaDocument:void 0))})),k.length===0)return!1;var Q=Object.values(_),H=new Set,X={},U=xP(Q,t.input.pushBatchSize);await Promise.all(U.map(async Te=>{t.hasAttachments&&await Promise.all(Te.map(async G=>{G.newDocumentState=await Ky(t.primaryPath,t.input.forkInstance,Pn(G.newDocumentState),G.assumedMasterState)}));var Dt=await n.masterWrite(Te);Dt.forEach(G=>{var oe=G[t.primaryPath];H.add(oe),X[oe]=G})}));var ee=[];if(k.forEach(Te=>{H.has(Te)||(t.events.processed.up.next(_[Te]),ee.push(z[Te]))}),t.events.canceled.getValue())return!1;ee.length>0&&await t.input.metaInstance.bulkWrite(Uy(t,ee),"replication-up-write-meta");var ce=!1;if(H.size>0){t.stats.up.persistToMasterHadConflicts=t.stats.up.persistToMasterHadConflicts+1;var de=[],Pe={};if(await Promise.all(Object.entries(X).map(([Te,Dt])=>{var G=_[Te],oe={newDocumentState:G.newDocumentState,assumedMasterState:G.assumedMasterState,realMasterState:Dt};return lN(t,oe,W[Te]).then(async ue=>{if(ue){t.events.resolvedConflicts.next({input:oe,output:ue.output}),de.push({previous:W[Te],document:ue.resolvedDoc});var Re=S[Te];Pe[Te]=await _d(t,ye(Dt),Re?Re.metaDocument:void 0,ue.resolvedDoc._rev)}})})),de.length>0){ce=!0,t.stats.up.persistToMasterConflictWrites=t.stats.up.persistToMasterConflictWrites+1;var ot=await t.input.forkInstance.bulkWrite(de,"replication-up-write-conflict"),ct=[];ot.success.forEach(Te=>{var Dt=Te[t.primaryPath];ct.push(Pe[Dt])}),ct.length>0&&await t.input.metaInstance.bulkWrite(Uy(t,ct),"replication-up-write-conflict-meta")}}return wd(t,"up",E),ce}).catch(I=>(t.events.error.next(I),!1)),o}}function hO(t){t=$e(t),t.forkInstance=zy(t.forkInstance),t.metaInstance=zy(t.metaInstance);var e=aN(t),n={primaryPath:Fn(t.forkInstance.schema.primaryKey),hasAttachments:!!t.forkInstance.schema.attachments,input:t,checkpointKey:e,downstreamBulkWriteFlag:e.then(r=>"replication-downstream-"+r),events:{canceled:new Gr(!1),active:{down:new Gr(!0),up:new Gr(!0)},processed:{down:new Kt,up:new Kt},resolvedConflicts:new Kt,error:new Kt},stats:{down:{addNewTask:0,downstreamProcessChanges:0,downstreamResyncOnce:0,masterChangeStreamEmit:0,persistFromMaster:0},up:{forkChangeStreamEmit:0,persistToMaster:0,persistToMasterConflictWrites:0,persistToMasterHadConflicts:0,processTasks:0,upstreamInitialSync:0}},firstSyncDone:{down:new Gr(!1),up:new Gr(!1)},streamQueue:{down:un,up:un},checkpointQueue:un,lastCheckpointDoc:{}};return uN(n),cN(n),n}function Tf(t){return Cs(AE([t.firstSyncDone.down.pipe(lt(e=>!!e)),t.firstSyncDone.up.pipe(lt(e=>!!e))])).then(()=>{})}function ob(t){return Promise.all([t.streamQueue.up,t.streamQueue.down,t.checkpointQueue])}function fN(t,e,n,r=!1){t=zy(t);var i=!!t.schema.attachments,s=Fn(t.schema.primaryKey),o={masterChangeStream$:t.changeStream().pipe(Nr(async a=>{var l={checkpoint:a.checkpoint,documents:await Promise.all(a.events.map(async f=>{var h=cs(f.documentData,i,r);return i&&(h=await Ky(s,t,Pn(h),void 0)),h}))};return l})),masterChangesSince(a,l){return sO(t,l,a).then(async f=>({checkpoint:f.documents.length>0?f.checkpoint:a,documents:await Promise.all(f.documents.map(async h=>{var m=cs(h,i,r);return i&&(m=await Ky(s,t,Pn(m),void 0)),m}))}))},async masterWrite(a){var l={};a.forEach(E=>{var F=E.newDocumentState[s];l[F]=E});var f=Object.keys(l),h=await t.findDocumentsById(f,!0),m=new Map;h.forEach(E=>m.set(E[s],E));var y=[],w=[];if(await Promise.all(Object.entries(l).map(async([E,F])=>{var S=m.get(E);S?S&&!F.assumedMasterState?y.push(cs(S,i,r)):(await e({realMasterState:cs(S,i,r),newDocumentState:ye(F.assumedMasterState)},"rxStorageInstanceToReplicationHandler-masterWrite")).isEqual===!0?w.push({previous:S,document:sb(n,i,r,F.newDocumentState,S)}):y.push(cs(S,i,r)):w.push({document:sb(n,i,r,F.newDocumentState)})})),w.length>0){var I=await t.bulkWrite(w,"replication-master-write");I.error.forEach(E=>{if(E.status!==409)throw new Error("non conflict error");y.push(cs(ye(E.documentInDb),i,r))})}return y}};return o}async function pO(t){t.events.canceled.next(!0),t.events.active.up.complete(),t.events.active.down.complete(),t.events.processed.up.complete(),t.events.processed.down.complete(),t.events.resolvedConflicts.complete(),t.events.canceled.complete(),await t.checkpointQueue}var mO=["pre","post"],yO=["insert","save","remove","create"],ab=!1,vO=function(){function t(n,r,i,s,o={},a={},l={},f={},h={},m=GE,y={},w=bd){this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=O2(),this.$={},this.checkpoint$={},this._changeEventBuffer={},this.onDestroy=[],this.destroyed=!1,this.database=n,this.name=r,this.schema=i,this.internalStorageInstance=s,this.instanceCreationOptions=o,this.migrationStrategies=a,this.methods=l,this.attachments=f,this.options=h,this.cacheReplacementPolicy=m,this.statics=y,this.conflictHandler=w,dN(this.asRxCollection)}var e=t.prototype;return e.prepare=async function(){this.storageInstance=$g(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new oO(this.storageInstance,this.schema.primaryPath,(o,a)=>uO(this,o,a),o=>this._runHooks("post","save",o));var r=this.database.eventBulks$.pipe(lt(o=>o.collectionName===this.name));this.$=r.pipe(Nr(o=>o.events)),this.checkpoint$=r.pipe(Mt(o=>o.checkpoint)),this._changeEventBuffer=tN(this.asRxCollection),this._docCache=new JE(this.schema.primaryPath,this.$.pipe(lt(o=>!o.isLocal)),o=>sN(this.asRxCollection,o));var i=await this.database.storageToken,s=this.storageInstance.changeStream().subscribe(o=>{var a={id:o.id,internal:!1,collectionName:this.name,storageToken:i,events:o.events.map(l=>nO(!1,l,this)),databaseToken:this.database.token,checkpoint:o.checkpoint,context:o.context,endTime:o.endTime,startTime:o.startTime};this.database.$emit(a)});return this._subs.push(s),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe(o=>{this.conflictHandler(o.input,o.context).then(a=>{this.storageInstance.resolveConflictResultionTask({id:o.id,output:a})})})),un},e.cleanup=function(r){throw pt("cleanup")},e.migrationNeeded=function(){throw pt("migration-schema")},e.getMigrationState=function(){throw pt("migration-schema")},e.startMigration=function(r=10){return this.getMigrationState().startMigration(r)},e.migratePromise=function(r=10){return this.getMigrationState().migratePromise(r)},e.insert=async function(r){var i=await this.bulkInsert([r]),s=i.error[0];yd(this,r[this.schema.primaryPath],r,s);var o=ye(i.success[0]);return o},e.bulkInsert=async function(r){if(r.length===0)return{success:[],error:[]};var i=this.schema.primaryPath,s=r.map(m=>{var y=dm(this.schema,m);return y}),o=this.hasHooks("pre","insert")?await Promise.all(s.map(m=>this._runHooks("pre","insert",m).then(()=>m))):s,a=o.map(m=>{var y={document:m};return y}),l=await this.storageInstance.bulkWrite(a,"rx-collection-bulk-insert"),f=XE(this._docCache,l.success);if(this.hasHooks("post","insert")){var h=new Map;o.forEach(m=>{h.set(m[i],m)}),await Promise.all(f.map(m=>this._runHooks("post","insert",h.get(m.primary),m)))}return{success:f,error:l.error}},e.bulkRemove=async function(r){var i=this.schema.primaryPath;if(r.length===0)return{success:[],error:[]};var s=await this.findByIds(r).exec(),o=[],a=new Map;Array.from(s.values()).forEach(y=>{var w=y.toMutableJSON(!0);o.push(w),a.set(y.primary,w)}),await Promise.all(o.map(y=>{var w=y[this.schema.primaryPath];return this._runHooks("pre","remove",y,s.get(w))}));var l=o.map(y=>{var w=$e(y);return w._deleted=!0,{previous:y,document:w}}),f=await this.storageInstance.bulkWrite(l,"rx-collection-bulk-remove"),h=f.success.map(y=>y[i]);await Promise.all(h.map(y=>this._runHooks("post","remove",a.get(y),s.get(y))));var m=h.map(y=>Mo(s,y));return{success:m,error:f.error}},e.bulkUpsert=async function(r){var i=[],s=new Map;r.forEach(f=>{var h=dm(this.schema,f),m=h[this.schema.primaryPath];if(!m)throw le("COL3",{primaryPath:this.schema.primaryPath,data:h,schema:this.schema.jsonSchema});s.set(m,h),i.push(h)});var o=await this.bulkInsert(i),a=o.success.slice(0),l=[];return await Promise.all(o.error.map(async f=>{if(f.status!==409)l.push(f);else{var h=f.documentId,m=Mo(s,h),y=ye(f.documentInDb),w=this._docCache.getCachedRxDocument(y),I=await w.incrementalModify(()=>m);a.push(I)}})),{error:l,success:a}},e.upsert=async function(r){var i=await this.bulkUpsert([r]);return yd(this.asRxCollection,r[this.schema.primaryPath],r,i.error[0]),i.success[0]},e.incrementalUpsert=function(r){var i=dm(this.schema,r),s=i[this.schema.primaryPath];if(!s)throw le("COL4",{data:r});var o=this._incrementalUpsertQueues.get(s);return o||(o=un),o=o.then(()=>pN(this,s,i)).then(a=>a.inserted?a.doc:hN(a.doc,i)),this._incrementalUpsertQueues.set(s,o),o},e.find=function(r){if(typeof r=="string")throw le("COL5",{queryObj:r});r||(r=tl());var i=na("find",r,this);return i},e.findOne=function(r){if(typeof r=="number"||Array.isArray(r))throw el("COL6",{queryObj:r});var i;if(typeof r=="string")i=na("findOne",{selector:{[this.schema.primaryPath]:r},limit:1},this);else{if(r||(r=tl()),r.limit)throw le("QU6");r=$e(r),r.limit=1,i=na("findOne",r,this)}return i},e.count=function(r){r||(r=tl());var i=na("count",r,this);return i},e.findByIds=function(r){var i={selector:{[this.schema.primaryPath]:{$in:r.slice(0)}}},s=na("findByIds",i,this);return s},e.exportJSON=function(){throw pt("json-dump")},e.importJSON=function(r){throw pt("json-dump")},e.insertCRDT=function(r){throw pt("crdt")},e.addHook=function(r,i,s,o=!1){if(typeof s!="function")throw el("COL7",{key:i,when:r});if(!mO.includes(r))throw el("COL8",{key:i,when:r});if(!yO.includes(i))throw le("COL9",{key:i});if(r==="post"&&i==="create"&&o===!0)throw le("COL10",{when:r,key:i,parallel:o});var a=s.bind(this),l=o?"parallel":"series";this.hooks[i]=this.hooks[i]||{},this.hooks[i][r]=this.hooks[i][r]||{series:[],parallel:[]},this.hooks[i][r][l].push(a)},e.getHooks=function(r,i){return!this.hooks[i]||!this.hooks[i][r]?{series:[],parallel:[]}:this.hooks[i][r]},e.hasHooks=function(r,i){var s=this.getHooks(r,i);return s?s.series.length>0||s.parallel.length>0:!1},e._runHooks=function(r,i,s,o){var a=this.getHooks(r,i);if(!a)return un;var l=a.series.map(f=>()=>f(s,o));return QP(l).then(()=>Promise.all(a.parallel.map(f=>f(s,o))))},e._runHooksSync=function(r,i,s,o){var a=this.getHooks(r,i);a&&a.series.forEach(l=>l(s,o))},e.promiseWait=function(r){var i=new Promise(s=>{var o=setTimeout(()=>{this.timeouts.delete(o),s()},r);this.timeouts.add(o)});return i},e.destroy=function(){return this.destroyed?Gn:(this.destroyed=!0,Array.from(this.timeouts).forEach(r=>clearTimeout(r)),this._changeEventBuffer&&this._changeEventBuffer.destroy(),this.database.requestIdlePromise().then(()=>Promise.all(this.onDestroy.map(r=>r()))).then(()=>this.storageInstance.close()).then(()=>(this._subs.forEach(r=>r.unsubscribe()),delete this.database.collections[this.name],No("postDestroyRxCollection",this).then(()=>!0))))},e.remove=async function(){await this.destroy(),await fO(this.database.storage,this.database.internalStore,this.database.token,this.database.name,this.name,this.database.password,this.database.hashFunction)},Vs(t,[{key:"insert$",get:function(){return this.$.pipe(lt(n=>n.operation==="INSERT"))}},{key:"update$",get:function(){return this.$.pipe(lt(n=>n.operation==="UPDATE"))}},{key:"remove$",get:function(){return this.$.pipe(lt(n=>n.operation==="DELETE"))}},{key:"asRxCollection",get:function(){return this}}]),t}();function dN(t){if(!ab){ab=!0;var e=Object.getPrototypeOf(t);yO.forEach(n=>{mO.map(r=>{var i=r+ZI(n);e[i]=function(s,o){return this.addHook(r,n,s,o)}})})}}function hN(t,e){return t.incrementalModify(n=>e)}function pN(t,e,n){var r=t._docCache.getLatestDocumentDataIfExists(e);return r?Promise.resolve({doc:t._docCache.getCachedRxDocument(r),inserted:!1}):t.findOne(e).exec().then(i=>i?{doc:i,inserted:!1}:t.insert(n).then(s=>({doc:s,inserted:!0})))}function mN({database:t,name:e,schema:n,instanceCreationOptions:r={},migrationStrategies:i={},autoMigrate:s=!0,statics:o={},methods:a={},attachments:l={},options:f={},localDocuments:h=!1,cacheReplacementPolicy:m=GE,conflictHandler:y=bd}){var w={databaseInstanceToken:t.token,databaseName:t.name,collectionName:e,schema:n.jsonSchema,options:r,multiInstance:t.multiInstance,password:t.password,devMode:it.isDevMode()};return Mr("preCreateRxStorageInstance",w),Z2(t,w).then(I=>{var E=new vO(t,e,n,I,r,i,a,l,f,m,o,y);return E.prepare().then(()=>{Object.entries(o).forEach(([S,_])=>{Object.defineProperty(E,S,{get:()=>_.bind(E)})});var F=un;return s&&E.schema.version!==0&&(F=E.migratePromise()),F}).then(()=>(Mr("createRxCollection",{collection:E,creator:{name:e,schema:n,storageInstance:I,instanceCreationOptions:r,migrationStrategies:i,methods:a,attachments:l,options:f,cacheReplacementPolicy:m,localDocuments:h,statics:o}}),E)).catch(F=>I.close().then(()=>Promise.reject(F)))})}var gO=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this._parallels=e||1,this._qC=0,this._iC=new Set,this._lHN=0,this._hPM=new Map,this._pHM=new Map};gO.prototype={isIdle:function(){return this._qC{this._to=!1,vN(this)},0))}clear(){this.map.clear()}}function vN(t){const e=wO()-t.ttl,n=t.map[Symbol.iterator]();for(;;){const r=n.next().value;if(!r)return;const i=r[0];if(r[1]E.events)),this.storageToken=Gn,this.storageTokenDocument=Gn,this.emittedEventBulkIds=new Vg(60*1e3),this.name=n,this.token=r,this.storage=i,this.instanceCreationOptions=s,this.password=o,this.multiInstance=a,this.eventReduce=l,this.options=f,this.internalStore=h,this.hashFunction=m,this.cleanupPolicy=y,this.allowSlowCount=w,this.reactivity=I,this.name!=="pseudoInstance"&&(this.internalStore=$g(this.asRxDatabase,h,Ug),this.storageTokenDocument=J2(this.asRxDatabase).catch(E=>this.startupErrors.push(E)),this.storageToken=this.storageTokenDocument.then(E=>E.data.token).catch(E=>this.startupErrors.push(E)))}var e=t.prototype;return e.getReactivityFactory=function(){if(!this.reactivity)throw le("DB14",{database:this.name});return this.reactivity},e.$emit=function(r){this.emittedEventBulkIds.has(r.id)||(this.emittedEventBulkIds.add(r.id),this.eventBulks$.next(r))},e.removeCollectionDoc=async function(r,i){var s=await Xl(this.internalStore,Ha(jy(r,i),ko));if(!s)throw le("SNH",{name:r,schema:i});var o=Lg(s);o._deleted=!0,await this.internalStore.bulkWrite([{document:o,previous:s}],"rx-database-remove-collection")},e.addCollections=async function(r){var i={},s={},o=[],a={};await Promise.all(Object.entries(r).map(async([h,m])=>{var y=h,w=m.schema;i[y]=w;var I=dR(w,this.hashFunction);if(s[y]=I,this.collections[h])throw le("DB3",{name:h});var E=jy(h,w),F={id:Ha(E,ko),key:E,context:ko,data:{name:y,schemaHash:await I.hash,schema:I.jsonSchema,version:I.version,connectedStorages:[]},_deleted:!1,_meta:Ks(),_rev:Rn(),_attachments:{}};o.push({document:F});var S=Object.assign({},m,{name:y,schema:I,database:this}),_=$e(m);_.database=this,_.name=h,Mr("preCreateRxCollection",_),S.conflictHandler=_.conflictHandler,a[y]=S}));var l=await this.internalStore.bulkWrite(o,"rx-database-add-collection");await bN(this),await Promise.all(l.error.map(async h=>{if(h.status!==409)throw le("DB12",{database:this.name,writeError:h});var m=ye(h.documentInDb),y=m.data.name,w=s[y];if(m.data.schemaHash!==await w.hash)throw le("DB6",{database:this.name,collection:y,previousSchemaHash:m.data.schemaHash,schemaHash:await w.hash,previousSchema:m.data.schema,schema:ye(i[y])})}));var f={};return await Promise.all(Object.keys(r).map(async h=>{var m=a[h],y=await mN(m);f[h]=y,this.collections[h]=y,this[h]||Object.defineProperty(this,h,{get:()=>this.collections[h]})})),f},e.lockedRun=function(r){return this.idleQueue.wrapCall(r)},e.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},e.exportJSON=function(r){throw pt("json-dump")},e.importJSON=function(r){throw pt("json-dump")},e.backup=function(r){throw pt("backup")},e.leaderElector=function(){throw pt("leader-election")},e.isLeader=function(){throw pt("leader-election")},e.waitForLeadership=function(){throw pt("leader-election")},e.migrationStates=function(){throw pt("migration-schema")},e.destroy=async function(){return this.destroyed||(this.destroyed=!0,await No("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map(r=>r.unsubscribe()),this.name==="pseudoInstance")?Gn:this.requestIdlePromise().then(()=>Promise.all(this.onDestroy.map(r=>r()))).then(()=>Promise.all(Object.keys(this.collections).map(r=>this.collections[r]).map(r=>r.destroy()))).then(()=>this.internalStore.close()).then(()=>Sd.delete(this.storage.name+"|"+this.name)).then(()=>!0)},e.remove=function(){return this.destroy().then(()=>bO(this.name,this.storage,this.password))},Vs(t,[{key:"$",get:function(){return this.observable$}},{key:"asRxDatabase",get:function(){return this}}]),t}();function gN(t,e){var n=e.name+"|"+t;if(Sd.has(n))throw le("DB8",{name:t,storage:e.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}async function _O(t,e,n,r,i,s){var o=await e.createStorageInstance({databaseInstanceToken:t,databaseName:n,collectionName:z2,schema:Ug,options:r,multiInstance:i,password:s,devMode:it.isDevMode()});return o}function wN({storage:t,instanceCreationOptions:e,name:n,password:r,multiInstance:i=!0,eventReduce:s=!0,ignoreDuplicate:o=!1,options:a={},cleanupPolicy:l,allowSlowCount:f=!1,localDocuments:h=!1,hashFunction:m=KP,reactivity:y}){Mr("preCreateRxDatabase",{storage:t,instanceCreationOptions:e,name:n,password:r,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:a,localDocuments:h}),o||gN(n,t),Sd.add(t.name+"|"+n);var w=iu(10);return _O(w,t,n,e,i,r).catch(I=>{throw Sd.delete(t.name+"|"+n),I}).then(I=>{var E=new Kg(n,w,t,e,r,i,s,a,I,m,l,f,y);return No("createRxDatabase",{database:E,creator:{storage:t,instanceCreationOptions:e,name:n,password:r,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:a,localDocuments:h}}).then(()=>E)})}async function bO(t,e,n){var r=iu(10),i=await _O(r,e,t,{},!1,n),s=await zg(i),o=new Set;s.forEach(l=>o.add(l.data.name));var a=Array.from(o);return await Promise.all(a.map(l=>fO(e,i,r,t,l,n))),await No("postRemoveRxDatabase",{databaseName:t,storage:e}),await i.remove(),a}function _N(t){return t instanceof Kg}async function SO(t){var e=await t.storageTokenDocument;return e.data.instanceToken===t.token}async function bN(t){if(await t.storageToken,t.startupErrors[0])throw t.startupErrors[0]}var SN={RxSchema:aE.prototype,RxDocument:kh,RxQuery:ZE.prototype,RxCollection:vO.prototype,RxDatabase:Kg.prototype},pm=new Set,ub=new Set;function gi(t){if(Mr("preAddRxPlugin",{plugin:t,plugins:pm}),!pm.has(t)){{if(ub.has(t.name))throw le("PL3",{name:t.name,plugin:t});pm.add(t),ub.add(t.name)}if(!t.rxdb)throw el("PL1",{plugin:t});t.init&&t.init(),t.prototypes&&Object.entries(t.prototypes).forEach(([e,n])=>n(SN[e])),t.overwritable&&Object.assign(it,t.overwritable),t.hooks&&Object.entries(t.hooks).forEach(([e,n])=>{n.after&&xl[e].push(n.after),n.before&&xl[e].unshift(n.before)})}}function IN(t){return t&&typeof t.then=="function"}Promise.resolve(!1);var EN=Promise.resolve(!0),Mi=Promise.resolve();function mo(t,e){return t||(t=0),new Promise(function(n){return setTimeout(function(){return n(e)},t)})}function ON(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function Zl(){return Math.random().toString(36).substring(2)}var mm=0;function ec(){var t=Date.now()*1e3;return t<=mm&&(t=mm+1),mm=t,t}function kN(){return typeof navigator<"u"&&typeof navigator.locks<"u"&&typeof navigator.locks.request=="function"}var DN=ec,xN="native";function AN(t){var e={time:ec(),messagesCallback:null,bc:new BroadcastChannel(t),subFns:[]};return e.bc.onmessage=function(n){e.messagesCallback&&e.messagesCallback(n.data)},e}function CN(t){t.bc.close(),t.subFns=[]}function PN(t,e){try{return t.bc.postMessage(e,!1),Mi}catch(n){return Promise.reject(n)}}function RN(t,e){t.messagesCallback=e}function TN(){if(typeof globalThis<"u"&&globalThis.Deno&&globalThis.Deno.args)return!0;if((typeof window<"u"||typeof self<"u")&&typeof BroadcastChannel=="function"){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}else return!1}function MN(){return 150}var NN={create:AN,close:CN,onMessage:RN,postMessage:PN,canBeUsed:TN,type:xN,averageResponseTime:MN,microSeconds:DN};function Wg(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=JSON.parse(JSON.stringify(t));return typeof e.webWorkerSupport>"u"&&(e.webWorkerSupport=!0),e.idb||(e.idb={}),e.idb.ttl||(e.idb.ttl=1e3*45),e.idb.fallbackInterval||(e.idb.fallbackInterval=150),t.idb&&typeof t.idb.onclose=="function"&&(e.idb.onclose=t.idb.onclose),e.localstorage||(e.localstorage={}),e.localstorage.removeTimeout||(e.localstorage.removeTimeout=1e3*60),t.methods&&(e.methods=t.methods),e.node||(e.node={}),e.node.ttl||(e.node.ttl=1e3*60*2),e.node.maxParallelWrites||(e.node.maxParallelWrites=2048),typeof e.node.useFastPath>"u"&&(e.node.useFastPath=!0),e}var BN=ec,FN="pubkey.broadcast-channel-0-",qi="messages",Dh={durability:"relaxed"},LN="idb";function IO(){if(typeof indexedDB<"u")return indexedDB;if(typeof window<"u"){if(typeof window.mozIndexedDB<"u")return window.mozIndexedDB;if(typeof window.webkitIndexedDB<"u")return window.webkitIndexedDB;if(typeof window.msIndexedDB<"u")return window.msIndexedDB}return!1}function qg(t){t.commit&&t.commit()}function $N(t){var e=IO(),n=FN+t,r=e.open(n);return r.onupgradeneeded=function(i){var s=i.target.result;s.createObjectStore(qi,{keyPath:"id",autoIncrement:!0})},new Promise(function(i,s){r.onerror=function(o){return s(o)},r.onsuccess=function(){i(r.result)}})}function jN(t,e,n){var r=Date.now(),i={uuid:e,time:r,data:n},s=t.transaction([qi],"readwrite",Dh);return new Promise(function(o,a){s.oncomplete=function(){return o()},s.onerror=function(f){return a(f)};var l=s.objectStore(qi);l.add(i),qg(s)})}function UN(t,e){var n=t.transaction(qi,"readonly",Dh),r=n.objectStore(qi),i=[],s=IDBKeyRange.bound(e+1,1/0);if(r.getAll){var o=r.getAll(s);return new Promise(function(l,f){o.onerror=function(h){return f(h)},o.onsuccess=function(h){l(h.target.result)}})}function a(){try{return s=IDBKeyRange.bound(e+1,1/0),r.openCursor(s)}catch{return r.openCursor()}}return new Promise(function(l,f){var h=a();h.onerror=function(m){return f(m)},h.onsuccess=function(m){var y=m.target.result;y?y.value.idt.lastCursorId&&(t.lastCursorId=r.id),r}).filter(function(r){return qN(r,t)}).sort(function(r,i){return r.time-i.time});return n.forEach(function(r){t.messagesCallback&&(t.eMIs.add(r.id),t.messagesCallback(r.data))}),Mi})}function HN(t){t.closed=!0,t.db.close()}function QN(t,e){return t.writeBlockPromise=t.writeBlockPromise.then(function(){return jN(t.db,t.uuid,e)}).then(function(){ON(0,10)===0&&KN(t)}),t.writeBlockPromise}function YN(t,e,n){t.messagesCallbackTime=n,t.messagesCallback=e,OO(t)}function GN(){return!!IO()}function JN(t){return t.idb.fallbackInterval*2}var XN={create:WN,close:HN,onMessage:YN,postMessage:QN,canBeUsed:GN,type:LN,averageResponseTime:JN,microSeconds:BN},ZN=ec,eB="pubkey.broadcastChannel-",tB="localstorage";function kO(){var t;if(typeof window>"u")return null;try{t=window.localStorage,t=window["ie8-eventlistener/storage"]||window.localStorage}catch{}return t}function DO(t){return eB+t}function nB(t,e){return new Promise(function(n){mo().then(function(){var r=DO(t.channelName),i={token:Zl(),time:Date.now(),data:e,uuid:t.uuid},s=JSON.stringify(i);kO().setItem(r,s);var o=document.createEvent("Event");o.initEvent("storage",!0,!0),o.key=r,o.newValue=s,window.dispatchEvent(o),n()})})}function rB(t,e){var n=DO(t),r=function(s){s.key===n&&e(JSON.parse(s.newValue))};return window.addEventListener("storage",r),r}function iB(t){window.removeEventListener("storage",t)}function sB(t,e){if(e=Wg(e),!xO())throw new Error("BroadcastChannel: localstorage cannot be used");var n=Zl(),r=new Vg(e.localstorage.removeTimeout),i={channelName:t,uuid:n,eMIs:r};return i.listener=rB(t,function(s){i.messagesCallback&&s.uuid!==n&&(!s.token||r.has(s.token)||s.data.time&&s.data.time0||t._addEL.internal.length>0}function db(t,e,n){t._addEL[e].push(n),bB(t)}function hb(t,e,n){t._addEL[e]=t._addEL[e].filter(function(r){return r!==n}),SB(t)}function bB(t){if(!t._iL&&RO(t)){var e=function(i){t._addEL[i.type].forEach(function(s){i.time>=s.time&&s.fn(i.data)})},n=t.method.microSeconds();t._prepP?t._prepP.then(function(){t._iL=!0,t.method.onMessage(t._state,e,n)}):(t._iL=!0,t.method.onMessage(t._state,e,n))}}function SB(t){if(t._iL&&!RO(t)){t._iL=!1;var e=t.method.microSeconds();t.method.onMessage(t._state,null,e)}}function IB(t){if(typeof WorkerGlobalScope=="function"&&self instanceof WorkerGlobalScope){var e=self.close.bind(self);self.close=function(){return t(),e()}}else{if(typeof window.addEventListener!="function")return;window.addEventListener("beforeunload",function(){t()},!0),window.addEventListener("unload",function(){t()},!0)}}function EB(t){process.on("exit",function(){return t()}),process.on("beforeExit",function(){return t().then(function(){return process.exit()})}),process.on("SIGINT",function(){return t().then(function(){return process.exit()})}),process.on("uncaughtException",function(e){return t().then(function(){console.trace(e),process.exit(101)})})}var OB=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",kB=OB?EB:IB,nl=new Set,pb=!1;function DB(){pb||(pb=!0,kB(AB))}function xB(t){if(DB(),typeof t!="function")throw new Error("Listener is no function");nl.add(t);var e={remove:function(){return nl.delete(t)},run:function(){return nl.delete(t),t()}};return e}function AB(){var t=[];return nl.forEach(function(e){t.push(e()),nl.delete(e)}),Promise.all(t)}function Do(t,e){var n={context:"leader",action:e,token:t.token};return t.broadcastChannel.postInternal(n)}function TO(t){t.isLeader=!0,t._hasLeader=!0;var e=xB(function(){return t.die()});t._unl.push(e);var n=function(i){i.context==="leader"&&i.action==="apply"&&Do(t,"tell"),i.context==="leader"&&i.action==="tell"&&!t._dpLC&&(t._dpLC=!0,t._dpL(),Do(t,"tell"))};return t.broadcastChannel.addEventListener("internal",n),t._lstns.push(n),Do(t,"tell")}var MO=function(e,n){var r=this;this.broadcastChannel=e,e._befC.push(function(){return r.die()}),this._options=n,this.isLeader=!1,this.isDead=!1,this.token=Zl(),this._lstns=[],this._unl=[],this._dpL=function(){},this._dpLC=!1,this._wKMC={},this.lN="pubkey-bc||"+e.method.type+"||"+e.name};MO.prototype={hasLeader:function(){var e=this;return navigator.locks.query().then(function(n){var r=n.held?n.held.filter(function(i){return i.name===e.lN}):[];return!!(r&&r.length>0)})},awaitLeadership:function(){var e=this;if(!this._wLMP){this._wKMC.c=new AbortController;var n=new Promise(function(r,i){e._wKMC.res=r,e._wKMC.rej=i});this._wLMP=new Promise(function(r){navigator.locks.request(e.lN,{signal:e._wKMC.c.signal},function(){return e._wKMC.c=void 0,TO(e),r(),n}).catch(function(){})})}return this._wLMP},set onduplicate(t){},die:function(){var e=this;return this._lstns.forEach(function(n){return e.broadcastChannel.removeEventListener("internal",n)}),this._lstns=[],this._unl.forEach(function(n){return n.remove()}),this._unl=[],this.isLeader&&(this.isLeader=!1),this.isDead=!0,this._wKMC.res&&this._wKMC.res(),this._wKMC.c&&this._wKMC.c.abort("LeaderElectionWebLock.die() called"),Do(this,"death")}};var NO=function(e,n){var r=this;this.broadcastChannel=e,this._options=n,this.isLeader=!1,this._hasLeader=!1,this.isDead=!1,this.token=Zl(),this._aplQ=Mi,this._aplQC=0,this._unl=[],this._lstns=[],this._dpL=function(){},this._dpLC=!1;var i=function(o){o.context==="leader"&&(o.action==="death"&&(r._hasLeader=!1),o.action==="tell"&&(r._hasLeader=!0))};this.broadcastChannel.addEventListener("internal",i),this._lstns.push(i)};NO.prototype={hasLeader:function(){return Promise.resolve(this._hasLeader)},applyOnce:function(e){var n=this;if(this.isLeader)return mo(0,!0);if(this.isDead)return mo(0,!1);if(this._aplQC>1)return this._aplQ;var r=function(){if(n.isLeader)return EN;var s=!1,o,a=new Promise(function(h){o=function(){s=!0,h()}}),l=function(m){m.context==="leader"&&m.token!=n.token&&(m.action==="apply"&&m.token>n.token&&o(),m.action==="tell"&&(o(),n._hasLeader=!0))};n.broadcastChannel.addEventListener("internal",l);var f=e?n._options.responseTime*4:n._options.responseTime;return Do(n,"apply").then(function(){return Promise.race([mo(f),a.then(function(){return Promise.reject(new Error)})])}).then(function(){return Do(n,"apply")}).then(function(){return Promise.race([mo(f),a.then(function(){return Promise.reject(new Error)})])}).catch(function(){}).then(function(){return n.broadcastChannel.removeEventListener("internal",l),s?!1:TO(n).then(function(){return!0})})};return this._aplQC=this._aplQC+1,this._aplQ=this._aplQ.then(function(){return r()}).then(function(){n._aplQC=n._aplQC-1}),this._aplQ.then(function(){return n.isLeader})},awaitLeadership:function(){return this._aLP||(this._aLP=CB(this)),this._aLP},set onduplicate(t){this._dpL=t},die:function(){var e=this;return this._lstns.forEach(function(n){return e.broadcastChannel.removeEventListener("internal",n)}),this._lstns=[],this._unl.forEach(function(n){return n.remove()}),this._unl=[],this.isLeader&&(this._hasLeader=!1,this.isLeader=!1),this.isDead=!0,Do(this,"death")}};function CB(t){return t.isLeader?Mi:new Promise(function(e){var n=!1;function r(){n||(n=!0,t.broadcastChannel.removeEventListener("internal",s),e(!0))}t.applyOnce().then(function(){t.isLeader&&r()});var i=function o(){return mo(t._options.fallbackInterval).then(function(){if(!(t.isDead||n))if(t.isLeader)r();else return t.applyOnce(!0).then(function(){t.isLeader?r():o()})})};i();var s=function(a){a.context==="leader"&&a.action==="death"&&(t._hasLeader=!1,t.applyOnce().then(function(){t.isLeader&&r()}))};t.broadcastChannel.addEventListener("internal",s),t._lstns.push(s)})}function PB(t,e){return t||(t={}),t=JSON.parse(JSON.stringify(t)),t.fallbackInterval||(t.fallbackInterval=3e3),t.responseTime||(t.responseTime=e.method.averageResponseTime(e.options)),t}function RB(t,e){if(t._leaderElector)throw new Error("BroadcastChannel already has a leader-elector");e=PB(e,t);var n=kN()?new MO(t,e):new NO(t,e);return t._befC.push(function(){return n.die()}),t._leaderElector=n,n}var Id=new Map;function TB(t,e,n,r){var i=Id.get(e);return i||(i={bc:new xh(["RxDB:",t,n].join("|")),refs:new Set},Id.set(e,i)),i.refs.add(r),i.bc}function mb(t,e){var n=Id.get(t);if(n&&(n.refs.delete(e),n.refs.size===0))return Id.delete(t),n.bc.close()}function MB(t,e,n,r){if(e.multiInstance){var i=r||TB(t,e.databaseInstanceToken,n.databaseName,n),s=new Kt,o=y=>{y.storageName===t&&y.databaseName===e.databaseName&&y.collectionName===e.collectionName&&y.version===e.schema.version&&s.next(y.eventBulk)};i.addEventListener("message",o);var a=n.changeStream(),l=!1,f=a.subscribe(y=>{l||i.postMessage({storageName:t,databaseName:e.databaseName,collectionName:e.collectionName,version:e.schema.version,eventBulk:y})});n.changeStream=function(){return s.asObservable().pipe(sT(a))};var h=n.close.bind(n);n.close=async function(){return l=!0,f.unsubscribe(),i.removeEventListener("message",o),r||await mb(e.databaseInstanceToken,n),h()};var m=n.remove.bind(n);n.remove=async function(){return l=!0,f.unsubscribe(),i.removeEventListener("message",o),r||await mb(e.databaseInstanceToken,n),m()}}}function NB(t,e){var n=e.map(r=>{var i=zi(t,r);if(!i)throw new Error("not in schema: "+r);var s=i.type,o;(s==="number"||s==="integer")&&(o=Qg(i));var a=JI(r),l=i.maxLength?i.maxLength:0,f;s==="string"?f=m=>{var y=a(m);return y||(y=""),y.padEnd(l," ")}:s==="boolean"?f=m=>{var y=a(m);return y?"1":"0"}:f=m=>{var y=a(m);return Ed(o,y)};var h={fieldName:r,schemaPart:i,parsedLengths:o,getValue:a,getIndexStringPart:f};return h});return n}function BB(t,e){var n=NB(t,e),r=n.length,i=n.map(o=>o.getIndexStringPart),s=function(o){for(var a="",l=0;l1&&(a=o[1].length),{minimum:e,maximum:n,nonDecimals:s,decimals:a,roundedMinimum:e}}function Ed(t,e){typeof e>"u"&&(e=0),et.maximum&&(e=t.maximum);var n=(Math.floor(e)-t.roundedMinimum).toString(),r=n.padStart(t.nonDecimals,"0");if(t.decimals>0){var i=e.toString().split("."),s=i.length>1?i[1]:"0";r+=s.padEnd(t.decimals,"0")}return r}function yb(t,e,n){var r="";return e.forEach((i,s)=>{var o=zi(t,i),a=n[s],l=o.type;switch(l){case"string":var f=ye(o.maxLength,"maxLength not set");typeof a=="string"?r+=a.padEnd(f," "):r+="".padEnd(f," ");break;case"boolean":if(a===null)r+="0";else if(a===li)r+="0";else if(a===Ar)r+="1";else{var h=a?"1":"0";r+=h}break;case"number":case"integer":var m=Qg(o);if(a===null||a===li){var y="0";r+=y.repeat(m.nonDecimals+m.decimals)}else if(a===Ar)r+=Ed(m,m.maximum);else{var w=Ed(m,a);r+=w}break;default:throw new Error("unknown index type "+l)}}),r}function FB(t,e,n){var r="";return e.forEach((i,s)=>{var o=zi(t,i),a=n[s],l=o.type;switch(l){case"string":var f=ye(o.maxLength,"maxLength not set");typeof a=="string"&&a!==Ar?r+=a.padEnd(f," "):a===li?r+="".padEnd(f," "):r+="".padEnd(f,Ar);break;case"boolean":if(a===null)r+="1";else{var h=a?"1":"0";r+=h}break;case"number":case"integer":var m=Qg(o);if(a===null||a===Ar){var y="9";r+=y.repeat(m.nonDecimals+m.decimals)}else if(a===li){var w="0";r+=w.repeat(m.nonDecimals+m.decimals)}else r+=Ed(m,a);break;default:throw new Error("unknown index type "+l)}}),r}var vb=t=>Promise.resolve(t);function gb(t,e){if(t==="_deleted")return e;e=$e(e);var n=!!e._deleted;return e[t]=n,delete e._deleted,e}function ym(t,e,n){return n.map(r=>{var i=$e(r);if(e!=="_deleted"){var s=!!i[e];i._deleted=s,delete i[e]}else i._deleted=!!i._deleted;var o=t.schema.primaryPath;return i[o]=Ws(t.schema.jsonSchema,i),i})}function wb(t,e){if(typeof window>"u"||typeof window!="object"||typeof window.addEventListener>"u"||navigator.onLine)return t.promiseWait(e);var n,r=new Promise(i=>{n=()=>{window.removeEventListener("online",n),i()},window.addEventListener("online",n)});return Promise.race([r,t.promiseWait(e)]).then(()=>{window.removeEventListener("online",n)})}var BO=new WeakMap,LB=function(){function t(n,r,i,s,o,a,l,f){this.subs=[],this.subjects={received:new Kt,sent:new Kt,error:new Kt,canceled:new Gr(!1),active:new Gr(!1)},this.received$=this.subjects.received.asObservable(),this.sent$=this.subjects.sent.asObservable(),this.error$=this.subjects.error.asObservable(),this.canceled$=this.subjects.canceled.asObservable(),this.active$=this.subjects.active.asObservable(),this.onCancel=[],this.callOnStart=void 0,this.remoteEvents$=new Kt,this.replicationIdentifier=n,this.collection=r,this.deletedField=i,this.pull=s,this.push=o,this.live=a,this.retryTime=l,this.autoStart=f;var h=Tr(BO,r,()=>[]);h.push(this),this.collection.onDestroy.push(()=>this.cancel()),Object.keys(this.subjects).forEach(y=>{Object.defineProperty(this,y+"$",{get:function(){return this.subjects[y].asObservable()}})});var m=new Promise(y=>{this.callOnStart=y});this.startPromise=m}var e=t.prototype;return e.start=async function(){if(!this.isStopped()){var r=this.pull&&this.pull.modifier?this.pull.modifier:vb,i=this.push&&this.push.modifier?this.push.modifier:vb,s=this.collection.database,o="rx-replication-meta-"+await s.hashFunction([this.collection.name,this.replicationIdentifier].join("-")),a=Vy(this.collection.schema.jsonSchema,vd(this.collection.schema.jsonSchema)),[l]=await Promise.all([this.collection.database.storage.createStorageInstance({databaseName:s.name,collectionName:o,databaseInstanceToken:s.token,multiInstance:s.multiInstance,options:{},schema:a,password:s.password,devMode:it.isDevMode()}),cO(this.collection,o,a)]);this.metaInstance=l,this.internalReplicationState=hO({pushBatchSize:this.push&&this.push.batchSize?this.push.batchSize:100,pullBatchSize:this.pull&&this.pull.batchSize?this.pull.batchSize:100,initialCheckpoint:{upstream:this.push?this.push.initialCheckpoint:void 0,downstream:this.pull?this.pull.initialCheckpoint:void 0},forkInstance:this.collection.storageInstance,metaInstance:this.metaInstance,hashFunction:s.hashFunction,identifier:"rxdbreplication"+this.replicationIdentifier,conflictHandler:this.collection.conflictHandler,replicationHandler:{masterChangeStream$:this.remoteEvents$.asObservable().pipe(lt(f=>!!this.pull),Nr(async f=>{if(f==="RESYNC")return f;var h=$e(f);return h.documents=ym(this.collection,this.deletedField,h.documents),h.documents=await Promise.all(h.documents.map(m=>r(m))),h})),masterChangesSince:async(f,h)=>{if(!this.pull)return{checkpoint:null,documents:[]};for(var m=!1,y={};!m&&!this.isStopped();)try{y=await this.pull.handler(f,h),m=!0}catch(E){var w=le("RC_PULL",{checkpoint:f,errors:ja(E).map(F=>Oy(F)),direction:"pull"});this.subjects.error.next(w),await wb(this.collection,ye(this.retryTime))}if(this.isStopped())return{checkpoint:null,documents:[]};var I=$e(y);return I.documents=ym(this.collection,this.deletedField,I.documents),I.documents=await Promise.all(I.documents.map(E=>r(E))),I},masterWrite:async f=>{if(!this.push)return[];var h=!1;await No("preReplicationMasterWrite",{rows:f,collection:this.collection});var m=await Promise.all(f.map(async F=>(F.newDocumentState=await i(F.newDocumentState),F.newDocumentState===null?null:(F.assumedMasterState&&(F.assumedMasterState=await i(F.assumedMasterState)),this.deletedField!=="_deleted"&&(F.newDocumentState=gb(this.deletedField,F.newDocumentState),F.assumedMasterState&&(F.assumedMasterState=gb(this.deletedField,F.assumedMasterState))),F)))),y=m.filter(GI),w=null;for(y.length===0&&(h=!0,w=[]);!h&&!this.isStopped();)try{if(w=await this.push.handler(y),!Array.isArray(w))throw le("RC_PUSH_NO_AR",{pushRows:f,direction:"push",args:{result:w}});h=!0}catch(F){var I=F.rxdb?F:le("RC_PUSH",{pushRows:f,errors:ja(F).map(S=>Oy(S)),direction:"push"});this.subjects.error.next(I),await wb(this.collection,ye(this.retryTime))}if(this.isStopped())return[];await No("preReplicationMasterWriteDocumentsHandle",{result:w,collection:this.collection});var E=ym(this.collection,this.deletedField,ye(w));return E}}}),this.subs.push(this.internalReplicationState.events.error.subscribe(f=>{this.subjects.error.next(f)}),this.internalReplicationState.events.processed.down.subscribe(f=>this.subjects.received.next(f.document)),this.internalReplicationState.events.processed.up.subscribe(f=>{this.subjects.sent.next(f.newDocumentState)}),AE([this.internalReplicationState.events.active.down,this.internalReplicationState.events.active.up]).subscribe(([f,h])=>{var m=f||h;this.subjects.active.next(m)})),this.pull&&this.pull.stream$&&this.live&&this.subs.push(this.pull.stream$.subscribe({next:f=>{this.remoteEvents$.next(f)},error:f=>{this.subjects.error.next(f)}})),this.live||(await Tf(this.internalReplicationState),await ob(this.internalReplicationState),await this.cancel()),this.callOnStart()}},e.isStopped=function(){return!!this.subjects.canceled.getValue()},e.awaitInitialReplication=async function(){return await this.startPromise,Tf(ye(this.internalReplicationState))},e.awaitInSync=async function(){await this.startPromise,await Tf(ye(this.internalReplicationState));for(var r=2;r>0;)r--,await this.collection.database.requestIdlePromise(),await ob(ye(this.internalReplicationState));return!0},e.reSync=function(){this.remoteEvents$.next("RESYNC")},e.emitEvent=function(r){this.remoteEvents$.next(r)},e.cancel=async function(){if(this.isStopped())return Gn;var r=this.onCancel.map(i=>XI(i()));return this.internalReplicationState&&await pO(this.internalReplicationState),this.metaInstance&&r.push(ye(this.internalReplicationState).checkpointQueue.then(()=>ye(this.metaInstance).close())),this.subs.forEach(i=>i.unsubscribe()),this.subjects.canceled.next(!0),this.subjects.active.complete(),this.subjects.canceled.complete(),this.subjects.error.complete(),this.subjects.received.complete(),this.subjects.sent.complete(),Promise.all(r)},t}(),Br;(function(t){function e(U){return Array.isArray(U)?U.slice():t.isObject(U)?{...U}:U}t.clone=e;function n(U){let ee=r(U);return Array.isArray(U)&&(ee=ee.filter(ce=>ce!=="length")),ee}t.keys=n;function r(U){return U?Object.getOwnPropertyNames(U):[]}t.keysOfNonArray=r;function i(U,ee){return a(n(U),ce=>ee(U[ce],ce)),U}t.forOwn=i;function s(U,ee){return a(r(U),ce=>ee(U[ce],ce)),U}t.forOwnOfNonArray=s;function o(U,ee){return Array.isArray(U)?a(U,ee):s(U,ee),U}t.forEach=o;function a(U,ee){for(let ce=0,de=U.length;ce{const ot=U[Pe];ot instanceof Object&&(de=l(e(ot),de)),U[Pe]=de});return U}t.merge=l;function f(U){return Array.isArray(U)||(U=r(U)),U.length===0}t.isEmpty=f,t.isFunction=U=>typeof U=="function",t.isUndefined=U=>U===void 0||U==="undefined";function h(U){return U==null||U==="undefined"||U==="null"}t.isNullOrUndefined=h,t.isObject=U=>Object.prototype.toString.call(U)==="[object Object]",t.isEmptyObject=U=>h(U)||t.isObject(U)&&f(U);function m(){return typeof globalThis.ngDevMode>"u"||!!globalThis.ngDevMode}t.isDevMode=m;function y(U){return typeof U=="number"&&!isNaN(U)}t.isValidNumber=y;function w(){}t.noop=w;function I(U){return U}t.identity=I;function E(U,ee){const ce=[];for(let de=0;deU+ce*de)}t.range=F;function S(U){return t.isObject(U)?U._id:String(U)}t.getMaybeId=S;function _(U){return U.filter(I)}t.compact=_;function k(U){return f(U)?U:Array.isArray(U)?_(U):Object.entries(U).filter(([,ee])=>!h(ee)&&!f(ee)).reduce((ee,[ce,de])=>({...ee,[ce]:de}),{})}t.compactObject=k;function z(){var U;return(U=localStorage.debug)==null?void 0:U.includes("@ngx-odm/rxdb")}t.isDevModeForced=z;function W(){return typeof __karma__<"u"&&!!__karma__||typeof jasmine<"u"&&!!jasmine||typeof jest<"u"&&!!jest||typeof Mocha<"u"&&!!Mocha}t.isTestEnvironment=W,t.logger={log:function(){const U="#8d2089";return W()||!m()||!z()?w:console.log.bind(console,"%c[DEBUG::@ngx-odm/rxdb]",`background:${U};color:#fff;padding:2px;font-size:normal;`)}(),table:function(){return W()||!m()||!z()?w:console.table.bind(console)}()};function Q(U="Event"){return function(ce){return m()?ce.pipe(xy({next(de){t.logger.log(`observable:${U}:next:`,de)},error(de){t.logger.log(`observable:${U}:error:`,de.message)},complete(){t.logger.log(`observable:${U}:complete`)}})):ce}}t.debug=Q;function H(U=3,ee=1e4){return ce=>ce.pipe(oT({count:U,delay:(de,Pe)=>{const ot=Math.pow(2,Pe-1)*ee;return t.logger.log("replication:kinto:longpoll:retry",Pe,ot),SE(ot)}}))}t.retryWithBackoff=H,t.tapOnce=U=>ee=>Ay(()=>(U(),ee)),t.deferUntil=U=>ee=>Ay(()=>U.pipe(Al(()=>ee))),t.getDefaultQuery=()=>({selector:{_deleted:{$eq:!1}},skip:0,sort:[{id:"asc"}]});const X={properties:{id:{type:"string"},_deleted:{type:"boolean"}},primaryKey:"id",indexes:[["_deleted","id"]]};t.getDefaultQuery(),t.getDefaultPreparedQuery=()=>Jl(X,t.getDefaultQuery())})(Br||(Br={}));const FO=()=>typeof window=="object"&&"fetch"in window?window.fetch.bind(window):fetch;function _b(t){return t&&t instanceof LB}function bb(t=!1){return Mt(e=>(Array.isArray(e)?e:[...e.values()]).map(n=>{const r={...n._data};return t||(delete r._rev,delete r._attachments,delete r._deleted,delete r._meta),r}))}const{debug:$B,isEmptyObject:jB,isFunction:UB}=Br;function zB(t){return!jB(t)&&UB(t.run)}function Bu(t){return zB(t)?e=>new Ot(n=>e.subscribe(r=>t.run(()=>n.next(r)),r=>t.run(()=>n.error(r)),()=>t.run(()=>n.complete()))):e=>e}function tc(){return function(t,e,n){const r=n.value;return n.value=function(...i){return Ay(()=>this.initialized$.pipe(Al(()=>r.apply(this,i)),$B(`collection.${e}`)))},n}}function kt(){return function(t,e,n){const r=n.value;return n.value=async function(...i){return await cT(this.initialized$).catch(()=>{throw new Error(`Collection "${this.config.name}" was not initialized. Please check RxDB errors.`)}),r.apply(this,i)},n}}var Sb,Ib,Eb,Ob,kb,Db;const{getMaybeId:VB,logger:vm,debug:KB,noop:WB}=Br;class Je{get initialized$(){return this._init$.asObservable()}get collection(){return this._collection}get db(){return this.dbService.db}get dbOptions(){return this.dbService.dbOptions}get replicationState(){return this._replicationState}get queryParams$(){var e;return(e=this.config.options)!=null&&e.useQueryParams?this.initialized$.pipe(Al(()=>this.collection.queryParams.$)):im({})}constructor(e,n,r={},i=im(""),s=WB){this.config=e,this.dbService=n,this.ngZone=r,this.currentUrl$=i,this.updateQueryParamsFn=s,this._replicationState=null,this._init$=new RE,this.init(e)}destroy(){var e;(e=this.collection)==null||e.destroy()}setQueryParams(e){var n;(n=this.collection.queryParams)==null||n.set(e)}patchQueryParams(e){var n;(n=this.collection.queryParams)==null||n.patch(e)}async sync(){var e;if(_b(this.replicationState)){this.replicationState.reSync();return}if(typeof((e=this.config.options)==null?void 0:e.replicationStateFactory)=="function"){try{this._replicationState=this.config.options.replicationStateFactory(this.collection)}catch(n){vm.log("replicationState has error, ignore replication"),vm.log(n.message)}if(_b(this.replicationState))return this.replicationState.autoStart||this.replicationState.reSync(),Cy(window,"online").pipe(KB("online"),TE(()=>!this.replicationState.isStopped())).subscribe(()=>{this._replicationState.reSync()}),this.replicationState.startPromise}}async info(){return this.collection.getMetadata()}async import(e){const n=await this.collection.schema.hash,r={name:this.collection.name,schemaHash:n,docs:e};this.collection.importJSON(r)}async export(){return this.collection.exportJSON()}docs(e,n=!1){return(lT(e)?e:im(e)).pipe(Al(r=>this.collection.find(r).$),bb(n),Bu(this.ngZone),Pi(Ci))}docsByIds(e,n=!1){return this.collection.findByIds(e).$.pipe(bb(n),Bu(this.ngZone),Pi(Ci))}count(e){return this.collection.count(e).$.pipe(Bu(this.ngZone),Pi(Ci))}get(e,n=!1){return this.collection.findOne(e).$.pipe(Mt(r=>r?r.toMutableJSON(n):null),Bu(this.ngZone),Pi(Ci))}async insert(e){return this.collection.insert(e)}async insertBulk(e){return this.collection.bulkInsert(e)}async upsert(e){return this.collection.upsert(e)}async upsertBulk(e){return this.collection.bulkUpsert(e)}async set(e,n){return this.collection.findOne(e).update({$set:n})}async updateBulk(e,n){return this.collection.find(e).update({$set:n})}async remove(e){const n=VB(e);return this.collection.findOne(n).remove()}async removeBulk(e){return Array.isArray(e)?this.collection.bulkRemove(e):{success:[...(await this.collection.find(e).remove().catch(()=>new Map)).values()],error:[]}}async clear(){return this.collection.remove()}async getAttachments(e){const n=await this.collection.findOne(e).exec();if(!n)return null;const r=n.allAttachments().map(i=>i.getData());return Promise.all(r)}async getAttachmentById(e,n){const r=await this.collection.findOne(e).exec();if(!r)return null;const i=r.getAttachment(n);return i?i.getData():null}async putAttachment(e,n){const r=await this.collection.findOne(e).exec();r&&await r.putAttachment(n)}async removeAttachment(e,n){const r=await this.collection.findOne(e).exec();if(!r)return;const i=r.getAttachment(n);i&&await i.remove()}async addHook(e,n,r=!1){this.collection[e](n,r)}async getLocal(e,n){const r=await this.collection.getLocal(e);return r?n?r==null?void 0:r.get(n):r==null?void 0:r.toJSON().data:null}getLocal$(e,n){return this.collection.getLocal$(e).pipe(Mt(r=>r?n?r.get(n):r.toJSON().data:null),Bo(),Bu(this.ngZone))}async insertLocal(e,n){await this.collection.insertLocal(e,n)}async upsertLocal(e,n){await this.collection.upsertLocal(e,n)}async setLocal(e,n,r){var s,o;const i=await this.collection.getLocal(e);await this.collection.upsertLocal(e,{...((o=(s=i==null?void 0:i.toJSON)==null?void 0:s.call(i))==null?void 0:o.data)||{},[n]:r})}async removeLocal(e){const n=await this.collection.getLocal(e);await(n==null?void 0:n.remove())}async init(e){var i,s,o,a;const{name:n,options:r}=e;try{await this.dbService.initCollections({[n]:e}),this._collection=this.db.collections[n],r!=null&&r.useQueryParams&&this.collection.queryParamsInit(this.currentUrl$,this.updateQueryParamsFn),this._init$.next(!0),this._init$.complete()}catch(l){if(l.message.includes("DM5")||l.message.includes("DB6")&&((i=l.parameters.previousSchema)==null?void 0:i.version)===((s=l.parameters.schema)==null?void 0:s.version))vm.log("Reload the page to fix the issue. The database is in a state where it can not be used."),await bO(this.db.name,this.db.storage),(a=(o=window==null?void 0:window.location)==null?void 0:o.reload)==null||a.call(o);else throw this._init$.complete(),l}}}tt([kt(),re("design:type",Function),re("design:paramtypes",[]),re("design:returntype",Promise)],Je.prototype,"sync",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[]),re("design:returntype",Promise)],Je.prototype,"info",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Array]),re("design:returntype",Promise)],Je.prototype,"import",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[]),re("design:returntype",Promise)],Je.prototype,"export",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[Object,Object]),re("design:returntype",Ot)],Je.prototype,"docs",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[Array,Object]),re("design:returntype",Ot)],Je.prototype,"docsByIds",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Ot)],Je.prototype,"count",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[String,Object]),re("design:returntype",Ot)],Je.prototype,"get",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Promise)],Je.prototype,"insert",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Array]),re("design:returntype",Promise)],Je.prototype,"insertBulk",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Promise)],Je.prototype,"upsert",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Array]),re("design:returntype",Promise)],Je.prototype,"upsertBulk",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,Object]),re("design:returntype",Promise)],Je.prototype,"set",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object,Object]),re("design:returntype",Promise)],Je.prototype,"updateBulk",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Promise)],Je.prototype,"remove",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Promise)],Je.prototype,"removeBulk",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[]),re("design:returntype",Promise)],Je.prototype,"clear",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String]),re("design:returntype",Promise)],Je.prototype,"getAttachments",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,String]),re("design:returntype",Promise)],Je.prototype,"getAttachmentById",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,Object]),re("design:returntype",Promise)],Je.prototype,"putAttachment",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,String]),re("design:returntype",Promise)],Je.prototype,"removeAttachment",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[typeof(Sb=typeof Hook<"u"&&Hook)=="function"?Sb:Object,Object,Object]),re("design:returntype",Promise)],Je.prototype,"addHook",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,typeof(Ib=typeof K<"u"&&K)=="function"?Ib:Object]),re("design:returntype",Promise)],Je.prototype,"getLocal",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[String,typeof(Eb=typeof K<"u"&&K)=="function"?Eb:Object]),re("design:returntype",Ot)],Je.prototype,"getLocal$",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,typeof(Ob=typeof L<"u"&&L)=="function"?Ob:Object]),re("design:returntype",Promise)],Je.prototype,"insertLocal",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,typeof(kb=typeof L<"u"&&L)=="function"?kb:Object]),re("design:returntype",Promise)],Je.prototype,"upsertLocal",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,typeof(Db=typeof K<"u"&&K)=="function"?Db:Object,Object]),re("design:returntype",Promise)],Je.prototype,"setLocal",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String]),re("design:returntype",Promise)],Je.prototype,"removeLocal",null);var LO={exports:{}};(function(t,e){(function(n,r){t.exports=r()})(yw,function(){var n=function(u,c){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,p){d.__proto__=p}||function(d,p){for(var v in p)Object.prototype.hasOwnProperty.call(p,v)&&(d[v]=p[v])})(u,c)},r=function(){return(r=Object.assign||function(u){for(var c,d=1,p=arguments.length;d"u"||s.Promise||(s.Promise=Promise);var f=Object.getPrototypeOf,h={}.hasOwnProperty;function m(u,c){return h.call(u,c)}function y(u,c){typeof c=="function"&&(c=c(f(u))),(typeof Reflect>"u"?o:Reflect.ownKeys)(c).forEach(function(d){I(u,d,c[d])})}var w=Object.defineProperty;function I(u,c,d,p){w(u,c,l(d&&m(d,"get")&&typeof d.get=="function"?{get:d.get,set:d.set,configurable:!0}:{value:d,configurable:!0,writable:!0},p))}function E(u){return{from:function(c){return u.prototype=Object.create(c.prototype),I(u.prototype,"constructor",u),{extend:y.bind(null,u.prototype)}}}}var F=Object.getOwnPropertyDescriptor,S=[].slice;function _(u,c,d){return S.call(u,c,d)}function k(u,c){return c(u)}function z(u){if(!u)throw new Error("Assertion Failed")}function W(u){s.setImmediate?setImmediate(u):setTimeout(u,0)}function Q(u,c){if(typeof c=="string"&&m(u,c))return u[c];if(!c)return u;if(typeof c!="string"){for(var d=[],p=0,v=c.length;p"u"?[]:function(){var u=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[u,f(u),u];var c=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[c,f(c),u]}(),mu=jr[0],ur=jr[1],jr=jr[2],ur=ur&&ur.then,yu=mu&&mu.constructor,Kh=!!jr,vu=function(u,c){gu.push([u,c]),pc&&(queueMicrotask(Dx),pc=!1)},Wh=!0,pc=!0,Js=[],mc=[],qh=hu,Zi={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:et,pgp:!1,env:{},finalize:et},fe=Zi,gu=[],Xs=0,yc=[];function se(u){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var c=this._PSD=fe;if(typeof u!="function"){if(u!==pu)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Qh(this,this._value))}this._state=null,this._value=null,++c.ref,function d(p,v){try{v(function(g){if(p._state===null){if(g===p)throw new TypeError("A promise cannot be resolved with itself.");var b=p._lib&&qo();g&&typeof g.then=="function"?d(p,function(O,C){g instanceof se?g._then(O,C):g.then(O,C)}):(p._state=!0,p._value=g,z0(p)),b&&Ho()}},Qh.bind(null,p))}catch(g){Qh(p,g)}}(this,u)}var Hh={get:function(){var u=fe,c=_c;function d(p,v){var g=this,b=!u.global&&(u!==fe||c!==_c),O=b&&!ts(),C=new se(function(x,M){Yh(g,new U0(K0(p,u,b,O),K0(v,u,b,O),x,M,u))});return this._consoleTask&&(C._consoleTask=this._consoleTask),C}return d.prototype=pu,d},set:function(u){I(this,"then",u&&u.prototype===pu?Hh:{get:function(){return u},set:Hh.set})}};function U0(u,c,d,p,v){this.onFulfilled=typeof u=="function"?u:null,this.onRejected=typeof c=="function"?c:null,this.resolve=d,this.reject=p,this.psd=v}function Qh(u,c){var d,p;mc.push(c),u._state===null&&(d=u._lib&&qo(),c=qh(c),u._state=!1,u._value=c,p=u,Js.some(function(v){return v._value===p._value})||Js.push(p),z0(u),d&&Ho())}function z0(u){var c=u._listeners;u._listeners=[];for(var d=0,p=c.length;d.",W0="String expected.",Yo=[],Sc="__dbnames",Xh="readonly",Zh="readwrite";function to(u,c){return u?c?function(){return u.apply(this,arguments)&&c.apply(this,arguments)}:u:c}var q0={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ic(u){return typeof u!="string"||/\./.test(u)?function(c){return c}:function(c){return c[u]===void 0&&u in c&&delete(c=Pe(c))[u],c}}function H0(){throw pe.Type()}function je(u,c){try{var d=Q0(u),p=Q0(c);if(d!==p)return d==="Array"?1:p==="Array"?-1:d==="binary"?1:p==="binary"?-1:d==="string"?1:p==="string"?-1:d==="Date"?1:p!=="Date"?NaN:-1;switch(d){case"number":case"Date":case"string":return cj+V&&$(j+A)})})}return $(0).then(function(){if(0=A})).length!==0?(M.forEach(function($){B.push(function(){var j=R,V=$._cfg.dbschema;Pc(D,j,T),Pc(D,V,T),R=D._dbSchema=V;var q=up(j,V);q.add.forEach(function(te){lp(T,te[0],te[1].primKey,te[1].indexes)}),q.change.forEach(function(te){if(te.recreate)throw new pe.Upgrade("Not yet support for changing primary key");var he=T.objectStore(te.name);te.add.forEach(function(me){return Ac(he,me)}),te.change.forEach(function(me){he.deleteIndex(me.name),Ac(he,me)}),te.del.forEach(function(me){return he.deleteIndex(me)})});var Y=$._cfg.contentUpgrade;if(Y&&$._cfg.version>A){Dc(D,T),P._memoizedTables={};var ne=X(V);q.del.forEach(function(te){ne[te]=j[te]}),ap(D,[D.Transaction.prototype]),xc(D,[D.Transaction.prototype],o(ne),ne),P.schema=ne;var J,ie=Re(Y);return ie&&Qo(),q=se.follow(function(){var te;(J=Y(P))&&ie&&(te=ts.bind(null,null),J.then(te,te))}),J&&typeof J.then=="function"?se.resolve(J):q.then(function(){return J})}}),B.push(function(j){var V,q,Y=$._cfg.dbschema;V=Y,q=j,[].slice.call(q.db.objectStoreNames).forEach(function(ne){return V[ne]==null&&q.db.deleteObjectStore(ne)}),ap(D,[D.Transaction.prototype]),xc(D,[D.Transaction.prototype],D._storeNames,D._dbSchema),P.schema=D._dbSchema}),B.push(function(j){D.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(D.idbdb.version/10)===$._cfg.version?(D.idbdb.deleteObjectStore("$meta"),delete D._dbSchema.$meta,D._storeNames=D._storeNames.filter(function(V){return V!=="$meta"})):j.objectStore("$meta").put($._cfg.version,"version"))})}),function $(){return B.length?se.resolve(B.shift()(P.idbtrans)).then($):se.resolve()}().then(function(){rw(R,T)})):se.resolve();var D,A,P,T,B,R}).catch(b)):(o(v).forEach(function(M){lp(d,M,v[M].primKey,v[M].indexes)}),Dc(u,d),void se.follow(function(){return u.on.populate.fire(g)}).catch(b));var C,x})}function jx(u,c){rw(u._dbSchema,c),c.db.version%10!=0||c.objectStoreNames.contains("$meta")||c.db.createObjectStore("$meta").add(Math.ceil(c.db.version/10-1),"version");var d=Cc(0,u.idbdb,c);Pc(u,u._dbSchema,c);for(var p=0,v=up(d,u._dbSchema).change;pMath.pow(2,62)?0:R.oldVersion,D=R<1,u.idbdb=B.result,g&&jx(u,M),$x(u,R/10,M,P))},P),B.onsuccess=vt(function(){M=null;var R,$,j,V,q,Y=u.idbdb=B.result,ne=_(Y.objectStoreNames);if(0"u"?se.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(A){function P(){return indexedDB.databases().finally(A)}C=setInterval(P,100),P()}).finally(function(){return clearInterval(C)}):Promise.resolve()).then(O)]).then(function(){return b(),c.onReadyBeingFired=[],se.resolve(dp(function(){return u.on.ready.fire(u.vip)})).then(function A(){if(0c.limit?A.length=c.limit:u.length===c.limit&&A.length=$.limit&&(!$.values||Y.req.values)&&Hx(Y.req.query.range,$.query.range)}),!1,j,V];case"count":return q=V.find(function(Y){return hw(Y.req.query.range,$.query.range)}),[q,!!q,j,V]}}(c,d,"query",g),M=x[0],D=x[1],A=x[2],P=x[3];return M&&D?M.obsSet=g.obsSet:(D=p.query(g).then(function(T){var B=T.result;if(M&&(M.res=B),b){for(var R=0,$=B.length;R<$;++R)Object.freeze(B[R]);Object.freeze(B)}else T.result=Pe(B);return T}).catch(function(T){return P&&M&&G(P,M),Promise.reject(T)}),M={obsSet:g.obsSet,promise:D,subscribers:new Set,type:"query",req:g,dirty:!1},P?P.push(M):(P=[M],(A=A||(no["idb://".concat(c,"/").concat(d)]={queries:{query:{},count:{}},objs:new Map,optimisticOps:[],unsignaledParts:{}})).queries.query[g.query.index.name||""]=P)),Qx(M,P,O,C),M.promise.then(function(T){return{result:dw(T.result,g,A==null?void 0:A.optimisticOps,p,M,b)}})}})}})}};function Fc(u,c){return new Proxy(u,{get:function(d,p,v){return p==="db"?c:Reflect.get(d,p,v)}})}var yi=(Rt.prototype.version=function(u){if(isNaN(u)||u<.1)throw new pe.Type("Given version is not a positive number");if(u=Math.round(10*u)/10,this.idbdb||this._state.isBeingOpened)throw new pe.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,u);var c=this._versions,d=c.filter(function(p){return p._cfg.version===u})[0];return d||(d=new this.Version(u),c.push(d),c.sort(Lx),d.stores({}),this._state.autoSchema=!1,d)},Rt.prototype._whenReady=function(u){var c=this;return this.idbdb&&(this._state.openComplete||fe.letThrough||this._vip)?u():new se(function(d,p){if(c._state.openComplete)return p(new pe.DatabaseClosed(c._state.dbOpenError));if(!c._state.isBeingOpened){if(!c._state.autoOpen)return void p(new pe.DatabaseClosed);c.open().catch(et)}c._state.dbReadyPromise.then(d,p)}).then(u)},Rt.prototype.use=function(u){var c=u.stack,d=u.create,p=u.level,v=u.name;return v&&this.unuse({stack:c,name:v}),u=this._middlewares[c]||(this._middlewares[c]=[]),u.push({stack:c,create:d,level:p??10,name:v}),u.sort(function(g,b){return g.level-b.level}),this},Rt.prototype.unuse=function(u){var c=u.stack,d=u.name,p=u.create;return c&&this._middlewares[c]&&(this._middlewares[c]=this._middlewares[c].filter(function(v){return p?v.create!==p:!!d&&v.name!==d})),this},Rt.prototype.open=function(){var u=this;return Zs(Zi,function(){return zx(u)})},Rt.prototype._close=function(){var u=this._state,c=Yo.indexOf(this);if(0<=c&&Yo.splice(c,1),this.idbdb){try{this.idbdb.close()}catch{}this.idbdb=null}u.isBeingOpened||(u.dbReadyPromise=new se(function(d){u.dbReadyResolve=d}),u.openCanceller=new se(function(d,p){u.cancelOpen=p}))},Rt.prototype.close=function(d){var c=(d===void 0?{disableAutoOpen:!0}:d).disableAutoOpen,d=this._state;c?(d.isBeingOpened&&d.cancelOpen(new pe.DatabaseClosed),this._close(),d.autoOpen=!1,d.dbOpenError=new pe.DatabaseClosed):(this._close(),d.autoOpen=this._options.autoOpen||d.isBeingOpened,d.openComplete=!1,d.dbOpenError=null)},Rt.prototype.delete=function(u){var c=this;u===void 0&&(u={disableAutoOpen:!0});var d=0{var o=(async()=>{var a=$e(n);a.autoOpen=!1;var l=new Hy(i,a),f={[Od]:JB(r),[HB]:"++sequence, id",[Ab]:"id"};return l.version(1).stores(f),await l.open(),{dexieDb:l,dexieTable:l[Od],dexieAttachmentsTable:l[Ab],booleanIndexes:XB(r)}})();return Cb.set(i,s),Mf.set(s,0),o});return s}async function YB(t){var e=await t,n=Mf.get(t),r=n-1;r===0?(e.dexieDb.close(),Mf.delete(t)):Mf.set(t,r)}var Qy="__";function nc(t){var e=t.split(".");if(e.length>1)return e.map(r=>nc(r)).join(".");if(t.startsWith("|")){var n=t.substring(1);return Qy+n}else return t}function jO(t){var e=t.split(".");if(e.length>1)return e.map(r=>jO(r)).join(".");if(t.startsWith(Qy)){var n=t.substring(Qy.length);return"|"+n}else return t}function GB(t,e){return e&&(e=$e(e),e=Yy(e),t.forEach(n=>{var r=Ts(e,n),i=r?"1":"0";nE(e,n,i)}),e)}function UO(t,e){return e&&(e=$e(e),e=Gy(e),t.forEach(n=>{var r=Ts(e,n),i=r==="1";nE(e,n,i)}),e)}function Yy(t){if(!t||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(Array.isArray(t))return t.map(n=>Yy(n));if(typeof t=="object"){var e={};return Object.entries(t).forEach(([n,r])=>{typeof r=="object"&&(r=Yy(r)),e[nc(n)]=r}),e}}function Gy(t){if(!t||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(Array.isArray(t))return t.map(n=>Gy(n));if(typeof t=="object"){var e={};return Object.entries(t).forEach(([n,r])=>{(typeof r=="object"||Array.isArray(t))&&(r=Gy(r)),e[jO(n)]=r}),e}}function JB(t){var e=[],n=Fn(t.primaryKey);e.push([n]),e.push(["_deleted",n]),t.indexes&&t.indexes.forEach(s=>{var o=ja(s);e.push(o)}),e.push(["_meta.lwt",n]),e.push(["_meta.lwt"]),e=e.map(s=>s.map(o=>nc(o)));var r=e.map(s=>s.length===1?s[0]:"["+s.join("+")+"]");r=r.filter((s,o,a)=>a.indexOf(s)===o);var i=r.join(", ");return i}async function Pb(t,e){var n=await t,r=await n.dexieTable.bulkGet(e);return r.map(i=>UO(n.booleanIndexes,i))}function of(t,e){return t+"||"+e}function XB(t){var e=new Set,n=[];return t.indexes?(t.indexes.forEach(r=>{var i=ja(r);i.forEach(s=>{if(!e.has(s)){e.add(s);var o=zi(t,s);o.type==="boolean"&&n.push(s)}})}),n.push("_deleted"),AP(n)):n}function Rb(t){return t===li?-1/0:t}function Tb(t,e,n){if(t.includes(e)){var r=n===Ar||n===!0?"1":"0";return r}else return n}function zO(t,e,n){if(!n){if(typeof window>"u")throw new Error("IDBKeyRange missing");n=window.IDBKeyRange}var r=e.startKeys.map((o,a)=>{var l=e.index[a];return Tb(t,l,o)}).map(Rb),i=e.endKeys.map((o,a)=>{var l=e.index[a];return Tb(t,l,o)}).map(Rb),s=n.bound(r,i,!e.inclusiveStart,!e.inclusiveEnd);return s}async function Mb(t,e){var n=await t.internals,r=e.query,i=r.skip?r.skip:0,s=r.limit?r.limit:1/0,o=i+s,a=e.queryPlan,l=!1;a.selectorSatisfiedByIndex||(l=Oh(t.schema,e.query));var f=zO(n.booleanIndexes,a,n.dexieDb._options.IDBKeyRange),h=a.index,m=[];if(await n.dexieDb.transaction("r",n.dexieTable,async w=>{var I=w.idbtrans,E=I.objectStore(Od),F,S;S="["+h.map(k=>nc(k)).join("+")+"]",F=E.index(S);var _=F.openCursor(f);await new Promise(k=>{_.onsuccess=function(z){var W=z.target.result;if(W){var Q=UO(n.booleanIndexes,W.value);(!l||l(Q))&&m.push(Q),a.sortSatisfiedByIndex&&m.length===o?k():W.continue()}else k()}})}),!a.sortSatisfiedByIndex){var y=Fg(t.schema,e.query);m=m.sort(y)}return m=m.slice(i,o),{documents:m}}async function ZB(t,e){var n=await t.internals,r=e.queryPlan,i=r.index,s=zO(n.booleanIndexes,r,n.dexieDb._options.IDBKeyRange),o=-1;return await n.dexieDb.transaction("r",n.dexieTable,async a=>{var l=a.idbtrans,f=l.objectStore(Od),h,m;m="["+i.map(w=>nc(w)).join("+")+"]",h=f.index(m);var y=h.count(s);o=await new Promise((w,I)=>{y.onsuccess=function(){w(y.result)},y.onerror=E=>I(E)})}),o}var eF=Ft(),tF=function(){function t(n,r,i,s,o,a,l){this.changes$=new Kt,this.instanceId=eF++,this.storage=n,this.databaseName=r,this.collectionName=i,this.schema=s,this.internals=o,this.options=a,this.settings=l,this.primaryPath=Fn(this.schema.primaryKey)}var e=t.prototype;return e.bulkWrite=async function(r,i){oo(this),r.forEach(h=>{if(!h.document._rev||h.previous&&!h.previous._rev)throw le("SNH",{args:{row:h}})});var s=await this.internals,o={success:[],error:[]},a=r.map(h=>h.document[this.primaryPath]),l;if(await s.dexieDb.transaction("rw",s.dexieTable,s.dexieAttachmentsTable,async()=>{var h=new Map,m=await Pb(this.internals,a);m.forEach(I=>{var E=I;return E&&h.set(E[this.primaryPath],E),E}),l=rO(this,this.primaryPath,h,r,i),o.error=l.errors;var y=[];l.bulkInsertDocs.forEach(I=>{o.success.push(I.document),y.push(I.document)}),l.bulkUpdateDocs.forEach(I=>{o.success.push(I.document),y.push(I.document)}),y=y.map(I=>GB(s.booleanIndexes,I)),y.length>0&&await s.dexieTable.bulkPut(y);var w=[];l.attachmentsAdd.forEach(I=>{w.push({id:of(I.documentId,I.attachmentId),data:I.attachmentData.data})}),l.attachmentsUpdate.forEach(I=>{w.push({id:of(I.documentId,I.attachmentId),data:I.attachmentData.data})}),await s.dexieAttachmentsTable.bulkPut(w),await s.dexieAttachmentsTable.bulkDelete(l.attachmentsRemove.map(I=>of(I.documentId,I.attachmentId)))}),l=ye(l),l.eventBulk.events.length>0){var f=ye(l.newestRow).document;l.eventBulk.checkpoint={id:f[this.primaryPath],lwt:f._meta.lwt},l.eventBulk.endTime=Ft(),this.changes$.next(l.eventBulk)}return o},e.findDocumentsById=async function(r,i){oo(this);var s=await this.internals,o=[];return await s.dexieDb.transaction("r",s.dexieTable,async()=>{var a=await Pb(this.internals,r);a.forEach(l=>{l&&(!l._deleted||i)&&o.push(l)})}),o},e.query=function(r){return oo(this),Mb(this,r)},e.count=async function(r){if(r.queryPlan.selectorSatisfiedByIndex){var i=await ZB(this,r);return{count:i,mode:"fast"}}else{var s=await Mb(this,r);return{count:s.documents.length,mode:"slow"}}},e.changeStream=function(){return oo(this),this.changes$.asObservable()},e.cleanup=async function(r){oo(this);var i=await this.internals;return await i.dexieDb.transaction("rw",i.dexieTable,async()=>{var s=Ft()-r,o=await i.dexieTable.where("_meta.lwt").below(s).toArray(),a=[];o.forEach(l=>{l._deleted==="1"&&a.push(l[this.primaryPath])}),await i.dexieTable.bulkDelete(a)}),!0},e.getAttachmentData=async function(r,i,s){oo(this);var o=await this.internals,a=of(r,i);return await o.dexieDb.transaction("r",o.dexieAttachmentsTable,async()=>{var l=await o.dexieAttachmentsTable.get(a);if(l)return l.data;throw new Error("attachment missing documentId: "+r+" attachmentId: "+i)})},e.remove=async function(){oo(this);var r=await this.internals;return await r.dexieTable.clear(),this.close()},e.close=function(){return this.closed?this.closed:(this.closed=(async()=>{this.changes$.complete(),await YB(this.internals)})(),this.closed)},e.conflictResultionTasks=function(){return new Kt},e.resolveConflictResultionTask=async function(r){},t}();async function nF(t,e,n){var r=QB(e.databaseName,e.collectionName,n,e.schema),i=new tF(t,e.databaseName,e.collectionName,e.schema,r,e.options,n);return await MB($O,e,i),Promise.resolve(i)}function oo(t){if(t.closed)throw new Error("RxStorageInstanceDexie is closed "+t.databaseName+"-"+t.collectionName)}var rF=function(){function t(n){this.name=$O,this.rxdbVersion=vg,this.settings=n}var e=t.prototype;return e.createStorageInstance=function(r){return iO(r),nF(this,r,this.settings)},t}();function iF(t={}){var e=new rF(t);return e}function sF(t,e,n,r,i){for(var s=i+1;r<=i;){var o=r+i>>>1,a=t[o],l=n!==void 0?n(a,e):a-e;l>=0?(s=o,i=o-1):r=o+1}return s}function oF(t,e,n,r,i){for(var s=i+1;r<=i;){var o=r+i>>>1,a=t[o],l=n!==void 0?n(a,e):a-e;l>0?(s=o,i=o-1):r=o+1}return s}function aF(t,e,n,r,i){for(var s=r-1;r<=i;){var o=r+i>>>1,a=t[o],l=n!==void 0?n(a,e):a-e;l<0?(s=o,r=o+1):i=o-1}return s}function uF(t,e,n,r,i){for(var s=r-1;r<=i;){var o=r+i>>>1,a=t[o],l=n!==void 0?n(a,e):a-e;l<=0?(s=o,r=o+1):i=o-1}return s}function lF(t,e,n,r,i){for(;r<=i;){var s=r+i>>>1,o=t[s],a=n!==void 0?n(o,e):o-e;if(a===0)return s;a<=0?r=s+1:i=s-1}return-1}function rc(t,e,n,r,i,s){return typeof n=="function"?s(t,e,n,r===void 0?0:r|0,i===void 0?t.length-1:i|0):s(t,e,void 0,n===void 0?0:n|0,r===void 0?t.length-1:r|0)}function cF(t,e,n,r,i){return rc(t,e,n,r,i,sF)}function Nb(t,e,n,r,i){return rc(t,e,n,r,i,oF)}function fF(t,e,n,r,i){return rc(t,e,n,r,i,aF)}function dF(t,e,n,r,i){return rc(t,e,n,r,i,uF)}function VO(t,e,n,r,i){return rc(t,e,n,r,i,lF)}function KO(t,e,n){return[t,e,n].join("--memory--")}function af(t){if(t.internals.removed)throw new Error("removed")}function uf(t,e){return t+"||"+e}function hF(t,e){return t.indexString{var o=s.docsWithIndex,a=s.getIndexableString(r),l=VO(o,{indexString:a},rl);o.splice(l,1)})}function rl(t,e){var n=t.indexString,r=e.indexString;return nja(i)):[];r.push(["_deleted","_meta.lwt",n]),r.forEach(i=>{t.byIndex[Jy(i)]={index:i,docsWithIndex:[],getIndexableString:BB(e,i)}})}function Jy(t){return t.join(",")}var Fb=new Set,yF=function(){function t(n,r,i,s,o,a,l){this.closed=!1,this.storage=n,this.databaseName=r,this.collectionName=i,this.schema=s,this.internals=o,this.options=a,this.settings=l,Fb.add(this),this.primaryPath=Fn(this.schema.primaryKey)}var e=t.prototype;return e.bulkWrite=function(r,i){this.ensurePersistence(),af(this);for(var s=this.internals,o=this.internals.documents,a=this.primaryPath,l=rO(this,a,o,r,i),f=l.errors,h=new Array(l.bulkInsertDocs.length),m=l.bulkInsertDocs,y=0;y{this.internals.ensurePersistenceIdlePromise=void 0,this.ensurePersistence()})),l.eventBulk.events.length>0){var k=ye(l.newestRow).document;l.eventBulk.checkpoint={id:k[a],lwt:k._meta.lwt},l.eventBulk.endTime=Ft(),dd.then(()=>{s.changes$.next(l.eventBulk)})}var z=Promise.resolve({success:h,error:f});return z},e.ensurePersistence=function(){if(this.internals.ensurePersistenceTask){var r=this.internals,i=this.internals.documents,s=this.primaryPath,o=this.internals.ensurePersistenceTask;this.internals.ensurePersistenceTask=void 0;for(var a=Object.values(this.internals.byIndex),l=o.bulkInsertDocs,f=0;f{_.set(uf(k.documentId,k.attachmentId),{writeData:k.attachmentData,digest:k.digest})}),this.schema.attachments&&(o.attachmentsUpdate.forEach(k=>{_.set(uf(k.documentId,k.attachmentId),{writeData:k.attachmentData,digest:k.digest})}),o.attachmentsRemove.forEach(k=>{_.delete(uf(k.documentId,k.attachmentId))}))}}},e.findDocumentsById=function(r,i){this.ensurePersistence();var s=this.internals.documents,o=[];if(s.size===0)return Promise.resolve(o);for(var a=0;az)break;var X=H.doc;(!f||f(X))&&W.push(X),W.length>=l&&!m&&(Q=!0),k++}if(m){var U=Fg(this.schema,r.query);W=W.sort(U)}return W=W.slice(o,l),Promise.resolve({documents:W})},e.count=async function(r){this.ensurePersistence();var i=await this.query(r);return{count:i.documents.length,mode:"fast"}},e.cleanup=function(r){this.ensurePersistence();for(var i=Ft()-r,s=["_deleted","_meta.lwt",this.primaryPath],o=Jy(s),a=this.internals.byIndex[o].docsWithIndex,l=yb(this.schema,s,[!0,0,""]),f=Nb(a,{indexString:l},rl),h=!1;!h;){var m=a[f];!m||m.doc._meta.lwt>i?h=!0:(pF(this.primaryPath,this.schema,this.internals,m.doc),f++)}return dd},e.getAttachmentData=function(r,i,s){this.ensurePersistence(),af(this);var o=uf(r,i),a=this.internals.attachments.get(o);if(!s||!a||a.digest!==s)throw new Error("attachment does not exist: "+o);return Promise.resolve(a.writeData.data)},e.changeStream=function(){return af(this),this.internals.changes$.asObservable()},e.remove=async function(){if(this.closed)throw new Error("closed");this.ensurePersistence(),af(this),this.internals.removed=!0,this.storage.collectionStates.delete(KO(this.databaseName,this.collectionName,this.schema.version)),await this.close()},e.close=function(){return Fb.delete(this),this.ensurePersistence(),this.closed||(this.closed=!0,this.internals.refCount=this.internals.refCount-1),un},e.conflictResultionTasks=function(){return this.internals.conflictResultionTasks$.asObservable()},e.resolveConflictResultionTask=function(r){return un},t}();function vF(t,e,n){var r=KO(e.databaseName,e.collectionName,e.schema.version),i=t.collectionStates.get(r);if(!i)i={id:iu(5),schema:e.schema,removed:!1,refCount:1,documents:new Map,attachments:e.schema.attachments?new Map:void 0,byIndex:{},conflictResultionTasks$:new Kt,changes$:new Kt},mF(i,e.schema),t.collectionStates.set(r,i);else{if(e.devMode&&!Va(i.schema,e.schema))throw new Error("storage was already created with a different schema");i.refCount=i.refCount+1}var s=new yF(t,e.databaseName,e.collectionName,e.schema,i,e.options,n);return Promise.resolve(s)}var gF=new Map;function Lb(t={}){var e={name:"memory",rxdbVersion:vg,collectionStates:gF,createStorageInstance(n){iO(n);var r=Object.assign({},t,n.options);return vF(this,n,r)}};return e}function wF(t){let{name:e,options:n,storage:r,...i}=t;if(!r)switch(n.storageType){case"dexie":r=iF(n.storageOptions);break;case"memory":r=Lb(n.storageOptions);break;default:r=Lb(n.storageOptions);break}return{name:e,storage:r,options:n,...i}}const _F=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,$b=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");const e=t.match(_F);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},jb=t=>t==="*"||t==="x"||t==="X",Ub=t=>{const e=parseInt(t,10);return isNaN(e)?t:e},bF=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],SF=(t,e)=>{if(jb(t)||jb(e))return 0;const[n,r]=bF(Ub(t),Ub(e));return n>r?1:n{for(let n=0;n{const n=$b(t),r=$b(e),i=n.pop(),s=r.pop(),o=zb(n,r);return o!==0?o:i&&s?zb(i.split("."),s.split(".")):i||s?i?-1:1:0},EF=(t,e,n)=>{OF(n);const r=IF(t,e);return WO[n].includes(r)},WO={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},Vb=Object.keys(WO),OF=t=>{if(typeof t!="string")throw new TypeError(`Invalid operator type, expected string but got ${typeof t}`);if(Vb.indexOf(t)===-1)throw new Error(`Invalid operator, expected one of ${Vb.join("|")}`)},{logger:Qr,getDefaultPreparedQuery:kF}=Br,Kb="storage-token|storageToken",Yg=async t=>{let e;try{const r=await FO()(t);if(r.ok)e=await r.json();else throw new Error(`Failed to fetch schema from "${t}", status: ${r.status}`)}catch{throw new Error(`Failed to fetch schema from "${t}"`)}return e},DF=async t=>{var e;try{const n={};for(const r in t){const i=t[r];!i.schema&&((e=i.options)!=null&&e.schemaUrl)&&(i.schema=await Yg(i.options.schemaUrl)),n[i.name]=i}return n}catch(n){throw new Error(n.message)}},xF=async(t,e)=>{let n;const i=await FO()(t);if(i.ok)n=await i.json();else throw new Error(`Failed to fetch db dump from "${t}", status: ${i.status}`);if(!e||!Object.keys(e).length)throw new Error("collections must be initialized before importing");for(const s of n.collections){const o=e[s.name];if(o)s.schemaHash=o.schema._hash;else throw new Error("no such collection as provided in dump")}return n},AF=async(t,e,n)=>{var s,o;let r={};if(t.name!=="dexie")return;const i=(s=await e.internals)==null?void 0:s.dexieTable;if(r=(o=await i.get(Kb))==null?void 0:o.data,!(r!=null&&r.rxdbVersion)||EF(n,r.rxdbVersion,">"))try{await i.update(Kb,{data:{...r,rxdbVersion:n}}),Qr.log("prepare-plugin: migrated internal storage to",n)}catch{throw new Error("prepare-plugin: unable to migrate internal storage")}},CF=async({database:t,creator:e})=>{var o;const n=await SO(t);Qr.log("prepare-plugin: hook:createRxDatabase:after");const{storage:r,internalStore:i,rxdbVersion:s}=t;if(await AF(r,i,s),!(!((o=e.options)!=null&&o.dumpPath)||!n))try{const a=await xF(e.options.dumpPath,t.collections);await t.importJSON(a),Qr.log(`prepare-plugin: imported dump for db "${t.name}"`)}catch(a){Qr.log("prepare-plugin: imported dump error",a)}},PF=async t=>{if(typeof t=="string"){const e=await Yg(t);if(!e)throw new Error(`Failed to fetch schema from "${t}"`);t=e}},RF=async({collection:t,creator:e})=>{var l,f,h;Qr.log("prepare-plugin: hook:createRxCollection:before");const n=await t.getMetadata();Qr.log("prepare-plugin: hook:createRxCollection:before",n);const r=((l=e.options)==null?void 0:l.initialDocs)||[],i=await a();if(!r.length)return;if(i||!n.isFirstTimeInstantiated){if(!((f=e.options)!=null&&f.recreate)||(h=e.options)!=null&&h.replication)return;Qr.log(`prepare-plugin: collection "${t.name}" already has ${i} docs (including _deleted), but recreate option is set`)}const s=await t.schema.hash,o={name:t.name,schemaHash:s,docs:r};try{const{success:m,error:y}=await t.importJSON(o),w=await a();Qr.log(`prepare-plugin: imported ${m.length} docs for collection "${t.name}", errors count ${y.length}, current docs count ${w}`),Qr.table(m)}catch(m){Qr.log("prepare-plugin: imported dump error",m)}return;async function a(){const{count:m}=await t.storageInstance.count(kF()).catch(()=>({count:0}));return m}},TF={name:"prepare-plugin",rxdb:!0,prototypes:{RxDatabase:t=>{Object.assign(t,{fetchSchema:Yg})},RxCollection:t=>{Object.assign(t,{getMetadata:async function(){const n=await SO(this.database),r=await zg(this.database.internalStore),{id:i,data:s,_meta:o,_rev:a}=r.filter(l=>l.data.name===this.name).at(0)||{};return{id:i||this.name,databaseName:this.database.name,collectionName:(s==null?void 0:s.name)||this.name,storageName:this.storageInstance.originalStorageInstance.storage.name,last_modified:o!=null&&o.lwt?Math.floor(o==null?void 0:o.lwt):Date.now(),rev:a?Number(a==null?void 0:a.at(0)):1,isFirstTimeInstantiated:n}}})}},hooks:{createRxDatabase:{after:CF},preCreateRxSchema:{before:PF},createRxCollection:{after:RF}}};function qO(t,e){const n={};if(Array.isArray(e))for(const r of e){const i=Object.getOwnPropertyDescriptor(t,r);i!=null&&i.enumerable&&Object.defineProperty(n,r,i)}else for(const r of Reflect.ownKeys(t)){const i=Object.getOwnPropertyDescriptor(t,r);if(i.enumerable){const s=t[r];e(r,s,t)&&Object.defineProperty(n,r,i)}}return n}const HO="%[a-f0-9]{2}",Wb=new RegExp("("+HO+")|([^%]+?)","gi"),qb=new RegExp("("+HO+")+","gi");function Xy(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;const n=t.slice(0,e),r=t.slice(e);return Array.prototype.concat.call([],Xy(n),Xy(r))}function MF(t){try{return decodeURIComponent(t)}catch{let e=t.match(Wb)||[];for(let n=1;nt==null,LF=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Zy=Symbol("encodeFragmentIdentifier");function $F(t){switch(t.arrayFormat){case"index":return e=>(n,r)=>{const i=n.length;return r===void 0||t.skipNull&&r===null||t.skipEmptyString&&r===""?n:r===null?[...n,[Nt(e,t),"[",i,"]"].join("")]:[...n,[Nt(e,t),"[",Nt(i,t),"]=",Nt(r,t)].join("")]};case"bracket":return e=>(n,r)=>r===void 0||t.skipNull&&r===null||t.skipEmptyString&&r===""?n:r===null?[...n,[Nt(e,t),"[]"].join("")]:[...n,[Nt(e,t),"[]=",Nt(r,t)].join("")];case"colon-list-separator":return e=>(n,r)=>r===void 0||t.skipNull&&r===null||t.skipEmptyString&&r===""?n:r===null?[...n,[Nt(e,t),":list="].join("")]:[...n,[Nt(e,t),":list=",Nt(r,t)].join("")];case"comma":case"separator":case"bracket-separator":{const e=t.arrayFormat==="bracket-separator"?"[]=":"=";return n=>(r,i)=>i===void 0||t.skipNull&&i===null||t.skipEmptyString&&i===""?r:(i=i===null?"":i,r.length===0?[[Nt(n,t),e,Nt(i,t)].join("")]:[[r,Nt(i,t)].join(t.arrayFormatSeparator)])}default:return e=>(n,r)=>r===void 0||t.skipNull&&r===null||t.skipEmptyString&&r===""?n:r===null?[...n,Nt(e,t)]:[...n,[Nt(e,t),"=",Nt(r,t)].join("")]}}function jF(t){let e;switch(t.arrayFormat){case"index":return(n,r,i)=>{if(e=/\[(\d*)]$/.exec(n),n=n.replace(/\[\d*]$/,""),!e){i[n]=r;return}i[n]===void 0&&(i[n]={}),i[n][e[1]]=r};case"bracket":return(n,r,i)=>{if(e=/(\[])$/.exec(n),n=n.replace(/\[]$/,""),!e){i[n]=r;return}if(i[n]===void 0){i[n]=[r];return}i[n]=[...i[n],r]};case"colon-list-separator":return(n,r,i)=>{if(e=/(:list)$/.exec(n),n=n.replace(/:list$/,""),!e){i[n]=r;return}if(i[n]===void 0){i[n]=[r];return}i[n]=[...i[n],r]};case"comma":case"separator":return(n,r,i)=>{const s=typeof r=="string"&&r.includes(t.arrayFormatSeparator),o=typeof r=="string"&&!s&&Oi(r,t).includes(t.arrayFormatSeparator);r=o?Oi(r,t):r;const a=s||o?r.split(t.arrayFormatSeparator).map(l=>Oi(l,t)):r===null?r:Oi(r,t);i[n]=a};case"bracket-separator":return(n,r,i)=>{const s=/(\[])$/.test(n);if(n=n.replace(/\[]$/,""),!s){i[n]=r&&Oi(r,t);return}const o=r===null?[]:r.split(t.arrayFormatSeparator).map(a=>Oi(a,t));if(i[n]===void 0){i[n]=o;return}i[n]=[...i[n],...o]};default:return(n,r,i)=>{if(i[n]===void 0){i[n]=r;return}i[n]=[...[i[n]].flat(),r]}}}function YO(t){if(typeof t!="string"||t.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Nt(t,e){return e.encode?e.strict?LF(t):encodeURIComponent(t):t}function Oi(t,e){return e.decode?BF(t):t}function GO(t){return Array.isArray(t)?t.sort():typeof t=="object"?GO(Object.keys(t)).sort((e,n)=>Number(e)-Number(n)).map(e=>t[e]):t}function JO(t){const e=t.indexOf("#");return e!==-1&&(t=t.slice(0,e)),t}function UF(t){let e="";const n=t.indexOf("#");return n!==-1&&(e=t.slice(n)),e}function Hb(t,e){return e.parseNumbers&&!Number.isNaN(Number(t))&&typeof t=="string"&&t.trim()!==""?t=Number(t):e.parseBooleans&&t!==null&&(t.toLowerCase()==="true"||t.toLowerCase()==="false")&&(t=t.toLowerCase()==="true"),t}function Gg(t){t=JO(t);const e=t.indexOf("?");return e===-1?"":t.slice(e+1)}function Jg(t,e){e={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,...e},YO(e.arrayFormatSeparator);const n=jF(e),r=Object.create(null);if(typeof t!="string"||(t=t.trim().replace(/^[?#&]/,""),!t))return r;for(const i of t.split("&")){if(i==="")continue;const s=e.decode?i.replace(/\+/g," "):i;let[o,a]=QO(s,"=");o===void 0&&(o=s),a=a===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?a:Oi(a,e),n(Oi(o,e),a,r)}for(const[i,s]of Object.entries(r))if(typeof s=="object"&&s!==null)for(const[o,a]of Object.entries(s))s[o]=Hb(a,e);else r[i]=Hb(s,e);return e.sort===!1?r:(e.sort===!0?Object.keys(r).sort():Object.keys(r).sort(e.sort)).reduce((i,s)=>{const o=r[s];return o&&typeof o=="object"&&!Array.isArray(o)?i[s]=GO(o):i[s]=o,i},Object.create(null))}function XO(t,e){if(!t)return"";e={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...e},YO(e.arrayFormatSeparator);const n=o=>e.skipNull&&FF(t[o])||e.skipEmptyString&&t[o]==="",r=$F(e),i={};for(const[o,a]of Object.entries(t))n(o)||(i[o]=a);const s=Object.keys(i);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{const a=t[o];return a===void 0?"":a===null?Nt(o,e):Array.isArray(a)?a.length===0&&e.arrayFormat==="bracket-separator"?Nt(o,e)+"[]":a.reduce(r(o),[]).join("&"):Nt(o,e)+"="+Nt(a,e)}).filter(o=>o.length>0).join("&")}function ZO(t,e){var i;e={decode:!0,...e};let[n,r]=QO(t,"#");return n===void 0&&(n=t),{url:((i=n==null?void 0:n.split("?"))==null?void 0:i[0])??"",query:Jg(Gg(t),e),...e&&e.parseFragmentIdentifier&&r?{fragmentIdentifier:Oi(r,e)}:{}}}function ek(t,e){e={encode:!0,strict:!0,[Zy]:!0,...e};const n=JO(t.url).split("?")[0]||"",r=Gg(t.url),i={...Jg(r,{sort:!1}),...t.query};let s=XO(i,e);s&&(s=`?${s}`);let o=UF(t.url);if(t.fragmentIdentifier){const a=new URL(n);a.hash=t.fragmentIdentifier,o=e[Zy]?a.hash:`#${t.fragmentIdentifier}`}return`${n}${s}${o}`}function tk(t,e,n){n={parseFragmentIdentifier:!0,[Zy]:!1,...n};const{url:r,query:i,fragmentIdentifier:s}=ZO(t,n);return ek({url:r,query:qO(i,e),fragmentIdentifier:s},n)}function zF(t,e,n){const r=Array.isArray(e)?i=>!e.includes(i):(i,s)=>!e(i,s);return tk(t,r,n)}const gm=Object.freeze(Object.defineProperty({__proto__:null,exclude:zF,extract:Gg,parse:Jg,parseUrl:ZO,pick:tk,stringify:XO,stringifyUrl:ek},Symbol.toStringTag,{value:"Module"})),{keys:Qb,isEmpty:Yb,isNullOrUndefined:ev}=Br,VF=({selector:t,sort:e,limit:n,skip:r},i)=>{const s=Qb(i.jsonSchema.properties);return Yb(t)||(t=qO(t,o=>!o.startsWith("$")&&!o.includes(".")&&s.includes(o))),Yb(e)||(e=e==null?void 0:e.filter(o=>s.includes(Qb(o)[0]))),(ev(n)||isNaN(n))&&(n=void 0),(ev(r)||isNaN(r))&&(r=void 0),{selector:t,sort:e,limit:n,skip:r}},Gb=(t,e)=>{t=gm.extract(t);const n=gm.pick(t,["selector","sort","limit","skip"]),r=gm.parse(n,{parseNumbers:!0,parseBooleans:!0}),{selector:i,sort:s,limit:o,skip:a}=r,l=i?JSON.parse(i):void 0,f=s?JSON.parse(s):void 0;return VF({selector:l,sort:f,limit:o,skip:a},e)},lf=t=>ev(t)?"":JSON.stringify(t),{logger:Jb,compactObject:KF}=Br,WF={name:"query-params-plugin",rxdb:!0,prototypes:{RxCollection:t=>{const e=new Gr({});let n=!1,r,i=!1,s="",o=()=>Promise.resolve(!1);function a(h=CE,m){var y;n=!!((y=this.options)!=null&&y.useQueryParams),r=this.schema,!(!n||i)&&(o=m,h.pipe(Bo(),xy(w=>{s=w}),Mt(w=>Gb(w,r)),EE(w=>(Jb.log("Error in parsing url to mango query",w),e)),xy(w=>{Jb.log("queryParams",w)}),TE(()=>!this.destroyed)).subscribe(e),i=!0)}function l(h){if(!n)return;const{selector:m,sort:y,limit:w,skip:I}=h,E={limit:w,skip:I};m&&(E.selector=lf(h.selector)),y&&(E.sort=lf(h.sort)),o(E)}function f(h){if(!n)return;const m=Gb(s,r),y={selector:lf(h.selector||m.selector),sort:lf(h.sort||m.sort),limit:h.limit||m.limit,skip:h.skip||m.skip};o(KF(y))}Object.assign(t,{queryParams:{$:e.asObservable(),get:()=>e.getValue(),set:l,patch:f}},{queryParamsInit:a})}},hooks:{createRxCollection:{}}};var nk={minimumDeletedTime:1e3*60*60*24*31,minimumCollectionAge:1e3*60,runEach:1e3*60*5,awaitReplicationsInSync:!0,waitForLeadership:!0},wm=dd;async function qF(t){var e=t.database,n=Object.assign({},nk,e.cleanupPolicy?e.cleanupPolicy:{});await t.promiseWait(n.minimumCollectionAge),!t.destroyed&&(n.waitForLeadership&&await e.waitForLeadership(),!t.destroyed&&(await rk(t,n),await HF(t,n)))}async function rk(t,e){for(var n=t.database,r=t.storageInstance,i=!1;!i&&!t.destroyed;){if(e.awaitReplicationsInSync){var s=BO.get(t);s&&await Promise.all(s.map(o=>{if(!o.isStopped())return o.awaitInSync()}))}if(await n.requestIdlePromise(),t.destroyed)return;wm=wm.then(()=>t.destroyed?!0:r.cleanup(e.minimumDeletedTime)),i=await wm}}async function HF(t,e){for(;!t.destroyed;){if(await t.promiseWait(e.runEach),t.destroyed)return;await rk(t,e)}}var QF={name:"cleanup",rxdb:!0,prototypes:{RxCollection:t=>{t.cleanup=async function(e){var n=Object.assign({},nk,this.database.cleanupPolicy?this.database.cleanupPolicy:{});typeof e>"u"&&(e=n.minimumDeletedTime);for(var r=!1;!r&&!this.destroyed;)r=await this.storageInstance.cleanup(e)}}},hooks:{createRxCollection:{after:t=>{qF(t.collection)}}}};function YF(t){var e={name:this.name,instanceToken:this.token,collections:[]},n=Object.keys(this.collections).filter(r=>!t||t.includes(r)).filter(r=>r.charAt(0)!=="_").map(r=>this.collections[r]);return Promise.all(n.map(r=>r.exportJSON())).then(r=>(e.collections=r,e))}var GF=function(t){var e=t.collections.filter(n=>!this.collections[n.name]).map(n=>n.name);if(e.length>0)throw le("JD1",{missingCollections:e});return Promise.all(t.collections.map(n=>this.collections[n.name].importJSON(n)))},JF=async function(){var t={name:this.name,schemaHash:await this.schema.hash,docs:[]},e=na("find",tl(),this);return tO(e).then(n=>(t.docs=n.map(r=>(r=$e(r),delete r._rev,delete r._attachments,r)),t))};async function XF(t){if(t.schemaHash!==await this.schema.hash)throw le("JD2",{schemaHash:t.schemaHash,own:this.schema.hash});var e=t.docs;return this.storageInstance.bulkWrite(e.map(n=>{var r=Object.assign({},n,{_meta:{lwt:Ft()},_rev:Rn(),_attachments:{},_deleted:!1});return{document:r}}),"json-dump-import")}var ZF={name:"json-dump",rxdb:!0,prototypes:{RxDatabase:t=>{t.exportJSON=YF,t.importJSON=GF},RxCollection:t=>{t.exportJSON=JF,t.importJSON=XF}},overwritable:{}},eL=aO(),tL=function(t){gg(e,t);function e(n,r,i){var s;return s=t.call(this,null,r)||this,s.id=n,s.parent=i,s}return e}(eL),il={get isLocal(){return!0},get allAttachments$(){throw le("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var t=this,e=Mo(tv,this.parent);return t.parent.$.pipe(lt(n=>n.documentId===this.primary),lt(n=>n.isLocal),Mt(n=>kg(n)),Hl(e.docCache.getLatestDocumentData(this.primary)),Bo((n,r)=>n._rev===r._rev),Mt(n=>e.docCache.getCachedRxDocument(n)),Pi(Ci))},get $$(){var t=this,e=_m(t),n=e.getReactivityFactory();return n.fromObservable(t.$,t.getLatest()._data)},get deleted$$(){var t=this,e=_m(t),n=e.getReactivityFactory();return n.fromObservable(t.deleted$,t.getLatest().deleted)},getLatest(){var t=Mo(tv,this.parent),e=t.docCache.getLatestDocumentData(this.primary);return t.docCache.getCachedRxDocument(e)},get(t){if(t="data."+t,!!this._data){if(typeof t!="string")throw el("LD2",{objPath:t});var e=Ts(this._data,t);return e=it.deepFreezeWhenDevMode(e),e}},get$(t){if(t="data."+t,it.isDevMode()){if(t.includes(".item."))throw le("LD3",{objPath:t});if(t===this.primaryPath)throw le("LD4")}return this.$.pipe(Mt(e=>e._data),Mt(e=>Ts(e,t)),Bo())},get$$(t){var e=_m(this),n=e.getReactivityFactory();return n.fromObservable(this.get$(t),this.getLatest().get(t))},async incrementalModify(t){var e=await sl(this.parent);return e.incrementalWriteQueue.addWrite(this._data,async n=>(n.data=await t(n.data,this),n)).then(n=>e.docCache.getCachedRxDocument(n))},incrementalPatch(t){return this.incrementalModify(e=>(Object.entries(t).forEach(([n,r])=>{e[n]=r}),e))},async _saveData(t){var e=await sl(this.parent),n=this._data;return t.id=this.id,e.storageInstance.bulkWrite([{previous:n,document:t}],"local-document-save-data").then(r=>{var i=r.success[0];if(!i)throw r.error[0];t=$e(t),t._rev=i._rev})},async remove(){var t=await sl(this.parent),e={id:this._data.id,data:{},_deleted:!0,_meta:Ks(),_rev:Rn(),_attachments:{}};return Tl(t.storageInstance,{previous:this._data,document:e},"local-document-remove").then(n=>t.docCache.getCachedRxDocument(n))}},Xb=!1,nL=()=>{if(!Xb){Xb=!0;var t=kh,e=Object.getOwnPropertyNames(t);e.forEach(r=>{var i=Object.getOwnPropertyDescriptor(il,r);if(!i){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(il,r,s)}});var n=r=>()=>{throw le("LD6",{functionName:r})};["populate","update","putAttachment","getAttachment","allAttachments"].forEach(r=>il[r]=n(r))}};function rL(t,e){nL();var n=new tL(t.id,t,e);return Object.setPrototypeOf(n,il),n.prototype=il,n}function _m(t){var e=t.parent;return _N(e)?e:e.database}var kd=new WeakMap,tv=new WeakMap;function Zb(t){var e=t.database?t.database:t,n=t.database?t.name:"",r=(async()=>{var i=await ik(e.token,e.storage,e.name,n,e.instanceCreationOptions,e.multiInstance);i=$g(e,i,sk);var s=new JE("id",t.$.pipe(lt(h=>h.isLocal)),h=>rL(h,t)),o=new oO(i,"id",()=>{},()=>{}),a=await e.storageToken,l=i.changeStream().subscribe(h=>{var m={id:h.id,internal:!1,collectionName:t.database?t.name:void 0,storageToken:a,events:h.events.map(y=>nO(!0,y,t.database?t:void 0)),databaseToken:e.token,checkpoint:h.checkpoint,context:h.context,endTime:h.endTime,startTime:h.startTime};e.$emit(m)});t._subs.push(l);var f={database:e,parent:t,storageInstance:i,docCache:s,incrementalWriteQueue:o};return tv.set(t,f),f})();kd.set(t,r)}function sl(t){var e=kd.get(t);if(!e){var n=t.database?t.database:t,r=t.database?t.name:"";throw le("LD8",{database:n.name,collection:r})}return e}function ik(t,e,n,r,i,s){return e.createStorageInstance({databaseInstanceToken:t,databaseName:n,collectionName:iL(r),schema:sk,options:i,multiInstance:s,devMode:it.isDevMode()})}function e1(t){var e=kd.get(t);if(e)return kd.delete(t),e.then(n=>n.storageInstance.close())}async function t1(t,e,n){var r=iu(10),i=await ik(r,t,e,n,{},!1);await i.remove()}function iL(t){return"plugin-local-documents-"+t}var sk=bh({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function n1(t,e){var n=await sl(this),r={id:t,data:e,_deleted:!1,_meta:Ks(),_rev:Rn(),_attachments:{}};return Tl(n.storageInstance,{document:r},"local-document-insert").then(i=>n.docCache.getCachedRxDocument(i))}function r1(t,e){return this.getLocal(t).then(n=>{if(n)return n.incrementalModify(()=>e);var r=this.insertLocal(t,e);return r})}async function i1(t){var e=await sl(this),n=e.docCache,r=n.getLatestDocumentDataIfExists(t);return r?Promise.resolve(n.getCachedRxDocument(r)):Xl(e.storageInstance,t).then(i=>i?e.docCache.getCachedRxDocument(i):null)}function s1(t){return this.$.pipe(Hl(null),Nr(async e=>{if(e)return{changeEvent:e};var n=await this.getLocal(t);return{doc:n}}),Nr(async e=>{if(e.changeEvent){var n=e.changeEvent;if(!n.isLocal||n.documentId!==t)return{use:!1};var r=await this.getLocal(t);return{use:!0,doc:r}}else return{use:!0,doc:e.doc}}),lt(e=>e.use),Mt(e=>e.doc))}var ok={name:"local-documents",rxdb:!0,prototypes:{RxCollection:t=>{t.insertLocal=n1,t.upsertLocal=r1,t.getLocal=i1,t.getLocal$=s1},RxDatabase:t=>{t.insertLocal=n1,t.upsertLocal=r1,t.getLocal=i1,t.getLocal$=s1}},hooks:{createRxDatabase:{before:t=>{t.creator.localDocuments&&Zb(t.database)}},createRxCollection:{before:t=>{t.creator.localDocuments&&Zb(t.collection)}},preDestroyRxDatabase:{after:t=>e1(t)},postDestroyRxCollection:{after:t=>e1(t)},postRemoveRxDatabase:{after:t=>t1(t.storage,t.databaseName,"")},postRemoveRxCollection:{after:t=>t1(t.storage,t.databaseName,t.collectionName)}},overwritable:{}};async function ak(t){var e=fR(t.collection.schema.jsonSchema).map(r=>t.collection.name+"-"+r),n=await t.database.internalStore.findDocumentsById(e.map(r=>Ha(r,ko)),!1);if(n.length>1)throw new Error("more the one old collection meta found");return n[0]}function sL(t,e,n){var r=$e(n._attachments),i=Pn(n),s=i._meta;delete i._meta,i._attachments=r;for(var o=e+1,a=Promise.resolve(i),l=function(){var f=o;a=a.then(h=>oL(t,f,h)),o++};o<=t.schema.version;)l();return a.then(f=>f===null?mg:(f._meta=s,f))}function oL(t,e,n){if(n===null)return mg;var r=t.migrationStrategies[e](n,t),i=XI(r);return i}async function uk(t){if(t.collection.schema.version===0)return Gn;var e=await ak(t);return!!e}var aL=200,lk=new WeakMap;function uL(t){var e=ck(t.database),n=e.getValue().slice(0);n.push(t),e.next(n)}function ck(t){return Tr(lk,t,()=>new Gr([]))}function lL(t){var e=lk.get(t);e&&e.complete()}var cL=function(){function t(n,r,i=[n.name,"v",n.schema.version].join("-")){this.started=!1,this.updateStatusHandlers=[],this.updateStatusQueue=dd,this.collection=n,this.migrationStrategies=r,this.statusDocKey=i,this.database=n.database,this.oldCollectionMeta=ak(this),this.mustMigrate=uk(this),this.statusDocId=Ha(this.statusDocKey,Pf),uL(this),this.$=V2(this.database.internalStore,this.statusDocId).pipe(lt(s=>!!s),Mt(s=>ye(s).data),Pi(Ci))}var e=t.prototype;return e.getStatus=function(){return Cs(this.$)},e.startMigration=async function(r=aL){var i=await this.mustMigrate;if(i){if(this.started)throw le("DM1");this.started=!0;var s=void 0;if(this.database.multiInstance){s=new xh(["rx-migration-state",this.database.name,this.collection.name,this.collection.schema.version].join("|"));var o=RB(s);await o.awaitLeadership()}var a=await this.oldCollectionMeta,l=await this.database.storage.createStorageInstance({databaseName:this.database.name,collectionName:this.collection.name,databaseInstanceToken:this.database.token,multiInstance:this.database.multiInstance,options:{},schema:a.data.schema,password:this.database.password,devMode:it.isDevMode()}),f=await this.getConnectedStorageInstances(),h=await this.countAllDoucments([l].concat(f.map(m=>m.oldStorage)));await this.updateStatus(m=>(m.count.total=h,m));try{await Promise.all(f.map(async m=>{await cO(this.collection,m.newStorage.collectionName,m.newStorage.schema),await this.migrateStorage(m.oldStorage,m.newStorage,r),await m.newStorage.close()})),await this.migrateStorage(l,this.collection.storageInstance.originalStorageInstance,r)}catch(m){await l.close(),await this.updateStatus(y=>(y.status="ERROR",y.error=Oy(m),y));return}await Tl(this.database.internalStore,{previous:a,document:Object.assign({},a,{_deleted:!0})},"rx-migration-remove-collection-meta"),await this.updateStatus(m=>(m.status="DONE",m)),s&&await s.close()}},e.updateStatus=function(r){return this.updateStatusHandlers.push(r),this.updateStatusQueue=this.updateStatusQueue.then(async()=>{if(this.updateStatusHandlers.length!==0){var i=this.updateStatusHandlers;for(this.updateStatusHandlers=[];;){var s=await Xl(this.database.internalStore,this.statusDocId),o=Pn(s);s||(o={id:this.statusDocId,key:this.statusDocKey,context:Pf,data:{collectionName:this.collection.name,status:"RUNNING",count:{total:0,handled:0,percent:0}},_deleted:!1,_meta:Ks(),_rev:Rn(),_attachments:{}});var a=ye(o).data;for(var l of i)a=l(a);if(a.count.percent=Math.round(a.count.handled/a.count.total*100),o&&s&&Va(o.data,s.data))break;try{await Tl(this.database.internalStore,{previous:s,document:ye(o)},Pf);break}catch(f){if(!_h(f))throw f}}}}),this.updateStatusQueue},e.migrateStorage=async function(r,i,s){var o=await this.database.storage.createStorageInstance({databaseName:this.database.name,collectionName:"rx-migration-state-meta-"+this.collection.name+"-"+this.collection.schema.version,databaseInstanceToken:this.database.token,multiInstance:this.database.multiInstance,options:{},schema:Vy(r.schema,vd(r.schema)),password:this.database.password,devMode:it.isDevMode()}),a=fN(i,bd,this.database.token,!0),l=hO({keepMeta:!0,identifier:["rx-migration-state",this.collection.name,r.schema.version,this.collection.schema.version].join("-"),replicationHandler:{masterChangesSince(){return Promise.resolve({checkpoint:null,documents:[]})},masterWrite:async h=>{h=await Promise.all(h.map(async y=>{var w=y.newDocumentState;if(i.schema.title===Rf&&(w=y.newDocumentState.docData,y.newDocumentState.isCheckpoint==="1"))return{assumedMasterState:void 0,newDocumentState:y.newDocumentState};var I=await sL(this.collection,r.schema.version,w),E={assumedMasterState:void 0,newDocumentState:i.schema.title===Rf?Object.assign({},y.newDocumentState,{docData:I}):I};return E})),h=h.filter(y=>!!y.newDocumentState);var m=await a.masterWrite(h);return m},masterChangeStream$:new Kt().asObservable()},forkInstance:r,metaInstance:o,pushBatchSize:s,pullBatchSize:0,conflictHandler:bd,hashFunction:this.database.hashFunction}),f=!1;if(l.events.error.subscribe(h=>f=h),l.events.processed.up.subscribe(()=>{this.updateStatus(h=>(h.count.handled=h.count.handled+1,h))}),await Tf(l),await pO(l),await this.updateStatusQueue,f)throw await o.close(),f;await Promise.all([r.remove(),o.remove()])},e.countAllDoucments=async function(r){var i=0;return await Promise.all(r.map(async s=>{var o=Jl(s.schema,Rl(s.schema,{selector:{}})),a=await s.count(o);i+=a.count})),i},e.getConnectedStorageInstances=async function(){var r=await this.oldCollectionMeta,i=[];return await Promise.all(await Promise.all(r.data.connectedStorages.map(async s=>{if(s.schema.title!==Rf)throw new Error("unknown migration handling for schema");var o=Vy(Pn(this.collection.schema.jsonSchema),vd(s.schema));o.version=this.collection.schema.version;var[a,l]=await Promise.all([this.database.storage.createStorageInstance({databaseInstanceToken:this.database.token,databaseName:this.database.name,devMode:it.isDevMode(),multiInstance:this.database.multiInstance,options:{},schema:s.schema,password:this.database.password,collectionName:s.collectionName}),this.database.storage.createStorageInstance({databaseInstanceToken:this.database.token,databaseName:this.database.name,devMode:it.isDevMode(),multiInstance:this.database.multiInstance,options:{},schema:o,password:this.database.password,collectionName:s.collectionName})]);i.push({oldStorage:a,newStorage:l})}))),i},e.migratePromise=async function(r){this.startMigration(r);var i=await this.mustMigrate;if(!i)return{status:"DONE",collectionName:this.collection.name,count:{handled:0,percent:0,total:0}};var s=await Promise.race([Cs(this.$.pipe(lt(o=>o.status==="DONE"))),Cs(this.$.pipe(lt(o=>o.status==="ERROR")))]);if(s.status==="ERROR")throw le("DM4",{collection:this.collection.name,error:s.error});return s},t}(),fL=new WeakMap,dL={name:"migration-schema",rxdb:!0,init(){gi(ok)},hooks:{preDestroyRxDatabase:{after:lL}},prototypes:{RxDatabase:t=>{t.migrationStates=function(){return ck(this).pipe(Pi(Ci))}},RxCollection:t=>{t.getMigrationState=function(){return Tr(fL,this,()=>new cL(this.asRxCollection,this.migrationStrategies))},t.migrationNeeded=function(){return this.schema.version===0?Gn:uk(this.getMigrationState())}}}};const Xg=(t,e)=>{switch(t){case"deep":return Py(e);case"copy":return Ry(e)?new Date(e):Lt(e)?[...e]:wt(e)?Object.assign({},e):e;default:return e}},hL=/^[a-z]+[a-zA-Z0-9]*$/;function fk(t){if(!t.includes(".$"))return[{parent:t,selector:t},[]];const e=t.indexOf(".$"),n=t.indexOf("]"),r=t.substring(0,e),i=t.substring(e+3,n);Yt(i===""||hL.test(i),"The filter must begin with a lowercase letter and contain only alphanumeric characters.");const s=t.substring(n+2),[o,a]=s?fk(s):[];return[{selector:t,parent:r,child:i||"$",next:o},[i,...a||[]].filter(Boolean)]}const $n=(t,e,n,r,i)=>{const{parent:s,child:o,next:a}=e;if(!o){let f=!1;return Pl(t,s,(m,y)=>f=!!r(m,y)||f,i),f}const l=lu(t,s);return Lt(l)?l.map((f,h)=>n[o]&&!n[o].test({[o]:f})?!1:a?$n(f,a,n,r,i):r(l,h)).some(Boolean):!1};function or(t,e,n,r){const i=[];for(const[s,o]of Object.entries(t)){const[a,l]=fk(s);if(!l.length)r(o,a,{})&&i.push(a.parent);else{const f={};e.forEach(m=>{Object.keys(m).forEach(y=>{l.forEach(w=>{(y===w||y.startsWith(w+"."))&&(f[w]=f[w]||{},Object.assign(f[w],{[y]:m[y]}))})})});const h={};for(const[m,y]of Object.entries(f))h[m]=new qs(y,n.queryOptions);r(o,a,h)&&i.push(a.parent)}}return i}const pL=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>{const a={$each:[i]};return wt(i)&&Xn(i,"$each")&&Object.assign(a,i),$n(t,s,o,(l,f)=>{const h=l[f]||(l[f]=[]);return Ng([h,a.$each]).length===a.$each.length?!1:(l[f]=Xg(r.cloneMode,IM(h.concat(a.$each))),!0)},{buildGraph:!0})}),mL=new Set(["and","or","xor"]),yL=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>{const a=Object.keys(i);return Yt(a.length===1&&mL.has(a[0]),`Invalid bit operator '${a[0]}'. Must be one of 'and', 'or', or 'xor'.`),$n(t,s,o,(l,f)=>{let h=l[f];const m=i[a[0]];if(h!==void 0&&!(Hn(h)&&Hn(m)))return!1;switch(h=h||0,a[0]){case"and":l[f]=h&m;break;case"or":l[f]=h|m;break;case"xor":l[f]=h^m;break}return l[f]!==h},{buildGraph:!0})}),vL=(t,e,n=[],r={})=>{const i=Date.now();return or(e,n,r,(s,o,a)=>$n(t,o,a,(l,f)=>(l[f]=i,!0),{buildGraph:!0}))},gL=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>{if(!s.child){const a=lu(t,s.parent);Yt(a===void 0||Hn(a),"cannot apply $inc to a value of non-numeric type")}return $n(t,s,o,(a,l)=>(a[l]=(a[l]||(a[l]=0))+i,!0),{buildGraph:!0})}),wL=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>a[l]!==void 0&&Mn(a[l],i)>-1?!1:(a[l]=i,!0),{buildGraph:!0})),_L=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>a[l]!==void 0&&Mn(a[l],i)<1?!1:(a[l]=i,!0),{buildGraph:!0})),bL=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>{const f=a[l];return a[l]=a[l]===void 0?0:a[l]*i,a[l]!==f},{buildGraph:!0})),SL=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>{const f=a[l];return Yt(Lt(f),`path '${s.selector}' contains an element of non-array type.`),f.length?(i===-1?f.splice(0,1):f.pop(),!0):!1})),dk=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>{const a=!wt(i)||Object.keys(i).some(Ko),l=new qs(a?{k:i}:i,r.queryOptions),f=a?h=>l.test({k:h}):h=>l.test(h);return $n(t,s,o,(h,m)=>{const y=h[m],w=new Array;return y.map(E=>{const F=f(E);return F||w.push(E),F}).some(Boolean)?(h[m]=w,!0):!1})}),IL=(t,e,n=[],r={})=>{const i={};return Object.entries(e).forEach(([s,o])=>{i[s]={$in:o}}),dk(t,i,n,r)},EL=Object.freeze(["$each","$slice","$sort","$position"]),OL=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>{const a={$each:[i]};return wt(i)&&EL.some(l=>Xn(i,l))&&Object.assign(a,i),$n(t,s,o,(l,f)=>{const h=l[f]||(l[f]=[]),m=h.slice(0,a.$slice||h.length),y=h.length,w=Hn(a.$position)?a.$position:h.length;if(h.splice(w,0,...Xg(r.cloneMode,a.$each)),a.$sort){const I=wt(a.$sort)?Object.keys(a.$sort||{}).pop():"",E=I?a.$sort[I]:a.$sort,F=I?S=>lu(S,I):S=>S;h.sort((S,_)=>E*Mn(F(S),F(_)))}return Hn(a.$slice)&&(a.$slice<0?h.splice(0,h.length+a.$slice):h.splice(a.$slice)),y!=h.length||!Wi(m,h)},{descendArray:!0,buildGraph:!0})}),hk=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>Wi(a[l],i)?!1:(a[l]=Xg(r.cloneMode,i),!0),{buildGraph:!0})),kL=(t,e,n=[],r={})=>{const i=[],s=or(e,n,r,(o,a,l)=>$n(t,a,l,(f,h)=>Xn(f,h)?(i.push(...hk(t,{[o]:f[h]},n,r)),delete f[h],!0):!1));return Array.from(new Set(s.concat(i)))},DL=(t,e,n=[],r={})=>or(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>Xn(a,l)?(Lt(a)?a[l]=null:delete a[l],!0):!1)),o1=Object.freeze(Object.defineProperty({__proto__:null,$addToSet:pL,$bit:yL,$currentDate:vL,$inc:gL,$max:wL,$min:_L,$mul:bL,$pop:SL,$pull:dk,$pullAll:IL,$push:OL,$rename:kL,$set:hk,$unset:DL},Symbol.toStringTag,{value:"Module"}));function xL(t){return(e,n,r=[],i={},s={})=>{const o=Object.assign({cloneMode:"copy"},t,s);Object.assign(o,{queryOptions:Bg(Object.assign({useStrictMode:!1},o==null?void 0:o.queryOptions))}),r=r||[],i=i||{};const a=Object.entries(n);Yt(a.length===1,"Update expression must contain only one operator.");const[l,f]=a[0];Yt(Xn(o1,l),`Update operator '${l}' is not supported.`);const h=o1[l];return Object.keys(i).length&&!new qs(i,o.queryOptions).test(e)?[]:h(e,f,r,o)}}var bm;function pk(t,e){if(!bm){var n=xL({cloneMode:"none"});bm=(r,i)=>{var s=Pn(r);return n(s,i),s}}return bm(t,e)}function AL(t){return this.incrementalModify(e=>{var n=pk(e,t);return n})}function CL(t){var e=this._data,n=pk(e,t);return this._saveData(n,e)}function PL(t){return this.exec().then(e=>e?Array.isArray(e)?Promise.all(e.map(n=>n.update(t))).then(()=>e):e.update(t).then(()=>e):null)}var RL={name:"update",rxdb:!0,prototypes:{RxDocument:t=>{t.update=CL,t.incrementalUpdate=AL},RxQuery:t=>{t.update=PL}}};const{logger:TL}=Br;async function ML(t=[]){try{gi(ok),gi(ZF),gi(dL),gi(RL),gi(QF),gi(TF),gi(WF);for(const e of t)gi(e);TL.log("rxdb plugins loaded")}catch(e){throw new Error(e.message??e)}}const{logger:ea}=Br;class NL{get db(){return this.dbInstance}get dbOptions(){return this.options}get collections(){return this.db.collections}async destroyDb(){try{await this.db.remove(),await this.db.destroy(),this.dbInstance=null,ea.log("database destroy")}catch{ea.log("database destroy error")}}async initDb(e){var n,r;if(!this.dbInstance)try{if(await ML((n=e.options)==null?void 0:n.plugins),this.dbInstance=await wN(e),this.options=e,ea.log(`created database "${this.db.name}" with config "${JSON.stringify(e)}"`),(r=e==null?void 0:e.options)!=null&&r.schemas){const i=await this.initCollections(e.options.schemas);ea.log(`created ${Object.keys(i).length} collections bulk: ${Object.keys(i)}`)}}catch(i){throw ea.log("Error initializing the database:",i),i}}async initCollections(e){try{const n=await DF(e);return await this.db.addCollections(n)}catch(n){throw ea.log("Error initializing collection(s)",n),n}}}var mk={exports:{}},Xe={};/** @license React v16.13.1 + `):"",this.name="UnsubscriptionError",this.errors=n}});function pd(t,e){if(t){var n=t.indexOf(e);0<=n&&t.splice(n,1)}}var Bo=function(){function t(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var e,n,r,i,s;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=ja(o),l=a.next();!l.done;l=a.next()){var f=l.value;f.remove(this)}}catch(E){e={error:E}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}else o.remove(this);var h=this.initialTeardown;if(qe(h))try{h()}catch(E){s=E instanceof nm?E.errors:[E]}var m=this._finalizers;if(m){this._finalizers=null;try{for(var y=ja(m),w=y.next();!w.done;w=y.next()){var I=w.value;try{P_(I)}catch(E){s=s??[],E instanceof nm?s=ci(ci([],Tr(s)),Tr(E.errors)):s.push(E)}}}catch(E){r={error:E}}finally{try{w&&!w.done&&(i=y.return)&&i.call(y)}finally{if(r)throw r.error}}}if(s)throw new nm(s)}},t.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)P_(e);else{if(e instanceof t){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},t.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},t.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},t.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&pd(n,e)},t.prototype.remove=function(e){var n=this._finalizers;n&&pd(n,e),e instanceof t&&e._removeParent(this)},t.EMPTY=function(){var e=new t;return e.closed=!0,e}(),t}(),cE=Bo.EMPTY;function fE(t){return t instanceof Bo||t&&"closed"in t&&qe(t.remove)&&qe(t.add)&&qe(t.unsubscribe)}function P_(t){qe(t)?t():t.unsubscribe()}var dE={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},xy={setTimeout:function(t,e){for(var n=[],r=2;r0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var r=this,i=this,s=i.hasError,o=i.isStopped,a=i.observers;return s||o?cE:(this.currentObservers=null,a.push(n),new Bo(function(){r.currentObservers=null,pd(a,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,i=r.hasError,s=r.thrownError,o=r.isStopped;i?n.error(s):o&&n.complete()},e.prototype.asObservable=function(){var n=new Ot;return n.source=this,n},e.create=function(n,r){return new B_(n,r)},e}(Ot),B_=function(t){pi(e,t);function e(n,r){var i=t.call(this)||this;return i.destination=n,i.source=r,i}return e.prototype.next=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.next)===null||i===void 0||i.call(r,n)},e.prototype.error=function(n){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.error)===null||i===void 0||i.call(r,n)},e.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},e.prototype._subscribe=function(n){var r,i;return(i=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&i!==void 0?i:cE},e}(Kt);function F_(){for(var t=[],e=0;e0&&(h=new Wa({next:function(Q){return W.next(Q)},error:function(Q){E=!0,$(),m=sm(S,i,Q),W.error(Q)},complete:function(){I=!0,$(),m=sm(S,o),W.complete()}}),sr(O).subscribe(h))})(f)}}function sm(t,e){for(var n=[],r=2;r!!t.queryParams.limit,bT=t=>t.queryParams.limit===1,ST=t=>!!(t.queryParams.skip&&t.queryParams.skip>0),IT=t=>t.changeEvent.operation==="DELETE",ET=t=>t.changeEvent.operation==="INSERT",OT=t=>t.changeEvent.operation==="UPDATE",kT=t=>NE(t)&&t.previousResults.length>=t.queryParams.limit,DT=t=>{const e=t.queryParams.sortFields,n=t.changeEvent.previous,r=t.changeEvent.doc;if(!r)return!1;if(!n)return!0;for(let i=0;i{const e=t.changeEvent.id;if(t.keyDocumentMap)return t.keyDocumentMap.has(e);{const n=t.queryParams.primaryKey,r=t.previousResults;for(let i=0;i{const e=t.previousResults[0];return!!(e&&e[t.queryParams.primaryKey]===t.changeEvent.id)},AT=t=>{const e=xg(t.previousResults);return!!(e&&e[t.queryParams.primaryKey]===t.changeEvent.id)},PT=t=>{const e=t.changeEvent.previous;if(!e)return!1;const n=t.previousResults[0];return n?n[t.queryParams.primaryKey]===t.changeEvent.id?!0:t.queryParams.sortComparator(e,n)<0:!1},RT=t=>{const e=t.changeEvent.previous;if(!e)return!1;const n=xg(t.previousResults);return n?n[t.queryParams.primaryKey]===t.changeEvent.id?!0:t.queryParams.sortComparator(e,n)>0:!1},TT=t=>{const e=t.changeEvent.doc;if(!e)return!1;const n=t.previousResults[0];return n?n[t.queryParams.primaryKey]===t.changeEvent.id?!0:t.queryParams.sortComparator(e,n)<0:!1},MT=t=>{const e=t.changeEvent.doc;if(!e)return!1;const n=xg(t.previousResults);return n?n[t.queryParams.primaryKey]===t.changeEvent.id?!0:t.queryParams.sortComparator(e,n)>0:!1},NT=t=>{const e=t.changeEvent.previous;return e?t.queryParams.queryMatcher(e):!1},BT=t=>{const e=t.changeEvent.doc;return e?t.queryParams.queryMatcher(e):!1},FT=t=>t.previousResults.length===0,LT={0:ET,1:OT,2:IT,3:NE,4:bT,5:ST,6:FT,7:kT,8:CT,9:AT,10:DT,11:xT,12:PT,13:RT,14:TT,15:MT,16:NT,17:BT};function BE(t,e,n,r){var i=t.length,s=i-1,o=0;if(i===0)return t.push(e),0;for(var a;r<=s;)o=r+(s-r>>1),a=t[o],n(a,e)<=0?r=o+1:s=o-1;return n(a,e)<=0&&o++,t.splice(o,0,e),o}const $T=t=>{},Cg=t=>{t.previousResults.unshift(t.changeEvent.doc),t.keyDocumentMap&&t.keyDocumentMap.set(t.changeEvent.id,t.changeEvent.doc)},Ag=t=>{t.previousResults.push(t.changeEvent.doc),t.keyDocumentMap&&t.keyDocumentMap.set(t.changeEvent.id,t.changeEvent.doc)},Pg=t=>{const e=t.previousResults.shift();t.keyDocumentMap&&e&&t.keyDocumentMap.delete(e[t.queryParams.primaryKey])},Rg=t=>{const e=t.previousResults.pop();t.keyDocumentMap&&e&&t.keyDocumentMap.delete(e[t.queryParams.primaryKey])},jT=t=>{Pg(t),Ag(t)},UT=t=>{Rg(t),Cg(t)},zT=t=>{Pg(t),Cg(t)},VT=t=>{Rg(t),Ag(t)},FE=t=>{t.keyDocumentMap&&t.keyDocumentMap.delete(t.changeEvent.id);const e=t.queryParams.primaryKey,n=t.previousResults;for(let r=0;r{const e=t.changeEvent.doc,n=t.queryParams.primaryKey,r=t.previousResults;for(let i=0;i{const e={_id:"wrongHuman"+new Date().getTime()};t.previousResults.length=0,t.previousResults.push(e),t.keyDocumentMap&&(t.keyDocumentMap.clear(),t.keyDocumentMap.set(e._id,e))},LE=t=>{const e=t.changeEvent.id,n=t.changeEvent.doc;if(t.keyDocumentMap){if(t.keyDocumentMap.has(e))return;t.keyDocumentMap.set(e,n)}else if(t.previousResults.find(i=>i[t.queryParams.primaryKey]===e))return;BE(t.previousResults,n,t.queryParams.sortComparator,0)},qT=t=>{FE(t),LE(t)},HT=t=>{throw new Error("Action runFullQueryAgain must be implemented by yourself")},QT=t=>{throw new Error("Action unknownAction should never be called")},YT=["doNothing","insertFirst","insertLast","removeFirstItem","removeLastItem","removeFirstInsertLast","removeLastInsertFirst","removeFirstInsertFirst","removeLastInsertLast","removeExisting","replaceExisting","alwaysWrong","insertAtSortPosition","removeExistingAndInsertAtSortPosition","runFullQueryAgain","unknownAction"],GT={doNothing:$T,insertFirst:Cg,insertLast:Ag,removeFirstItem:Pg,removeLastItem:Rg,removeFirstInsertLast:jT,removeLastInsertFirst:UT,removeFirstInsertFirst:zT,removeLastInsertLast:VT,removeExisting:FE,replaceExisting:KT,alwaysWrong:WT,insertAtSortPosition:LE,removeExistingAndInsertAtSortPosition:qT,runFullQueryAgain:HT,unknownAction:QT},JT=40;function om(t){return t.charCodeAt(0)-JT}function XT(t){return t?"1":"0"}function j_(t,e){const n=[];for(let r=0,i=t.length;reM(nM(),LT,t);function iM(t){const e=rM(t);return YT[e]}function sM(t,e,n,r,i){const s=GT[t];return s({queryParams:e,changeEvent:n,previousResults:r,keyDocumentMap:i}),r}var Ar=String.fromCharCode(65535),li=Number.MIN_SAFE_INTEGER;function oM(t,e){var n=e.selector,r=t.indexes?t.indexes.slice(0):[];e.index&&(r=[e.index]);var i=!!e.sort.find(h=>Object.values(h)[0]==="desc"),s=new Set;Object.keys(n).forEach(h=>{var m=zi(t,h);m&&m.type==="boolean"&&Object.prototype.hasOwnProperty.call(n[h],"$eq")&&s.add(h)});var o=e.sort.map(h=>Object.keys(h)[0]),a=o.filter(h=>!s.has(h)).join(","),l=-1,f;if(r.forEach(h=>{var m=!0,y=!0,w=h.map(_=>{var O=n[_],z=O?Object.keys(O):[],W={};if(!O||!z.length){var Q=y?li:Ar;W={startKey:Q,endKey:m?Ar:li,inclusiveStart:!0,inclusiveEnd:!0}}else z.forEach(H=>{if(Tg.has(H)){var X=O[H],U=cM(H,X);W=Object.assign(W,U)}});return typeof W.startKey>"u"&&(W.startKey=li),typeof W.endKey>"u"&&(W.endKey=Ar),typeof W.inclusiveStart>"u"&&(W.inclusiveStart=!0),typeof W.inclusiveEnd>"u"&&(W.inclusiveEnd=!0),y&&!W.inclusiveStart&&(y=!1),m&&!W.inclusiveEnd&&(m=!1),W}),I=w.map(_=>_.startKey),E=w.map(_=>_.endKey),$={index:h,startKeys:I,endKeys:E,inclusiveEnd:m,inclusiveStart:y,sortSatisfiedByIndex:!i&&a===h.filter(_=>!s.has(_)).join(","),selectorSatisfiedByIndex:lM(h,e.selector,I,E)},S=fM(t,e,$);(S>=l||e.index)&&(l=S,f=$)}),!f)throw le("SNH",{query:e});return f}var Tg=new Set(["$eq","$gt","$gte","$lt","$lte"]),aM=new Set(["$eq","$gt","$gte"]),uM=new Set(["$eq","$lt","$lte"]);function lM(t,e,n,r){var i=Object.entries(e),s=i.find(([H,X])=>{if(!t.includes(H))return!0;var U=Object.entries(X).find(([ee,ce])=>!Tg.has(ee));return U});if(s||e.$and||e.$or)return!1;var o=[],a=new Set;for(var[l,f]of Object.entries(e)){if(!t.includes(l))return!1;var h=Object.keys(f).filter(H=>aM.has(H));if(h.length>1)return!1;var m=h[0];if(m&&a.add(l),m!=="$eq"){if(o.length>0)return!1;o.push(m)}}var y=[],w=new Set;for(var[I,E]of Object.entries(e)){if(!t.includes(I))return!1;var $=Object.keys(E).filter(H=>uM.has(H));if($.length>1)return!1;var S=$[0];if(S&&w.add(I),S!=="$eq"){if(y.length>0)return!1;y.push(S)}}var _=0;for(var O of t){for(var z of[a,w]){if(!z.has(O)&&z.size>0)return!1;z.delete(O)}var W=n[_],Q=r[_];if(W!==Q&&a.size>0&&w.size>0)return!1;_++}return!0}function cM(t,e){switch(t){case"$eq":return{startKey:e,endKey:e,inclusiveEnd:!0,inclusiveStart:!0};case"$lte":return{endKey:e,inclusiveEnd:!0};case"$gte":return{startKey:e,inclusiveStart:!0};case"$lt":return{endKey:e,inclusiveEnd:!1};case"$gt":return{startKey:e,inclusiveStart:!1};default:throw new Error("SNH")}}function fM(t,e,n){var r=0,i=h=>{h>0&&(r=r+h)},s=10,o=Xp(n.startKeys,h=>h!==li&&h!==Ar);i(o*s);var a=Xp(n.startKeys,h=>h!==Ar&&h!==li);i(a*s);var l=Xp(n.startKeys,(h,m)=>h===n.endKeys[m]);i(l*s*1.5);var f=n.sortSatisfiedByIndex?5:0;return i(f),r}const dM=2147483647,hM=-2147483648,pM=Number.MAX_SAFE_INTEGER,mM=Number.MIN_SAFE_INTEGER,Vi=Symbol("missing"),$E=Object.freeze(new Error("mingo: cycle detected while processing object/array")),yM=Object.getPrototypeOf([]),jE=Object.getPrototypeOf({}),vM="[object Object]",gM=/^\[object ([a-zA-Z0-9]+)\]$/;let Mg=class{};class Ng{}const Lo=t=>t===null?Mg:t===void 0?Ng:t.constructor,Ql=t=>{const e=OM(t);let n=0,r=e.length;for(;r;)n=(n<<5)-n^e.charCodeAt(--r);return n>>>0},UE=new Set(["null","undefined","boolean","number","string","date","regexp"]),U_=new Set([Ng,Mg,Boolean,String,Number]),Nu=t=>t.toString(),Sr=t=>`${Lo(t).name}[${t.toString()}]`,$o=new Map([[Number,Nu],[Boolean,Nu],[RegExp,Nu],[Function,Nu],[Symbol,Nu],[Date,t=>t.toISOString()],[String,JSON.stringify],[Mg,t=>"null"],[Ng,t=>"undefined"],[Int8Array,Sr],[Uint8Array,Sr],[Uint8ClampedArray,Sr],[Int16Array,Sr],[Uint16Array,Sr],[Int32Array,Sr],[Uint32Array,Sr],[Float32Array,Sr],[Float64Array,Sr]]);typeof BigInt<"u"&&$o.set(BigInt,t=>"0x"+t.toString(16));typeof BigInt64Array<"u"&&$o.set(BigInt64Array,Sr);typeof BigUint64Array<"u"&&$o.set(BigUint64Array,Sr);const wM={null:0,undefined:0,number:1,string:2,object:3,array:4,boolean:5,date:6,regexp:7,function:8},Mn=(t,e)=>{t===Vi&&(t=void 0),e===Vi&&(e=void 0);const[n,r]=[t,e].map(i=>wM[Al(i).toLowerCase()]);return n!==r?n-r:n===1||n===2||n===6?te?1:0:Wi(t,e)?0:te?1:0};function Yt(t,e){if(!t)throw new Error(e)}const _M=t=>{const e=Object.getPrototypeOf(Lo(t));return e&&e.name==="TypedArray"},Ry=t=>{if(U_.has(Lo(t)))return t;const e=new Set,n=r=>{if(e.has(r))throw $E;const i=Lo(r);if(U_.has(i))return r;try{if(Lt(r))return e.add(r),r.map(n);if(wt(r)){e.add(r);const s={};for(const o in r)s[o]=n(r[o]);return s}}finally{e.delete(r)}return i===Date||i===RegExp||_M(r)?new i(r):r};return n(t)},Al=t=>gM.exec(Object.prototype.toString.call(t))[1],um=t=>typeof t=="boolean",Ki=t=>typeof t=="string",Qn=t=>!isNaN(t)&&typeof t=="number",Lt=Array.isArray,wt=t=>{if(!t)return!1;const e=Object.getPrototypeOf(t);return(e===jE||e===null)&&vM===Object.prototype.toString.call(t)},Sh=t=>t===Object(t),Ty=t=>t instanceof Date,Cf=t=>t instanceof RegExp,Ih=t=>typeof t=="function",cn=t=>t==null,qa=(t,e)=>t.includes(e),zE=(t,e)=>!qa(t,e),bM=(t,e=!0)=>!!t||e&&t==="",uu=t=>cn(t)||Ki(t)&&!t||t instanceof Array&&t.length===0||wt(t)&&Object.keys(t).length===0,z_=t=>t===Vi,Yl=t=>t instanceof Array?t:[t],Zn=(t,e)=>!!t&&Object.prototype.hasOwnProperty.call(t,e),SM=(t,e)=>wt(t)&&wt(e)||Lt(t)&&Lt(e);function My(t,e,n){if(n=n||{flatten:!1},z_(t)||cn(t))return e;if(z_(e)||cn(e))return t;if(!SM(t,e)){if(n.skipValidation)return e||t;throw Error("mismatched types. must both be array or object")}if(n.skipValidation=!0,Lt(t)){const r=t,i=e;if(n.flatten){let s=0,o=0;for(;s{const s=KE(r,e);n.has(s)?n.get(s).some(o=>Wi(t[o],r))||n.get(s).push(i):n.set(s,[i])}),n}function Bg(t,e=Ql){if(t.some(a=>a.length==0))return[];if(t.length===1)return Array.from(t);const n=kM(t.map((a,l)=>[l,a.length]),a=>a[1]),r=t[n[0][0]],i=Ny(r,e),s=new Map,o=new Array;return i.forEach((a,l)=>{const f=a.map(w=>r[w]),h=f.map(w=>0),m=f.map(w=>[n[0][0],0]);let y=!1;for(let w=1;w$[_]);y=f.map((_,O)=>S.some((z,W)=>{const Q=h[O];return Wi(_,z)&&(h[O]++,Iw===t.length-1?[f[I],m[I]]:Vi).filter(w=>w!==Vi))}),o.sort((a,l)=>{const[f,[h,m]]=a,[y,[w,I]]=l,E=Mn(h,w);return E!==0?E:Mn(m,I)}).map(a=>a[0])}function VE(t,e=0){const n=new Array;function r(i,s){for(let o=0,a=i.length;o0||s<0)?r(i[o],Math.max(-1,s-1)):n.push(i[o])}return r(t,e),n}const IM=t=>{let[e,n]=[Object.getPrototypeOf(t),Object.getOwnPropertyNames(t)],r=e;for(;!n.length&&e!==jE&&e!==yM;)r=e,n=Object.getOwnPropertyNames(e),e=Object.getPrototypeOf(e);const i={};return n.forEach(s=>i[s]=t[s]),[i,r]};function Wi(t,e){const n=[[t,e]];for(;n.length>0;){if([t,e]=n.pop(),t===e)continue;const r=Lo(t);if(r!==Lo(e)||Ih(t))return!1;if($o.has(r)){const i=$o.get(r);if(i(t)!==i(e))return!1;continue}if(r===Array||r===Object){const i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length||new Set(i.concat(s)).size!=i.length)return!1;for(const o of i)n.push([t[o],e[o]]);continue}return!1}return!n.length}function EM(t,e=Ql){const n=t.map(r=>Vi);return Ny(t,e).forEach((r,i)=>{r.forEach(s=>n[s]=t[s])}),n.filter(r=>r!==Vi)}function OM(t){const e=new Set,n=r=>{const i=Lo(r);if($o.has(i))return $o.get(i)(r);const s=i===Object?"":i.name;if(Ih(r.toJSON))return`${s}(${JSON.stringify(r)})`;if(e.has(r))throw $E;e.add(r);try{if(i===Array)return"["+r.map(n).join(",")+"]";if(i!==Object){const[a,l]=IM(r);if(Lt(r))return`${s}${n([...r,a])}`;r=a}const o=Object.keys(r);return o.sort(),`${s}{`+o.map(a=>`${a}:${n(r[a])}`).join(",")+"}"}finally{e.delete(r)}};return n(t)}function KE(t,e){return e=e||Ql,cn(t)?null:e(t).toString()}function kM(t,e,n=Mn){if(uu(t))return t;const r=new Array,i=new Array;for(let s=0;sn(s[0],o[0])),Gl(i,r.map(s=>s[1]))}function DM(t,e,n=Ql){if(t.length<1)return new Map;const r=new Map,i=new Map;for(let s=0;sWi(h,a)):null;cn(f)?(i.set(a,[o]),r.has(l)?r.get(l).push(a):r.set(l,[a])):i.get(f).push(o)}}return i}const lm=5e4;function Gl(t,...e){return t instanceof Array?e.reduce((n,r)=>{let i=Math.ceil(r.length/lm),s=0;for(;i-- >0;)Array.prototype.push.apply(n,r.slice(s,s+lm)),s+=lm;return n},t):e.filter(Sh).reduce((n,r)=>(Object.assign(n,r),n),t)}function By(t,e){return Sh(t)?t[e]:void 0}function xM(t,e){if(e<1)return t;for(;e--&&t.length===1;)t=t[0];return t}function lu(t,e,n){let r=0;function i(o,a){let l=o;for(let f=0;f0)break;r+=1;const y=a.slice(f);l=l.reduce((w,I)=>{const E=i(I,y);return E!==void 0&&w.push(E),w},[]);break}else l=By(l,h);if(l===void 0)break}return l}const s=UE.has(Al(t).toLowerCase())?t:i(t,e.split("."));return s instanceof Array&&(n!=null&&n.unwrapArray)?xM(s,r):s}function Af(t,e,n){const r=e.split("."),i=r[0],s=r.slice(1).join("."),o=/^\d+$/.exec(i)!==null,a=r.length>1;let l,f;if(t instanceof Array)if(o)l=By(t,Number(i)),a&&(l=Af(l,s,n)),l=[l];else{l=[];for(const h of t)f=Af(h,e,n),n!=null&&n.preserveMissing?(f===void 0&&(f=Vi),l.push(f)):f!==void 0&&l.push(f)}else{if(f=By(t,i),a&&(f=Af(f,s,n)),f===void 0)return;l=n!=null&&n.preserveKeys?Object.assign({},t):{},l[i]=f}return l}function Fy(t){if(t instanceof Array)for(let e=t.length-1;e>=0;e--)t[e]===Vi?t.splice(e,1):Fy(t[e]);else if(wt(t))for(const e in t)Zn(t,e)&&Fy(t[e])}const V_=/^\d+$/;function Pl(t,e,n,r){const i=e.split("."),s=i[0],o=i.slice(1).join(".");if(i.length===1)(wt(t)||Lt(t)&&V_.test(s))&&n(t,s);else{r!=null&&r.buildGraph&&cn(t[s])&&(t[s]={});const a=t[s];if(!a)return;const l=!!(i.length>1&&V_.test(i[1]));a instanceof Array&&(r!=null&&r.descendArray)&&!l?a.forEach(f=>Pl(f,o,n,r)):Pl(a,o,n,r)}}function CM(t,e,n){Pl(t,e,(r,i)=>{r[i]=Ih(n)?n(r[i]):n},{buildGraph:!0})}function K_(t,e,n){Pl(t,e,(r,i)=>{if(r instanceof Array){if(/^\d+$/.test(i))r.splice(parseInt(i),1);else if(n&&n.descendArray)for(const s of r)wt(s)&&delete s[i]}else wt(r)&&delete r[i]},n)}const AM=/^\$[a-zA-Z0-9_]+$/;function Wo(t){return AM.test(t)}function WE(t){if(UE.has(Al(t).toLowerCase()))return Cf(t)?{$regex:t}:{$eq:t};if(Sh(t)){if(!Object.keys(t).some(Wo))return{$eq:t};if(Zn(t,"$regex")){const n=Object.assign({},t);return n.$regex=new RegExp(t.$regex,t.$options),delete n.$options,n}}return t}var vs;(function(t){t.CLONE_ALL="CLONE_ALL",t.CLONE_INPUT="CLONE_INPUT",t.CLONE_OUTPUT="CLONE_OUTPUT",t.CLONE_OFF="CLONE_OFF"})(vs||(vs={}));class Eo{constructor(e,n,r,i=Date.now()){this._opts=e,this._root=n,this._local=r,this.timestamp=i,this.update(n,r)}static init(e,n,r){return e instanceof Eo?new Eo(e._opts,cn(e.root)?n:e.root,Object.assign({},e.local,r)):new Eo(e,n,r)}update(e,n){var r;return this._root=e,this._local=n&&Object.assign({},n,{variables:Object.assign({},(r=this._local)===null||r===void 0?void 0:r.variables,n==null?void 0:n.variables)}),this}getOptions(){return Object.freeze(Object.assign(Object.assign({},this._opts),{context:jo.from(this._opts.context)}))}get root(){return this._root}get local(){return this._local}get idKey(){return this._opts.idKey}get collation(){var e;return(e=this._opts)===null||e===void 0?void 0:e.collation}get processingMode(){var e;return((e=this._opts)===null||e===void 0?void 0:e.processingMode)||vs.CLONE_OFF}get useStrictMode(){var e;return(e=this._opts)===null||e===void 0?void 0:e.useStrictMode}get scriptEnabled(){var e;return(e=this._opts)===null||e===void 0?void 0:e.scriptEnabled}get useGlobalContext(){var e;return(e=this._opts)===null||e===void 0?void 0:e.useGlobalContext}get hashFunction(){var e;return(e=this._opts)===null||e===void 0?void 0:e.hashFunction}get collectionResolver(){var e;return(e=this._opts)===null||e===void 0?void 0:e.collectionResolver}get jsonSchemaValidator(){var e;return(e=this._opts)===null||e===void 0?void 0:e.jsonSchemaValidator}get variables(){var e;return(e=this._opts)===null||e===void 0?void 0:e.variables}get context(){var e;return(e=this._opts)===null||e===void 0?void 0:e.context}}function Fg(t){return t instanceof Eo?t.getOptions():Object.freeze(Object.assign(Object.assign({idKey:"_id",scriptEnabled:!0,useStrictMode:!0,useGlobalContext:!0,processingMode:vs.CLONE_OFF},t),{context:t!=null&&t.context?jo.from(t==null?void 0:t.context):jo.init({})}))}var Ye;(function(t){t.ACCUMULATOR="accumulator",t.EXPRESSION="expression",t.PIPELINE="pipeline",t.PROJECTION="projection",t.QUERY="query",t.WINDOW="window"})(Ye||(Ye={}));class jo{constructor(e){this.operators={[Ye.ACCUMULATOR]:{},[Ye.EXPRESSION]:{},[Ye.PIPELINE]:{},[Ye.PROJECTION]:{},[Ye.QUERY]:{},[Ye.WINDOW]:{}};for(const[n,r]of Object.entries(e))this.addOperators(n,r)}static init(e={}){return new jo(e)}static from(e){return new jo(e.operators)}addOperators(e,n){for(const[r,i]of Object.entries(n))this.getOperator(e,r)||(this.operators[e][r]=i);return this}addAccumulatorOps(e){return this.addOperators(Ye.ACCUMULATOR,e)}addExpressionOps(e){return this.addOperators(Ye.EXPRESSION,e)}addQueryOps(e){return this.addOperators(Ye.QUERY,e)}addPipelineOps(e){return this.addOperators(Ye.PIPELINE,e)}addProjectionOps(e){return this.addOperators(Ye.PROJECTION,e)}addWindowOps(e){return this.addOperators(Ye.WINDOW,e)}getOperator(e,n){return e in this.operators&&this.operators[e][n]||null}}const co=jo.init();function W_(t,e){for(const[n,r]of Object.entries(e)){Yt(Ih(r)&&Wo(n),`'${n}' is not a valid operator`);const i=Oo(t,n,null);Yt(!i||r===i,`${n} already exists for '${t}' operators. Cannot change operator function once registered.`)}switch(t){case Ye.ACCUMULATOR:co.addAccumulatorOps(e);break;case Ye.EXPRESSION:co.addExpressionOps(e);break;case Ye.PIPELINE:co.addPipelineOps(e);break;case Ye.PROJECTION:co.addProjectionOps(e);break;case Ye.QUERY:co.addQueryOps(e);break;case Ye.WINDOW:co.addWindowOps(e);break}}function Oo(t,e,n){const{context:r,useGlobalContext:i}=n||{},s=r?r.getOperator(t,e):null;return!s&&i?co.getOperator(t,e):s}const q_={$$ROOT(t,e,n){return n.root},$$CURRENT(t,e,n){return t},$$REMOVE(t,e,n){},$$NOW(t,e,n){return new Date(n.timestamp)}},Ly={$$KEEP(t,e,n){return t},$$PRUNE(t,e,n){},$$DESCEND(t,e,n){if(!Zn(e,"$cond"))return t;let r;for(const[i,s]of Object.entries(t))if(Sh(s)){if(s instanceof Array){const o=[];for(let a of s)wt(a)&&(a=H_(a,e,n.update(a))),cn(a)||o.push(a);r=o}else r=H_(s,e,n.update(s));cn(r)?delete t[i]:t[i]=r}return t}};function Xr(t,e,n,r){var i;const s=Eo.init(r,t);if(n=n||"",Wo(n)){const o=Oo(Ye.EXPRESSION,n,r);if(o)return o(t,e,s);const a=Oo(Ye.ACCUMULATOR,n,r);if(a)return t instanceof Array||(t=Xr(t,e,null,s),e=null),Yt(t instanceof Array,`'${n}' target must be an array.`),a(t,e,s.update(null,s.local));throw new Error(`operator '${n}' is not registered`)}if(Ki(e)&&e.length>0&&e[0]==="$"){if(Zn(Ly,e))return e;let o=s.root;const a=e.split(".");if(Zn(q_,a[0]))o=q_[a[0]](t,null,s),e=e.slice(a[0].length+1);else if(a[0].slice(0,2)==="$$"){o=Object.assign({},s.variables,{this:t},(i=s.local)===null||i===void 0?void 0:i.variables);const l=a[0].slice(2);Yt(Zn(o,l),`Use of undefined variable: ${l}`),e=e.slice(2)}else e=e.slice(1);return e===""?o:lu(o,e)}if(Lt(e))return e.map(o=>Xr(t,o,null,s));if(wt(e)){const o={};for(const[a,l]of Object.entries(e))if(o[a]=Xr(t,l,a,s),[Ye.EXPRESSION,Ye.ACCUMULATOR].some(f=>!!Oo(f,a,r)))return Yt(Object.keys(e).length===1,"Invalid aggregation expression '"+JSON.stringify(e)+"'"),o[a];return o}return e}function H_(t,e,n){const r=Xr(t,e,null,n);return Zn(Ly,r)?Ly[r](t,e,n):r}function Ha(t){return t instanceof Q_?t:new Q_(t)}function PM(...t){let e=0;return Ha(()=>{for(;e{const i=r.next();if(i.done)throw $y;return i.value}}else if(e instanceof Array){const r=e,i=r.length;let s=0;n=()=>{if(s0?this.push(si.TAKE,e):this}drop(e){return e>0?this.push(si.DROP,e):this}transform(e){const n=this;let r;return Ha(()=>(r||(r=Ha(e(n.value()))),r.next()))}value(){return this.isDone||(this.isDone=this.getNext(!0).done),this.yieldedValues}each(e){for(;;){const n=this.next();if(n.done)break;if(e(n.value)===!1)return!1}return!0}reduce(e,n){let r=this.next();for(n===void 0&&!r.done&&(n=r.value,r=this.next());!r.done;)n=e(n,r.value),r=this.next();return n}size(){return this.reduce((e,n)=>++e,0)}[Symbol.iterator](){return this}}class NM{constructor(e,n){this.pipeline=e,this.options=Fg(n)}stream(e){let n=Ha(e);const r=this.options.processingMode;(r==vs.CLONE_ALL||r==vs.CLONE_INPUT)&&n.map(Ry);const i=new Array;if(!uu(this.pipeline))for(const s of this.pipeline){const o=Object.keys(s),a=o[0],l=Oo(Ye.PIPELINE,a,this.options);Yt(o.length===1&&!!l,`invalid pipeline operator ${a}`),i.push(a),n=l(n,s[a],this.options)}return(r==vs.CLONE_OUTPUT||r==vs.CLONE_ALL&&Bg([["$group","$unwind"],i]).length)&&n.map(Ry),n}run(e){return this.stream(e).value()}}class BM{constructor(e,n,r,i){this.source=e,this.predicate=n,this.projection=r,this.options=i,this.operators=[],this.result=null,this.buffer=[]}fetch(){return this.result?this.result:(wt(this.projection)&&this.operators.push({$project:this.projection}),this.result=Ha(this.source).filter(this.predicate),this.operators.length>0&&(this.result=new NM(this.operators,this.options).stream(this.result)),this.result)}fetchAll(){const e=Ha([...this.buffer]);return this.buffer=[],PM(e,this.fetch())}all(){return this.fetchAll().value()}count(){return this.all().length}skip(e){return this.operators.push({$skip:e}),this}limit(e){return this.operators.push({$limit:e}),this}sort(e){return this.operators.push({$sort:e}),this}collation(e){return this.options=Object.assign(Object.assign({},this.options),{collation:e}),this}next(){if(this.buffer.length>0)return this.buffer.pop();const e=this.fetch().next();if(!e.done)return e.value}hasNext(){if(this.buffer.length>0)return!0;const e=this.fetch().next();return e.done?!1:(this.buffer.push(e.value),!0)}map(e){return this.all().map(e)}forEach(e){this.all().forEach(e)}[Symbol.iterator](){return this.fetchAll()}}class qs{constructor(e,n){this.condition=e,this.options=Fg(n),this.compiled=[],this.compile()}compile(){Yt(wt(this.condition),`query criteria must be an object: ${JSON.stringify(this.condition)}`);const e={};for(const[n,r]of Object.entries(this.condition)){if(n==="$where")Object.assign(e,{field:n,expr:r});else if(qa(["$and","$or","$nor","$expr","$jsonSchema"],n))this.processOperator(n,n,r);else{Yt(!Wo(n),`unknown top level operator: ${n}`);for(const[i,s]of Object.entries(WE(r)))this.processOperator(n,i,s)}e.field&&this.processOperator(e.field,e.field,e.expr)}}processOperator(e,n,r){const i=Oo(Ye.QUERY,n,this.options);if(!i)throw new Error(`unknown operator ${n}`);const s=i(e,r,this.options);this.compiled.push(s)}test(e){for(let n=0,r=this.compiled.length;nthis.test(r),n||{},this.options)}remove(e){return e.reduce((n,r)=>(this.test(r)||n.push(r),n),[])}}const FM=(t,e,n)=>{if(uu(e)||!wt(e))return t;let r=Mn;const i=n.collation;return wt(i)&&Ki(i.locale)&&(r=$M(i)),t.transform(s=>{const o=Object.keys(e);for(const a of o.reverse()){const l=DM(s,h=>lu(h,a),n.hashFunction),f=Array.from(l.keys()).sort(r);e[a]===-1&&f.reverse(),s=[],f.reduce((h,m)=>Gl(h,l.get(m)),s)}return s})},LM={1:"base",2:"accent",3:"variant"};function $M(t){const e={sensitivity:LM[t.strength||3],caseFirst:t.caseFirst==="off"?"false":t.caseFirst||"false",numeric:t.numericOrdering||!1,ignorePunctuation:t.alternate==="shifted"};(t.caseLevel||!1)===!0&&(e.sensitivity==="base"&&(e.sensitivity="case"),e.sensitivity==="accent"&&(e.sensitivity="variant"));const n=new Intl.Collator(t.locale,e);return(r,i)=>{if(!Ki(r)||!Ki(i))return Mn(r,i);const s=n.compare(r,i);return s<0?-1:s>0?1:0}}function wn(t){const e=(n,r,i)=>{const s={unwrapArray:!0},o=Math.max(1,n.split(".").length-1);return a=>{const l=lu(a,n,s);return t(l,r,Object.assign(Object.assign({},i),{depth:o}))}};return e.op="query",e}function qE(t,e,n){if(Wi(t,e)||cn(t)&&cn(e))return!0;if(t instanceof Array){const r=Wi.bind(null,e);return t.some(r)||VE(t,n==null?void 0:n.depth).some(r)}return!1}function jM(t,e,n){return!qE(t,e,n)}function HE(t,e,n){return cn(t)?e.some(r=>r===null):Bg([Yl(t),e],n==null?void 0:n.hashFunction).length>0}function UM(t,e,n){return!HE(t,e,n)}function zM(t,e,n){return Eh(t,e,(r,i)=>Mn(r,i)<0)}function VM(t,e,n){return Eh(t,e,(r,i)=>Mn(r,i)<=0)}function KM(t,e,n){return Eh(t,e,(r,i)=>Mn(r,i)>0)}function WM(t,e,n){return Eh(t,e,(r,i)=>Mn(r,i)>=0)}function qM(t,e,n){return Yl(t).some(r=>e.length===2&&r%e[0]===e[1])}function HM(t,e,n){const r=Yl(t),i=s=>Ki(s)&&bM(e.exec(s),n==null?void 0:n.useStrictMode);return r.some(i)||VE(r,1).some(i)}function QM(t,e,n){return(e===!1||e===0)&&t===void 0||(e===!0||e===1)&&t!==void 0}function YM(t,e,n){if(!Lt(t)||!Lt(e)||!t.length||!e.length)return!1;let r=!0;for(const i of e){if(!r)break;wt(i)&&qa(Object.keys(i),"$elemMatch")?r=QE(t,i.$elemMatch,n):i instanceof RegExp?r=t.some(s=>typeof s=="string"&&i.test(s)):r=t.some(s=>Wi(i,s))}return r}function GM(t,e,n){return Array.isArray(t)&&t.length===e}function JM(t){return Wo(t)&&["$and","$or","$nor"].indexOf(t)===-1}function QE(t,e,n){if(Lt(t)&&!uu(t)){let r=o=>o,i=e;Object.keys(e).every(JM)&&(i={temp:e},r=o=>({temp:o}));const s=new qs(i,n);for(let o=0,a=t.length;ot===null,G_=t=>Qn(t)&&t>=hM&&t<=dM&&t.toString().indexOf(".")===-1,J_=t=>Qn(t)&&t>=mM&&t<=pM&&t.toString().indexOf(".")===-1,XM={array:Lt,bool:um,boolean:um,date:Ty,decimal:Qn,double:Qn,int:G_,long:J_,number:Qn,null:Y_,object:wt,regex:Cf,regexp:Cf,string:Ki,undefined:cn,function:t=>{throw new Error("unsupported type key `function`.")},1:Qn,2:Ki,3:wt,4:Lt,6:cn,8:um,9:Ty,10:Y_,11:Cf,16:G_,18:J_,19:Qn};function X_(t,e,n){const r=XM[e];return r?r(t):!1}function ZM(t,e,n){return Array.isArray(e)?e.findIndex(r=>X_(t,r))>=0:X_(t,e)}function Eh(t,e,n){return Yl(t).some(r=>Al(r)===Al(e)&&n(r,e))}const Z_=(t,e)=>{const n={};return t.split("").forEach((r,i)=>n[r]=e*(i+1)),n};Object.assign(Object.assign(Object.assign({},Z_("ABCDEFGHIKLM",1)),Z_("NOPQRSTUVWXY",-1)),{Z:0});const eb={undefined:null,null:null,NaN:NaN,Infinity:new Error,"-Infinity":new Error};function or(t,e=eb){const n=Object.assign({},eb,e),r=new Set(Object.keys(n));return(i,s,o)=>{const a=Xr(i,s,null,o);if(r.has(`${a}`)){const l=n[`${a}`];if(l instanceof Error)throw new Error(`cannot apply $${t.name} to -inf, value must in (-inf,inf)`);return l}return t(a)}}or(Math.acos,{Infinity:1/0,0:new Error});or(Math.acosh,{Infinity:1/0,0:new Error});or(Math.asin);or(Math.asinh,{Infinity:1/0,"-Infinity":-1/0});or(Math.atan);or(Math.atanh,{1:1/0,"-1":-1/0});or(Math.cos);or(Math.cosh,{"-Infinity":1/0,Infinity:1/0});const e2=Math.PI/180;or(t=>t*e2,{Infinity:1/0,"-Infinity":1/0});const t2=180/Math.PI;or(t=>t*t2,{Infinity:1/0,"-Infinity":-1/0});or(Math.sin);or(Math.sinh,{"-Infinity":-1/0,Infinity:1/0});or(Math.tan);const n2=(t,e,n)=>{if(uu(e))return t;let r=Object.keys(e),i=!1;YE(e,n);const s=n.idKey;if(qa(r,s)){const a=e[s];(a===0||a===!1)&&(r=r.filter(zE.bind(null,[s])),i=r.length==0)}else r.push(s);const o=Eo.init(n);return t.map(a=>jy(a,e,o.update(a),r,i))};function jy(t,e,n,r,i){let s={},o=!1,a=!1;const l=[];i&&l.push(n.idKey);for(const f of r){let h;const m=e[f];if(f!==n.idKey&&qa([0,!1],m)&&(a=!0),f===n.idKey&&uu(m))h=t[f];else if(Ki(m))h=Xr(t,m,f,n);else if(!qa([1,!0],m))if(m instanceof Array)h=m.map(w=>{const I=Xr(t,w,null,n);return cn(I)?null:I});else if(wt(m)){const w=m,I=Object.keys(m),E=I.length==1?I[0]:"",$=Oo(Ye.PROJECTION,E,n);if($)E==="$slice"?Yl(w[E]).every(Qn)?(h=$(t,w[E],f,n),o=!0):h=Xr(t,w,f,n):h=$(t,w[E],f,n);else if(Wo(E))h=Xr(t,w[E],E,n);else if(Zn(t,f)){YE(w,n);let S=t[f];S instanceof Array?h=S.map(_=>jy(_,w,n,I,!1)):(S=wt(S)?S:t,h=jy(S,w,n,I,!1))}else h=Xr(t,m,null,n)}else{l.push(f);continue}const y=Af(t,f,{preserveMissing:!0});y!==void 0&&My(s,y,{flatten:!0}),zE([0,1,!1,!0],m)&&(h===void 0?K_(s,f,{descendArray:!0}):CM(s,f,h))}if(Fy(s),(o||a||i)&&(s=Gl({},t,s),l.length>0))for(const f of l)K_(s,f,{descendArray:!0});return s}function YE(t,e){const n=[!1,!1];for(const[r,i]of Object.entries(t)){if(r===(e==null?void 0:e.idKey))return;i===0||i===!1?n[0]=!0:(i===1||i===!0)&&(n[1]=!0),Yt(!(n[0]&&n[1]),"Projection cannot have a mix of inclusion and exclusion.")}}const r2=(t,e,n)=>{Yt(Lt(e),"Invalid expression: $and expects value to be an Array.");const r=e.map(i=>new qs(i,n));return i=>r.every(s=>s.test(i))},GE=(t,e,n)=>{Yt(Lt(e),"Invalid expression. $or expects value to be an Array");const r=e.map(i=>new qs(i,n));return i=>r.some(s=>s.test(i))},i2=(t,e,n)=>{Yt(Lt(e),"Invalid expression. $nor expects value to be an array.");const r=GE("$or",e,n);return i=>!r(i)},s2=(t,e,n)=>{const r={};r[t]=WE(e);const i=new qs(r,n);return s=>!i.test(s)},o2=wn(qE),a2=wn(KM),u2=wn(WM),l2=wn(HE),c2=wn(zM),f2=wn(VM),d2=wn(jM),h2=wn(UM),p2=wn(qM),m2=wn(HM);wn(YM);const y2=wn(QE),v2=wn(GM),g2=wn(QM),w2=wn(ZM);var tb=!1;function _2(t){return tb||(W_(Ye.PIPELINE,{$sort:FM,$project:n2}),W_(Ye.QUERY,{$and:r2,$eq:o2,$elemMatch:y2,$exists:g2,$gt:a2,$gte:u2,$in:l2,$lt:c2,$lte:f2,$ne:d2,$nin:h2,$mod:p2,$nor:i2,$not:s2,$or:GE,$regex:m2,$size:v2,$type:w2}),tb=!0),new qs(t)}function Rl(t,e){var n=Fn(t.primaryKey);e=$e(e);var r=Pn(e);if(typeof r.skip!="number"&&(r.skip=0),r.selector?(r.selector=r.selector,Object.entries(r.selector).forEach(([f,h])=>{(typeof h!="object"||h===null)&&(r.selector[f]={$eq:h})})):r.selector={},r.index){var i=Ua(r.index);i.includes(n)||i.push(n),r.index=i}if(r.sort){var l=r.sort.find(f=>PP(f)===n);l||(r.sort=r.sort.slice(0),r.sort.push({[n]:"asc"}))}else if(r.index)r.sort=r.index.map(f=>({[f]:"asc"}));else{if(t.indexes){var s=new Set;Object.entries(r.selector).forEach(([f,h])=>{var m=!1;typeof h=="object"&&h!==null?m=!!Object.keys(h).find(y=>Tg.has(y)):m=!0,m&&s.add(f)});var o=-1,a;t.indexes.forEach(f=>{var h=pg(f)?f:[f],m=h.findIndex(y=>!s.has(y));m>0&&m>o&&(o=m,a=h)}),a&&(r.sort=a.map(f=>({[f]:"asc"})))}r.sort||(r.sort=[{[n]:"asc"}])}return r}function Lg(t,e){if(!e.sort)throw le("SNH",{query:e});var n=[];e.sort.forEach(i=>{var s=Object.keys(i)[0],o=Object.values(i)[0];n.push({key:s,direction:o,getValueFn:XI(s)})});var r=(i,s)=>{for(var o=0;on.test(i);return r}function b2(t,e){return!e.sort||e.sort.length===0?[t]:e.sort.map(n=>Object.keys(n)[0])}var S2=new WeakMap;function I2(t){return Mr(S2,t,()=>{var e=t.collection,n=Rl(e.storageInstance.schema,Pn(t.mangoQuery)),r=e.schema.primaryPath,i=Lg(e.schema.jsonSchema,n),s=(f,h)=>{var m={docA:f,docB:h,rxQuery:t};return i(m.docA,m.docB)},o=Oh(e.schema.jsonSchema,n),a=f=>{var h={doc:f,rxQuery:t};return o(h.doc)},l={primaryKey:t.collection.schema.primaryPath,skip:n.skip,limit:n.limit,sortFields:b2(r,n),sortComparator:s,queryMatcher:a};return l})}function E2(t,e){if(!t.collection.database.eventReduce)return{runFullQueryAgain:!0};var n=I2(t),r=ye(t._result).docsData.slice(0),i=ye(t._result).docsDataMap,s=!1,o=e.map(l=>lT(l)).filter(JI),a=o.find(l=>{var f={queryParams:n,changeEvent:l,previousResults:r,keyDocumentMap:i},h=iM(f);if(h==="runFullQueryAgain")return!0;if(h!=="doNothing")return s=!0,sM(h,n,l,r,i),!1});return a?{runFullQueryAgain:!0}:{runFullQueryAgain:!1,changed:s,newResults:r}}var O2=function(){function t(){this._map=new Map}var e=t.prototype;return e.getByQuery=function(r){var i=r.toString();return Mr(this._map,i,()=>r)},t}();function k2(){return new O2}function nb(t,e){e.uncached=!0;var n=e.toString();t._map.delete(n)}function D2(t){return t.refCount$.observers.length}var x2=100,C2=30*1e3,A2=(t,e)=>(n,r)=>{if(!(r._map.size0)){if(a._lastEnsureEqual===0&&a._creationTimem._lastEnsureEqual-y._lastEnsureEqual),h=f.slice(0,l);h.forEach(m=>nb(r,m))}}},JE=A2(x2,C2),cm=new WeakSet;function P2(t){cm.has(t)||(cm.add(t),qP().then(()=>QP(200)).then(()=>{t.destroyed||t.cacheReplacementPolicy(t,t._queryCache),cm.delete(t)}))}var XE=function(){function t(n,r,i){this.cacheItemByDocId=new Map,this.registry=typeof FinalizationRegistry=="function"?new FinalizationRegistry(s=>{var o=s.docId,a=this.cacheItemByDocId.get(o);a&&(a.byRev.delete(s.revisionHeight),a.byRev.size===0&&this.cacheItemByDocId.delete(o))}):void 0,this.registerIdleTasks=[],this.primaryPath=n,this.changes$=r,this.documentCreator=i,r.subscribe(s=>{var o=s.documentId,a=this.cacheItemByDocId.get(o);if(a){var l=Dg(s);a.last=l}})}var e=t.prototype;return e.getLatestDocumentData=function(r){var i=Mo(this.cacheItemByDocId,r);return i.last},e.getLatestDocumentDataIfExists=function(r){var i=this.cacheItemByDocId.get(r);if(i)return i.last},Vs(t,[{key:"getCachedRxDocument",get:function(){var n=R2(this);return xs(this,"getCachedRxDocument",n)}}]),t}();function R2(t){var e=t.primaryPath,n=t.cacheItemByDocId,r=t.registry,i=it.deepFreezeWhenDevMode,s=t.documentCreator,o=a=>{var l=a[e],f=x_(a._rev),h=Mr(n,l,()=>T2(a)),m=h.byRev,y=m.get(f),w=y?y.deref():void 0;return w||(a=i(a),w=s(a),m.set(f,N2(w)),r&&(t.registerIdleTasks.push(w),t.registerIdlePromise||(t.registerIdlePromise=vg().then(()=>{t.registerIdlePromise=void 0;var I=t.registerIdleTasks;I.length!==0&&(t.registerIdleTasks=[],I.forEach(E=>{r.register(E,{docId:E.primary,revisionHeight:x_(E.revision)})}))})))),w};return o}function ZE(t,e){for(var n=t.getCachedRxDocument,r=[],i=0;ie._data))}},{key:"docsDataMap",get:function(){var e=new Map;return this.documents.forEach(n=>{e.set(n.primary,n._data)}),xs(this,"docsDataMap",e)}},{key:"docsMap",get:function(){for(var e=new Map,n=this.documents,r=0;r{var m=this.collection._docCache.getLatestDocumentDataIfExists(h);if(m){if(!m._deleted){var y=this.collection._docCache.getCachedRxDocument(m);o.set(h,y)}}else a.push(h)}),a.length>0){var l=await this.collection.storageInstance.findDocumentsById(a,!1);l.forEach(h=>{var m=this.collection._docCache.getCachedRxDocument(h);o.set(m.primary,m)})}return o}var f=nO(this);return f.then(h=>(this._lastExecEnd=Ft(),h))},e.exec=function(r){if(r&&this.op!=="findOne")throw le("QU9",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return ib(this).then(()=>As(this.$)).then(i=>{if(!i&&r)throw le("QU10",{collection:this.collection.name,query:this.mangoQuery,op:this.op});return i})},e.toString=function(){var r=fd({op:this.op,query:this.mangoQuery,other:this.other},!0),i=JSON.stringify(r);return this.toString=()=>i,i},e.getPreparedQuery=function(){var r={rxQuery:this,mangoQuery:Rl(this.collection.schema.jsonSchema,this.mangoQuery)};r.mangoQuery.selector._deleted={$eq:!1},r.mangoQuery.index&&r.mangoQuery.index.unshift("_deleted"),Nr("prePrepareQuery",r);var i=Jl(this.collection.schema.jsonSchema,r.mangoQuery);return this.getPreparedQuery=()=>i,i},e.doesDocumentDataMatch=function(r){return r._deleted?!1:this.queryMatcher(r)},e.remove=function(){return this.exec().then(r=>Array.isArray(r)?Promise.all(r.map(i=>i.remove())):r.remove())},e.update=function(r){throw pt("update")},e.where=function(r){throw pt("query-builder")},e.sort=function(r){throw pt("query-builder")},e.skip=function(r){throw pt("query-builder")},e.limit=function(r){throw pt("query-builder")},Vs(t,[{key:"$",get:function(){if(!this._$){var n=this.collection.$.pipe(lt(r=>!r.isLocal),Hl(null),Br(()=>ib(this)),Mt(()=>this._result),Pi(Ai),Fo((r,i)=>!!(r&&r.time===ye(i).time)),lt(r=>!!r),Mt(r=>{var i=ye(r);return this.op==="count"?i.count:this.op==="findOne"?i.documents.length===0?null:i.documents[0]:this.op==="findByIds"?i.docsMap:i.documents.slice(0)}));this._$=gT(n,this.refCount$.pipe(lt(()=>!1)))}return this._$}},{key:"$$",get:function(){var n=this.collection.database.getReactivityFactory();return n.fromObservable(this.$,void 0)}},{key:"queryMatcher",get:function(){var n=this.collection.schema.jsonSchema,r=Rl(this.collection.schema.jsonSchema,this.mangoQuery);return xs(this,"queryMatcher",Oh(n,r))}},{key:"asRxQuery",get:function(){return this}}]),t}();function tl(){return{selector:{}}}function j2(t){return t.collection._queryCache.getByQuery(t)}function ra(t,e,n,r){Nr("preCreateRxQuery",{op:t,queryObj:e,collection:n,other:r});var i=new eO(t,e,n,r);return i=j2(i),P2(n),i}function tO(t){var e=t.asRxQuery.collection._changeEventBuffer.counter;return t._latestChangeEvent>=e}function ib(t){return t.collection.database.destroyed||tO(t)?Jn:(t._ensureEqualQueue=t._ensureEqualQueue.then(()=>U2(t)),t._ensureEqualQueue)}function U2(t){if(t._lastEnsureEqual=Ft(),t.collection.database.destroyed||tO(t))return Jn;var e=!1,n=!1;if(t._latestChangeEvent===-1&&(n=!0),!n){var r=t.asRxQuery.collection._changeEventBuffer.getFrom(t._latestChangeEvent+1);if(r===null)n=!0;else{t._latestChangeEvent=t.asRxQuery.collection._changeEventBuffer.counter;var i=t.asRxQuery.collection._changeEventBuffer.reduceByLastOfDoc(r);if(t.op==="count"){var s=ye(t._result).count,o=s;i.forEach(l=>{var f=l.previousDocumentData&&t.doesDocumentDataMatch(l.previousDocumentData),h=t.doesDocumentDataMatch(l.documentData);!f&&h&&o++,f&&!h&&o--}),o!==s&&(e=!0,t._setResultData(o))}else{var a=E2(t,i);a.runFullQueryAgain?n=!0:a.changed&&(e=!0,t._setResultData(a.newResults))}}}return n?t._execOverDatabase().then(l=>(t._latestChangeEvent=t.collection._changeEventBuffer.counter,typeof l=="number"?((!t._result||l!==t._result.count)&&(e=!0,t._setResultData(l)),e):((!t._result||!TP(t.collection.schema.primaryPath,l,t._result.docsData))&&(e=!0,t._setResultData(l)),e))):Promise.resolve(e)}function Jl(t,e){if(!e.sort)throw le("SNH",{query:e});var n=oM(t,e);return{query:e,queryPlan:n}}async function nO(t){var e=[],n=t.collection;if(t.isFindOneByIdQuery)if(Array.isArray(t.isFindOneByIdQuery)){var r=t.isFindOneByIdQuery;if(r=r.filter(h=>{var m=t.collection._docCache.getLatestDocumentDataIfExists(h);return m?(m._deleted||e.push(m),!1):!0}),r.length>0){var i=await n.storageInstance.findDocumentsById(r,!1);za(e,i)}}else{var s=t.isFindOneByIdQuery,o=t.collection._docCache.getLatestDocumentDataIfExists(s);if(!o){var a=await n.storageInstance.findDocumentsById([s],!1);a[0]&&(o=a[0])}o&&!o._deleted&&e.push(o)}else{var l=t.getPreparedQuery(),f=await n.storageInstance.query(l);e=f.documents}return e}function z2(t,e){if(!e.skip&&e.selector&&Object.keys(e.selector).length===1&&e.selector[t]){var n=e.selector[t];if(typeof n=="string")return n;if(Object.keys(n).length===1&&typeof n.$eq=="string"||Object.keys(n).length===1&&Array.isArray(n.$eq)&&!n.$eq.find(r=>typeof r!="string"))return n.$eq}return!1}var V2="_rxdb_internal";async function Xl(t,e){var n=await t.findDocumentsById([e],!1),r=n[0];if(r)return r}async function Tl(t,e,n){var r=await t.bulkWrite([e],n);if(r.error.length>0){var i=r.error[0];throw i}else{var s=r.success[0];return s}}function K2(t,e){var n=Xl(t,e),r=t.changeStream().pipe(Mt(i=>i.events.find(s=>s.documentId===e)),lt(i=>!!i),Mt(i=>Promise.resolve(ye(i).documentData)),Hl(n),Cl(i=>i),lt(i=>!!i));return r}function Ml(t){return Object.assign({},...t)}function rO(t,e,n){var r=e.documentData,i=e.previousDocumentData,s={documentId:e.documentId,collectionName:n?n.name:void 0,isLocal:t,operation:e.operation,documentData:it.deepFreezeWhenDevMode(r),previousDocumentData:it.deepFreezeWhenDevMode(i)};return s}function yd(t,e,n,r){if(r)throw r.status===409?le("CONFLICT",{collection:t.name,id:e,writeError:r,data:n}):r.status===422?le("VD2",{collection:t.name,id:e,writeError:r,data:n}):r}function iO(t,e,n,r,i,s,o){for(var a=!!t.schema.attachments,l=[],f=[],h=[],m=su(10),y={id:m,events:[],checkpoint:null,context:i,startTime:Ft(),endTime:0},w=y.events,I=[],E=[],$=[],S=n.size>0,_,O=r.length,z=function(){var Q=r[W],H=Q.document,X=Q.previous,U=H[e],ee=H._deleted,ce=X&&X._deleted,de=void 0;S&&(de=n.get(U));var Pe;if(de){var Te=de._rev;if(!X||X&&Te!==X._rev){var Dt={isError:!0,status:409,documentId:U,writeRow:Q,documentInDb:de};return h.push(Dt),1}var G=a?fm(Q):Q;a&&(ee?X&&Object.keys(X._attachments).forEach(ft=>{E.push({documentId:U,attachmentId:ft,digest:ye(X)._attachments[ft].digest})}):(Object.entries(H._attachments).find(([ft,Ct])=>{var Un=X?X._attachments[ft]:void 0;return!Un&&!Ct.data&&(Pe={documentId:U,documentInDb:de,isError:!0,status:510,writeRow:Q,attachmentId:ft}),!0}),Pe||Object.entries(H._attachments).forEach(([ft,Ct])=>{var Un=X?X._attachments[ft]:void 0;if(!Un)I.push({documentId:U,attachmentId:ft,attachmentData:Ct,digest:Ct.digest});else{var tn=G.document._attachments[ft].digest;Ct.data&&Un.digest!==tn&&$.push({documentId:U,attachmentId:ft,attachmentData:Ct,digest:Ct.digest})}}))),Pe?h.push(Pe):(a?(f.push(fm(G)),o&&o(H)):(f.push(G),o&&o(H)),_=G);var oe=null,ue=null,Re=null;if(ce&&!ee)Re="INSERT",oe=a?gs(H):H;else if(X&&!ce&&!ee)Re="UPDATE",oe=a?gs(H):H,ue=X;else if(ee)Re="DELETE",oe=ye(H),ue=X;else throw le("SNH",{args:{writeRow:Q}});var xt={documentId:U,documentData:oe,previousDocumentData:ue,operation:Re};w.push(xt)}else{var ot=!!ee;if(a&&Object.entries(H._attachments).forEach(([ft,Ct])=>{Ct.data?I.push({documentId:U,attachmentId:ft,attachmentData:Ct,digest:Ct.digest}):(Pe={documentId:U,isError:!0,status:510,writeRow:Q,attachmentId:ft},h.push(Pe))}),Pe||(a?(l.push(fm(Q)),s&&s(H)):(l.push(Q),s&&s(H)),_=Q),!ot){var ct={documentId:U,operation:"INSERT",documentData:a?gs(H):H,previousDocumentData:a&&X?gs(X):X};w.push(ct)}}},W=0;W{e._attachments[n]=q2(r)}),e}function $g(t){var e=$e(t);return e._meta=$e(t._meta),e}function jg(t,e,n){it.deepFreezeWhenDevMode(n);var r=Fn(n.primaryKey);function i(o){var a=$e(o.document);if(a._meta=$e(a._meta),it.isDevMode()){a=oE(r,n,a);try{typeof structuredClone=="function"?structuredClone(o):JSON.parse(JSON.stringify(o))}catch{throw le("DOC24",{collection:e.collectionName,document:o.document})}o.previous,o.previous&&Object.keys(o.previous._meta).forEach(l=>{if(!Object.prototype.hasOwnProperty.call(o.document._meta,l))throw le("SNH",{dataBefore:o.previous,dataAfter:o.document})})}return a._meta.lwt=Ft(),a._rev=Ui(t.token,o.previous),{document:a,previous:o.previous}}var s={originalStorageInstance:e,schema:e.schema,internals:e.internals,collectionName:e.collectionName,databaseName:e.databaseName,options:e.options,bulkWrite(o,a){var l=o.map(f=>i(f));return t.lockedRun(()=>e.bulkWrite(l,a)).then(f=>{var h={error:[],success:f.success.slice(0)},m=f.error.filter(w=>w.status===409&&!w.writeRow.previous&&!w.writeRow.document._deleted&&ye(w.documentInDb)._deleted?!0:(h.error.push(w),!1));if(m.length>0){var y=m.map(w=>({previous:w.documentInDb,document:Object.assign({},w.writeRow.document,{_rev:Ui(t.token,w.documentInDb)})}));return t.lockedRun(()=>e.bulkWrite(y,a)).then(w=>(za(h.error,w.error),za(h.success,w.success),h))}return f})},query(o){return t.lockedRun(()=>e.query(o))},count(o){return t.lockedRun(()=>e.count(o))},findDocumentsById(o,a){return t.lockedRun(()=>e.findDocumentsById(o,a))},getAttachmentData(o,a,l){return t.lockedRun(()=>e.getAttachmentData(o,a,l))},getChangedDocumentsSince:e.getChangedDocumentsSince?(o,a)=>t.lockedRun(()=>e.getChangedDocumentsSince(ye(o),a)):void 0,cleanup(o){return t.lockedRun(()=>e.cleanup(o))},remove(){return t.storageInstances.delete(s),t.lockedRun(()=>e.remove())},close(){return t.storageInstances.delete(s),t.lockedRun(()=>e.close())},changeStream(){return e.changeStream()},conflictResultionTasks(){return e.conflictResultionTasks()},resolveConflictResultionTask(o){if(o.output.isEqual)return e.resolveConflictResultionTask(o);var a=Object.assign({},o.output.documentData,{_meta:Ks(),_rev:Rn(),_attachments:{}}),l=$e(a);return delete l._meta,delete l._rev,delete l._attachments,e.resolveConflictResultionTask({id:o.id,output:{isEqual:!1,documentData:l}})}};return t.storageInstances.add(s),s}function sO(t){if(t.schema.keyCompression)throw le("UT5",{args:{params:t}});if(vd(t.schema))throw le("UT6",{args:{params:t}});if(t.schema.attachments&&t.schema.attachments.compression)throw le("UT7",{args:{params:t}})}function vd(t){return!!(t.encrypted&&t.encrypted.length>0||t.attachments&&t.attachments.encrypted)}function H2(t,e,n){var r=Fn(t.schema.primaryKey),i=n?n.lwt:mg,s=n?n.id:"";return Rl(t.schema,{selector:{$or:[{"_meta.lwt":{$gt:i}},{"_meta.lwt":{$eq:i},[r]:{$gt:n?s:""}}],"_meta.lwt":{$gte:i}},sort:[{"_meta.lwt":"asc"},{[r]:"asc"}],skip:0,limit:e})}async function oO(t,e,n){if(t.getChangedDocumentsSince)return t.getChangedDocumentsSince(e,n);var r=Fn(t.schema.primaryKey),i=Jl(t.schema,H2(t,e,n)),s=await t.query(i),o=s.documents,a=xP(o);return{documents:o,checkpoint:a?{id:a[r],lwt:a._meta.lwt}:n||{id:"",lwt:0}}}var aO=function(){function t(n,r,i,s){this.queueByDocId=new Map,this.isRunning=!1,this.storageInstance=n,this.primaryPath=r,this.preWrite=i,this.postWrite=s}var e=t.prototype;return e.addWrite=function(r,i){var s=r[this.primaryPath],o=Mr(this.queueByDocId,s,()=>[]),a=new Promise((l,f)=>{var h={lastKnownDocumentState:r,modifier:i,resolve:l,reject:f};ye(o).push(h),this.triggerRun()});return a},e.triggerRun=async function(){if(!(this.isRunning===!0||this.queueByDocId.size===0)){this.isRunning=!0;var r=[],i=this.queueByDocId;this.queueByDocId=new Map,await Promise.all(Array.from(i.entries()).map(async([o,a])=>{var l=Q2(a.map(m=>m.lastKnownDocumentState)),f=l;for(var h of a)try{f=await h.modifier(Pn(f))}catch(m){h.reject(m),h.reject=()=>{},h.resolve=()=>{}}try{await this.preWrite(f,l)}catch(m){a.forEach(y=>y.reject(m));return}r.push({previous:l,document:f})}));var s=r.length>0?await this.storageInstance.bulkWrite(r,"incremental-write"):{error:[],success:[]};return await Promise.all(s.success.map(o=>{var a=o[this.primaryPath];this.postWrite(o);var l=Mo(i,a);l.forEach(f=>f.resolve(o))})),s.error.forEach(o=>{var a=o.documentId,l=Mo(i,a),f=_h(o);if(f){var h=Mr(this.queueByDocId,a,()=>[]);l.reverse().forEach(y=>{y.lastKnownDocumentState=ye(f.documentInDb),ye(h).unshift(y)})}else{var m=sR(o);l.forEach(y=>y.reject(m))}}),this.isRunning=!1,this.triggerRun()}},t}();function sb(t){var e=async n=>{var r=RP(n);r._deleted=n._deleted;var i=await t(r),s=Object.assign({},i,{_meta:n._meta,_attachments:n._attachments,_rev:n._rev,_deleted:typeof i._deleted<"u"?i._deleted:n._deleted});return typeof s._deleted>"u"&&(s._deleted=!1),s};return e}function Q2(t){var e=t[0],n=Va(e._rev).height;return t.forEach(r=>{var i=Va(r._rev).height;i>n&&(e=r,n=i)}),e}var kh={get primaryPath(){var t=this;if(t.isInstanceOfRxDocument)return t.collection.schema.primaryPath},get primary(){var t=this;if(t.isInstanceOfRxDocument)return t._data[t.primaryPath]},get revision(){var t=this;if(t.isInstanceOfRxDocument)return t._data._rev},get deleted$(){var t=this;if(t.isInstanceOfRxDocument)return t.$.pipe(Mt(e=>e._data._deleted))},get deleted$$(){var t=this,e=t.collection.database.getReactivityFactory();return e.fromObservable(t.deleted$,t.getLatest().deleted)},get deleted(){var t=this;if(t.isInstanceOfRxDocument)return t._data._deleted},getLatest(){var t=this.collection._docCache.getLatestDocumentData(this.primary);return this.collection._docCache.getCachedRxDocument(t)},get $(){var t=this;return t.collection.$.pipe(lt(e=>!e.isLocal),lt(e=>e.documentId===this.primary),Mt(e=>Dg(e)),Hl(t.collection._docCache.getLatestDocumentData(this.primary)),Fo((e,n)=>e._rev===n._rev),Mt(e=>this.collection._docCache.getCachedRxDocument(e)),Pi(Ai))},get $$(){var t=this,e=t.collection.database.getReactivityFactory();return e.fromObservable(t.$,t.getLatest()._data)},get$(t){if(it.isDevMode()){if(t.includes(".item."))throw le("DOC1",{path:t});if(t===this.primaryPath)throw le("DOC2");if(this.collection.schema.finalFields.includes(t))throw le("DOC3",{path:t});var e=zi(this.collection.schema.jsonSchema,t);if(!e)throw le("DOC4",{path:t})}return this.$.pipe(Mt(n=>Ts(n,t)),Fo())},get$$(t){var e=this.get$(t),n=this.collection.database.getReactivityFactory();return n.fromObservable(e,this.getLatest().get(t))},populate(t){var e=zi(this.collection.schema.jsonSchema,t),n=this.get(t);if(!n)return yg;if(!e)throw le("DOC5",{path:t});if(!e.ref)throw le("DOC6",{path:t,schemaObj:e});var r=this.collection.database.collections[e.ref];if(!r)throw le("DOC7",{ref:e.ref,path:t,schemaObj:e});return e.type==="array"?r.findByIds(n).exec().then(i=>{var s=i.values();return Array.from(s)}):r.findOne(n).exec()},get(t){return Mr(this._propertyCache,t,()=>{var e=Ts(this._data,t);if(typeof e!="object"||e===null||Array.isArray(e))return it.deepFreezeWhenDevMode(e);var n=this,r=new Proxy($e(e),{get(i,s){if(typeof s!="string")return i[s];var o=s.charAt(s.length-1);if(s.endsWith("$$")){var a=s.slice(0,-2);return n.get$$(zu(t+"."+a))}else if(o==="$"){var l=s.slice(0,-1);return n.get$(zu(t+"."+l))}else if(o==="_"){var f=s.slice(0,-1);return n.populate(zu(t+"."+f))}else return n.get(zu(t+"."+s))}});return r})},toJSON(t=!1){if(t)return it.deepFreezeWhenDevMode(this._data);var e=$e(this._data);return delete e._rev,delete e._attachments,delete e._deleted,delete e._meta,it.deepFreezeWhenDevMode(e)},toMutableJSON(t=!1){return Pn(this.toJSON(t))},update(t){throw pt("update")},incrementalUpdate(t){throw pt("update")},updateCRDT(t){throw pt("crdt")},putAttachment(){throw pt("attachments")},getAttachment(){throw pt("attachments")},allAttachments(){throw pt("attachments")},get allAttachments$(){throw pt("attachments")},async modify(t,e){var n=this._data,r=await sb(t)(n);return this._saveData(r,n)},incrementalModify(t,e){return this.collection.incrementalWriteQueue.addWrite(this._data,sb(t)).then(n=>this.collection._docCache.getCachedRxDocument(n))},patch(t){var e=this._data,n=Pn(e);return Object.entries(t).forEach(([r,i])=>{n[r]=i}),this._saveData(n,e)},incrementalPatch(t){return this.incrementalModify(e=>(Object.entries(t).forEach(([n,r])=>{e[n]=r}),e))},async _saveData(t,e){if(t=$e(t),this._data._deleted)throw le("DOC11",{id:this.primary,document:this});await lO(this.collection,t,e);var n=await this.collection.storageInstance.bulkWrite([{previous:e,document:t}],"rx-document-save-data"),r=n.error[0];return yd(this.collection,this.primary,t,r),await this.collection._runHooks("post","save",t,this),this.collection._docCache.getCachedRxDocument(n.success[0])},remove(){var t=this.collection;if(this.deleted)return Promise.reject(le("DOC13",{document:this,id:this.primary}));var e=$e(this._data),n;return t._runHooks("pre","remove",e,this).then(async()=>{e._deleted=!0;var r=await t.storageInstance.bulkWrite([{previous:this._data,document:e}],"rx-document-remove"),i=r.error[0];return yd(t,this.primary,e,i),r.success[0]}).then(r=>(n=r,this.collection._runHooks("post","remove",e,this))).then(()=>this.collection._docCache.getCachedRxDocument(n))},incrementalRemove(){return this.incrementalModify(async t=>(await this.collection._runHooks("pre","remove",t,this),t._deleted=!0,t)).then(async t=>(await this.collection._runHooks("post","remove",t._data,t),t))},destroy(){throw le("DOC14")}};function uO(t=kh){var e=function(r,i){this.collection=r,this._data=i,this._propertyCache=new Map,this.isInstanceOfRxDocument=!0};return e.prototype=t,e}function Y2(t,e,n){var r=new t(e,n);return Nr("createRxDocument",r),r}function lO(t,e,n){return e._meta=Object.assign({},n._meta,e._meta),it.isDevMode()&&t.schema.validateChange(n,e),t._runHooks("pre","save",e,n)}var ko="collection",Ug="storage-token",Pf="rx-migration-status",G2="RxInternalDocument",zg=bh({version:0,title:G2,primaryKey:{key:"id",fields:["context","key"],separator:"|"},type:"object",properties:{id:{type:"string",maxLength:200},key:{type:"string"},context:{type:"string",enum:[ko,Ug,Pf,"OTHER"]},data:{type:"object",additionalProperties:!0}},indexes:[],required:["key","context","data"],additionalProperties:!1,sharding:{shards:1,mode:"collection"}});function Qa(t,e){return Ws(zg,{key:t,context:e})}async function Vg(t){var e=Jl(t.schema,{selector:{context:ko,_deleted:{$eq:!1}},sort:[{id:"asc"}],skip:0}),n=await t.query(e),r=n.documents;return r}var cO="storageToken",J2=Qa(cO,Ug);async function X2(t){var e=su(10),n=t.password?await t.hashFunction(JSON.stringify(t.password)):void 0,r={id:J2,context:Ug,key:cO,data:{rxdbVersion:t.rxdbVersion,token:e,instanceToken:t.token,passwordHash:n},_deleted:!1,_meta:Ks(),_rev:Rn(),_attachments:{}},i=await t.internalStore.bulkWrite([{document:r}],"internal-add-storage-token");if(i.success[0])return i.success[0];var s=ye(i.error[0]);if(s.isError&&_h(s)){var o=s;if(!Z2(o.documentInDb.data.rxdbVersion,t.rxdbVersion))throw le("DM5",{args:{database:t.name,databaseStateVersion:o.documentInDb.data.rxdbVersion,codeVersion:t.rxdbVersion}});if(n&&n!==o.documentInDb.data.passwordHash)throw le("DB1",{passwordHash:n,existingPasswordHash:o.documentInDb.data.passwordHash});var a=o.documentInDb;return ye(a)}throw s}function Z2(t,e){if(!t||e.includes("beta")&&e!==t)return!1;var n=t.split(".")[0],r=e.split(".")[0];return n===r}async function fO(t,e,n){if(t.schema.version!==n.version)throw le("SNH",{schema:n,version:t.schema.version,name:t.name,collection:t,args:{storageCollectionName:e}});for(var r=Uy(t.name,t.schema.jsonSchema),i=Qa(r,ko);;){var s=await Xl(t.database.internalStore,i),o=Pn(ye(s)),a=o.data.connectedStorages.find(l=>l.collectionName===e&&l.schema.version===n.version);if(a)return;o.data.connectedStorages.push({collectionName:e,schema:n});try{await Tl(t.database.internalStore,{previous:ye(s),document:o},"add-connected-storage-to-collection")}catch(l){if(!_h(l))throw l}}}function Uy(t,e){return t+"-"+e.version}function dm(t,e){return e=$e(e),e=cR(t,e),e=oE(t.primaryPath,t.jsonSchema,e),e._meta=Ks(),Object.prototype.hasOwnProperty.call(e,"_deleted")||(e._deleted=!1),Object.prototype.hasOwnProperty.call(e,"_attachments")||(e._attachments={}),Object.prototype.hasOwnProperty.call(e,"_rev")||(e._rev=Rn()),e}async function eN(t,e){e.multiInstance=t.multiInstance;var n=await t.storage.createStorageInstance(e);return n}async function dO(t,e,n,r,i,s,o){var a=await Vg(e),l=a.filter(y=>y.data.name===i),f=[];l.forEach(y=>{f.push({collectionName:y.data.name,schema:y.data.schema,isCollection:!0}),y.data.connectedStorages.forEach(w=>f.push({collectionName:w.collectionName,isCollection:!1,schema:w.schema}))});var h=new Set;if(f=f.filter(y=>{var w=y.collectionName+"||"+y.schema.version;return h.has(w)?!1:(h.add(w),!0)}),await Promise.all(f.map(async y=>{var w=await t.createStorageInstance({collectionName:y.collectionName,databaseInstanceToken:n,databaseName:r,multiInstance:!1,options:{},schema:y.schema,password:s,devMode:it.isDevMode()});await w.remove(),y.isCollection&&await No("postRemoveRxCollection",{storage:t,databaseName:r,collectionName:i})})),o){var m=l.map(y=>{var w=$g(y);return w._deleted=!0,w._meta.lwt=Ft(),w._rev=Ui(n,y),{previous:y,document:w}});await e.bulkWrite(m,"rx-database-remove-collection-all")}}var tN=function(){function t(n){this.subs=[],this.limit=100,this.counter=0,this.eventCounterMap=new WeakMap,this.buffer=[],this.collection=n,this.subs.push(this.collection.$.pipe(lt(r=>!r.isLocal)).subscribe(r=>this._handleChangeEvent(r)))}var e=t.prototype;return e._handleChangeEvent=function(r){for(this.counter++,this.buffer.push(r),this.eventCounterMap.set(r,this.counter);this.buffer.length>this.limit;)this.buffer.shift()},e.getArrayIndexByPointer=function(r){var i=this.buffer[0],s=this.eventCounterMap.get(i);if(ri(o))},e.reduceByLastOfDoc=function(r){return r.slice(0)},e.destroy=function(){this.subs.forEach(r=>r.unsubscribe())},t}();function nN(t){return new tN(t)}var rN=new WeakMap;function iN(t){var e=t.schema.getDocumentPrototype(),n=aN(t),r=kh,i={};return[e,n,r].forEach(s=>{var o=Object.getOwnPropertyNames(s);o.forEach(a=>{var l=Object.getOwnPropertyDescriptor(s,a),f=!0;(a.startsWith("_")||a.endsWith("_")||a.startsWith("$")||a.endsWith("$"))&&(f=!1),typeof l.value=="function"?Object.defineProperty(i,a,{get(){return l.value.bind(this)},enumerable:f,configurable:!1}):(l.enumerable=f,l.configurable=!1,l.writable&&(l.writable=!1),Object.defineProperty(i,a,l))})}),i}function sN(t){return Mr(rN,t,()=>uO(iN(t)))}function oN(t,e){var n=Y2(sN(t),t,it.deepFreezeWhenDevMode(e));return t._runHooksSync("post","create",e,n),Nr("postCreateRxDocument",n),n}function aN(t){var e={};return Object.entries(t.methods).forEach(([n,r])=>{e[n]=r}),e}async function gd(t,e){var n=Ws(t.input.metaInstance.schema,{isCheckpoint:"1",itemId:e}),r=await t.input.metaInstance.findDocumentsById([n],!1),i=r[0];if(t.lastCheckpointDoc[e]=i,i)return i.checkpointData}async function wd(t,e,n){t.checkpointQueue=t.checkpointQueue.then(async()=>{var r=t.lastCheckpointDoc[e];if(n&&!t.events.canceled.getValue()&&(!r||JSON.stringify(r.checkpointData)!==JSON.stringify(n))){var i={id:"",isCheckpoint:"1",itemId:e,_deleted:!1,_attachments:{},checkpointData:n,_meta:Ks(),_rev:Rn()};for(i.id=Ws(t.input.metaInstance.schema,i);!t.events.canceled.getValue();){if(r&&(i.checkpointData=Ml([r.checkpointData,i.checkpointData])),i._meta.lwt=Ft(),i._rev=Ui(await t.checkpointKey,r),t.events.canceled.getValue())return;var s=await t.input.metaInstance.bulkWrite([{previous:r,document:i}],"replication-set-checkpoint"),o=s.success[0];if(o){t.lastCheckpointDoc[e]=o;return}else{var a=s.error[0];if(a.status!==409)throw a;r=ye(a.documentInDb),i._rev=Ui(await t.checkpointKey,r)}}}}),await t.checkpointQueue}async function uN(t){var e=await t.hashFunction([t.identifier,t.forkInstance.databaseName,t.forkInstance.collectionName].join("||"));return"rx_storage_replication_"+e}function ob(t,e,n,r,i){var s=Object.assign({},r,{_attachments:e&&r._attachments?r._attachments:{},_meta:n?r._meta:{lwt:Ft()},_rev:n?r._rev:Rn()});return s._rev||(s._rev=Ui(t,i)),s}function cs(t,e,n){var r=$e(t);return e||delete r._attachments,n||(delete r._meta,delete r._rev),r}function zy(t,e){return t.hasAttachments?e.map(n=>{var r=Pn(n.document);return r.docData=gs(r.docData),{document:r,previous:n.previous}}):e}function Vy(t){for(;;)if(t.underlyingPersistentStorage)t=t.underlyingPersistentStorage;else return t}var Rf="RxReplicationProtocolMetaData";function Ky(t,e){var n=oR(t),r={title:Rf,primaryKey:{key:"id",fields:["itemId","isCheckpoint"],separator:"|"},type:"object",version:t.version,additionalProperties:!1,properties:{id:{type:"string",minLength:1,maxLength:n+2},isCheckpoint:{type:"string",enum:["0","1"],minLength:1,maxLength:1},itemId:{type:"string",maxLength:n>4?n:4},checkpointData:{type:"object",additionalProperties:!0},docData:{type:"object",properties:t.properties},isResolvedConflict:{type:"string"}},keyCompression:t.keyCompression,required:["id","isCheckpoint","itemId"]};e&&(r.encrypted=["docData"]);var i=bh(r);return i}function hO(t,e){return t.input.metaInstance.findDocumentsById(e.map(n=>{var r=Ws(t.input.metaInstance.schema,{itemId:n,isCheckpoint:"0"});return r}),!0).then(n=>{var r={};return Object.values(n).forEach(i=>{r[i.itemId]={docData:i.docData,metaDocument:i}}),r})}async function _d(t,e,n,r){var i=e[t.primaryPath],s=n?$g(n):{id:"",isCheckpoint:"0",itemId:i,docData:e,_attachments:{},_deleted:!1,_rev:Rn(),_meta:{lwt:0}};s.docData=e,r&&(s.isResolvedConflict=r),s._meta.lwt=Ft(),s.id=Ws(t.input.metaInstance.schema,s),s._rev=Ui(await t.checkpointKey,n);var o={previous:n,document:s};return o}async function lN(t){if(t.input.initialCheckpoint&&t.input.initialCheckpoint.downstream){var e=await gd(t,"down");e||await wd(t,"down",t.input.initialCheckpoint.downstream)}var n=await t.input.hashFunction(t.input.identifier),r=t.input.replicationHandler,i=0,s=[];function o(I){t.stats.down.addNewTask=t.stats.down.addNewTask+1;var E={time:i++,task:I};s.push(E),t.streamQueue.down=t.streamQueue.down.then(()=>{for(var $=[];s.length>0;){t.events.active.down.next(!0);var S=ye(s.shift());if(!(S.time{t.events.active.down.next(!1),!t.firstSyncDone.down.getValue()&&!t.events.canceled.getValue()&&t.firstSyncDone.down.next(!0)})}if(o("RESYNC"),!t.events.canceled.getValue()){var a=r.masterChangeStream$.pipe(Br(async I=>(await As(t.events.active.up.pipe(lt(E=>!E))),I))).subscribe(I=>{t.stats.down.masterChangeStreamEmit=t.stats.down.masterChangeStreamEmit+1,o(I)});As(t.events.canceled.pipe(lt(I=>!!I))).then(()=>a.unsubscribe())}var l=-1;async function f(){if(t.stats.down.downstreamResyncOnce=t.stats.down.downstreamResyncOnce+1,!t.events.canceled.getValue()){t.checkpointQueue=t.checkpointQueue.then(()=>gd(t,"down"));for(var I=await t.checkpointQueue,E=[];!t.events.canceled.getValue();){l=i++;var $=await r.masterChangesSince(I,t.input.pullBatchSize);if($.documents.length===0||(I=Ml([I,$.checkpoint]),E.push(w($.documents,I)),$.documents.length{if(S==="RESYNC")throw new Error("SNH");za(E,S.documents),$=Ml([$,S.checkpoint])}),w(E,ye($))}var m=un,y={docs:{}};function w(I,E){var $=t.primaryPath;return t.stats.down.persistFromMaster=t.stats.down.persistFromMaster+1,I.forEach(S=>{var _=S[$];y.docs[_]=S}),y.checkpoint=E,m=m.then(()=>{var S=y.docs;y.docs={};var _=y.checkpoint,O=Object.keys(S);if(t.events.canceled.getValue()||O.length===0)return un;var z=[],W={},Q={},H=[];return Promise.all([t.input.forkInstance.findDocumentsById(O,!0),hO(t,O)]).then(([X,U])=>{var ee=new Map;return X.forEach(ce=>ee.set(ce[$],ce)),Promise.all(O.map(async ce=>{var de=ee.get(ce),Pe=de?cs(de,t.hasAttachments,!1):void 0,ot=S[ce],ct=U[ce];if(ct&&de&&ct.metaDocument.isResolvedConflict===de._rev)return un;var Te=!ct||!Pe?!1:await t.input.conflictHandler({realMasterState:ct.docData,newDocumentState:Pe},"downstream-check-if-equal-0").then(Re=>Re.isEqual);if(!Te&&ct&&ct.docData._rev&&de&&de._meta[t.input.identifier]&&Va(de._rev).height===de._meta[t.input.identifier]&&(Te=!0),de&&ct&&Te===!1||de&&!ct)return un;var Dt=Pe?await t.input.conflictHandler({realMasterState:ot,newDocumentState:Pe},"downstream-check-if-equal-1").then(Re=>Re.isEqual):!1;if(Pe&&Dt)return(!ct||Te===!1)&&H.push(await _d(t,Pe,ct?ct.metaDocument:void 0)),un;var G=Object.assign({},ot,de?{_meta:$e(de._meta),_attachments:t.hasAttachments&&ot._attachments?ot._attachments:{},_rev:Rn()}:{_meta:{lwt:Ft()},_rev:Rn(),_attachments:t.hasAttachments&&ot._attachments?ot._attachments:{}});if(ot._rev){var oe=de?Va(de._rev).height+1:1;G._meta[t.input.identifier]=oe,t.input.keepMeta&&(G._rev=ot._rev)}t.input.keepMeta&&ot._meta&&(G._meta=ot._meta);var ue={previous:de,document:G};ue.document._rev=ue.document._rev?ue.document._rev:Ui(n,ue.previous),z.push(ue),W[ce]=ue,Q[ce]=await _d(t,ot,ct?ct.metaDocument:void 0)}))}).then(async()=>{if(z.length>0)return t.input.forkInstance.bulkWrite(z,await t.downstreamBulkWriteFlag).then(X=>{X.success.forEach(U=>{var ee=U[$];t.events.processed.down.next(W[ee]),H.push(Q[ee])}),X.error.forEach(U=>{U.status!==409&&t.events.error.next(le("RC_PULL",{writeError:U}))})})}).then(()=>{if(H.length>0)return t.input.metaInstance.bulkWrite(zy(t,H),"replication-down-write-meta").then(X=>{X.error.forEach(U=>{t.events.error.next(le("RC_PULL",{id:U.documentId,writeError:U}))})})}).then(()=>{wd(t,"down",_)})}).catch(S=>t.events.error.next(S)),m}}var bd=function(t,e){var n=gs(t.newDocumentState),r=gs(t.realMasterState);return Ka(n,r)?Promise.resolve({isEqual:!0}):Promise.resolve({isEqual:!1,documentData:t.realMasterState})};async function cN(t,e,n){var r=t.input.conflictHandler,i=await r(e,"replication-resolve-conflict");if(!i.isEqual){var s=Object.assign({},i.documentData,{_meta:$e(n._meta),_rev:Rn(),_attachments:$e(n._attachments)});return s._meta.lwt=Ft(),s._rev=Ui(await t.checkpointKey,n),{resolvedDoc:s,output:i}}}async function Wy(t,e,n,r){if(!n._attachments||r&&!r._attachments)throw new Error("_attachments missing");var i=n[t],s=new Set(r&&r._attachments?Object.keys(r._attachments):[]);return await Promise.all(Object.entries(n._attachments).map(async([o,a])=>{if((!s.has(o)||r&&ye(r._attachments)[o].digest!==a.digest)&&!a.data){var l=await e.getAttachmentData(i,o,a.digest);a.data=l}})),n}async function fN(t){if(t.input.initialCheckpoint&&t.input.initialCheckpoint.upstream){var e=await gd(t,"up");e||await wd(t,"up",t.input.initialCheckpoint.upstream)}var n=t.input.replicationHandler;t.streamQueue.up=t.streamQueue.up.then(()=>f().then(()=>{h()}));var r=0,i=-1,s=[],o=Jn,a={docs:{}},l=t.input.forkInstance.changeStream().subscribe(async y=>{if(y.context!==await t.downstreamBulkWriteFlag)return t.stats.up.forkChangeStreamEmit=t.stats.up.forkChangeStreamEmit+1,s.push({task:y,time:r++}),t.events.active.up.getValue()||t.events.active.up.next(!0),t.input.waitBeforePersist?t.input.waitBeforePersist().then(()=>h()):h()});As(t.events.canceled.pipe(lt(y=>!!y))).then(()=>l.unsubscribe());async function f(){if(t.stats.up.upstreamInitialSync=t.stats.up.upstreamInitialSync+1,!t.events.canceled.getValue()){t.checkpointQueue=t.checkpointQueue.then(()=>gd(t,"up"));for(var y=await t.checkpointQueue,w=new Set,I=async function(){i=r++,w.size>3&&await Promise.race(Array.from(w));var S=await oO(t.input.forkInstance,t.input.pushBatchSize,y);if(S.documents.length===0)return 1;y=Ml([y,S.checkpoint]);var _=m(S.documents,ye(y));w.add(_),_.catch().then(()=>w.delete(_))};!t.events.canceled.getValue()&&!await I(););var E=await Promise.all(w),$=E.find(S=>!!S);$?await f():!t.firstSyncDone.up.getValue()&&!t.events.canceled.getValue()&&t.firstSyncDone.up.next(!0)}}function h(){if(t.events.canceled.getValue()||s.length===0){t.events.active.up.next(!1);return}t.stats.up.processTasks=t.stats.up.processTasks+1,t.events.active.up.next(!0),t.streamQueue.up=t.streamQueue.up.then(()=>{for(var y=[],w={};s.length>0;){var I=ye(s.shift());I.time$.documentData)),w=Ml([w,I.task.checkpoint]))}var E=y.length===0?Jn:m(y,w);return E.then(()=>{s.length===0?t.events.active.up.next(!1):h()})})}function m(y,w){return t.stats.up.persistToMaster=t.stats.up.persistToMaster+1,y.forEach(I=>{var E=I[t.primaryPath];a.docs[E]=I}),a.checkpoint=w,o=o.then(async()=>{if(t.events.canceled.getValue())return!1;var I=a.docs;a.docs={};var E=a.checkpoint,$=Object.keys(I);if($.length===0)return!1;var S=await hO(t,$),_={},O=[],z={},W={};if(await Promise.all($.map(async Te=>{var Dt=I[Te];W[Te]=Dt;var G=cs(Dt,t.hasAttachments,!!t.input.keepMeta),oe=S[Te];oe&&oe.metaDocument.isResolvedConflict!==Dt._rev&&(await t.input.conflictHandler({realMasterState:oe.docData,newDocumentState:G},"upstream-check-if-equal")).isEqual||oe&&oe.docData._rev&&Va(Dt._rev).height===Dt._meta[t.input.identifier]||(O.push(Te),_[Te]={assumedMasterState:oe?oe.docData:void 0,newDocumentState:G},z[Te]=await _d(t,G,oe?oe.metaDocument:void 0))})),O.length===0)return!1;var Q=Object.values(_),H=new Set,X={},U=CP(Q,t.input.pushBatchSize);await Promise.all(U.map(async Te=>{t.hasAttachments&&await Promise.all(Te.map(async G=>{G.newDocumentState=await Wy(t.primaryPath,t.input.forkInstance,Pn(G.newDocumentState),G.assumedMasterState)}));var Dt=await n.masterWrite(Te);Dt.forEach(G=>{var oe=G[t.primaryPath];H.add(oe),X[oe]=G})}));var ee=[];if(O.forEach(Te=>{H.has(Te)||(t.events.processed.up.next(_[Te]),ee.push(z[Te]))}),t.events.canceled.getValue())return!1;ee.length>0&&await t.input.metaInstance.bulkWrite(zy(t,ee),"replication-up-write-meta");var ce=!1;if(H.size>0){t.stats.up.persistToMasterHadConflicts=t.stats.up.persistToMasterHadConflicts+1;var de=[],Pe={};if(await Promise.all(Object.entries(X).map(([Te,Dt])=>{var G=_[Te],oe={newDocumentState:G.newDocumentState,assumedMasterState:G.assumedMasterState,realMasterState:Dt};return cN(t,oe,W[Te]).then(async ue=>{if(ue){t.events.resolvedConflicts.next({input:oe,output:ue.output}),de.push({previous:W[Te],document:ue.resolvedDoc});var Re=S[Te];Pe[Te]=await _d(t,ye(Dt),Re?Re.metaDocument:void 0,ue.resolvedDoc._rev)}})})),de.length>0){ce=!0,t.stats.up.persistToMasterConflictWrites=t.stats.up.persistToMasterConflictWrites+1;var ot=await t.input.forkInstance.bulkWrite(de,"replication-up-write-conflict"),ct=[];ot.success.forEach(Te=>{var Dt=Te[t.primaryPath];ct.push(Pe[Dt])}),ct.length>0&&await t.input.metaInstance.bulkWrite(zy(t,ct),"replication-up-write-conflict-meta")}}return wd(t,"up",E),ce}).catch(I=>(t.events.error.next(I),!1)),o}}function pO(t){t=$e(t),t.forkInstance=Vy(t.forkInstance),t.metaInstance=Vy(t.metaInstance);var e=uN(t),n={primaryPath:Fn(t.forkInstance.schema.primaryKey),hasAttachments:!!t.forkInstance.schema.attachments,input:t,checkpointKey:e,downstreamBulkWriteFlag:e.then(r=>"replication-downstream-"+r),events:{canceled:new Jr(!1),active:{down:new Jr(!0),up:new Jr(!0)},processed:{down:new Kt,up:new Kt},resolvedConflicts:new Kt,error:new Kt},stats:{down:{addNewTask:0,downstreamProcessChanges:0,downstreamResyncOnce:0,masterChangeStreamEmit:0,persistFromMaster:0},up:{forkChangeStreamEmit:0,persistToMaster:0,persistToMasterConflictWrites:0,persistToMasterHadConflicts:0,processTasks:0,upstreamInitialSync:0}},firstSyncDone:{down:new Jr(!1),up:new Jr(!1)},streamQueue:{down:un,up:un},checkpointQueue:un,lastCheckpointDoc:{}};return lN(n),fN(n),n}function Tf(t){return As(AE([t.firstSyncDone.down.pipe(lt(e=>!!e)),t.firstSyncDone.up.pipe(lt(e=>!!e))])).then(()=>{})}function ab(t){return Promise.all([t.streamQueue.up,t.streamQueue.down,t.checkpointQueue])}function dN(t,e,n,r=!1){t=Vy(t);var i=!!t.schema.attachments,s=Fn(t.schema.primaryKey),o={masterChangeStream$:t.changeStream().pipe(Br(async a=>{var l={checkpoint:a.checkpoint,documents:await Promise.all(a.events.map(async f=>{var h=cs(f.documentData,i,r);return i&&(h=await Wy(s,t,Pn(h),void 0)),h}))};return l})),masterChangesSince(a,l){return oO(t,l,a).then(async f=>({checkpoint:f.documents.length>0?f.checkpoint:a,documents:await Promise.all(f.documents.map(async h=>{var m=cs(h,i,r);return i&&(m=await Wy(s,t,Pn(m),void 0)),m}))}))},async masterWrite(a){var l={};a.forEach(E=>{var $=E.newDocumentState[s];l[$]=E});var f=Object.keys(l),h=await t.findDocumentsById(f,!0),m=new Map;h.forEach(E=>m.set(E[s],E));var y=[],w=[];if(await Promise.all(Object.entries(l).map(async([E,$])=>{var S=m.get(E);S?S&&!$.assumedMasterState?y.push(cs(S,i,r)):(await e({realMasterState:cs(S,i,r),newDocumentState:ye($.assumedMasterState)},"rxStorageInstanceToReplicationHandler-masterWrite")).isEqual===!0?w.push({previous:S,document:ob(n,i,r,$.newDocumentState,S)}):y.push(cs(S,i,r)):w.push({document:ob(n,i,r,$.newDocumentState)})})),w.length>0){var I=await t.bulkWrite(w,"replication-master-write");I.error.forEach(E=>{if(E.status!==409)throw new Error("non conflict error");y.push(cs(ye(E.documentInDb),i,r))})}return y}};return o}async function mO(t){t.events.canceled.next(!0),t.events.active.up.complete(),t.events.active.down.complete(),t.events.processed.up.complete(),t.events.processed.down.complete(),t.events.resolvedConflicts.complete(),t.events.canceled.complete(),await t.checkpointQueue}var yO=["pre","post"],vO=["insert","save","remove","create"],ub=!1,gO=function(){function t(n,r,i,s,o={},a={},l={},f={},h={},m=JE,y={},w=bd){this.storageInstance={},this.timeouts=new Set,this.incrementalWriteQueue={},this._incrementalUpsertQueues=new Map,this.synced=!1,this.hooks={},this._subs=[],this._docCache={},this._queryCache=k2(),this.$={},this.checkpoint$={},this._changeEventBuffer={},this.onDestroy=[],this.destroyed=!1,this.database=n,this.name=r,this.schema=i,this.internalStorageInstance=s,this.instanceCreationOptions=o,this.migrationStrategies=a,this.methods=l,this.attachments=f,this.options=h,this.cacheReplacementPolicy=m,this.statics=y,this.conflictHandler=w,hN(this.asRxCollection)}var e=t.prototype;return e.prepare=async function(){this.storageInstance=jg(this.database,this.internalStorageInstance,this.schema.jsonSchema),this.incrementalWriteQueue=new aO(this.storageInstance,this.schema.primaryPath,(o,a)=>lO(this,o,a),o=>this._runHooks("post","save",o));var r=this.database.eventBulks$.pipe(lt(o=>o.collectionName===this.name));this.$=r.pipe(Br(o=>o.events)),this.checkpoint$=r.pipe(Mt(o=>o.checkpoint)),this._changeEventBuffer=nN(this.asRxCollection),this._docCache=new XE(this.schema.primaryPath,this.$.pipe(lt(o=>!o.isLocal)),o=>oN(this.asRxCollection,o));var i=await this.database.storageToken,s=this.storageInstance.changeStream().subscribe(o=>{var a={id:o.id,internal:!1,collectionName:this.name,storageToken:i,events:o.events.map(l=>rO(!1,l,this)),databaseToken:this.database.token,checkpoint:o.checkpoint,context:o.context,endTime:o.endTime,startTime:o.startTime};this.database.$emit(a)});return this._subs.push(s),this._subs.push(this.storageInstance.conflictResultionTasks().subscribe(o=>{this.conflictHandler(o.input,o.context).then(a=>{this.storageInstance.resolveConflictResultionTask({id:o.id,output:a})})})),un},e.cleanup=function(r){throw pt("cleanup")},e.migrationNeeded=function(){throw pt("migration-schema")},e.getMigrationState=function(){throw pt("migration-schema")},e.startMigration=function(r=10){return this.getMigrationState().startMigration(r)},e.migratePromise=function(r=10){return this.getMigrationState().migratePromise(r)},e.insert=async function(r){var i=await this.bulkInsert([r]),s=i.error[0];yd(this,r[this.schema.primaryPath],r,s);var o=ye(i.success[0]);return o},e.bulkInsert=async function(r){if(r.length===0)return{success:[],error:[]};var i=this.schema.primaryPath,s=r.map(m=>{var y=dm(this.schema,m);return y}),o=this.hasHooks("pre","insert")?await Promise.all(s.map(m=>this._runHooks("pre","insert",m).then(()=>m))):s,a=o.map(m=>{var y={document:m};return y}),l=await this.storageInstance.bulkWrite(a,"rx-collection-bulk-insert"),f=ZE(this._docCache,l.success);if(this.hasHooks("post","insert")){var h=new Map;o.forEach(m=>{h.set(m[i],m)}),await Promise.all(f.map(m=>this._runHooks("post","insert",h.get(m.primary),m)))}return{success:f,error:l.error}},e.bulkRemove=async function(r){var i=this.schema.primaryPath;if(r.length===0)return{success:[],error:[]};var s=await this.findByIds(r).exec(),o=[],a=new Map;Array.from(s.values()).forEach(y=>{var w=y.toMutableJSON(!0);o.push(w),a.set(y.primary,w)}),await Promise.all(o.map(y=>{var w=y[this.schema.primaryPath];return this._runHooks("pre","remove",y,s.get(w))}));var l=o.map(y=>{var w=$e(y);return w._deleted=!0,{previous:y,document:w}}),f=await this.storageInstance.bulkWrite(l,"rx-collection-bulk-remove"),h=f.success.map(y=>y[i]);await Promise.all(h.map(y=>this._runHooks("post","remove",a.get(y),s.get(y))));var m=h.map(y=>Mo(s,y));return{success:m,error:f.error}},e.bulkUpsert=async function(r){var i=[],s=new Map;r.forEach(f=>{var h=dm(this.schema,f),m=h[this.schema.primaryPath];if(!m)throw le("COL3",{primaryPath:this.schema.primaryPath,data:h,schema:this.schema.jsonSchema});s.set(m,h),i.push(h)});var o=await this.bulkInsert(i),a=o.success.slice(0),l=[];return await Promise.all(o.error.map(async f=>{if(f.status!==409)l.push(f);else{var h=f.documentId,m=Mo(s,h),y=ye(f.documentInDb),w=this._docCache.getCachedRxDocument(y),I=await w.incrementalModify(()=>m);a.push(I)}})),{error:l,success:a}},e.upsert=async function(r){var i=await this.bulkUpsert([r]);return yd(this.asRxCollection,r[this.schema.primaryPath],r,i.error[0]),i.success[0]},e.incrementalUpsert=function(r){var i=dm(this.schema,r),s=i[this.schema.primaryPath];if(!s)throw le("COL4",{data:r});var o=this._incrementalUpsertQueues.get(s);return o||(o=un),o=o.then(()=>mN(this,s,i)).then(a=>a.inserted?a.doc:pN(a.doc,i)),this._incrementalUpsertQueues.set(s,o),o},e.find=function(r){if(typeof r=="string")throw le("COL5",{queryObj:r});r||(r=tl());var i=ra("find",r,this);return i},e.findOne=function(r){if(typeof r=="number"||Array.isArray(r))throw el("COL6",{queryObj:r});var i;if(typeof r=="string")i=ra("findOne",{selector:{[this.schema.primaryPath]:r},limit:1},this);else{if(r||(r=tl()),r.limit)throw le("QU6");r=$e(r),r.limit=1,i=ra("findOne",r,this)}return i},e.count=function(r){r||(r=tl());var i=ra("count",r,this);return i},e.findByIds=function(r){var i={selector:{[this.schema.primaryPath]:{$in:r.slice(0)}}},s=ra("findByIds",i,this);return s},e.exportJSON=function(){throw pt("json-dump")},e.importJSON=function(r){throw pt("json-dump")},e.insertCRDT=function(r){throw pt("crdt")},e.addHook=function(r,i,s,o=!1){if(typeof s!="function")throw el("COL7",{key:i,when:r});if(!yO.includes(r))throw el("COL8",{key:i,when:r});if(!vO.includes(i))throw le("COL9",{key:i});if(r==="post"&&i==="create"&&o===!0)throw le("COL10",{when:r,key:i,parallel:o});var a=s.bind(this),l=o?"parallel":"series";this.hooks[i]=this.hooks[i]||{},this.hooks[i][r]=this.hooks[i][r]||{series:[],parallel:[]},this.hooks[i][r][l].push(a)},e.getHooks=function(r,i){return!this.hooks[i]||!this.hooks[i][r]?{series:[],parallel:[]}:this.hooks[i][r]},e.hasHooks=function(r,i){var s=this.getHooks(r,i);return s?s.series.length>0||s.parallel.length>0:!1},e._runHooks=function(r,i,s,o){var a=this.getHooks(r,i);if(!a)return un;var l=a.series.map(f=>()=>f(s,o));return YP(l).then(()=>Promise.all(a.parallel.map(f=>f(s,o))))},e._runHooksSync=function(r,i,s,o){var a=this.getHooks(r,i);a&&a.series.forEach(l=>l(s,o))},e.promiseWait=function(r){var i=new Promise(s=>{var o=setTimeout(()=>{this.timeouts.delete(o),s()},r);this.timeouts.add(o)});return i},e.destroy=function(){return this.destroyed?Jn:(this.destroyed=!0,Array.from(this.timeouts).forEach(r=>clearTimeout(r)),this._changeEventBuffer&&this._changeEventBuffer.destroy(),this.database.requestIdlePromise().then(()=>Promise.all(this.onDestroy.map(r=>r()))).then(()=>this.storageInstance.close()).then(()=>(this._subs.forEach(r=>r.unsubscribe()),delete this.database.collections[this.name],No("postDestroyRxCollection",this).then(()=>!0))))},e.remove=async function(){await this.destroy(),await dO(this.database.storage,this.database.internalStore,this.database.token,this.database.name,this.name,this.database.password,this.database.hashFunction)},Vs(t,[{key:"insert$",get:function(){return this.$.pipe(lt(n=>n.operation==="INSERT"))}},{key:"update$",get:function(){return this.$.pipe(lt(n=>n.operation==="UPDATE"))}},{key:"remove$",get:function(){return this.$.pipe(lt(n=>n.operation==="DELETE"))}},{key:"asRxCollection",get:function(){return this}}]),t}();function hN(t){if(!ub){ub=!0;var e=Object.getPrototypeOf(t);vO.forEach(n=>{yO.map(r=>{var i=r+eE(n);e[i]=function(s,o){return this.addHook(r,n,s,o)}})})}}function pN(t,e){return t.incrementalModify(n=>e)}function mN(t,e,n){var r=t._docCache.getLatestDocumentDataIfExists(e);return r?Promise.resolve({doc:t._docCache.getCachedRxDocument(r),inserted:!1}):t.findOne(e).exec().then(i=>i?{doc:i,inserted:!1}:t.insert(n).then(s=>({doc:s,inserted:!0})))}function yN({database:t,name:e,schema:n,instanceCreationOptions:r={},migrationStrategies:i={},autoMigrate:s=!0,statics:o={},methods:a={},attachments:l={},options:f={},localDocuments:h=!1,cacheReplacementPolicy:m=JE,conflictHandler:y=bd}){var w={databaseInstanceToken:t.token,databaseName:t.name,collectionName:e,schema:n.jsonSchema,options:r,multiInstance:t.multiInstance,password:t.password,devMode:it.isDevMode()};return Nr("preCreateRxStorageInstance",w),eN(t,w).then(I=>{var E=new gO(t,e,n,I,r,i,a,l,f,m,o,y);return E.prepare().then(()=>{Object.entries(o).forEach(([S,_])=>{Object.defineProperty(E,S,{get:()=>_.bind(E)})});var $=un;return s&&E.schema.version!==0&&($=E.migratePromise()),$}).then(()=>(Nr("createRxCollection",{collection:E,creator:{name:e,schema:n,storageInstance:I,instanceCreationOptions:r,migrationStrategies:i,methods:a,attachments:l,options:f,cacheReplacementPolicy:m,localDocuments:h,statics:o}}),E)).catch($=>I.close().then(()=>Promise.reject($)))})}var wO=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;this._parallels=e||1,this._qC=0,this._iC=new Set,this._lHN=0,this._hPM=new Map,this._pHM=new Map};wO.prototype={isIdle:function(){return this._qC{this._to=!1,gN(this)},0))}clear(){this.map.clear()}}function gN(t){const e=_O()-t.ttl,n=t.map[Symbol.iterator]();for(;;){const r=n.next().value;if(!r)return;const i=r[0];if(r[1]E.events)),this.storageToken=Jn,this.storageTokenDocument=Jn,this.emittedEventBulkIds=new Kg(60*1e3),this.name=n,this.token=r,this.storage=i,this.instanceCreationOptions=s,this.password=o,this.multiInstance=a,this.eventReduce=l,this.options=f,this.internalStore=h,this.hashFunction=m,this.cleanupPolicy=y,this.allowSlowCount=w,this.reactivity=I,this.name!=="pseudoInstance"&&(this.internalStore=jg(this.asRxDatabase,h,zg),this.storageTokenDocument=X2(this.asRxDatabase).catch(E=>this.startupErrors.push(E)),this.storageToken=this.storageTokenDocument.then(E=>E.data.token).catch(E=>this.startupErrors.push(E)))}var e=t.prototype;return e.getReactivityFactory=function(){if(!this.reactivity)throw le("DB14",{database:this.name});return this.reactivity},e.$emit=function(r){this.emittedEventBulkIds.has(r.id)||(this.emittedEventBulkIds.add(r.id),this.eventBulks$.next(r))},e.removeCollectionDoc=async function(r,i){var s=await Xl(this.internalStore,Qa(Uy(r,i),ko));if(!s)throw le("SNH",{name:r,schema:i});var o=$g(s);o._deleted=!0,await this.internalStore.bulkWrite([{document:o,previous:s}],"rx-database-remove-collection")},e.addCollections=async function(r){var i={},s={},o=[],a={};await Promise.all(Object.entries(r).map(async([h,m])=>{var y=h,w=m.schema;i[y]=w;var I=hR(w,this.hashFunction);if(s[y]=I,this.collections[h])throw le("DB3",{name:h});var E=Uy(h,w),$={id:Qa(E,ko),key:E,context:ko,data:{name:y,schemaHash:await I.hash,schema:I.jsonSchema,version:I.version,connectedStorages:[]},_deleted:!1,_meta:Ks(),_rev:Rn(),_attachments:{}};o.push({document:$});var S=Object.assign({},m,{name:y,schema:I,database:this}),_=$e(m);_.database=this,_.name=h,Nr("preCreateRxCollection",_),S.conflictHandler=_.conflictHandler,a[y]=S}));var l=await this.internalStore.bulkWrite(o,"rx-database-add-collection");await SN(this),await Promise.all(l.error.map(async h=>{if(h.status!==409)throw le("DB12",{database:this.name,writeError:h});var m=ye(h.documentInDb),y=m.data.name,w=s[y];if(m.data.schemaHash!==await w.hash)throw le("DB6",{database:this.name,collection:y,previousSchemaHash:m.data.schemaHash,schemaHash:await w.hash,previousSchema:m.data.schema,schema:ye(i[y])})}));var f={};return await Promise.all(Object.keys(r).map(async h=>{var m=a[h],y=await yN(m);f[h]=y,this.collections[h]=y,this[h]||Object.defineProperty(this,h,{get:()=>this.collections[h]})})),f},e.lockedRun=function(r){return this.idleQueue.wrapCall(r)},e.requestIdlePromise=function(){return this.idleQueue.requestIdlePromise()},e.exportJSON=function(r){throw pt("json-dump")},e.importJSON=function(r){throw pt("json-dump")},e.backup=function(r){throw pt("backup")},e.leaderElector=function(){throw pt("leader-election")},e.isLeader=function(){throw pt("leader-election")},e.waitForLeadership=function(){throw pt("leader-election")},e.migrationStates=function(){throw pt("migration-schema")},e.destroy=async function(){return this.destroyed||(this.destroyed=!0,await No("preDestroyRxDatabase",this),this.eventBulks$.complete(),this._subs.map(r=>r.unsubscribe()),this.name==="pseudoInstance")?Jn:this.requestIdlePromise().then(()=>Promise.all(this.onDestroy.map(r=>r()))).then(()=>Promise.all(Object.keys(this.collections).map(r=>this.collections[r]).map(r=>r.destroy()))).then(()=>this.internalStore.close()).then(()=>Sd.delete(this.storage.name+"|"+this.name)).then(()=>!0)},e.remove=function(){return this.destroy().then(()=>SO(this.name,this.storage,this.password))},Vs(t,[{key:"$",get:function(){return this.observable$}},{key:"asRxDatabase",get:function(){return this}}]),t}();function wN(t,e){var n=e.name+"|"+t;if(Sd.has(n))throw le("DB8",{name:t,storage:e.name,link:"https://rxdb.info/rx-database.html#ignoreduplicate"})}async function bO(t,e,n,r,i,s){var o=await e.createStorageInstance({databaseInstanceToken:t,databaseName:n,collectionName:V2,schema:zg,options:r,multiInstance:i,password:s,devMode:it.isDevMode()});return o}function _N({storage:t,instanceCreationOptions:e,name:n,password:r,multiInstance:i=!0,eventReduce:s=!0,ignoreDuplicate:o=!1,options:a={},cleanupPolicy:l,allowSlowCount:f=!1,localDocuments:h=!1,hashFunction:m=WP,reactivity:y}){Nr("preCreateRxDatabase",{storage:t,instanceCreationOptions:e,name:n,password:r,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:a,localDocuments:h}),o||wN(n,t),Sd.add(t.name+"|"+n);var w=su(10);return bO(w,t,n,e,i,r).catch(I=>{throw Sd.delete(t.name+"|"+n),I}).then(I=>{var E=new Wg(n,w,t,e,r,i,s,a,I,m,l,f,y);return No("createRxDatabase",{database:E,creator:{storage:t,instanceCreationOptions:e,name:n,password:r,multiInstance:i,eventReduce:s,ignoreDuplicate:o,options:a,localDocuments:h}}).then(()=>E)})}async function SO(t,e,n){var r=su(10),i=await bO(r,e,t,{},!1,n),s=await Vg(i),o=new Set;s.forEach(l=>o.add(l.data.name));var a=Array.from(o);return await Promise.all(a.map(l=>dO(e,i,r,t,l,n))),await No("postRemoveRxDatabase",{databaseName:t,storage:e}),await i.remove(),a}function bN(t){return t instanceof Wg}async function IO(t){var e=await t.storageTokenDocument;return e.data.instanceToken===t.token}async function SN(t){if(await t.storageToken,t.startupErrors[0])throw t.startupErrors[0]}var IN={RxSchema:uE.prototype,RxDocument:kh,RxQuery:eO.prototype,RxCollection:gO.prototype,RxDatabase:Wg.prototype},pm=new Set,lb=new Set;function gi(t){if(Nr("preAddRxPlugin",{plugin:t,plugins:pm}),!pm.has(t)){{if(lb.has(t.name))throw le("PL3",{name:t.name,plugin:t});pm.add(t),lb.add(t.name)}if(!t.rxdb)throw el("PL1",{plugin:t});t.init&&t.init(),t.prototypes&&Object.entries(t.prototypes).forEach(([e,n])=>n(IN[e])),t.overwritable&&Object.assign(it,t.overwritable),t.hooks&&Object.entries(t.hooks).forEach(([e,n])=>{n.after&&xl[e].push(n.after),n.before&&xl[e].unshift(n.before)})}}function EN(t){return t&&typeof t.then=="function"}Promise.resolve(!1);var ON=Promise.resolve(!0),Mi=Promise.resolve();function mo(t,e){return t||(t=0),new Promise(function(n){return setTimeout(function(){return n(e)},t)})}function kN(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function Zl(){return Math.random().toString(36).substring(2)}var mm=0;function ec(){var t=Date.now()*1e3;return t<=mm&&(t=mm+1),mm=t,t}function DN(){return typeof navigator<"u"&&typeof navigator.locks<"u"&&typeof navigator.locks.request=="function"}var xN=ec,CN="native";function AN(t){var e={time:ec(),messagesCallback:null,bc:new BroadcastChannel(t),subFns:[]};return e.bc.onmessage=function(n){e.messagesCallback&&e.messagesCallback(n.data)},e}function PN(t){t.bc.close(),t.subFns=[]}function RN(t,e){try{return t.bc.postMessage(e,!1),Mi}catch(n){return Promise.reject(n)}}function TN(t,e){t.messagesCallback=e}function MN(){if(typeof globalThis<"u"&&globalThis.Deno&&globalThis.Deno.args)return!0;if((typeof window<"u"||typeof self<"u")&&typeof BroadcastChannel=="function"){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}else return!1}function NN(){return 150}var BN={create:AN,close:PN,onMessage:TN,postMessage:RN,canBeUsed:MN,type:CN,averageResponseTime:NN,microSeconds:xN};function qg(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=JSON.parse(JSON.stringify(t));return typeof e.webWorkerSupport>"u"&&(e.webWorkerSupport=!0),e.idb||(e.idb={}),e.idb.ttl||(e.idb.ttl=1e3*45),e.idb.fallbackInterval||(e.idb.fallbackInterval=150),t.idb&&typeof t.idb.onclose=="function"&&(e.idb.onclose=t.idb.onclose),e.localstorage||(e.localstorage={}),e.localstorage.removeTimeout||(e.localstorage.removeTimeout=1e3*60),t.methods&&(e.methods=t.methods),e.node||(e.node={}),e.node.ttl||(e.node.ttl=1e3*60*2),e.node.maxParallelWrites||(e.node.maxParallelWrites=2048),typeof e.node.useFastPath>"u"&&(e.node.useFastPath=!0),e}var FN=ec,LN="pubkey.broadcast-channel-0-",qi="messages",Dh={durability:"relaxed"},$N="idb";function EO(){if(typeof indexedDB<"u")return indexedDB;if(typeof window<"u"){if(typeof window.mozIndexedDB<"u")return window.mozIndexedDB;if(typeof window.webkitIndexedDB<"u")return window.webkitIndexedDB;if(typeof window.msIndexedDB<"u")return window.msIndexedDB}return!1}function Hg(t){t.commit&&t.commit()}function jN(t){var e=EO(),n=LN+t,r=e.open(n);return r.onupgradeneeded=function(i){var s=i.target.result;s.createObjectStore(qi,{keyPath:"id",autoIncrement:!0})},new Promise(function(i,s){r.onerror=function(o){return s(o)},r.onsuccess=function(){i(r.result)}})}function UN(t,e,n){var r=Date.now(),i={uuid:e,time:r,data:n},s=t.transaction([qi],"readwrite",Dh);return new Promise(function(o,a){s.oncomplete=function(){return o()},s.onerror=function(f){return a(f)};var l=s.objectStore(qi);l.add(i),Hg(s)})}function zN(t,e){var n=t.transaction(qi,"readonly",Dh),r=n.objectStore(qi),i=[],s=IDBKeyRange.bound(e+1,1/0);if(r.getAll){var o=r.getAll(s);return new Promise(function(l,f){o.onerror=function(h){return f(h)},o.onsuccess=function(h){l(h.target.result)}})}function a(){try{return s=IDBKeyRange.bound(e+1,1/0),r.openCursor(s)}catch{return r.openCursor()}}return new Promise(function(l,f){var h=a();h.onerror=function(m){return f(m)},h.onsuccess=function(m){var y=m.target.result;y?y.value.idt.lastCursorId&&(t.lastCursorId=r.id),r}).filter(function(r){return HN(r,t)}).sort(function(r,i){return r.time-i.time});return n.forEach(function(r){t.messagesCallback&&(t.eMIs.add(r.id),t.messagesCallback(r.data))}),Mi})}function QN(t){t.closed=!0,t.db.close()}function YN(t,e){return t.writeBlockPromise=t.writeBlockPromise.then(function(){return UN(t.db,t.uuid,e)}).then(function(){kN(0,10)===0&&WN(t)}),t.writeBlockPromise}function GN(t,e,n){t.messagesCallbackTime=n,t.messagesCallback=e,kO(t)}function JN(){return!!EO()}function XN(t){return t.idb.fallbackInterval*2}var ZN={create:qN,close:QN,onMessage:GN,postMessage:YN,canBeUsed:JN,type:$N,averageResponseTime:XN,microSeconds:FN},eB=ec,tB="pubkey.broadcastChannel-",nB="localstorage";function DO(){var t;if(typeof window>"u")return null;try{t=window.localStorage,t=window["ie8-eventlistener/storage"]||window.localStorage}catch{}return t}function xO(t){return tB+t}function rB(t,e){return new Promise(function(n){mo().then(function(){var r=xO(t.channelName),i={token:Zl(),time:Date.now(),data:e,uuid:t.uuid},s=JSON.stringify(i);DO().setItem(r,s);var o=document.createEvent("Event");o.initEvent("storage",!0,!0),o.key=r,o.newValue=s,window.dispatchEvent(o),n()})})}function iB(t,e){var n=xO(t),r=function(s){s.key===n&&e(JSON.parse(s.newValue))};return window.addEventListener("storage",r),r}function sB(t){window.removeEventListener("storage",t)}function oB(t,e){if(e=qg(e),!CO())throw new Error("BroadcastChannel: localstorage cannot be used");var n=Zl(),r=new Kg(e.localstorage.removeTimeout),i={channelName:t,uuid:n,eMIs:r};return i.listener=iB(t,function(s){i.messagesCallback&&s.uuid!==n&&(!s.token||r.has(s.token)||s.data.time&&s.data.time0||t._addEL.internal.length>0}function hb(t,e,n){t._addEL[e].push(n),SB(t)}function pb(t,e,n){t._addEL[e]=t._addEL[e].filter(function(r){return r!==n}),IB(t)}function SB(t){if(!t._iL&&TO(t)){var e=function(i){t._addEL[i.type].forEach(function(s){i.time>=s.time&&s.fn(i.data)})},n=t.method.microSeconds();t._prepP?t._prepP.then(function(){t._iL=!0,t.method.onMessage(t._state,e,n)}):(t._iL=!0,t.method.onMessage(t._state,e,n))}}function IB(t){if(t._iL&&!TO(t)){t._iL=!1;var e=t.method.microSeconds();t.method.onMessage(t._state,null,e)}}function EB(t){if(typeof WorkerGlobalScope=="function"&&self instanceof WorkerGlobalScope){var e=self.close.bind(self);self.close=function(){return t(),e()}}else{if(typeof window.addEventListener!="function")return;window.addEventListener("beforeunload",function(){t()},!0),window.addEventListener("unload",function(){t()},!0)}}function OB(t){process.on("exit",function(){return t()}),process.on("beforeExit",function(){return t().then(function(){return process.exit()})}),process.on("SIGINT",function(){return t().then(function(){return process.exit()})}),process.on("uncaughtException",function(e){return t().then(function(){console.trace(e),process.exit(101)})})}var kB=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",DB=kB?OB:EB,nl=new Set,mb=!1;function xB(){mb||(mb=!0,DB(AB))}function CB(t){if(xB(),typeof t!="function")throw new Error("Listener is no function");nl.add(t);var e={remove:function(){return nl.delete(t)},run:function(){return nl.delete(t),t()}};return e}function AB(){var t=[];return nl.forEach(function(e){t.push(e()),nl.delete(e)}),Promise.all(t)}function Do(t,e){var n={context:"leader",action:e,token:t.token};return t.broadcastChannel.postInternal(n)}function MO(t){t.isLeader=!0,t._hasLeader=!0;var e=CB(function(){return t.die()});t._unl.push(e);var n=function(i){i.context==="leader"&&i.action==="apply"&&Do(t,"tell"),i.context==="leader"&&i.action==="tell"&&!t._dpLC&&(t._dpLC=!0,t._dpL(),Do(t,"tell"))};return t.broadcastChannel.addEventListener("internal",n),t._lstns.push(n),Do(t,"tell")}var NO=function(e,n){var r=this;this.broadcastChannel=e,e._befC.push(function(){return r.die()}),this._options=n,this.isLeader=!1,this.isDead=!1,this.token=Zl(),this._lstns=[],this._unl=[],this._dpL=function(){},this._dpLC=!1,this._wKMC={},this.lN="pubkey-bc||"+e.method.type+"||"+e.name};NO.prototype={hasLeader:function(){var e=this;return navigator.locks.query().then(function(n){var r=n.held?n.held.filter(function(i){return i.name===e.lN}):[];return!!(r&&r.length>0)})},awaitLeadership:function(){var e=this;if(!this._wLMP){this._wKMC.c=new AbortController;var n=new Promise(function(r,i){e._wKMC.res=r,e._wKMC.rej=i});this._wLMP=new Promise(function(r){navigator.locks.request(e.lN,{signal:e._wKMC.c.signal},function(){return e._wKMC.c=void 0,MO(e),r(),n}).catch(function(){})})}return this._wLMP},set onduplicate(t){},die:function(){var e=this;return this._lstns.forEach(function(n){return e.broadcastChannel.removeEventListener("internal",n)}),this._lstns=[],this._unl.forEach(function(n){return n.remove()}),this._unl=[],this.isLeader&&(this.isLeader=!1),this.isDead=!0,this._wKMC.res&&this._wKMC.res(),this._wKMC.c&&this._wKMC.c.abort("LeaderElectionWebLock.die() called"),Do(this,"death")}};var BO=function(e,n){var r=this;this.broadcastChannel=e,this._options=n,this.isLeader=!1,this._hasLeader=!1,this.isDead=!1,this.token=Zl(),this._aplQ=Mi,this._aplQC=0,this._unl=[],this._lstns=[],this._dpL=function(){},this._dpLC=!1;var i=function(o){o.context==="leader"&&(o.action==="death"&&(r._hasLeader=!1),o.action==="tell"&&(r._hasLeader=!0))};this.broadcastChannel.addEventListener("internal",i),this._lstns.push(i)};BO.prototype={hasLeader:function(){return Promise.resolve(this._hasLeader)},applyOnce:function(e){var n=this;if(this.isLeader)return mo(0,!0);if(this.isDead)return mo(0,!1);if(this._aplQC>1)return this._aplQ;var r=function(){if(n.isLeader)return ON;var s=!1,o,a=new Promise(function(h){o=function(){s=!0,h()}}),l=function(m){m.context==="leader"&&m.token!=n.token&&(m.action==="apply"&&m.token>n.token&&o(),m.action==="tell"&&(o(),n._hasLeader=!0))};n.broadcastChannel.addEventListener("internal",l);var f=e?n._options.responseTime*4:n._options.responseTime;return Do(n,"apply").then(function(){return Promise.race([mo(f),a.then(function(){return Promise.reject(new Error)})])}).then(function(){return Do(n,"apply")}).then(function(){return Promise.race([mo(f),a.then(function(){return Promise.reject(new Error)})])}).catch(function(){}).then(function(){return n.broadcastChannel.removeEventListener("internal",l),s?!1:MO(n).then(function(){return!0})})};return this._aplQC=this._aplQC+1,this._aplQ=this._aplQ.then(function(){return r()}).then(function(){n._aplQC=n._aplQC-1}),this._aplQ.then(function(){return n.isLeader})},awaitLeadership:function(){return this._aLP||(this._aLP=PB(this)),this._aLP},set onduplicate(t){this._dpL=t},die:function(){var e=this;return this._lstns.forEach(function(n){return e.broadcastChannel.removeEventListener("internal",n)}),this._lstns=[],this._unl.forEach(function(n){return n.remove()}),this._unl=[],this.isLeader&&(this._hasLeader=!1,this.isLeader=!1),this.isDead=!0,Do(this,"death")}};function PB(t){return t.isLeader?Mi:new Promise(function(e){var n=!1;function r(){n||(n=!0,t.broadcastChannel.removeEventListener("internal",s),e(!0))}t.applyOnce().then(function(){t.isLeader&&r()});var i=function o(){return mo(t._options.fallbackInterval).then(function(){if(!(t.isDead||n))if(t.isLeader)r();else return t.applyOnce(!0).then(function(){t.isLeader?r():o()})})};i();var s=function(a){a.context==="leader"&&a.action==="death"&&(t._hasLeader=!1,t.applyOnce().then(function(){t.isLeader&&r()}))};t.broadcastChannel.addEventListener("internal",s),t._lstns.push(s)})}function RB(t,e){return t||(t={}),t=JSON.parse(JSON.stringify(t)),t.fallbackInterval||(t.fallbackInterval=3e3),t.responseTime||(t.responseTime=e.method.averageResponseTime(e.options)),t}function TB(t,e){if(t._leaderElector)throw new Error("BroadcastChannel already has a leader-elector");e=RB(e,t);var n=DN()?new NO(t,e):new BO(t,e);return t._befC.push(function(){return n.die()}),t._leaderElector=n,n}var Id=new Map;function MB(t,e,n,r){var i=Id.get(e);return i||(i={bc:new xh(["RxDB:",t,n].join("|")),refs:new Set},Id.set(e,i)),i.refs.add(r),i.bc}function yb(t,e){var n=Id.get(t);if(n&&(n.refs.delete(e),n.refs.size===0))return Id.delete(t),n.bc.close()}function NB(t,e,n,r){if(e.multiInstance){var i=r||MB(t,e.databaseInstanceToken,n.databaseName,n),s=new Kt,o=y=>{y.storageName===t&&y.databaseName===e.databaseName&&y.collectionName===e.collectionName&&y.version===e.schema.version&&s.next(y.eventBulk)};i.addEventListener("message",o);var a=n.changeStream(),l=!1,f=a.subscribe(y=>{l||i.postMessage({storageName:t,databaseName:e.databaseName,collectionName:e.collectionName,version:e.schema.version,eventBulk:y})});n.changeStream=function(){return s.asObservable().pipe(oT(a))};var h=n.close.bind(n);n.close=async function(){return l=!0,f.unsubscribe(),i.removeEventListener("message",o),r||await yb(e.databaseInstanceToken,n),h()};var m=n.remove.bind(n);n.remove=async function(){return l=!0,f.unsubscribe(),i.removeEventListener("message",o),r||await yb(e.databaseInstanceToken,n),m()}}}function BB(t,e){var n=e.map(r=>{var i=zi(t,r);if(!i)throw new Error("not in schema: "+r);var s=i.type,o;(s==="number"||s==="integer")&&(o=Yg(i));var a=XI(r),l=i.maxLength?i.maxLength:0,f;s==="string"?f=m=>{var y=a(m);return y||(y=""),y.padEnd(l," ")}:s==="boolean"?f=m=>{var y=a(m);return y?"1":"0"}:f=m=>{var y=a(m);return Ed(o,y)};var h={fieldName:r,schemaPart:i,parsedLengths:o,getValue:a,getIndexStringPart:f};return h});return n}function FB(t,e){var n=BB(t,e),r=n.length,i=n.map(o=>o.getIndexStringPart),s=function(o){for(var a="",l=0;l1&&(a=o[1].length),{minimum:e,maximum:n,nonDecimals:s,decimals:a,roundedMinimum:e}}function Ed(t,e){typeof e>"u"&&(e=0),et.maximum&&(e=t.maximum);var n=(Math.floor(e)-t.roundedMinimum).toString(),r=n.padStart(t.nonDecimals,"0");if(t.decimals>0){var i=e.toString().split("."),s=i.length>1?i[1]:"0";r+=s.padEnd(t.decimals,"0")}return r}function vb(t,e,n){var r="";return e.forEach((i,s)=>{var o=zi(t,i),a=n[s],l=o.type;switch(l){case"string":var f=ye(o.maxLength,"maxLength not set");typeof a=="string"?r+=a.padEnd(f," "):r+="".padEnd(f," ");break;case"boolean":if(a===null)r+="0";else if(a===li)r+="0";else if(a===Ar)r+="1";else{var h=a?"1":"0";r+=h}break;case"number":case"integer":var m=Yg(o);if(a===null||a===li){var y="0";r+=y.repeat(m.nonDecimals+m.decimals)}else if(a===Ar)r+=Ed(m,m.maximum);else{var w=Ed(m,a);r+=w}break;default:throw new Error("unknown index type "+l)}}),r}function LB(t,e,n){var r="";return e.forEach((i,s)=>{var o=zi(t,i),a=n[s],l=o.type;switch(l){case"string":var f=ye(o.maxLength,"maxLength not set");typeof a=="string"&&a!==Ar?r+=a.padEnd(f," "):a===li?r+="".padEnd(f," "):r+="".padEnd(f,Ar);break;case"boolean":if(a===null)r+="1";else{var h=a?"1":"0";r+=h}break;case"number":case"integer":var m=Yg(o);if(a===null||a===Ar){var y="9";r+=y.repeat(m.nonDecimals+m.decimals)}else if(a===li){var w="0";r+=w.repeat(m.nonDecimals+m.decimals)}else r+=Ed(m,a);break;default:throw new Error("unknown index type "+l)}}),r}var gb=t=>Promise.resolve(t);function wb(t,e){if(t==="_deleted")return e;e=$e(e);var n=!!e._deleted;return e[t]=n,delete e._deleted,e}function ym(t,e,n){return n.map(r=>{var i=$e(r);if(e!=="_deleted"){var s=!!i[e];i._deleted=s,delete i[e]}else i._deleted=!!i._deleted;var o=t.schema.primaryPath;return i[o]=Ws(t.schema.jsonSchema,i),i})}function _b(t,e){if(typeof window>"u"||typeof window!="object"||typeof window.addEventListener>"u"||navigator.onLine)return t.promiseWait(e);var n,r=new Promise(i=>{n=()=>{window.removeEventListener("online",n),i()},window.addEventListener("online",n)});return Promise.race([r,t.promiseWait(e)]).then(()=>{window.removeEventListener("online",n)})}var FO=new WeakMap,$B=function(){function t(n,r,i,s,o,a,l,f){this.subs=[],this.subjects={received:new Kt,sent:new Kt,error:new Kt,canceled:new Jr(!1),active:new Jr(!1)},this.received$=this.subjects.received.asObservable(),this.sent$=this.subjects.sent.asObservable(),this.error$=this.subjects.error.asObservable(),this.canceled$=this.subjects.canceled.asObservable(),this.active$=this.subjects.active.asObservable(),this.onCancel=[],this.callOnStart=void 0,this.remoteEvents$=new Kt,this.replicationIdentifier=n,this.collection=r,this.deletedField=i,this.pull=s,this.push=o,this.live=a,this.retryTime=l,this.autoStart=f;var h=Mr(FO,r,()=>[]);h.push(this),this.collection.onDestroy.push(()=>this.cancel()),Object.keys(this.subjects).forEach(y=>{Object.defineProperty(this,y+"$",{get:function(){return this.subjects[y].asObservable()}})});var m=new Promise(y=>{this.callOnStart=y});this.startPromise=m}var e=t.prototype;return e.start=async function(){if(!this.isStopped()){var r=this.pull&&this.pull.modifier?this.pull.modifier:gb,i=this.push&&this.push.modifier?this.push.modifier:gb,s=this.collection.database,o="rx-replication-meta-"+await s.hashFunction([this.collection.name,this.replicationIdentifier].join("-")),a=Ky(this.collection.schema.jsonSchema,vd(this.collection.schema.jsonSchema)),[l]=await Promise.all([this.collection.database.storage.createStorageInstance({databaseName:s.name,collectionName:o,databaseInstanceToken:s.token,multiInstance:s.multiInstance,options:{},schema:a,password:s.password,devMode:it.isDevMode()}),fO(this.collection,o,a)]);this.metaInstance=l,this.internalReplicationState=pO({pushBatchSize:this.push&&this.push.batchSize?this.push.batchSize:100,pullBatchSize:this.pull&&this.pull.batchSize?this.pull.batchSize:100,initialCheckpoint:{upstream:this.push?this.push.initialCheckpoint:void 0,downstream:this.pull?this.pull.initialCheckpoint:void 0},forkInstance:this.collection.storageInstance,metaInstance:this.metaInstance,hashFunction:s.hashFunction,identifier:"rxdbreplication"+this.replicationIdentifier,conflictHandler:this.collection.conflictHandler,replicationHandler:{masterChangeStream$:this.remoteEvents$.asObservable().pipe(lt(f=>!!this.pull),Br(async f=>{if(f==="RESYNC")return f;var h=$e(f);return h.documents=ym(this.collection,this.deletedField,h.documents),h.documents=await Promise.all(h.documents.map(m=>r(m))),h})),masterChangesSince:async(f,h)=>{if(!this.pull)return{checkpoint:null,documents:[]};for(var m=!1,y={};!m&&!this.isStopped();)try{y=await this.pull.handler(f,h),m=!0}catch(E){var w=le("RC_PULL",{checkpoint:f,errors:Ua(E).map($=>ky($)),direction:"pull"});this.subjects.error.next(w),await _b(this.collection,ye(this.retryTime))}if(this.isStopped())return{checkpoint:null,documents:[]};var I=$e(y);return I.documents=ym(this.collection,this.deletedField,I.documents),I.documents=await Promise.all(I.documents.map(E=>r(E))),I},masterWrite:async f=>{if(!this.push)return[];var h=!1;await No("preReplicationMasterWrite",{rows:f,collection:this.collection});var m=await Promise.all(f.map(async $=>($.newDocumentState=await i($.newDocumentState),$.newDocumentState===null?null:($.assumedMasterState&&($.assumedMasterState=await i($.assumedMasterState)),this.deletedField!=="_deleted"&&($.newDocumentState=wb(this.deletedField,$.newDocumentState),$.assumedMasterState&&($.assumedMasterState=wb(this.deletedField,$.assumedMasterState))),$)))),y=m.filter(JI),w=null;for(y.length===0&&(h=!0,w=[]);!h&&!this.isStopped();)try{if(w=await this.push.handler(y),!Array.isArray(w))throw le("RC_PUSH_NO_AR",{pushRows:f,direction:"push",args:{result:w}});h=!0}catch($){var I=$.rxdb?$:le("RC_PUSH",{pushRows:f,errors:Ua($).map(S=>ky(S)),direction:"push"});this.subjects.error.next(I),await _b(this.collection,ye(this.retryTime))}if(this.isStopped())return[];await No("preReplicationMasterWriteDocumentsHandle",{result:w,collection:this.collection});var E=ym(this.collection,this.deletedField,ye(w));return E}}}),this.subs.push(this.internalReplicationState.events.error.subscribe(f=>{this.subjects.error.next(f)}),this.internalReplicationState.events.processed.down.subscribe(f=>this.subjects.received.next(f.document)),this.internalReplicationState.events.processed.up.subscribe(f=>{this.subjects.sent.next(f.newDocumentState)}),AE([this.internalReplicationState.events.active.down,this.internalReplicationState.events.active.up]).subscribe(([f,h])=>{var m=f||h;this.subjects.active.next(m)})),this.pull&&this.pull.stream$&&this.live&&this.subs.push(this.pull.stream$.subscribe({next:f=>{this.remoteEvents$.next(f)},error:f=>{this.subjects.error.next(f)}})),this.live||(await Tf(this.internalReplicationState),await ab(this.internalReplicationState),await this.cancel()),this.callOnStart()}},e.isStopped=function(){return!!this.subjects.canceled.getValue()},e.awaitInitialReplication=async function(){return await this.startPromise,Tf(ye(this.internalReplicationState))},e.awaitInSync=async function(){await this.startPromise,await Tf(ye(this.internalReplicationState));for(var r=2;r>0;)r--,await this.collection.database.requestIdlePromise(),await ab(ye(this.internalReplicationState));return!0},e.reSync=function(){this.remoteEvents$.next("RESYNC")},e.emitEvent=function(r){this.remoteEvents$.next(r)},e.cancel=async function(){if(this.isStopped())return Jn;var r=this.onCancel.map(i=>ZI(i()));return this.internalReplicationState&&await mO(this.internalReplicationState),this.metaInstance&&r.push(ye(this.internalReplicationState).checkpointQueue.then(()=>ye(this.metaInstance).close())),this.subs.forEach(i=>i.unsubscribe()),this.subjects.canceled.next(!0),this.subjects.active.complete(),this.subjects.canceled.complete(),this.subjects.error.complete(),this.subjects.received.complete(),this.subjects.sent.complete(),Promise.all(r)},t}(),Fr;(function(t){function e(U){return Array.isArray(U)?U.slice():t.isObject(U)?{...U}:U}t.clone=e;function n(U){let ee=r(U);return Array.isArray(U)&&(ee=ee.filter(ce=>ce!=="length")),ee}t.keys=n;function r(U){return U?Object.getOwnPropertyNames(U):[]}t.keysOfNonArray=r;function i(U,ee){return a(n(U),ce=>ee(U[ce],ce)),U}t.forOwn=i;function s(U,ee){return a(r(U),ce=>ee(U[ce],ce)),U}t.forOwnOfNonArray=s;function o(U,ee){return Array.isArray(U)?a(U,ee):s(U,ee),U}t.forEach=o;function a(U,ee){for(let ce=0,de=U.length;ce{const ot=U[Pe];ot instanceof Object&&(de=l(e(ot),de)),U[Pe]=de});return U}t.merge=l;function f(U){return Array.isArray(U)||(U=r(U)),U.length===0}t.isEmpty=f,t.isFunction=U=>typeof U=="function",t.isUndefined=U=>U===void 0||U==="undefined";function h(U){return U==null||U==="undefined"||U==="null"}t.isNullOrUndefined=h,t.isObject=U=>Object.prototype.toString.call(U)==="[object Object]",t.isEmptyObject=U=>h(U)||t.isObject(U)&&f(U);function m(){return typeof globalThis.ngDevMode>"u"||!!globalThis.ngDevMode}t.isDevMode=m;function y(U){return typeof U=="number"&&!isNaN(U)}t.isValidNumber=y;function w(){}t.noop=w;function I(U){return U}t.identity=I;function E(U,ee){const ce=[];for(let de=0;deU+ce*de)}t.range=$;function S(U){return t.isObject(U)?U._id:String(U)}t.getMaybeId=S;function _(U){return U.filter(I)}t.compact=_;function O(U){return f(U)?U:Array.isArray(U)?_(U):Object.entries(U).filter(([,ee])=>!h(ee)&&!f(ee)).reduce((ee,[ce,de])=>({...ee,[ce]:de}),{})}t.compactObject=O;function z(){var U;return(U=localStorage.debug)==null?void 0:U.includes("@ngx-odm/rxdb")}t.isDevModeForced=z;function W(){return typeof __karma__<"u"&&!!__karma__||typeof jasmine<"u"&&!!jasmine||typeof jest<"u"&&!!jest||typeof Mocha<"u"&&!!Mocha}t.isTestEnvironment=W,t.logger={log:function(){const U="#8d2089";return W()||!m()||!z()?w:console.log.bind(console,"%c[DEBUG::@ngx-odm/rxdb]",`background:${U};color:#fff;padding:2px;font-size:normal;`)}(),table:function(){return W()||!m()||!z()?w:console.table.bind(console)}()};function Q(U="Event"){return function(ce){return m()?ce.pipe(Cy({next(de){t.logger.log(`observable:${U}:next:`,de)},error(de){t.logger.log(`observable:${U}:error:`,de.message)},complete(){t.logger.log(`observable:${U}:complete`)}})):ce}}t.debug=Q;function H(U=3,ee=1e4){return ce=>ce.pipe(aT({count:U,delay:(de,Pe)=>{const ot=Math.pow(2,Pe-1)*ee;return t.logger.log("replication:kinto:longpoll:retry",Pe,ot),IE(ot)}}))}t.retryWithBackoff=H,t.tapOnce=U=>ee=>Ay(()=>(U(),ee)),t.deferUntil=U=>ee=>Ay(()=>U.pipe(Cl(()=>ee))),t.getDefaultQuery=()=>({selector:{_deleted:{$eq:!1}},skip:0,sort:[{id:"asc"}]});const X={properties:{id:{type:"string"},_deleted:{type:"boolean"}},primaryKey:"id",indexes:[["_deleted","id"]]};t.getDefaultQuery(),t.getDefaultPreparedQuery=()=>Jl(X,t.getDefaultQuery())})(Fr||(Fr={}));const LO=()=>typeof window=="object"&&"fetch"in window?window.fetch.bind(window):fetch;function bb(t){return t&&t instanceof $B}function Sb(t=!1){return Mt(e=>(Array.isArray(e)?e:[...e.values()]).map(n=>{const r={...n._data};return t||(delete r._rev,delete r._attachments,delete r._deleted,delete r._meta),r}))}const{debug:jB,isEmptyObject:UB,isFunction:zB}=Fr;function VB(t){return!UB(t)&&zB(t.run)}function Bu(t){return VB(t)?e=>new Ot(n=>e.subscribe(r=>t.run(()=>n.next(r)),r=>t.run(()=>n.error(r)),()=>t.run(()=>n.complete()))):e=>e}function tc(){return function(t,e,n){const r=n.value;return n.value=function(...i){return Ay(()=>this.initialized$.pipe(Cl(()=>r.apply(this,i)),jB(`collection.${e}`)))},n}}function kt(){return function(t,e,n){const r=n.value;return n.value=async function(...i){return await fT(this.initialized$).catch(()=>{throw new Error(`Collection "${this.config.name}" was not initialized. Please check RxDB errors.`)}),r.apply(this,i)},n}}var Ib,Eb,Ob,kb,Db,xb;const{getMaybeId:KB,logger:vm,debug:WB,noop:qB}=Fr;class Je{get initialized$(){return this._init$.asObservable()}get collection(){return this._collection}get db(){return this.dbService.db}get dbOptions(){return this.dbService.dbOptions}get replicationState(){return this._replicationState}get queryParams$(){var e;return(e=this.config.options)!=null&&e.useQueryParams?this.initialized$.pipe(Cl(()=>this.collection.queryParams.$)):im({})}constructor(e,n,r={},i=im(""),s=qB){this.config=e,this.dbService=n,this.ngZone=r,this.currentUrl$=i,this.updateQueryParamsFn=s,this._replicationState=null,this._init$=new TE,this.init(e)}destroy(){var e;(e=this.collection)==null||e.destroy()}setQueryParams(e){var n;(n=this.collection.queryParams)==null||n.set(e)}patchQueryParams(e){var n;(n=this.collection.queryParams)==null||n.patch(e)}async sync(){var e;if(bb(this.replicationState)){this.replicationState.reSync();return}if(typeof((e=this.config.options)==null?void 0:e.replicationStateFactory)=="function"){try{this._replicationState=this.config.options.replicationStateFactory(this.collection)}catch(n){vm.log("replicationState has error, ignore replication"),vm.log(n.message)}if(bb(this.replicationState))return this.replicationState.autoStart||this.replicationState.reSync(),Py(window,"online").pipe(WB("online"),ME(()=>!this.replicationState.isStopped())).subscribe(()=>{this._replicationState.reSync()}),this.replicationState.startPromise}}async info(){return this.collection.getMetadata()}async import(e){const n=await this.collection.schema.hash,r={name:this.collection.name,schemaHash:n,docs:e};this.collection.importJSON(r)}async export(){return this.collection.exportJSON()}docs(e,n=!1){return(cT(e)?e:im(e)).pipe(Cl(r=>this.collection.find(r).$),Sb(n),Bu(this.ngZone),Pi(Ai))}docsByIds(e,n=!1){return this.collection.findByIds(e).$.pipe(Sb(n),Bu(this.ngZone),Pi(Ai))}count(e){return this.collection.count(e).$.pipe(Bu(this.ngZone),Pi(Ai))}get(e,n=!1){return this.collection.findOne(e).$.pipe(Mt(r=>r?r.toMutableJSON(n):null),Bu(this.ngZone),Pi(Ai))}async insert(e){return this.collection.insert(e)}async insertBulk(e){return this.collection.bulkInsert(e)}async upsert(e){return this.collection.upsert(e)}async upsertBulk(e){return this.collection.bulkUpsert(e)}async set(e,n){return this.collection.findOne(e).update({$set:n})}async updateBulk(e,n){return this.collection.find(e).update({$set:n})}async remove(e){const n=KB(e);return this.collection.findOne(n).remove()}async removeBulk(e){return Array.isArray(e)?this.collection.bulkRemove(e):{success:[...(await this.collection.find(e).remove().catch(()=>new Map)).values()],error:[]}}async clear(){return this.collection.remove()}async getAttachments(e){const n=await this.collection.findOne(e).exec();if(!n)return null;const r=n.allAttachments().map(i=>i.getData());return Promise.all(r)}async getAttachmentById(e,n){const r=await this.collection.findOne(e).exec();if(!r)return null;const i=r.getAttachment(n);return i?i.getData():null}async putAttachment(e,n){const r=await this.collection.findOne(e).exec();r&&await r.putAttachment(n)}async removeAttachment(e,n){const r=await this.collection.findOne(e).exec();if(!r)return;const i=r.getAttachment(n);i&&await i.remove()}async addHook(e,n,r=!1){this.collection[e](n,r)}async getLocal(e,n){const r=await this.collection.getLocal(e);return r?n?r==null?void 0:r.get(n):r==null?void 0:r.toJSON().data:null}getLocal$(e,n){return this.collection.getLocal$(e).pipe(Mt(r=>r?n?r.get(n):r.toJSON().data:null),Fo(),Bu(this.ngZone))}async insertLocal(e,n){await this.collection.insertLocal(e,n)}async upsertLocal(e,n){await this.collection.upsertLocal(e,n)}async setLocal(e,n,r){var s,o;const i=await this.collection.getLocal(e);await this.collection.upsertLocal(e,{...((o=(s=i==null?void 0:i.toJSON)==null?void 0:s.call(i))==null?void 0:o.data)||{},[n]:r})}async removeLocal(e){const n=await this.collection.getLocal(e);await(n==null?void 0:n.remove())}async init(e){var i,s,o,a;const{name:n,options:r}=e;try{await this.dbService.initCollections({[n]:e}),this._collection=this.db.collections[n],r!=null&&r.useQueryParams&&this.collection.queryParamsInit(this.currentUrl$,this.updateQueryParamsFn),this._init$.next(!0),this._init$.complete()}catch(l){if(l.message.includes("DM5")||l.message.includes("DB6")&&((i=l.parameters.previousSchema)==null?void 0:i.version)===((s=l.parameters.schema)==null?void 0:s.version))vm.log("Reload the page to fix the issue. The database is in a state where it can not be used."),await SO(this.db.name,this.db.storage),(a=(o=window==null?void 0:window.location)==null?void 0:o.reload)==null||a.call(o);else throw this._init$.complete(),l}}}tt([kt(),re("design:type",Function),re("design:paramtypes",[]),re("design:returntype",Promise)],Je.prototype,"sync",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[]),re("design:returntype",Promise)],Je.prototype,"info",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Array]),re("design:returntype",Promise)],Je.prototype,"import",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[]),re("design:returntype",Promise)],Je.prototype,"export",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[Object,Object]),re("design:returntype",Ot)],Je.prototype,"docs",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[Array,Object]),re("design:returntype",Ot)],Je.prototype,"docsByIds",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Ot)],Je.prototype,"count",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[String,Object]),re("design:returntype",Ot)],Je.prototype,"get",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Promise)],Je.prototype,"insert",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Array]),re("design:returntype",Promise)],Je.prototype,"insertBulk",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Promise)],Je.prototype,"upsert",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Array]),re("design:returntype",Promise)],Je.prototype,"upsertBulk",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,Object]),re("design:returntype",Promise)],Je.prototype,"set",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object,Object]),re("design:returntype",Promise)],Je.prototype,"updateBulk",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Promise)],Je.prototype,"remove",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[Object]),re("design:returntype",Promise)],Je.prototype,"removeBulk",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[]),re("design:returntype",Promise)],Je.prototype,"clear",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String]),re("design:returntype",Promise)],Je.prototype,"getAttachments",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,String]),re("design:returntype",Promise)],Je.prototype,"getAttachmentById",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,Object]),re("design:returntype",Promise)],Je.prototype,"putAttachment",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,String]),re("design:returntype",Promise)],Je.prototype,"removeAttachment",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[typeof(Ib=typeof Hook<"u"&&Hook)=="function"?Ib:Object,Object,Object]),re("design:returntype",Promise)],Je.prototype,"addHook",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,typeof(Eb=typeof K<"u"&&K)=="function"?Eb:Object]),re("design:returntype",Promise)],Je.prototype,"getLocal",null);tt([tc(),re("design:type",Function),re("design:paramtypes",[String,typeof(Ob=typeof K<"u"&&K)=="function"?Ob:Object]),re("design:returntype",Ot)],Je.prototype,"getLocal$",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,typeof(kb=typeof L<"u"&&L)=="function"?kb:Object]),re("design:returntype",Promise)],Je.prototype,"insertLocal",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,typeof(Db=typeof L<"u"&&L)=="function"?Db:Object]),re("design:returntype",Promise)],Je.prototype,"upsertLocal",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String,typeof(xb=typeof K<"u"&&K)=="function"?xb:Object,Object]),re("design:returntype",Promise)],Je.prototype,"setLocal",null);tt([kt(),re("design:type",Function),re("design:paramtypes",[String]),re("design:returntype",Promise)],Je.prototype,"removeLocal",null);var $O={exports:{}};(function(t,e){(function(n,r){t.exports=r()})(vw,function(){var n=function(u,c){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,p){d.__proto__=p}||function(d,p){for(var v in p)Object.prototype.hasOwnProperty.call(p,v)&&(d[v]=p[v])})(u,c)},r=function(){return(r=Object.assign||function(u){for(var c,d=1,p=arguments.length;d"u"||s.Promise||(s.Promise=Promise);var f=Object.getPrototypeOf,h={}.hasOwnProperty;function m(u,c){return h.call(u,c)}function y(u,c){typeof c=="function"&&(c=c(f(u))),(typeof Reflect>"u"?o:Reflect.ownKeys)(c).forEach(function(d){I(u,d,c[d])})}var w=Object.defineProperty;function I(u,c,d,p){w(u,c,l(d&&m(d,"get")&&typeof d.get=="function"?{get:d.get,set:d.set,configurable:!0}:{value:d,configurable:!0,writable:!0},p))}function E(u){return{from:function(c){return u.prototype=Object.create(c.prototype),I(u.prototype,"constructor",u),{extend:y.bind(null,u.prototype)}}}}var $=Object.getOwnPropertyDescriptor,S=[].slice;function _(u,c,d){return S.call(u,c,d)}function O(u,c){return c(u)}function z(u){if(!u)throw new Error("Assertion Failed")}function W(u){s.setImmediate?setImmediate(u):setTimeout(u,0)}function Q(u,c){if(typeof c=="string"&&m(u,c))return u[c];if(!c)return u;if(typeof c!="string"){for(var d=[],p=0,v=c.length;p"u"?[]:function(){var u=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[u,f(u),u];var c=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[c,f(c),u]}(),mu=Ur[0],lr=Ur[1],Ur=Ur[2],lr=lr&&lr.then,yu=mu&&mu.constructor,Kh=!!Ur,vu=function(u,c){gu.push([u,c]),pc&&(queueMicrotask(xx),pc=!1)},Wh=!0,pc=!0,Js=[],mc=[],qh=hu,Zi={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:et,pgp:!1,env:{},finalize:et},fe=Zi,gu=[],Xs=0,yc=[];function se(u){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this._lib=!1;var c=this._PSD=fe;if(typeof u!="function"){if(u!==pu)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&Qh(this,this._value))}this._state=null,this._value=null,++c.ref,function d(p,v){try{v(function(g){if(p._state===null){if(g===p)throw new TypeError("A promise cannot be resolved with itself.");var b=p._lib&&Ho();g&&typeof g.then=="function"?d(p,function(k,A){g instanceof se?g._then(k,A):g.then(k,A)}):(p._state=!0,p._value=g,V0(p)),b&&Qo()}},Qh.bind(null,p))}catch(g){Qh(p,g)}}(this,u)}var Hh={get:function(){var u=fe,c=_c;function d(p,v){var g=this,b=!u.global&&(u!==fe||c!==_c),k=b&&!ts(),A=new se(function(x,M){Yh(g,new z0(W0(p,u,b,k),W0(v,u,b,k),x,M,u))});return this._consoleTask&&(A._consoleTask=this._consoleTask),A}return d.prototype=pu,d},set:function(u){I(this,"then",u&&u.prototype===pu?Hh:{get:function(){return u},set:Hh.set})}};function z0(u,c,d,p,v){this.onFulfilled=typeof u=="function"?u:null,this.onRejected=typeof c=="function"?c:null,this.resolve=d,this.reject=p,this.psd=v}function Qh(u,c){var d,p;mc.push(c),u._state===null&&(d=u._lib&&Ho(),c=qh(c),u._state=!1,u._value=c,p=u,Js.some(function(v){return v._value===p._value})||Js.push(p),V0(u),d&&Qo())}function V0(u){var c=u._listeners;u._listeners=[];for(var d=0,p=c.length;d.",q0="String expected.",Go=[],Sc="__dbnames",Xh="readonly",Zh="readwrite";function to(u,c){return u?c?function(){return u.apply(this,arguments)&&c.apply(this,arguments)}:u:c}var H0={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function Ic(u){return typeof u!="string"||/\./.test(u)?function(c){return c}:function(c){return c[u]===void 0&&u in c&&delete(c=Pe(c))[u],c}}function Q0(){throw pe.Type()}function je(u,c){try{var d=Y0(u),p=Y0(c);if(d!==p)return d==="Array"?1:p==="Array"?-1:d==="binary"?1:p==="binary"?-1:d==="string"?1:p==="string"?-1:d==="Date"?1:p!=="Date"?NaN:-1;switch(d){case"number":case"Date":case"string":return cj+V&&F(j+C)})})}return F(0).then(function(){if(0=C})).length!==0?(M.forEach(function(F){B.push(function(){var j=R,V=F._cfg.dbschema;Pc(D,j,T),Pc(D,V,T),R=D._dbSchema=V;var q=up(j,V);q.add.forEach(function(te){lp(T,te[0],te[1].primKey,te[1].indexes)}),q.change.forEach(function(te){if(te.recreate)throw new pe.Upgrade("Not yet support for changing primary key");var he=T.objectStore(te.name);te.add.forEach(function(me){return Cc(he,me)}),te.change.forEach(function(me){he.deleteIndex(me.name),Cc(he,me)}),te.del.forEach(function(me){return he.deleteIndex(me)})});var Y=F._cfg.contentUpgrade;if(Y&&F._cfg.version>C){Dc(D,T),P._memoizedTables={};var ne=X(V);q.del.forEach(function(te){ne[te]=j[te]}),ap(D,[D.Transaction.prototype]),xc(D,[D.Transaction.prototype],o(ne),ne),P.schema=ne;var J,ie=Re(Y);return ie&&Yo(),q=se.follow(function(){var te;(J=Y(P))&&ie&&(te=ts.bind(null,null),J.then(te,te))}),J&&typeof J.then=="function"?se.resolve(J):q.then(function(){return J})}}),B.push(function(j){var V,q,Y=F._cfg.dbschema;V=Y,q=j,[].slice.call(q.db.objectStoreNames).forEach(function(ne){return V[ne]==null&&q.db.deleteObjectStore(ne)}),ap(D,[D.Transaction.prototype]),xc(D,[D.Transaction.prototype],D._storeNames,D._dbSchema),P.schema=D._dbSchema}),B.push(function(j){D.idbdb.objectStoreNames.contains("$meta")&&(Math.ceil(D.idbdb.version/10)===F._cfg.version?(D.idbdb.deleteObjectStore("$meta"),delete D._dbSchema.$meta,D._storeNames=D._storeNames.filter(function(V){return V!=="$meta"})):j.objectStore("$meta").put(F._cfg.version,"version"))})}),function F(){return B.length?se.resolve(B.shift()(P.idbtrans)).then(F):se.resolve()}().then(function(){iw(R,T)})):se.resolve();var D,C,P,T,B,R}).catch(b)):(o(v).forEach(function(M){lp(d,M,v[M].primKey,v[M].indexes)}),Dc(u,d),void se.follow(function(){return u.on.populate.fire(g)}).catch(b));var A,x})}function Ux(u,c){iw(u._dbSchema,c),c.db.version%10!=0||c.objectStoreNames.contains("$meta")||c.db.createObjectStore("$meta").add(Math.ceil(c.db.version/10-1),"version");var d=Ac(0,u.idbdb,c);Pc(u,u._dbSchema,c);for(var p=0,v=up(d,u._dbSchema).change;pMath.pow(2,62)?0:R.oldVersion,D=R<1,u.idbdb=B.result,g&&Ux(u,M),jx(u,R/10,M,P))},P),B.onsuccess=vt(function(){M=null;var R,F,j,V,q,Y=u.idbdb=B.result,ne=_(Y.objectStoreNames);if(0"u"?se.resolve():!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(C){function P(){return indexedDB.databases().finally(C)}A=setInterval(P,100),P()}).finally(function(){return clearInterval(A)}):Promise.resolve()).then(k)]).then(function(){return b(),c.onReadyBeingFired=[],se.resolve(dp(function(){return u.on.ready.fire(u.vip)})).then(function C(){if(0c.limit?C.length=c.limit:u.length===c.limit&&C.length=F.limit&&(!F.values||Y.req.values)&&Qx(Y.req.query.range,F.query.range)}),!1,j,V];case"count":return q=V.find(function(Y){return pw(Y.req.query.range,F.query.range)}),[q,!!q,j,V]}}(c,d,"query",g),M=x[0],D=x[1],C=x[2],P=x[3];return M&&D?M.obsSet=g.obsSet:(D=p.query(g).then(function(T){var B=T.result;if(M&&(M.res=B),b){for(var R=0,F=B.length;R{var o=(async()=>{var a=$e(n);a.autoOpen=!1;var l=new Qy(i,a),f={[Od]:XB(r),[QB]:"++sequence, id",[Ab]:"id"};return l.version(1).stores(f),await l.open(),{dexieDb:l,dexieTable:l[Od],dexieAttachmentsTable:l[Ab],booleanIndexes:ZB(r)}})();return Pb.set(i,s),Mf.set(s,0),o});return s}async function GB(t){var e=await t,n=Mf.get(t),r=n-1;r===0?(e.dexieDb.close(),Mf.delete(t)):Mf.set(t,r)}var Yy="__";function nc(t){var e=t.split(".");if(e.length>1)return e.map(r=>nc(r)).join(".");if(t.startsWith("|")){var n=t.substring(1);return Yy+n}else return t}function UO(t){var e=t.split(".");if(e.length>1)return e.map(r=>UO(r)).join(".");if(t.startsWith(Yy)){var n=t.substring(Yy.length);return"|"+n}else return t}function JB(t,e){return e&&(e=$e(e),e=Gy(e),t.forEach(n=>{var r=Ts(e,n),i=r?"1":"0";rE(e,n,i)}),e)}function zO(t,e){return e&&(e=$e(e),e=Jy(e),t.forEach(n=>{var r=Ts(e,n),i=r==="1";rE(e,n,i)}),e)}function Gy(t){if(!t||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(Array.isArray(t))return t.map(n=>Gy(n));if(typeof t=="object"){var e={};return Object.entries(t).forEach(([n,r])=>{typeof r=="object"&&(r=Gy(r)),e[nc(n)]=r}),e}}function Jy(t){if(!t||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(Array.isArray(t))return t.map(n=>Jy(n));if(typeof t=="object"){var e={};return Object.entries(t).forEach(([n,r])=>{(typeof r=="object"||Array.isArray(t))&&(r=Jy(r)),e[UO(n)]=r}),e}}function XB(t){var e=[],n=Fn(t.primaryKey);e.push([n]),e.push(["_deleted",n]),t.indexes&&t.indexes.forEach(s=>{var o=Ua(s);e.push(o)}),e.push(["_meta.lwt",n]),e.push(["_meta.lwt"]),e=e.map(s=>s.map(o=>nc(o)));var r=e.map(s=>s.length===1?s[0]:"["+s.join("+")+"]");r=r.filter((s,o,a)=>a.indexOf(s)===o);var i=r.join(", ");return i}async function Rb(t,e){var n=await t,r=await n.dexieTable.bulkGet(e);return r.map(i=>zO(n.booleanIndexes,i))}function of(t,e){return t+"||"+e}function ZB(t){var e=new Set,n=[];return t.indexes?(t.indexes.forEach(r=>{var i=Ua(r);i.forEach(s=>{if(!e.has(s)){e.add(s);var o=zi(t,s);o.type==="boolean"&&n.push(s)}})}),n.push("_deleted"),AP(n)):n}function Tb(t){return t===li?-1/0:t}function Mb(t,e,n){if(t.includes(e)){var r=n===Ar||n===!0?"1":"0";return r}else return n}function VO(t,e,n){if(!n){if(typeof window>"u")throw new Error("IDBKeyRange missing");n=window.IDBKeyRange}var r=e.startKeys.map((o,a)=>{var l=e.index[a];return Mb(t,l,o)}).map(Tb),i=e.endKeys.map((o,a)=>{var l=e.index[a];return Mb(t,l,o)}).map(Tb),s=n.bound(r,i,!e.inclusiveStart,!e.inclusiveEnd);return s}async function Nb(t,e){var n=await t.internals,r=e.query,i=r.skip?r.skip:0,s=r.limit?r.limit:1/0,o=i+s,a=e.queryPlan,l=!1;a.selectorSatisfiedByIndex||(l=Oh(t.schema,e.query));var f=VO(n.booleanIndexes,a,n.dexieDb._options.IDBKeyRange),h=a.index,m=[];if(await n.dexieDb.transaction("r",n.dexieTable,async w=>{var I=w.idbtrans,E=I.objectStore(Od),$,S;S="["+h.map(O=>nc(O)).join("+")+"]",$=E.index(S);var _=$.openCursor(f);await new Promise(O=>{_.onsuccess=function(z){var W=z.target.result;if(W){var Q=zO(n.booleanIndexes,W.value);(!l||l(Q))&&m.push(Q),a.sortSatisfiedByIndex&&m.length===o?O():W.continue()}else O()}})}),!a.sortSatisfiedByIndex){var y=Lg(t.schema,e.query);m=m.sort(y)}return m=m.slice(i,o),{documents:m}}async function eF(t,e){var n=await t.internals,r=e.queryPlan,i=r.index,s=VO(n.booleanIndexes,r,n.dexieDb._options.IDBKeyRange),o=-1;return await n.dexieDb.transaction("r",n.dexieTable,async a=>{var l=a.idbtrans,f=l.objectStore(Od),h,m;m="["+i.map(w=>nc(w)).join("+")+"]",h=f.index(m);var y=h.count(s);o=await new Promise((w,I)=>{y.onsuccess=function(){w(y.result)},y.onerror=E=>I(E)})}),o}var tF=Ft(),nF=function(){function t(n,r,i,s,o,a,l){this.changes$=new Kt,this.instanceId=tF++,this.storage=n,this.databaseName=r,this.collectionName=i,this.schema=s,this.internals=o,this.options=a,this.settings=l,this.primaryPath=Fn(this.schema.primaryKey)}var e=t.prototype;return e.bulkWrite=async function(r,i){oo(this),r.forEach(h=>{if(!h.document._rev||h.previous&&!h.previous._rev)throw le("SNH",{args:{row:h}})});var s=await this.internals,o={success:[],error:[]},a=r.map(h=>h.document[this.primaryPath]),l;if(await s.dexieDb.transaction("rw",s.dexieTable,s.dexieAttachmentsTable,async()=>{var h=new Map,m=await Rb(this.internals,a);m.forEach(I=>{var E=I;return E&&h.set(E[this.primaryPath],E),E}),l=iO(this,this.primaryPath,h,r,i),o.error=l.errors;var y=[];l.bulkInsertDocs.forEach(I=>{o.success.push(I.document),y.push(I.document)}),l.bulkUpdateDocs.forEach(I=>{o.success.push(I.document),y.push(I.document)}),y=y.map(I=>JB(s.booleanIndexes,I)),y.length>0&&await s.dexieTable.bulkPut(y);var w=[];l.attachmentsAdd.forEach(I=>{w.push({id:of(I.documentId,I.attachmentId),data:I.attachmentData.data})}),l.attachmentsUpdate.forEach(I=>{w.push({id:of(I.documentId,I.attachmentId),data:I.attachmentData.data})}),await s.dexieAttachmentsTable.bulkPut(w),await s.dexieAttachmentsTable.bulkDelete(l.attachmentsRemove.map(I=>of(I.documentId,I.attachmentId)))}),l=ye(l),l.eventBulk.events.length>0){var f=ye(l.newestRow).document;l.eventBulk.checkpoint={id:f[this.primaryPath],lwt:f._meta.lwt},l.eventBulk.endTime=Ft(),this.changes$.next(l.eventBulk)}return o},e.findDocumentsById=async function(r,i){oo(this);var s=await this.internals,o=[];return await s.dexieDb.transaction("r",s.dexieTable,async()=>{var a=await Rb(this.internals,r);a.forEach(l=>{l&&(!l._deleted||i)&&o.push(l)})}),o},e.query=function(r){return oo(this),Nb(this,r)},e.count=async function(r){if(r.queryPlan.selectorSatisfiedByIndex){var i=await eF(this,r);return{count:i,mode:"fast"}}else{var s=await Nb(this,r);return{count:s.documents.length,mode:"slow"}}},e.changeStream=function(){return oo(this),this.changes$.asObservable()},e.cleanup=async function(r){oo(this);var i=await this.internals;return await i.dexieDb.transaction("rw",i.dexieTable,async()=>{var s=Ft()-r,o=await i.dexieTable.where("_meta.lwt").below(s).toArray(),a=[];o.forEach(l=>{l._deleted==="1"&&a.push(l[this.primaryPath])}),await i.dexieTable.bulkDelete(a)}),!0},e.getAttachmentData=async function(r,i,s){oo(this);var o=await this.internals,a=of(r,i);return await o.dexieDb.transaction("r",o.dexieAttachmentsTable,async()=>{var l=await o.dexieAttachmentsTable.get(a);if(l)return l.data;throw new Error("attachment missing documentId: "+r+" attachmentId: "+i)})},e.remove=async function(){oo(this);var r=await this.internals;return await r.dexieTable.clear(),this.close()},e.close=function(){return this.closed?this.closed:(this.closed=(async()=>{this.changes$.complete(),await GB(this.internals)})(),this.closed)},e.conflictResultionTasks=function(){return new Kt},e.resolveConflictResultionTask=async function(r){},t}();async function rF(t,e,n){var r=YB(e.databaseName,e.collectionName,n,e.schema),i=new nF(t,e.databaseName,e.collectionName,e.schema,r,e.options,n);return await NB(jO,e,i),Promise.resolve(i)}function oo(t){if(t.closed)throw new Error("RxStorageInstanceDexie is closed "+t.databaseName+"-"+t.collectionName)}var iF=function(){function t(n){this.name=jO,this.rxdbVersion=gg,this.settings=n}var e=t.prototype;return e.createStorageInstance=function(r){return sO(r),rF(this,r,this.settings)},t}();function sF(t={}){var e=new iF(t);return e}function oF(t,e,n,r,i){for(var s=i+1;r<=i;){var o=r+i>>>1,a=t[o],l=n!==void 0?n(a,e):a-e;l>=0?(s=o,i=o-1):r=o+1}return s}function aF(t,e,n,r,i){for(var s=i+1;r<=i;){var o=r+i>>>1,a=t[o],l=n!==void 0?n(a,e):a-e;l>0?(s=o,i=o-1):r=o+1}return s}function uF(t,e,n,r,i){for(var s=r-1;r<=i;){var o=r+i>>>1,a=t[o],l=n!==void 0?n(a,e):a-e;l<0?(s=o,r=o+1):i=o-1}return s}function lF(t,e,n,r,i){for(var s=r-1;r<=i;){var o=r+i>>>1,a=t[o],l=n!==void 0?n(a,e):a-e;l<=0?(s=o,r=o+1):i=o-1}return s}function cF(t,e,n,r,i){for(;r<=i;){var s=r+i>>>1,o=t[s],a=n!==void 0?n(o,e):o-e;if(a===0)return s;a<=0?r=s+1:i=s-1}return-1}function rc(t,e,n,r,i,s){return typeof n=="function"?s(t,e,n,r===void 0?0:r|0,i===void 0?t.length-1:i|0):s(t,e,void 0,n===void 0?0:n|0,r===void 0?t.length-1:r|0)}function fF(t,e,n,r,i){return rc(t,e,n,r,i,oF)}function Bb(t,e,n,r,i){return rc(t,e,n,r,i,aF)}function dF(t,e,n,r,i){return rc(t,e,n,r,i,uF)}function hF(t,e,n,r,i){return rc(t,e,n,r,i,lF)}function KO(t,e,n,r,i){return rc(t,e,n,r,i,cF)}function WO(t,e,n){return[t,e,n].join("--memory--")}function af(t){if(t.internals.removed)throw new Error("removed")}function uf(t,e){return t+"||"+e}function pF(t,e){return t.indexString{var o=s.docsWithIndex,a=s.getIndexableString(r),l=KO(o,{indexString:a},rl);o.splice(l,1)})}function rl(t,e){var n=t.indexString,r=e.indexString;return nUa(i)):[];r.push(["_deleted","_meta.lwt",n]),r.forEach(i=>{t.byIndex[Xy(i)]={index:i,docsWithIndex:[],getIndexableString:FB(e,i)}})}function Xy(t){return t.join(",")}var Lb=new Set,vF=function(){function t(n,r,i,s,o,a,l){this.closed=!1,this.storage=n,this.databaseName=r,this.collectionName=i,this.schema=s,this.internals=o,this.options=a,this.settings=l,Lb.add(this),this.primaryPath=Fn(this.schema.primaryKey)}var e=t.prototype;return e.bulkWrite=function(r,i){this.ensurePersistence(),af(this);for(var s=this.internals,o=this.internals.documents,a=this.primaryPath,l=iO(this,a,o,r,i),f=l.errors,h=new Array(l.bulkInsertDocs.length),m=l.bulkInsertDocs,y=0;y{this.internals.ensurePersistenceIdlePromise=void 0,this.ensurePersistence()})),l.eventBulk.events.length>0){var O=ye(l.newestRow).document;l.eventBulk.checkpoint={id:O[a],lwt:O._meta.lwt},l.eventBulk.endTime=Ft(),dd.then(()=>{s.changes$.next(l.eventBulk)})}var z=Promise.resolve({success:h,error:f});return z},e.ensurePersistence=function(){if(this.internals.ensurePersistenceTask){var r=this.internals,i=this.internals.documents,s=this.primaryPath,o=this.internals.ensurePersistenceTask;this.internals.ensurePersistenceTask=void 0;for(var a=Object.values(this.internals.byIndex),l=o.bulkInsertDocs,f=0;f{_.set(uf(O.documentId,O.attachmentId),{writeData:O.attachmentData,digest:O.digest})}),this.schema.attachments&&(o.attachmentsUpdate.forEach(O=>{_.set(uf(O.documentId,O.attachmentId),{writeData:O.attachmentData,digest:O.digest})}),o.attachmentsRemove.forEach(O=>{_.delete(uf(O.documentId,O.attachmentId))}))}}},e.findDocumentsById=function(r,i){this.ensurePersistence();var s=this.internals.documents,o=[];if(s.size===0)return Promise.resolve(o);for(var a=0;az)break;var X=H.doc;(!f||f(X))&&W.push(X),W.length>=l&&!m&&(Q=!0),O++}if(m){var U=Lg(this.schema,r.query);W=W.sort(U)}return W=W.slice(o,l),Promise.resolve({documents:W})},e.count=async function(r){this.ensurePersistence();var i=await this.query(r);return{count:i.documents.length,mode:"fast"}},e.cleanup=function(r){this.ensurePersistence();for(var i=Ft()-r,s=["_deleted","_meta.lwt",this.primaryPath],o=Xy(s),a=this.internals.byIndex[o].docsWithIndex,l=vb(this.schema,s,[!0,0,""]),f=Bb(a,{indexString:l},rl),h=!1;!h;){var m=a[f];!m||m.doc._meta.lwt>i?h=!0:(mF(this.primaryPath,this.schema,this.internals,m.doc),f++)}return dd},e.getAttachmentData=function(r,i,s){this.ensurePersistence(),af(this);var o=uf(r,i),a=this.internals.attachments.get(o);if(!s||!a||a.digest!==s)throw new Error("attachment does not exist: "+o);return Promise.resolve(a.writeData.data)},e.changeStream=function(){return af(this),this.internals.changes$.asObservable()},e.remove=async function(){if(this.closed)throw new Error("closed");this.ensurePersistence(),af(this),this.internals.removed=!0,this.storage.collectionStates.delete(WO(this.databaseName,this.collectionName,this.schema.version)),await this.close()},e.close=function(){return Lb.delete(this),this.ensurePersistence(),this.closed||(this.closed=!0,this.internals.refCount=this.internals.refCount-1),un},e.conflictResultionTasks=function(){return this.internals.conflictResultionTasks$.asObservable()},e.resolveConflictResultionTask=function(r){return un},t}();function gF(t,e,n){var r=WO(e.databaseName,e.collectionName,e.schema.version),i=t.collectionStates.get(r);if(!i)i={id:su(5),schema:e.schema,removed:!1,refCount:1,documents:new Map,attachments:e.schema.attachments?new Map:void 0,byIndex:{},conflictResultionTasks$:new Kt,changes$:new Kt},yF(i,e.schema),t.collectionStates.set(r,i);else{if(e.devMode&&!Ka(i.schema,e.schema))throw new Error("storage was already created with a different schema");i.refCount=i.refCount+1}var s=new vF(t,e.databaseName,e.collectionName,e.schema,i,e.options,n);return Promise.resolve(s)}var wF=new Map;function $b(t={}){var e={name:"memory",rxdbVersion:gg,collectionStates:wF,createStorageInstance(n){sO(n);var r=Object.assign({},t,n.options);return gF(this,n,r)}};return e}function _F(t){let{name:e,options:n,storage:r,...i}=t;if(!r)switch(n.storageType){case"dexie":r=sF(n.storageOptions);break;case"memory":r=$b(n.storageOptions);break;default:r=$b(n.storageOptions);break}return{name:e,storage:r,options:n,...i}}const bF=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,jb=t=>{if(typeof t!="string")throw new TypeError("Invalid argument expected string");const e=t.match(bF);if(!e)throw new Error(`Invalid argument not valid semver ('${t}' received)`);return e.shift(),e},Ub=t=>t==="*"||t==="x"||t==="X",zb=t=>{const e=parseInt(t,10);return isNaN(e)?t:e},SF=(t,e)=>typeof t!=typeof e?[String(t),String(e)]:[t,e],IF=(t,e)=>{if(Ub(t)||Ub(e))return 0;const[n,r]=SF(zb(t),zb(e));return n>r?1:n{for(let n=0;n{const n=jb(t),r=jb(e),i=n.pop(),s=r.pop(),o=Vb(n,r);return o!==0?o:i&&s?Vb(i.split("."),s.split(".")):i||s?i?-1:1:0},OF=(t,e,n)=>{kF(n);const r=EF(t,e);return qO[n].includes(r)},qO={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},Kb=Object.keys(qO),kF=t=>{if(typeof t!="string")throw new TypeError(`Invalid operator type, expected string but got ${typeof t}`);if(Kb.indexOf(t)===-1)throw new Error(`Invalid operator, expected one of ${Kb.join("|")}`)},{logger:Yr,getDefaultPreparedQuery:DF}=Fr,Wb="storage-token|storageToken",Gg=async t=>{let e;try{const r=await LO()(t);if(r.ok)e=await r.json();else throw new Error(`Failed to fetch schema from "${t}", status: ${r.status}`)}catch{throw new Error(`Failed to fetch schema from "${t}"`)}return e},xF=async t=>{var e;try{const n={};for(const r in t){const i=t[r];!i.schema&&((e=i.options)!=null&&e.schemaUrl)&&(i.schema=await Gg(i.options.schemaUrl)),n[i.name]=i}return n}catch(n){throw new Error(n.message)}},CF=async(t,e)=>{let n;const i=await LO()(t);if(i.ok)n=await i.json();else throw new Error(`Failed to fetch db dump from "${t}", status: ${i.status}`);if(!e||!Object.keys(e).length)throw new Error("collections must be initialized before importing");for(const s of n.collections){const o=e[s.name];if(o)s.schemaHash=o.schema._hash;else throw new Error("no such collection as provided in dump")}return n},AF=async(t,e,n)=>{var s,o;let r={};if(t.name!=="dexie")return;const i=(s=await e.internals)==null?void 0:s.dexieTable;if(r=(o=await i.get(Wb))==null?void 0:o.data,!(r!=null&&r.rxdbVersion)||OF(n,r.rxdbVersion,">"))try{await i.update(Wb,{data:{...r,rxdbVersion:n}}),Yr.log("prepare-plugin: migrated internal storage to",n)}catch{throw new Error("prepare-plugin: unable to migrate internal storage")}},PF=async({database:t,creator:e})=>{var o;const n=await IO(t);Yr.log("prepare-plugin: hook:createRxDatabase:after");const{storage:r,internalStore:i,rxdbVersion:s}=t;if(await AF(r,i,s),!(!((o=e.options)!=null&&o.dumpPath)||!n))try{const a=await CF(e.options.dumpPath,t.collections);await t.importJSON(a),Yr.log(`prepare-plugin: imported dump for db "${t.name}"`)}catch(a){Yr.log("prepare-plugin: imported dump error",a)}},RF=async t=>{if(typeof t=="string"){const e=await Gg(t);if(!e)throw new Error(`Failed to fetch schema from "${t}"`);t=e}},TF=async({collection:t,creator:e})=>{var l,f,h;Yr.log("prepare-plugin: hook:createRxCollection:before");const n=await t.getMetadata();Yr.log("prepare-plugin: hook:createRxCollection:before",n);const r=((l=e.options)==null?void 0:l.initialDocs)||[],i=await a();if(!r.length)return;if(i||!n.isFirstTimeInstantiated){if(!((f=e.options)!=null&&f.recreate)||(h=e.options)!=null&&h.replication)return;Yr.log(`prepare-plugin: collection "${t.name}" already has ${i} docs (including _deleted), but recreate option is set`)}const s=await t.schema.hash,o={name:t.name,schemaHash:s,docs:r};try{const{success:m,error:y}=await t.importJSON(o),w=await a();Yr.log(`prepare-plugin: imported ${m.length} docs for collection "${t.name}", errors count ${y.length}, current docs count ${w}`),Yr.table(m)}catch(m){Yr.log("prepare-plugin: imported dump error",m)}return;async function a(){const{count:m}=await t.storageInstance.count(DF()).catch(()=>({count:0}));return m}},MF={name:"prepare-plugin",rxdb:!0,prototypes:{RxDatabase:t=>{Object.assign(t,{fetchSchema:Gg})},RxCollection:t=>{Object.assign(t,{getMetadata:async function(){const n=await IO(this.database),r=await Vg(this.database.internalStore),{id:i,data:s,_meta:o,_rev:a}=r.filter(l=>l.data.name===this.name).at(0)||{};return{id:i||this.name,databaseName:this.database.name,collectionName:(s==null?void 0:s.name)||this.name,storageName:this.storageInstance.originalStorageInstance.storage.name,last_modified:o!=null&&o.lwt?Math.floor(o==null?void 0:o.lwt):Date.now(),rev:a?Number(a==null?void 0:a.at(0)):1,isFirstTimeInstantiated:n}}})}},hooks:{createRxDatabase:{after:PF},preCreateRxSchema:{before:RF},createRxCollection:{after:TF}}};function HO(t,e){const n={};if(Array.isArray(e))for(const r of e){const i=Object.getOwnPropertyDescriptor(t,r);i!=null&&i.enumerable&&Object.defineProperty(n,r,i)}else for(const r of Reflect.ownKeys(t)){const i=Object.getOwnPropertyDescriptor(t,r);if(i.enumerable){const s=t[r];e(r,s,t)&&Object.defineProperty(n,r,i)}}return n}const QO="%[a-f0-9]{2}",qb=new RegExp("("+QO+")|([^%]+?)","gi"),Hb=new RegExp("("+QO+")+","gi");function Zy(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;const n=t.slice(0,e),r=t.slice(e);return Array.prototype.concat.call([],Zy(n),Zy(r))}function NF(t){try{return decodeURIComponent(t)}catch{let e=t.match(qb)||[];for(let n=1;nt==null,$F=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),ev=Symbol("encodeFragmentIdentifier");function jF(t){switch(t.arrayFormat){case"index":return e=>(n,r)=>{const i=n.length;return r===void 0||t.skipNull&&r===null||t.skipEmptyString&&r===""?n:r===null?[...n,[Nt(e,t),"[",i,"]"].join("")]:[...n,[Nt(e,t),"[",Nt(i,t),"]=",Nt(r,t)].join("")]};case"bracket":return e=>(n,r)=>r===void 0||t.skipNull&&r===null||t.skipEmptyString&&r===""?n:r===null?[...n,[Nt(e,t),"[]"].join("")]:[...n,[Nt(e,t),"[]=",Nt(r,t)].join("")];case"colon-list-separator":return e=>(n,r)=>r===void 0||t.skipNull&&r===null||t.skipEmptyString&&r===""?n:r===null?[...n,[Nt(e,t),":list="].join("")]:[...n,[Nt(e,t),":list=",Nt(r,t)].join("")];case"comma":case"separator":case"bracket-separator":{const e=t.arrayFormat==="bracket-separator"?"[]=":"=";return n=>(r,i)=>i===void 0||t.skipNull&&i===null||t.skipEmptyString&&i===""?r:(i=i===null?"":i,r.length===0?[[Nt(n,t),e,Nt(i,t)].join("")]:[[r,Nt(i,t)].join(t.arrayFormatSeparator)])}default:return e=>(n,r)=>r===void 0||t.skipNull&&r===null||t.skipEmptyString&&r===""?n:r===null?[...n,Nt(e,t)]:[...n,[Nt(e,t),"=",Nt(r,t)].join("")]}}function UF(t){let e;switch(t.arrayFormat){case"index":return(n,r,i)=>{if(e=/\[(\d*)]$/.exec(n),n=n.replace(/\[\d*]$/,""),!e){i[n]=r;return}i[n]===void 0&&(i[n]={}),i[n][e[1]]=r};case"bracket":return(n,r,i)=>{if(e=/(\[])$/.exec(n),n=n.replace(/\[]$/,""),!e){i[n]=r;return}if(i[n]===void 0){i[n]=[r];return}i[n]=[...i[n],r]};case"colon-list-separator":return(n,r,i)=>{if(e=/(:list)$/.exec(n),n=n.replace(/:list$/,""),!e){i[n]=r;return}if(i[n]===void 0){i[n]=[r];return}i[n]=[...i[n],r]};case"comma":case"separator":return(n,r,i)=>{const s=typeof r=="string"&&r.includes(t.arrayFormatSeparator),o=typeof r=="string"&&!s&&Oi(r,t).includes(t.arrayFormatSeparator);r=o?Oi(r,t):r;const a=s||o?r.split(t.arrayFormatSeparator).map(l=>Oi(l,t)):r===null?r:Oi(r,t);i[n]=a};case"bracket-separator":return(n,r,i)=>{const s=/(\[])$/.test(n);if(n=n.replace(/\[]$/,""),!s){i[n]=r&&Oi(r,t);return}const o=r===null?[]:r.split(t.arrayFormatSeparator).map(a=>Oi(a,t));if(i[n]===void 0){i[n]=o;return}i[n]=[...i[n],...o]};default:return(n,r,i)=>{if(i[n]===void 0){i[n]=r;return}i[n]=[...[i[n]].flat(),r]}}}function GO(t){if(typeof t!="string"||t.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Nt(t,e){return e.encode?e.strict?$F(t):encodeURIComponent(t):t}function Oi(t,e){return e.decode?FF(t):t}function JO(t){return Array.isArray(t)?t.sort():typeof t=="object"?JO(Object.keys(t)).sort((e,n)=>Number(e)-Number(n)).map(e=>t[e]):t}function XO(t){const e=t.indexOf("#");return e!==-1&&(t=t.slice(0,e)),t}function zF(t){let e="";const n=t.indexOf("#");return n!==-1&&(e=t.slice(n)),e}function Qb(t,e){return e.parseNumbers&&!Number.isNaN(Number(t))&&typeof t=="string"&&t.trim()!==""?t=Number(t):e.parseBooleans&&t!==null&&(t.toLowerCase()==="true"||t.toLowerCase()==="false")&&(t=t.toLowerCase()==="true"),t}function Jg(t){t=XO(t);const e=t.indexOf("?");return e===-1?"":t.slice(e+1)}function Xg(t,e){e={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,...e},GO(e.arrayFormatSeparator);const n=UF(e),r=Object.create(null);if(typeof t!="string"||(t=t.trim().replace(/^[?#&]/,""),!t))return r;for(const i of t.split("&")){if(i==="")continue;const s=e.decode?i.replace(/\+/g," "):i;let[o,a]=YO(s,"=");o===void 0&&(o=s),a=a===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?a:Oi(a,e),n(Oi(o,e),a,r)}for(const[i,s]of Object.entries(r))if(typeof s=="object"&&s!==null)for(const[o,a]of Object.entries(s))s[o]=Qb(a,e);else r[i]=Qb(s,e);return e.sort===!1?r:(e.sort===!0?Object.keys(r).sort():Object.keys(r).sort(e.sort)).reduce((i,s)=>{const o=r[s];return o&&typeof o=="object"&&!Array.isArray(o)?i[s]=JO(o):i[s]=o,i},Object.create(null))}function ZO(t,e){if(!t)return"";e={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...e},GO(e.arrayFormatSeparator);const n=o=>e.skipNull&&LF(t[o])||e.skipEmptyString&&t[o]==="",r=jF(e),i={};for(const[o,a]of Object.entries(t))n(o)||(i[o]=a);const s=Object.keys(i);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{const a=t[o];return a===void 0?"":a===null?Nt(o,e):Array.isArray(a)?a.length===0&&e.arrayFormat==="bracket-separator"?Nt(o,e)+"[]":a.reduce(r(o),[]).join("&"):Nt(o,e)+"="+Nt(a,e)}).filter(o=>o.length>0).join("&")}function ek(t,e){var i;e={decode:!0,...e};let[n,r]=YO(t,"#");return n===void 0&&(n=t),{url:((i=n==null?void 0:n.split("?"))==null?void 0:i[0])??"",query:Xg(Jg(t),e),...e&&e.parseFragmentIdentifier&&r?{fragmentIdentifier:Oi(r,e)}:{}}}function tk(t,e){e={encode:!0,strict:!0,[ev]:!0,...e};const n=XO(t.url).split("?")[0]||"",r=Jg(t.url),i={...Xg(r,{sort:!1}),...t.query};let s=ZO(i,e);s&&(s=`?${s}`);let o=zF(t.url);if(t.fragmentIdentifier){const a=new URL(n);a.hash=t.fragmentIdentifier,o=e[ev]?a.hash:`#${t.fragmentIdentifier}`}return`${n}${s}${o}`}function nk(t,e,n){n={parseFragmentIdentifier:!0,[ev]:!1,...n};const{url:r,query:i,fragmentIdentifier:s}=ek(t,n);return tk({url:r,query:HO(i,e),fragmentIdentifier:s},n)}function VF(t,e,n){const r=Array.isArray(e)?i=>!e.includes(i):(i,s)=>!e(i,s);return nk(t,r,n)}const gm=Object.freeze(Object.defineProperty({__proto__:null,exclude:VF,extract:Jg,parse:Xg,parseUrl:ek,pick:nk,stringify:ZO,stringifyUrl:tk},Symbol.toStringTag,{value:"Module"})),{keys:Yb,isEmpty:Gb,isNullOrUndefined:tv}=Fr,KF=({selector:t,sort:e,limit:n,skip:r},i)=>{const s=Yb(i.jsonSchema.properties);return Gb(t)||(t=HO(t,o=>!o.startsWith("$")&&!o.includes(".")&&s.includes(o))),Gb(e)||(e=e==null?void 0:e.filter(o=>s.includes(Yb(o)[0]))),(tv(n)||isNaN(n))&&(n=void 0),(tv(r)||isNaN(r))&&(r=void 0),{selector:t,sort:e,limit:n,skip:r}},Jb=(t,e)=>{t=gm.extract(t);const n=gm.pick(t,["selector","sort","limit","skip"]),r=gm.parse(n,{parseNumbers:!0,parseBooleans:!0}),{selector:i,sort:s,limit:o,skip:a}=r,l=i?JSON.parse(i):void 0,f=s?JSON.parse(s):void 0;return KF({selector:l,sort:f,limit:o,skip:a},e)},lf=t=>tv(t)?"":JSON.stringify(t),{logger:Xb,compactObject:WF}=Fr,qF={name:"query-params-plugin",rxdb:!0,prototypes:{RxCollection:t=>{const e=new Jr({});let n=!1,r,i=!1,s="",o=()=>Promise.resolve(!1);function a(h=PE,m){var y;n=!!((y=this.options)!=null&&y.useQueryParams),r=this.schema,!(!n||i)&&(o=m,h.pipe(Fo(),Cy(w=>{s=w}),Mt(w=>Jb(w,r)),OE(w=>(Xb.log("Error in parsing url to mango query",w),e)),Cy(w=>{Xb.log("queryParams",w)}),ME(()=>!this.destroyed)).subscribe(e),i=!0)}function l(h){if(!n)return;const{selector:m,sort:y,limit:w,skip:I}=h,E={limit:w,skip:I};m&&(E.selector=lf(h.selector)),y&&(E.sort=lf(h.sort)),o(E)}function f(h){if(!n)return;const m=Jb(s,r),y={selector:lf(h.selector||m.selector),sort:lf(h.sort||m.sort),limit:h.limit||m.limit,skip:h.skip||m.skip};o(WF(y))}Object.assign(t,{queryParams:{$:e.asObservable(),get:()=>e.getValue(),set:l,patch:f}},{queryParamsInit:a})}},hooks:{createRxCollection:{}}};var rk={minimumDeletedTime:1e3*60*60*24*31,minimumCollectionAge:1e3*60,runEach:1e3*60*5,awaitReplicationsInSync:!0,waitForLeadership:!0},wm=dd;async function HF(t){var e=t.database,n=Object.assign({},rk,e.cleanupPolicy?e.cleanupPolicy:{});await t.promiseWait(n.minimumCollectionAge),!t.destroyed&&(n.waitForLeadership&&await e.waitForLeadership(),!t.destroyed&&(await ik(t,n),await QF(t,n)))}async function ik(t,e){for(var n=t.database,r=t.storageInstance,i=!1;!i&&!t.destroyed;){if(e.awaitReplicationsInSync){var s=FO.get(t);s&&await Promise.all(s.map(o=>{if(!o.isStopped())return o.awaitInSync()}))}if(await n.requestIdlePromise(),t.destroyed)return;wm=wm.then(()=>t.destroyed?!0:r.cleanup(e.minimumDeletedTime)),i=await wm}}async function QF(t,e){for(;!t.destroyed;){if(await t.promiseWait(e.runEach),t.destroyed)return;await ik(t,e)}}var YF={name:"cleanup",rxdb:!0,prototypes:{RxCollection:t=>{t.cleanup=async function(e){var n=Object.assign({},rk,this.database.cleanupPolicy?this.database.cleanupPolicy:{});typeof e>"u"&&(e=n.minimumDeletedTime);for(var r=!1;!r&&!this.destroyed;)r=await this.storageInstance.cleanup(e)}}},hooks:{createRxCollection:{after:t=>{HF(t.collection)}}}};function GF(t){var e={name:this.name,instanceToken:this.token,collections:[]},n=Object.keys(this.collections).filter(r=>!t||t.includes(r)).filter(r=>r.charAt(0)!=="_").map(r=>this.collections[r]);return Promise.all(n.map(r=>r.exportJSON())).then(r=>(e.collections=r,e))}var JF=function(t){var e=t.collections.filter(n=>!this.collections[n.name]).map(n=>n.name);if(e.length>0)throw le("JD1",{missingCollections:e});return Promise.all(t.collections.map(n=>this.collections[n.name].importJSON(n)))},XF=async function(){var t={name:this.name,schemaHash:await this.schema.hash,docs:[]},e=ra("find",tl(),this);return nO(e).then(n=>(t.docs=n.map(r=>(r=$e(r),delete r._rev,delete r._attachments,r)),t))};async function ZF(t){if(t.schemaHash!==await this.schema.hash)throw le("JD2",{schemaHash:t.schemaHash,own:this.schema.hash});var e=t.docs;return this.storageInstance.bulkWrite(e.map(n=>{var r=Object.assign({},n,{_meta:{lwt:Ft()},_rev:Rn(),_attachments:{},_deleted:!1});return{document:r}}),"json-dump-import")}var eL={name:"json-dump",rxdb:!0,prototypes:{RxDatabase:t=>{t.exportJSON=GF,t.importJSON=JF},RxCollection:t=>{t.exportJSON=XF,t.importJSON=ZF}},overwritable:{}},tL=uO(),nL=function(t){wg(e,t);function e(n,r,i){var s;return s=t.call(this,null,r)||this,s.id=n,s.parent=i,s}return e}(tL),il={get isLocal(){return!0},get allAttachments$(){throw le("LD1",{document:this})},get primaryPath(){return"id"},get primary(){return this.id},get $(){var t=this,e=Mo(nv,this.parent);return t.parent.$.pipe(lt(n=>n.documentId===this.primary),lt(n=>n.isLocal),Mt(n=>Dg(n)),Hl(e.docCache.getLatestDocumentData(this.primary)),Fo((n,r)=>n._rev===r._rev),Mt(n=>e.docCache.getCachedRxDocument(n)),Pi(Ai))},get $$(){var t=this,e=_m(t),n=e.getReactivityFactory();return n.fromObservable(t.$,t.getLatest()._data)},get deleted$$(){var t=this,e=_m(t),n=e.getReactivityFactory();return n.fromObservable(t.deleted$,t.getLatest().deleted)},getLatest(){var t=Mo(nv,this.parent),e=t.docCache.getLatestDocumentData(this.primary);return t.docCache.getCachedRxDocument(e)},get(t){if(t="data."+t,!!this._data){if(typeof t!="string")throw el("LD2",{objPath:t});var e=Ts(this._data,t);return e=it.deepFreezeWhenDevMode(e),e}},get$(t){if(t="data."+t,it.isDevMode()){if(t.includes(".item."))throw le("LD3",{objPath:t});if(t===this.primaryPath)throw le("LD4")}return this.$.pipe(Mt(e=>e._data),Mt(e=>Ts(e,t)),Fo())},get$$(t){var e=_m(this),n=e.getReactivityFactory();return n.fromObservable(this.get$(t),this.getLatest().get(t))},async incrementalModify(t){var e=await sl(this.parent);return e.incrementalWriteQueue.addWrite(this._data,async n=>(n.data=await t(n.data,this),n)).then(n=>e.docCache.getCachedRxDocument(n))},incrementalPatch(t){return this.incrementalModify(e=>(Object.entries(t).forEach(([n,r])=>{e[n]=r}),e))},async _saveData(t){var e=await sl(this.parent),n=this._data;return t.id=this.id,e.storageInstance.bulkWrite([{previous:n,document:t}],"local-document-save-data").then(r=>{var i=r.success[0];if(!i)throw r.error[0];t=$e(t),t._rev=i._rev})},async remove(){var t=await sl(this.parent),e={id:this._data.id,data:{},_deleted:!0,_meta:Ks(),_rev:Rn(),_attachments:{}};return Tl(t.storageInstance,{previous:this._data,document:e},"local-document-remove").then(n=>t.docCache.getCachedRxDocument(n))}},Zb=!1,rL=()=>{if(!Zb){Zb=!0;var t=kh,e=Object.getOwnPropertyNames(t);e.forEach(r=>{var i=Object.getOwnPropertyDescriptor(il,r);if(!i){var s=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(il,r,s)}});var n=r=>()=>{throw le("LD6",{functionName:r})};["populate","update","putAttachment","getAttachment","allAttachments"].forEach(r=>il[r]=n(r))}};function iL(t,e){rL();var n=new nL(t.id,t,e);return Object.setPrototypeOf(n,il),n.prototype=il,n}function _m(t){var e=t.parent;return bN(e)?e:e.database}var kd=new WeakMap,nv=new WeakMap;function e1(t){var e=t.database?t.database:t,n=t.database?t.name:"",r=(async()=>{var i=await sk(e.token,e.storage,e.name,n,e.instanceCreationOptions,e.multiInstance);i=jg(e,i,ok);var s=new XE("id",t.$.pipe(lt(h=>h.isLocal)),h=>iL(h,t)),o=new aO(i,"id",()=>{},()=>{}),a=await e.storageToken,l=i.changeStream().subscribe(h=>{var m={id:h.id,internal:!1,collectionName:t.database?t.name:void 0,storageToken:a,events:h.events.map(y=>rO(!0,y,t.database?t:void 0)),databaseToken:e.token,checkpoint:h.checkpoint,context:h.context,endTime:h.endTime,startTime:h.startTime};e.$emit(m)});t._subs.push(l);var f={database:e,parent:t,storageInstance:i,docCache:s,incrementalWriteQueue:o};return nv.set(t,f),f})();kd.set(t,r)}function sl(t){var e=kd.get(t);if(!e){var n=t.database?t.database:t,r=t.database?t.name:"";throw le("LD8",{database:n.name,collection:r})}return e}function sk(t,e,n,r,i,s){return e.createStorageInstance({databaseInstanceToken:t,databaseName:n,collectionName:sL(r),schema:ok,options:i,multiInstance:s,devMode:it.isDevMode()})}function t1(t){var e=kd.get(t);if(e)return kd.delete(t),e.then(n=>n.storageInstance.close())}async function n1(t,e,n){var r=su(10),i=await sk(r,t,e,n,{},!1);await i.remove()}function sL(t){return"plugin-local-documents-"+t}var ok=bh({title:"RxLocalDocument",version:0,primaryKey:"id",type:"object",properties:{id:{type:"string",maxLength:128},data:{type:"object",additionalProperties:!0}},required:["id","data"]});async function r1(t,e){var n=await sl(this),r={id:t,data:e,_deleted:!1,_meta:Ks(),_rev:Rn(),_attachments:{}};return Tl(n.storageInstance,{document:r},"local-document-insert").then(i=>n.docCache.getCachedRxDocument(i))}function i1(t,e){return this.getLocal(t).then(n=>{if(n)return n.incrementalModify(()=>e);var r=this.insertLocal(t,e);return r})}async function s1(t){var e=await sl(this),n=e.docCache,r=n.getLatestDocumentDataIfExists(t);return r?Promise.resolve(n.getCachedRxDocument(r)):Xl(e.storageInstance,t).then(i=>i?e.docCache.getCachedRxDocument(i):null)}function o1(t){return this.$.pipe(Hl(null),Br(async e=>{if(e)return{changeEvent:e};var n=await this.getLocal(t);return{doc:n}}),Br(async e=>{if(e.changeEvent){var n=e.changeEvent;if(!n.isLocal||n.documentId!==t)return{use:!1};var r=await this.getLocal(t);return{use:!0,doc:r}}else return{use:!0,doc:e.doc}}),lt(e=>e.use),Mt(e=>e.doc))}var ak={name:"local-documents",rxdb:!0,prototypes:{RxCollection:t=>{t.insertLocal=r1,t.upsertLocal=i1,t.getLocal=s1,t.getLocal$=o1},RxDatabase:t=>{t.insertLocal=r1,t.upsertLocal=i1,t.getLocal=s1,t.getLocal$=o1}},hooks:{createRxDatabase:{before:t=>{t.creator.localDocuments&&e1(t.database)}},createRxCollection:{before:t=>{t.creator.localDocuments&&e1(t.collection)}},preDestroyRxDatabase:{after:t=>t1(t)},postDestroyRxCollection:{after:t=>t1(t)},postRemoveRxDatabase:{after:t=>n1(t.storage,t.databaseName,"")},postRemoveRxCollection:{after:t=>n1(t.storage,t.databaseName,t.collectionName)}},overwritable:{}};async function uk(t){var e=dR(t.collection.schema.jsonSchema).map(r=>t.collection.name+"-"+r),n=await t.database.internalStore.findDocumentsById(e.map(r=>Qa(r,ko)),!1);if(n.length>1)throw new Error("more the one old collection meta found");return n[0]}function oL(t,e,n){var r=$e(n._attachments),i=Pn(n),s=i._meta;delete i._meta,i._attachments=r;for(var o=e+1,a=Promise.resolve(i),l=function(){var f=o;a=a.then(h=>aL(t,f,h)),o++};o<=t.schema.version;)l();return a.then(f=>f===null?yg:(f._meta=s,f))}function aL(t,e,n){if(n===null)return yg;var r=t.migrationStrategies[e](n,t),i=ZI(r);return i}async function lk(t){if(t.collection.schema.version===0)return Jn;var e=await uk(t);return!!e}var uL=200,ck=new WeakMap;function lL(t){var e=fk(t.database),n=e.getValue().slice(0);n.push(t),e.next(n)}function fk(t){return Mr(ck,t,()=>new Jr([]))}function cL(t){var e=ck.get(t);e&&e.complete()}var fL=function(){function t(n,r,i=[n.name,"v",n.schema.version].join("-")){this.started=!1,this.updateStatusHandlers=[],this.updateStatusQueue=dd,this.collection=n,this.migrationStrategies=r,this.statusDocKey=i,this.database=n.database,this.oldCollectionMeta=uk(this),this.mustMigrate=lk(this),this.statusDocId=Qa(this.statusDocKey,Pf),lL(this),this.$=K2(this.database.internalStore,this.statusDocId).pipe(lt(s=>!!s),Mt(s=>ye(s).data),Pi(Ai))}var e=t.prototype;return e.getStatus=function(){return As(this.$)},e.startMigration=async function(r=uL){var i=await this.mustMigrate;if(i){if(this.started)throw le("DM1");this.started=!0;var s=void 0;if(this.database.multiInstance){s=new xh(["rx-migration-state",this.database.name,this.collection.name,this.collection.schema.version].join("|"));var o=TB(s);await o.awaitLeadership()}var a=await this.oldCollectionMeta,l=await this.database.storage.createStorageInstance({databaseName:this.database.name,collectionName:this.collection.name,databaseInstanceToken:this.database.token,multiInstance:this.database.multiInstance,options:{},schema:a.data.schema,password:this.database.password,devMode:it.isDevMode()}),f=await this.getConnectedStorageInstances(),h=await this.countAllDoucments([l].concat(f.map(m=>m.oldStorage)));await this.updateStatus(m=>(m.count.total=h,m));try{await Promise.all(f.map(async m=>{await fO(this.collection,m.newStorage.collectionName,m.newStorage.schema),await this.migrateStorage(m.oldStorage,m.newStorage,r),await m.newStorage.close()})),await this.migrateStorage(l,this.collection.storageInstance.originalStorageInstance,r)}catch(m){await l.close(),await this.updateStatus(y=>(y.status="ERROR",y.error=ky(m),y));return}await Tl(this.database.internalStore,{previous:a,document:Object.assign({},a,{_deleted:!0})},"rx-migration-remove-collection-meta"),await this.updateStatus(m=>(m.status="DONE",m)),s&&await s.close()}},e.updateStatus=function(r){return this.updateStatusHandlers.push(r),this.updateStatusQueue=this.updateStatusQueue.then(async()=>{if(this.updateStatusHandlers.length!==0){var i=this.updateStatusHandlers;for(this.updateStatusHandlers=[];;){var s=await Xl(this.database.internalStore,this.statusDocId),o=Pn(s);s||(o={id:this.statusDocId,key:this.statusDocKey,context:Pf,data:{collectionName:this.collection.name,status:"RUNNING",count:{total:0,handled:0,percent:0}},_deleted:!1,_meta:Ks(),_rev:Rn(),_attachments:{}});var a=ye(o).data;for(var l of i)a=l(a);if(a.count.percent=Math.round(a.count.handled/a.count.total*100),o&&s&&Ka(o.data,s.data))break;try{await Tl(this.database.internalStore,{previous:s,document:ye(o)},Pf);break}catch(f){if(!_h(f))throw f}}}}),this.updateStatusQueue},e.migrateStorage=async function(r,i,s){var o=await this.database.storage.createStorageInstance({databaseName:this.database.name,collectionName:"rx-migration-state-meta-"+this.collection.name+"-"+this.collection.schema.version,databaseInstanceToken:this.database.token,multiInstance:this.database.multiInstance,options:{},schema:Ky(r.schema,vd(r.schema)),password:this.database.password,devMode:it.isDevMode()}),a=dN(i,bd,this.database.token,!0),l=pO({keepMeta:!0,identifier:["rx-migration-state",this.collection.name,r.schema.version,this.collection.schema.version].join("-"),replicationHandler:{masterChangesSince(){return Promise.resolve({checkpoint:null,documents:[]})},masterWrite:async h=>{h=await Promise.all(h.map(async y=>{var w=y.newDocumentState;if(i.schema.title===Rf&&(w=y.newDocumentState.docData,y.newDocumentState.isCheckpoint==="1"))return{assumedMasterState:void 0,newDocumentState:y.newDocumentState};var I=await oL(this.collection,r.schema.version,w),E={assumedMasterState:void 0,newDocumentState:i.schema.title===Rf?Object.assign({},y.newDocumentState,{docData:I}):I};return E})),h=h.filter(y=>!!y.newDocumentState);var m=await a.masterWrite(h);return m},masterChangeStream$:new Kt().asObservable()},forkInstance:r,metaInstance:o,pushBatchSize:s,pullBatchSize:0,conflictHandler:bd,hashFunction:this.database.hashFunction}),f=!1;if(l.events.error.subscribe(h=>f=h),l.events.processed.up.subscribe(()=>{this.updateStatus(h=>(h.count.handled=h.count.handled+1,h))}),await Tf(l),await mO(l),await this.updateStatusQueue,f)throw await o.close(),f;await Promise.all([r.remove(),o.remove()])},e.countAllDoucments=async function(r){var i=0;return await Promise.all(r.map(async s=>{var o=Jl(s.schema,Rl(s.schema,{selector:{}})),a=await s.count(o);i+=a.count})),i},e.getConnectedStorageInstances=async function(){var r=await this.oldCollectionMeta,i=[];return await Promise.all(await Promise.all(r.data.connectedStorages.map(async s=>{if(s.schema.title!==Rf)throw new Error("unknown migration handling for schema");var o=Ky(Pn(this.collection.schema.jsonSchema),vd(s.schema));o.version=this.collection.schema.version;var[a,l]=await Promise.all([this.database.storage.createStorageInstance({databaseInstanceToken:this.database.token,databaseName:this.database.name,devMode:it.isDevMode(),multiInstance:this.database.multiInstance,options:{},schema:s.schema,password:this.database.password,collectionName:s.collectionName}),this.database.storage.createStorageInstance({databaseInstanceToken:this.database.token,databaseName:this.database.name,devMode:it.isDevMode(),multiInstance:this.database.multiInstance,options:{},schema:o,password:this.database.password,collectionName:s.collectionName})]);i.push({oldStorage:a,newStorage:l})}))),i},e.migratePromise=async function(r){this.startMigration(r);var i=await this.mustMigrate;if(!i)return{status:"DONE",collectionName:this.collection.name,count:{handled:0,percent:0,total:0}};var s=await Promise.race([As(this.$.pipe(lt(o=>o.status==="DONE"))),As(this.$.pipe(lt(o=>o.status==="ERROR")))]);if(s.status==="ERROR")throw le("DM4",{collection:this.collection.name,error:s.error});return s},t}(),dL=new WeakMap,hL={name:"migration-schema",rxdb:!0,init(){gi(ak)},hooks:{preDestroyRxDatabase:{after:cL}},prototypes:{RxDatabase:t=>{t.migrationStates=function(){return fk(this).pipe(Pi(Ai))}},RxCollection:t=>{t.getMigrationState=function(){return Mr(dL,this,()=>new fL(this.asRxCollection,this.migrationStrategies))},t.migrationNeeded=function(){return this.schema.version===0?Jn:lk(this.getMigrationState())}}}};const Zg=(t,e)=>{switch(t){case"deep":return Ry(e);case"copy":return Ty(e)?new Date(e):Lt(e)?[...e]:wt(e)?Object.assign({},e):e;default:return e}},pL=/^[a-z]+[a-zA-Z0-9]*$/;function dk(t){if(!t.includes(".$"))return[{parent:t,selector:t},[]];const e=t.indexOf(".$"),n=t.indexOf("]"),r=t.substring(0,e),i=t.substring(e+3,n);Yt(i===""||pL.test(i),"The filter must begin with a lowercase letter and contain only alphanumeric characters.");const s=t.substring(n+2),[o,a]=s?dk(s):[];return[{selector:t,parent:r,child:i||"$",next:o},[i,...a||[]].filter(Boolean)]}const $n=(t,e,n,r,i)=>{const{parent:s,child:o,next:a}=e;if(!o){let f=!1;return Pl(t,s,(m,y)=>f=!!r(m,y)||f,i),f}const l=lu(t,s);return Lt(l)?l.map((f,h)=>n[o]&&!n[o].test({[o]:f})?!1:a?$n(f,a,n,r,i):r(l,h)).some(Boolean):!1};function ar(t,e,n,r){const i=[];for(const[s,o]of Object.entries(t)){const[a,l]=dk(s);if(!l.length)r(o,a,{})&&i.push(a.parent);else{const f={};e.forEach(m=>{Object.keys(m).forEach(y=>{l.forEach(w=>{(y===w||y.startsWith(w+"."))&&(f[w]=f[w]||{},Object.assign(f[w],{[y]:m[y]}))})})});const h={};for(const[m,y]of Object.entries(f))h[m]=new qs(y,n.queryOptions);r(o,a,h)&&i.push(a.parent)}}return i}const mL=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>{const a={$each:[i]};return wt(i)&&Zn(i,"$each")&&Object.assign(a,i),$n(t,s,o,(l,f)=>{const h=l[f]||(l[f]=[]);return Bg([h,a.$each]).length===a.$each.length?!1:(l[f]=Zg(r.cloneMode,EM(h.concat(a.$each))),!0)},{buildGraph:!0})}),yL=new Set(["and","or","xor"]),vL=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>{const a=Object.keys(i);return Yt(a.length===1&&yL.has(a[0]),`Invalid bit operator '${a[0]}'. Must be one of 'and', 'or', or 'xor'.`),$n(t,s,o,(l,f)=>{let h=l[f];const m=i[a[0]];if(h!==void 0&&!(Qn(h)&&Qn(m)))return!1;switch(h=h||0,a[0]){case"and":l[f]=h&m;break;case"or":l[f]=h|m;break;case"xor":l[f]=h^m;break}return l[f]!==h},{buildGraph:!0})}),gL=(t,e,n=[],r={})=>{const i=Date.now();return ar(e,n,r,(s,o,a)=>$n(t,o,a,(l,f)=>(l[f]=i,!0),{buildGraph:!0}))},wL=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>{if(!s.child){const a=lu(t,s.parent);Yt(a===void 0||Qn(a),"cannot apply $inc to a value of non-numeric type")}return $n(t,s,o,(a,l)=>(a[l]=(a[l]||(a[l]=0))+i,!0),{buildGraph:!0})}),_L=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>a[l]!==void 0&&Mn(a[l],i)>-1?!1:(a[l]=i,!0),{buildGraph:!0})),bL=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>a[l]!==void 0&&Mn(a[l],i)<1?!1:(a[l]=i,!0),{buildGraph:!0})),SL=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>{const f=a[l];return a[l]=a[l]===void 0?0:a[l]*i,a[l]!==f},{buildGraph:!0})),IL=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>{const f=a[l];return Yt(Lt(f),`path '${s.selector}' contains an element of non-array type.`),f.length?(i===-1?f.splice(0,1):f.pop(),!0):!1})),hk=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>{const a=!wt(i)||Object.keys(i).some(Wo),l=new qs(a?{k:i}:i,r.queryOptions),f=a?h=>l.test({k:h}):h=>l.test(h);return $n(t,s,o,(h,m)=>{const y=h[m],w=new Array;return y.map(E=>{const $=f(E);return $||w.push(E),$}).some(Boolean)?(h[m]=w,!0):!1})}),EL=(t,e,n=[],r={})=>{const i={};return Object.entries(e).forEach(([s,o])=>{i[s]={$in:o}}),hk(t,i,n,r)},OL=Object.freeze(["$each","$slice","$sort","$position"]),kL=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>{const a={$each:[i]};return wt(i)&&OL.some(l=>Zn(i,l))&&Object.assign(a,i),$n(t,s,o,(l,f)=>{const h=l[f]||(l[f]=[]),m=h.slice(0,a.$slice||h.length),y=h.length,w=Qn(a.$position)?a.$position:h.length;if(h.splice(w,0,...Zg(r.cloneMode,a.$each)),a.$sort){const I=wt(a.$sort)?Object.keys(a.$sort||{}).pop():"",E=I?a.$sort[I]:a.$sort,$=I?S=>lu(S,I):S=>S;h.sort((S,_)=>E*Mn($(S),$(_)))}return Qn(a.$slice)&&(a.$slice<0?h.splice(0,h.length+a.$slice):h.splice(a.$slice)),y!=h.length||!Wi(m,h)},{descendArray:!0,buildGraph:!0})}),pk=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>Wi(a[l],i)?!1:(a[l]=Zg(r.cloneMode,i),!0),{buildGraph:!0})),DL=(t,e,n=[],r={})=>{const i=[],s=ar(e,n,r,(o,a,l)=>$n(t,a,l,(f,h)=>Zn(f,h)?(i.push(...pk(t,{[o]:f[h]},n,r)),delete f[h],!0):!1));return Array.from(new Set(s.concat(i)))},xL=(t,e,n=[],r={})=>ar(e,n,r,(i,s,o)=>$n(t,s,o,(a,l)=>Zn(a,l)?(Lt(a)?a[l]=null:delete a[l],!0):!1)),a1=Object.freeze(Object.defineProperty({__proto__:null,$addToSet:mL,$bit:vL,$currentDate:gL,$inc:wL,$max:_L,$min:bL,$mul:SL,$pop:IL,$pull:hk,$pullAll:EL,$push:kL,$rename:DL,$set:pk,$unset:xL},Symbol.toStringTag,{value:"Module"}));function CL(t){return(e,n,r=[],i={},s={})=>{const o=Object.assign({cloneMode:"copy"},t,s);Object.assign(o,{queryOptions:Fg(Object.assign({useStrictMode:!1},o==null?void 0:o.queryOptions))}),r=r||[],i=i||{};const a=Object.entries(n);Yt(a.length===1,"Update expression must contain only one operator.");const[l,f]=a[0];Yt(Zn(a1,l),`Update operator '${l}' is not supported.`);const h=a1[l];return Object.keys(i).length&&!new qs(i,o.queryOptions).test(e)?[]:h(e,f,r,o)}}var bm;function mk(t,e){if(!bm){var n=CL({cloneMode:"none"});bm=(r,i)=>{var s=Pn(r);return n(s,i),s}}return bm(t,e)}function AL(t){return this.incrementalModify(e=>{var n=mk(e,t);return n})}function PL(t){var e=this._data,n=mk(e,t);return this._saveData(n,e)}function RL(t){return this.exec().then(e=>e?Array.isArray(e)?Promise.all(e.map(n=>n.update(t))).then(()=>e):e.update(t).then(()=>e):null)}var TL={name:"update",rxdb:!0,prototypes:{RxDocument:t=>{t.update=PL,t.incrementalUpdate=AL},RxQuery:t=>{t.update=RL}}};const{logger:ML}=Fr;async function NL(t=[]){try{gi(ak),gi(eL),gi(hL),gi(TL),gi(YF),gi(MF),gi(qF);for(const e of t)gi(e);ML.log("rxdb plugins loaded")}catch(e){throw new Error(e.message??e)}}const{logger:ta}=Fr;class BL{get db(){return this.dbInstance}get dbOptions(){return this.options}get collections(){return this.db.collections}async destroyDb(){try{await this.db.remove(),await this.db.destroy(),this.dbInstance=null,ta.log("database destroy")}catch{ta.log("database destroy error")}}async initDb(e){var n,r;if(!this.dbInstance)try{if(await NL((n=e.options)==null?void 0:n.plugins),this.dbInstance=await _N(e),this.options=e,ta.log(`created database "${this.db.name}" with config "${JSON.stringify(e)}"`),(r=e==null?void 0:e.options)!=null&&r.schemas){const i=await this.initCollections(e.options.schemas);ta.log(`created ${Object.keys(i).length} collections bulk: ${Object.keys(i)}`)}}catch(i){throw ta.log("Error initializing the database:",i),i}}async initCollections(e){try{const n=await xF(e);return await this.db.addCollections(n)}catch(n){throw ta.log("Error initializing collection(s)",n),n}}}var yk={exports:{}},Xe={};/** @license React v16.13.1 * react-is.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Gt=typeof Symbol=="function"&&Symbol.for,Zg=Gt?Symbol.for("react.element"):60103,e0=Gt?Symbol.for("react.portal"):60106,Ah=Gt?Symbol.for("react.fragment"):60107,Ch=Gt?Symbol.for("react.strict_mode"):60108,Ph=Gt?Symbol.for("react.profiler"):60114,Rh=Gt?Symbol.for("react.provider"):60109,Th=Gt?Symbol.for("react.context"):60110,t0=Gt?Symbol.for("react.async_mode"):60111,Mh=Gt?Symbol.for("react.concurrent_mode"):60111,Nh=Gt?Symbol.for("react.forward_ref"):60112,Bh=Gt?Symbol.for("react.suspense"):60113,BL=Gt?Symbol.for("react.suspense_list"):60120,Fh=Gt?Symbol.for("react.memo"):60115,Lh=Gt?Symbol.for("react.lazy"):60116,FL=Gt?Symbol.for("react.block"):60121,LL=Gt?Symbol.for("react.fundamental"):60117,$L=Gt?Symbol.for("react.responder"):60118,jL=Gt?Symbol.for("react.scope"):60119;function ar(t){if(typeof t=="object"&&t!==null){var e=t.$$typeof;switch(e){case Zg:switch(t=t.type,t){case t0:case Mh:case Ah:case Ph:case Ch:case Bh:return t;default:switch(t=t&&t.$$typeof,t){case Th:case Nh:case Lh:case Fh:case Rh:return t;default:return e}}case e0:return e}}}function yk(t){return ar(t)===Mh}Xe.AsyncMode=t0;Xe.ConcurrentMode=Mh;Xe.ContextConsumer=Th;Xe.ContextProvider=Rh;Xe.Element=Zg;Xe.ForwardRef=Nh;Xe.Fragment=Ah;Xe.Lazy=Lh;Xe.Memo=Fh;Xe.Portal=e0;Xe.Profiler=Ph;Xe.StrictMode=Ch;Xe.Suspense=Bh;Xe.isAsyncMode=function(t){return yk(t)||ar(t)===t0};Xe.isConcurrentMode=yk;Xe.isContextConsumer=function(t){return ar(t)===Th};Xe.isContextProvider=function(t){return ar(t)===Rh};Xe.isElement=function(t){return typeof t=="object"&&t!==null&&t.$$typeof===Zg};Xe.isForwardRef=function(t){return ar(t)===Nh};Xe.isFragment=function(t){return ar(t)===Ah};Xe.isLazy=function(t){return ar(t)===Lh};Xe.isMemo=function(t){return ar(t)===Fh};Xe.isPortal=function(t){return ar(t)===e0};Xe.isProfiler=function(t){return ar(t)===Ph};Xe.isStrictMode=function(t){return ar(t)===Ch};Xe.isSuspense=function(t){return ar(t)===Bh};Xe.isValidElementType=function(t){return typeof t=="string"||typeof t=="function"||t===Ah||t===Mh||t===Ph||t===Ch||t===Bh||t===BL||typeof t=="object"&&t!==null&&(t.$$typeof===Lh||t.$$typeof===Fh||t.$$typeof===Rh||t.$$typeof===Th||t.$$typeof===Nh||t.$$typeof===LL||t.$$typeof===$L||t.$$typeof===jL||t.$$typeof===FL)};Xe.typeOf=ar;mk.exports=Xe;var UL=mk.exports,n0=UL,zL={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},VL={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},KL={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},vk={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},r0={};r0[n0.ForwardRef]=KL;r0[n0.Memo]=vk;function a1(t){return n0.isMemo(t)?vk:r0[t.$$typeof]||zL}var WL=Object.defineProperty,qL=Object.getOwnPropertyNames,u1=Object.getOwnPropertySymbols,HL=Object.getOwnPropertyDescriptor,QL=Object.getPrototypeOf,l1=Object.prototype;function gk(t,e,n){if(typeof e!="string"){if(l1){var r=QL(e);r&&r!==l1&&gk(t,r,n)}var i=qL(e);u1&&(i=i.concat(u1(e)));for(var s=a1(t),o=a1(e),a=0;aDd.length&&Dd.push(t)}function nv(t,e,n,r){var i=typeof t;(i==="undefined"||i==="boolean")&&(t=null);var s=!1;if(t===null)s=!0;else switch(i){case"string":case"number":s=!0;break;case"object":switch(t.$$typeof){case ic:case n3:s=!0}}if(s)return n(r,t,e===""?"."+Sm(t,0):e),1;if(s=0,e=e===""?".":e+":",Array.isArray(t))for(var o=0;og3.decode(t),w3=new TextEncoder,l0=t=>w3.encode(t),[_4,_3]=(()=>{const t=()=>{throw new Error("BigInt is not available in this environment")};function e(){throw t()}return e.asIntN=()=>{throw t()},e.asUintN=()=>{throw t()},typeof BigInt<"u"?[BigInt,!0]:[e,!1]})(),[oc,b4]=(()=>{const t=()=>{throw new Error("BigInt64Array is not available in this environment")};class e{static get BYTES_PER_ELEMENT(){return 8}static of(){throw t()}static from(){throw t()}constructor(){throw t()}}return typeof BigInt64Array<"u"?[BigInt64Array,!0]:[e,!1]})(),[ac,S4]=(()=>{const t=()=>{throw new Error("BigUint64Array is not available in this environment")};class e{static get BYTES_PER_ELEMENT(){return 8}static of(){throw t()}static from(){throw t()}constructor(){throw t()}}return typeof BigUint64Array<"u"?[BigUint64Array,!0]:[e,!1]})(),b3=t=>typeof t=="number",Ck=t=>typeof t=="boolean",Ut=t=>typeof t=="function",Nn=t=>t!=null&&Object(t)===t,Ms=t=>Nn(t)&&Ut(t.then),uc=t=>Nn(t)&&Ut(t[Symbol.iterator]),fu=t=>Nn(t)&&Ut(t[Symbol.asyncIterator]),ov=t=>Nn(t)&&Nn(t.schema),Pk=t=>Nn(t)&&"done"in t&&"value"in t,Rk=t=>Nn(t)&&Ut(t.stat)&&b3(t.fd),Tk=t=>Nn(t)&&c0(t.body),$h=t=>"_getDOMStream"in t&&"_getNodeStream"in t,S3=t=>Nn(t)&&Ut(t.abort)&&Ut(t.getWriter)&&!$h(t),c0=t=>Nn(t)&&Ut(t.cancel)&&Ut(t.getReader)&&!$h(t),I3=t=>Nn(t)&&Ut(t.end)&&Ut(t.write)&&Ck(t.writable)&&!$h(t),Mk=t=>Nn(t)&&Ut(t.read)&&Ut(t.pipe)&&Ck(t.readable)&&!$h(t),E3=t=>Nn(t)&&Ut(t.clear)&&Ut(t.bytes)&&Ut(t.position)&&Ut(t.setPosition)&&Ut(t.capacity)&&Ut(t.getBufferIdentifier)&&Ut(t.createLong),f0=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function O3(t){const e=t[0]?[t[0]]:[];let n,r,i,s;for(let o,a,l=0,f=0,h=t.length;++lh+m.byteLength,0);let i,s,o,a=0,l=-1;const f=Math.min(e||Number.POSITIVE_INFINITY,r);for(const h=n.length;++lrt(Int32Array,t),Ue=t=>rt(Uint8Array,t),av=t=>(t.next(),t);function*k3(t,e){const n=function*(i){yield i},r=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof f0?n(e):uc(e)?e:n(e);return yield*av(function*(i){let s=null;do s=i.next(yield rt(t,s));while(!s.done)}(r[Symbol.iterator]())),new t}const D3=t=>k3(Uint8Array,t);function Nk(t,e){return kr(this,arguments,function*(){if(Ms(e))return yield ge(yield ge(yield*Df(Ds(Nk(t,yield ge(e))))));const r=function(o){return kr(this,arguments,function*(){yield yield ge(yield ge(o))})},i=function(o){return kr(this,arguments,function*(){yield ge(yield*Df(Ds(av(function*(a){let l=null;do l=a.next(yield l==null?void 0:l.value);while(!l.done)}(o[Symbol.iterator]())))))})},s=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof f0?r(e):uc(e)?i(e):fu(e)?e:r(e);return yield ge(yield*Df(Ds(av(function(o){return kr(this,arguments,function*(){let a=null;do a=yield ge(o.next(yield yield ge(rt(t,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield ge(new t)})}const x3=t=>Nk(Uint8Array,t);function d0(t,e,n){if(t!==0){n=n.slice(0,e+1);for(let r=-1;++r<=e;)n[r]+=t}return n}function A3(t,e){let n=0;const r=t.length;if(r!==e.length)return!1;if(r>0)do if(t[n]!==e[n])return!1;while(++n(t.next(),t);function*C3(t){let e,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?fi(r,o)[0]:([i,r,a]=fi(r,o),i)}({cmd:s,size:o}=yield null);const f=D3(t)[Symbol.iterator]();try{do if({done:e,value:i}=Number.isNaN(o-a)?f.next():f.next(o-a),!e&&i.byteLength>0&&(r.push(i),a+=i.byteLength),e||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(i.push(s),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield ge(f()));while(a0&&(i.push(Ue(s)),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield ge(f()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return ve(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(e).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(e){return ve(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=Ue(n)),n})}}const Im=(t,e)=>{const n=i=>r([e,i]);let r;return[e,n,new Promise(i=>(r=i)&&t.once(e,n))]};function M3(t){return kr(this,arguments,function*(){const n=[];let r="error",i=!1,s=null,o,a,l=0,f=[],h;function m(){return o==="peek"?fi(f,a)[0]:([h,f,l]=fi(f,a),h)}if({cmd:o,size:a}=yield yield ge(null),t.isTTY)return yield yield ge(new Uint8Array(0)),yield ge(null);try{n[0]=Im(t,"end"),n[1]=Im(t,"error");do{if(n[2]=Im(t,"readable"),[r,s]=yield ge(Promise.race(n.map(w=>w[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(a-l)?(h=Ue(t.read(a-l)),h.byteLength0&&(f.push(h),l+=h.byteLength)),i||a<=l)do({cmd:o,size:a}=yield yield ge(m()));while(a{for(const[S,_]of w)t.off(S,_);try{const S=t.destroy;S&&S.call(t,I),I=void 0}catch(S){I=S||I}finally{I!=null?F(I):E()}})}})}var Qn;(function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"})(Qn||(Qn={}));var er;(function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"})(er||(er={}));var Cn;(function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"})(Cn||(Cn={}));var Hi;(function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"})(Hi||(Hi={}));var ze;(function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"})(ze||(ze={}));var Ns;(function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(Ns||(Ns={}));var Ve;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var N;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"})(N||(N={}));var bi;(function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"})(bi||(bi={}));const N3=void 0;function Nl(t){if(t===null)return"null";if(t===N3)return"undefined";switch(typeof t){case"number":return`${t}`;case"bigint":return`${t}`;case"string":return`"${t}"`}return typeof t[Symbol.toPrimitive]=="function"?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof oc||t instanceof ac?`[${[...t].map(e=>Nl(e))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}`:n)}const B3=Symbol.for("isArrowBigNum");function Lr(t,...e){return e.length===0?Object.setPrototypeOf(rt(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}Lr.prototype[B3]=!0;Lr.prototype.toJSON=function(){return`"${xo(this)}"`};Lr.prototype.valueOf=function(){return Bk(this)};Lr.prototype.toString=function(){return xo(this)};Lr.prototype[Symbol.toPrimitive]=function(t="default"){switch(t){case"number":return Bk(this);case"string":return xo(this);case"default":return uv(this)}return xo(this)};function Da(...t){return Lr.apply(this,t)}function xa(...t){return Lr.apply(this,t)}function Bl(...t){return Lr.apply(this,t)}Object.setPrototypeOf(Da.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(xa.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Bl.prototype,Object.create(Uint32Array.prototype));Object.assign(Da.prototype,Lr.prototype,{constructor:Da,signed:!0,TypedArray:Int32Array,BigIntArray:oc});Object.assign(xa.prototype,Lr.prototype,{constructor:xa,signed:!1,TypedArray:Uint32Array,BigIntArray:ac});Object.assign(Bl.prototype,Lr.prototype,{constructor:Bl,signed:!0,TypedArray:Uint32Array,BigIntArray:ac});function Bk(t){const{buffer:e,byteOffset:n,length:r,signed:i}=t,s=new ac(e,n,r),o=i&&s[s.length-1]&BigInt(1)<t.byteLength===8?new t.BigIntArray(t.buffer,t.byteOffset,1)[0]:Em(t),xo=t=>t.byteLength===8?`${new t.BigIntArray(t.buffer,t.byteOffset,1)[0]}`:Em(t)):(xo=Em,uv=xo);function Em(t){let e="";const n=new Uint32Array(2);let r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const o=r.length-1;do{for(n[0]=r[s=0];s(t.children=null,t.ArrayType=Array,t[Symbol.toStringTag]="DataType"))(we.prototype);let Bs=class extends we{toString(){return"Null"}get typeId(){return N.Null}};Lk=Symbol.toStringTag;Bs[Lk]=(t=>t[Symbol.toStringTag]="Null")(Bs.prototype);class Fs extends we{constructor(e,n){super(),this.isSigned=e,this.bitWidth=n}get typeId(){return N.Int}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?oc:ac}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}$k=Symbol.toStringTag;Fs[$k]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Fs.prototype);class Fl extends Fs{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Fl.prototype,"ArrayType",{value:Int32Array});class Ll extends we{constructor(e){super(),this.precision=e}get typeId(){return N.Float}get ArrayType(){switch(this.precision){case Cn.HALF:return Uint16Array;case Cn.SINGLE:return Float32Array;case Cn.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}jk=Symbol.toStringTag;Ll[jk]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Ll.prototype);let xd=class extends we{constructor(){super()}get typeId(){return N.Binary}toString(){return"Binary"}};Uk=Symbol.toStringTag;xd[Uk]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(xd.prototype);let Ad=class extends we{constructor(){super()}get typeId(){return N.Utf8}toString(){return"Utf8"}};zk=Symbol.toStringTag;Ad[zk]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Ad.prototype);let Cd=class extends we{constructor(){super()}get typeId(){return N.Bool}toString(){return"Bool"}};Vk=Symbol.toStringTag;Cd[Vk]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(Cd.prototype);let Pd=class extends we{constructor(e,n,r=128){super(),this.scale=e,this.precision=n,this.bitWidth=r}get typeId(){return N.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};Kk=Symbol.toStringTag;Pd[Kk]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(Pd.prototype);class Rd extends we{constructor(e){super(),this.unit=e}get typeId(){return N.Date}toString(){return`Date${(this.unit+1)*32}<${Hi[this.unit]}>`}}Wk=Symbol.toStringTag;Rd[Wk]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"))(Rd.prototype);class $l extends we{constructor(e,n){super(),this.unit=e,this.bitWidth=n}get typeId(){return N.Time}toString(){return`Time${this.bitWidth}<${ze[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return oc}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}qk=Symbol.toStringTag;$l[qk]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))($l.prototype);class Td extends we{constructor(e,n){super(),this.unit=e,this.timezone=n}get typeId(){return N.Timestamp}toString(){return`Timestamp<${ze[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Hk=Symbol.toStringTag;Td[Hk]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"))(Td.prototype);class Md extends we{constructor(e){super(),this.unit=e}get typeId(){return N.Interval}toString(){return`Interval<${Ns[this.unit]}>`}}Qk=Symbol.toStringTag;Md[Qk]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(Md.prototype);let Nd=class extends we{constructor(e){super(),this.children=[e]}get typeId(){return N.List}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};Yk=Symbol.toStringTag;Nd[Yk]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(Nd.prototype);class pn extends we{constructor(e){super(),this.children=e}get typeId(){return N.Struct}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}Gk=Symbol.toStringTag;pn[Gk]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(pn.prototype);class Bd extends we{constructor(e,n,r){super(),this.mode=e,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}get typeId(){return N.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}Jk=Symbol.toStringTag;Bd[Jk]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(Bd.prototype);let Fd=class extends we{constructor(e){super(),this.byteWidth=e}get typeId(){return N.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};Xk=Symbol.toStringTag;Fd[Xk]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(Fd.prototype);let Ld=class extends we{constructor(e,n){super(),this.listSize=e,this.children=[n]}get typeId(){return N.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};Zk=Symbol.toStringTag;Ld[Zk]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(Ld.prototype);class $d extends we{constructor(e,n=!1){super(),this.children=[e],this.keysSorted=n}get typeId(){return N.Map}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}eD=Symbol.toStringTag;$d[eD]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))($d.prototype);const F3=(t=>()=>++t)(-1);class Qa extends we{constructor(e,n,r,i){super(),this.indices=n,this.dictionary=e,this.isOrdered=i||!1,this.id=r==null?F3():typeof r=="number"?r:r.low}get typeId(){return N.Dictionary}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}tD=Symbol.toStringTag;Qa[tD]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(Qa.prototype);function Si(t){const e=t;switch(t.typeId){case N.Decimal:return t.bitWidth/32;case N.Timestamp:return 2;case N.Date:return 1+e.unit;case N.Interval:return 1+e.unit;case N.FixedSizeList:return e.listSize;case N.FixedSizeBinary:return e.byteWidth;default:return 1}}class Be{visitMany(e,...n){return e.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,n=!0){return L3(this,e,n)}getVisitFnByTypeId(e,n=!0){return ia(this,e,n)}visitNull(e,...n){return null}visitBool(e,...n){return null}visitInt(e,...n){return null}visitFloat(e,...n){return null}visitUtf8(e,...n){return null}visitBinary(e,...n){return null}visitFixedSizeBinary(e,...n){return null}visitDate(e,...n){return null}visitTimestamp(e,...n){return null}visitTime(e,...n){return null}visitDecimal(e,...n){return null}visitList(e,...n){return null}visitStruct(e,...n){return null}visitUnion(e,...n){return null}visitDictionary(e,...n){return null}visitInterval(e,...n){return null}visitFixedSizeList(e,...n){return null}visitMap(e,...n){return null}}function L3(t,e,n=!0){return typeof e=="number"?ia(t,e,n):typeof e=="string"&&e in N?ia(t,N[e],n):e&&e instanceof we?ia(t,h1(e),n):e!=null&&e.type&&e.type instanceof we?ia(t,h1(e.type),n):ia(t,N.NONE,n)}function ia(t,e,n=!0){let r=null;switch(e){case N.Null:r=t.visitNull;break;case N.Bool:r=t.visitBool;break;case N.Int:r=t.visitInt;break;case N.Int8:r=t.visitInt8||t.visitInt;break;case N.Int16:r=t.visitInt16||t.visitInt;break;case N.Int32:r=t.visitInt32||t.visitInt;break;case N.Int64:r=t.visitInt64||t.visitInt;break;case N.Uint8:r=t.visitUint8||t.visitInt;break;case N.Uint16:r=t.visitUint16||t.visitInt;break;case N.Uint32:r=t.visitUint32||t.visitInt;break;case N.Uint64:r=t.visitUint64||t.visitInt;break;case N.Float:r=t.visitFloat;break;case N.Float16:r=t.visitFloat16||t.visitFloat;break;case N.Float32:r=t.visitFloat32||t.visitFloat;break;case N.Float64:r=t.visitFloat64||t.visitFloat;break;case N.Utf8:r=t.visitUtf8;break;case N.Binary:r=t.visitBinary;break;case N.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case N.Date:r=t.visitDate;break;case N.DateDay:r=t.visitDateDay||t.visitDate;break;case N.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case N.Timestamp:r=t.visitTimestamp;break;case N.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case N.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case N.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case N.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case N.Time:r=t.visitTime;break;case N.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case N.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case N.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case N.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case N.Decimal:r=t.visitDecimal;break;case N.List:r=t.visitList;break;case N.Struct:r=t.visitStruct;break;case N.Union:r=t.visitUnion;break;case N.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case N.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case N.Dictionary:r=t.visitDictionary;break;case N.Interval:r=t.visitInterval;break;case N.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case N.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case N.FixedSizeList:r=t.visitFixedSizeList;break;case N.Map:r=t.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${N[e]}'`)}function h1(t){switch(t.typeId){case N.Null:return N.Null;case N.Int:{const{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?N.Int8:N.Uint8;case 16:return n?N.Int16:N.Uint16;case 32:return n?N.Int32:N.Uint32;case 64:return n?N.Int64:N.Uint64}return N.Int}case N.Float:switch(t.precision){case Cn.HALF:return N.Float16;case Cn.SINGLE:return N.Float32;case Cn.DOUBLE:return N.Float64}return N.Float;case N.Binary:return N.Binary;case N.Utf8:return N.Utf8;case N.Bool:return N.Bool;case N.Decimal:return N.Decimal;case N.Time:switch(t.unit){case ze.SECOND:return N.TimeSecond;case ze.MILLISECOND:return N.TimeMillisecond;case ze.MICROSECOND:return N.TimeMicrosecond;case ze.NANOSECOND:return N.TimeNanosecond}return N.Time;case N.Timestamp:switch(t.unit){case ze.SECOND:return N.TimestampSecond;case ze.MILLISECOND:return N.TimestampMillisecond;case ze.MICROSECOND:return N.TimestampMicrosecond;case ze.NANOSECOND:return N.TimestampNanosecond}return N.Timestamp;case N.Date:switch(t.unit){case Hi.DAY:return N.DateDay;case Hi.MILLISECOND:return N.DateMillisecond}return N.Date;case N.Interval:switch(t.unit){case Ns.DAY_TIME:return N.IntervalDayTime;case Ns.YEAR_MONTH:return N.IntervalYearMonth}return N.Interval;case N.Map:return N.Map;case N.List:return N.List;case N.Struct:return N.Struct;case N.Union:switch(t.mode){case er.Dense:return N.DenseUnion;case er.Sparse:return N.SparseUnion}return N.Union;case N.FixedSizeBinary:return N.FixedSizeBinary;case N.FixedSizeList:return N.FixedSizeList;case N.Dictionary:return N.Dictionary}throw new Error(`Unrecognized type '${N[t.typeId]}'`)}Be.prototype.visitInt8=null;Be.prototype.visitInt16=null;Be.prototype.visitInt32=null;Be.prototype.visitInt64=null;Be.prototype.visitUint8=null;Be.prototype.visitUint16=null;Be.prototype.visitUint32=null;Be.prototype.visitUint64=null;Be.prototype.visitFloat16=null;Be.prototype.visitFloat32=null;Be.prototype.visitFloat64=null;Be.prototype.visitDateDay=null;Be.prototype.visitDateMillisecond=null;Be.prototype.visitTimestampSecond=null;Be.prototype.visitTimestampMillisecond=null;Be.prototype.visitTimestampMicrosecond=null;Be.prototype.visitTimestampNanosecond=null;Be.prototype.visitTimeSecond=null;Be.prototype.visitTimeMillisecond=null;Be.prototype.visitTimeMicrosecond=null;Be.prototype.visitTimeNanosecond=null;Be.prototype.visitDenseUnion=null;Be.prototype.visitSparseUnion=null;Be.prototype.visitIntervalDayTime=null;Be.prototype.visitIntervalYearMonth=null;const nD=new Float64Array(1),ta=new Uint32Array(nD.buffer);function rD(t){const e=(t&31744)>>10,n=(t&1023)/1024,r=Math.pow(-1,(t&32768)>>15);switch(e){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,e-15)*(1+n)}function $3(t){if(t!==t)return 32256;nD[0]=t;const e=(ta[1]&2147483648)>>16&65535;let n=ta[1]&2146435072,r=0;return n>=1089470464?ta[0]>0?n=31744:(n=(n&2080374784)>>16,r=(ta[1]&1048575)>>10):n<=1056964608?(r=1048576+(ta[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(ta[1]&1048575)+512>>10),e|n|r&65535}class Ee extends Be{}function xe(t){return(e,n,r)=>{if(e.setValid(n,r!=null))return t(e,n,r)}}const j3=(t,e,n)=>{t[e]=Math.trunc(n/864e5)},p0=(t,e,n)=>{t[e]=Math.trunc(n%4294967296),t[e+1]=Math.trunc(n/4294967296)},U3=(t,e,n)=>{t[e]=Math.trunc(n*1e3%4294967296),t[e+1]=Math.trunc(n*1e3/4294967296)},z3=(t,e,n)=>{t[e]=Math.trunc(n*1e6%4294967296),t[e+1]=Math.trunc(n*1e6/4294967296)},iD=(t,e,n,r)=>{if(n+1{const i=t+n;r?e[i>>3]|=1<>3]&=~(1<{t[e]=n},m0=({values:t},e,n)=>{t[e]=n},sD=({values:t},e,n)=>{t[e]=$3(n)},K3=(t,e,n)=>{switch(t.type.precision){case Cn.HALF:return sD(t,e,n);case Cn.SINGLE:case Cn.DOUBLE:return m0(t,e,n)}},oD=({values:t},e,n)=>{j3(t,e,n.valueOf())},aD=({values:t},e,n)=>{p0(t,e*2,n.valueOf())},W3=({stride:t,values:e},n,r)=>{e.set(r.subarray(0,t),t*n)},q3=({values:t,valueOffsets:e},n,r)=>iD(t,e,n,r),H3=({values:t,valueOffsets:e},n,r)=>{iD(t,e,n,l0(r))},Q3=(t,e,n)=>{t.type.unit===Hi.DAY?oD(t,e,n):aD(t,e,n)},uD=({values:t},e,n)=>p0(t,e*2,n/1e3),lD=({values:t},e,n)=>p0(t,e*2,n),cD=({values:t},e,n)=>U3(t,e*2,n),fD=({values:t},e,n)=>z3(t,e*2,n),Y3=(t,e,n)=>{switch(t.type.unit){case ze.SECOND:return uD(t,e,n);case ze.MILLISECOND:return lD(t,e,n);case ze.MICROSECOND:return cD(t,e,n);case ze.NANOSECOND:return fD(t,e,n)}},dD=({values:t},e,n)=>{t[e]=n},hD=({values:t},e,n)=>{t[e]=n},pD=({values:t},e,n)=>{t[e]=n},mD=({values:t},e,n)=>{t[e]=n},G3=(t,e,n)=>{switch(t.type.unit){case ze.SECOND:return dD(t,e,n);case ze.MILLISECOND:return hD(t,e,n);case ze.MICROSECOND:return pD(t,e,n);case ze.NANOSECOND:return mD(t,e,n)}},J3=({values:t,stride:e},n,r)=>{t.set(r.subarray(0,e),e*n)},X3=(t,e,n)=>{const r=t.children[0],i=t.valueOffsets,s=wr.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[e],l=i[e+1];a{const r=t.children[0],{valueOffsets:i}=t,s=wr.getVisitFn(r);let{[e]:o,[e+1]:a}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const f of l)if(s(r,o,f),++o>=a)break},e$=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[s]),t$=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(s)),n$=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(i.name)),r$=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[i.name]),i$=(t,e,n)=>{const r=t.type.children.map(s=>wr.getVisitFn(s.type)),i=n instanceof Map?n$(e,n):n instanceof Ke?t$(e,n):Array.isArray(n)?e$(e,n):r$(e,n);t.type.children.forEach((s,o)=>i(r[o],t.children[o],s,o))},s$=(t,e,n)=>{t.type.mode===er.Dense?yD(t,e,n):vD(t,e,n)},yD=(t,e,n)=>{const r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];wr.visit(i,t.valueOffsets[e],n)},vD=(t,e,n)=>{const r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];wr.visit(i,e,n)},o$=(t,e,n)=>{var r;(r=t.dictionary)===null||r===void 0||r.set(t.values[e],n)},a$=(t,e,n)=>{t.type.unit===Ns.DAY_TIME?gD(t,e,n):wD(t,e,n)},gD=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},wD=({values:t},e,n)=>{t[e]=n[0]*12+n[1]%12},u$=(t,e,n)=>{const{stride:r}=t,i=t.children[0],s=wr.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=e*r;++o`${Nl(e)}: ${Nl(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new l$(this[Er],this[Aa])}}class l${constructor(e,n){this.childIndex=0,this.children=e.children,this.rowIndex=n,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return en.name)}has(e,n){return e[Er].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(e,n){if(e[Er].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];const r=e[Er].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=Bn.visit(e[Er].children[r],e[Aa]);return Reflect.set(e,n,i),i}}set(e,n,r){const i=e[Er].type.children.findIndex(s=>s.name===n);return i!==-1?(wr.visit(e[Er].children[i],e[Aa],r),Reflect.set(e,n,r)):Reflect.has(e,n)||typeof n=="symbol"?Reflect.set(e,n,r):!1}}class _e extends Be{}function Oe(t){return(e,n)=>e.getValid(n)?t(e,n):null}const f$=(t,e)=>864e5*t[e],v0=(t,e)=>4294967296*t[e+1]+(t[e]>>>0),d$=(t,e)=>4294967296*(t[e+1]/1e3)+(t[e]>>>0)/1e3,h$=(t,e)=>4294967296*(t[e+1]/1e6)+(t[e]>>>0)/1e6,_D=t=>new Date(t),p$=(t,e)=>_D(f$(t,e)),m$=(t,e)=>_D(v0(t,e)),y$=(t,e)=>null,bD=(t,e,n)=>{if(n+1>=e.length)return null;const r=e[n],i=e[n+1];return t.subarray(r,i)},v$=({offset:t,values:e},n)=>{const r=t+n;return(e[r>>3]&1<p$(t,e),ID=({values:t},e)=>m$(t,e*2),Hs=({stride:t,values:e},n)=>e[t*n],g$=({stride:t,values:e},n)=>rD(e[t*n]),ED=({values:t},e)=>t[e],w$=({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)),_$=({values:t,valueOffsets:e},n)=>bD(t,e,n),b$=({values:t,valueOffsets:e},n)=>{const r=bD(t,e,n);return r!==null?sv(r):null},S$=({values:t},e)=>t[e],I$=({type:t,values:e},n)=>t.precision!==Cn.HALF?e[n]:rD(e[n]),E$=(t,e)=>t.type.unit===Hi.DAY?SD(t,e):ID(t,e),OD=({values:t},e)=>1e3*v0(t,e*2),kD=({values:t},e)=>v0(t,e*2),DD=({values:t},e)=>d$(t,e*2),xD=({values:t},e)=>h$(t,e*2),O$=(t,e)=>{switch(t.type.unit){case ze.SECOND:return OD(t,e);case ze.MILLISECOND:return kD(t,e);case ze.MICROSECOND:return DD(t,e);case ze.NANOSECOND:return xD(t,e)}},AD=({values:t},e)=>t[e],CD=({values:t},e)=>t[e],PD=({values:t},e)=>t[e],RD=({values:t},e)=>t[e],k$=(t,e)=>{switch(t.type.unit){case ze.SECOND:return AD(t,e);case ze.MILLISECOND:return CD(t,e);case ze.MICROSECOND:return PD(t,e);case ze.NANOSECOND:return RD(t,e)}},D$=({values:t,stride:e},n)=>h0.decimal(t.subarray(e*n,e*(n+1))),x$=(t,e)=>{const{valueOffsets:n,stride:r,children:i}=t,{[e*r]:s,[e*r+1]:o}=n,l=i[0].slice(s,o-s);return new Ke([l])},A$=(t,e)=>{const{valueOffsets:n,children:r}=t,{[e]:i,[e+1]:s}=n,o=r[0];return new g0(o.slice(i,s-i))},C$=(t,e)=>new y0(t,e),P$=(t,e)=>t.type.mode===er.Dense?TD(t,e):MD(t,e),TD=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Bn.visit(r,t.valueOffsets[e])},MD=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Bn.visit(r,e)},R$=(t,e)=>{var n;return(n=t.dictionary)===null||n===void 0?void 0:n.get(t.values[e])},T$=(t,e)=>t.type.unit===Ns.DAY_TIME?ND(t,e):BD(t,e),ND=({values:t},e)=>t.subarray(2*e,2*(e+1)),BD=({values:t},e)=>{const n=t[e],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},M$=(t,e)=>{const{stride:n,children:r}=t,s=r[0].slice(e*n,n);return new Ke([s])};_e.prototype.visitNull=Oe(y$);_e.prototype.visitBool=Oe(v$);_e.prototype.visitInt=Oe(S$);_e.prototype.visitInt8=Oe(Hs);_e.prototype.visitInt16=Oe(Hs);_e.prototype.visitInt32=Oe(Hs);_e.prototype.visitInt64=Oe(ED);_e.prototype.visitUint8=Oe(Hs);_e.prototype.visitUint16=Oe(Hs);_e.prototype.visitUint32=Oe(Hs);_e.prototype.visitUint64=Oe(ED);_e.prototype.visitFloat=Oe(I$);_e.prototype.visitFloat16=Oe(g$);_e.prototype.visitFloat32=Oe(Hs);_e.prototype.visitFloat64=Oe(Hs);_e.prototype.visitUtf8=Oe(b$);_e.prototype.visitBinary=Oe(_$);_e.prototype.visitFixedSizeBinary=Oe(w$);_e.prototype.visitDate=Oe(E$);_e.prototype.visitDateDay=Oe(SD);_e.prototype.visitDateMillisecond=Oe(ID);_e.prototype.visitTimestamp=Oe(O$);_e.prototype.visitTimestampSecond=Oe(OD);_e.prototype.visitTimestampMillisecond=Oe(kD);_e.prototype.visitTimestampMicrosecond=Oe(DD);_e.prototype.visitTimestampNanosecond=Oe(xD);_e.prototype.visitTime=Oe(k$);_e.prototype.visitTimeSecond=Oe(AD);_e.prototype.visitTimeMillisecond=Oe(CD);_e.prototype.visitTimeMicrosecond=Oe(PD);_e.prototype.visitTimeNanosecond=Oe(RD);_e.prototype.visitDecimal=Oe(D$);_e.prototype.visitList=Oe(x$);_e.prototype.visitStruct=Oe(C$);_e.prototype.visitUnion=Oe(P$);_e.prototype.visitDenseUnion=Oe(TD);_e.prototype.visitSparseUnion=Oe(MD);_e.prototype.visitDictionary=Oe(R$);_e.prototype.visitInterval=Oe(T$);_e.prototype.visitIntervalDayTime=Oe(ND);_e.prototype.visitIntervalYearMonth=Oe(BD);_e.prototype.visitFixedSizeList=Oe(M$);_e.prototype.visitMap=Oe(A$);const Bn=new _e,Xr=Symbol.for("keys"),Ca=Symbol.for("vals");class g0{constructor(e){return this[Xr]=new Ke([e.children[0]]).memoize(),this[Ca]=e.children[1],new Proxy(this,new B$)}[Symbol.iterator](){return new N$(this[Xr],this[Ca])}get size(){return this[Xr].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[Xr],n=this[Ca],r={};for(let i=-1,s=e.length;++i`${Nl(e)}: ${Nl(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class N${constructor(e,n){this.keys=e,this.vals=n,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Bn.visit(this.vals,e)]})}}class B${isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[Xr].toArray().map(String)}has(e,n){return e[Xr].includes(n)}getOwnPropertyDescriptor(e,n){if(e[Xr].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];const r=e[Xr].indexOf(n);if(r!==-1){const i=Bn.visit(Reflect.get(e,Ca),r);return Reflect.set(e,n,i),i}}set(e,n,r){const i=e[Xr].indexOf(n);return i!==-1?(wr.visit(Reflect.get(e,Ca),i,r),Reflect.set(e,n,r)):Reflect.has(e,n)?Reflect.set(e,n,r):!1}}Object.defineProperties(g0.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Xr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ca]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let p1;function FD(t,e,n,r){const{length:i=0}=t;let s=typeof e!="number"?0:e,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(t,s,o):[s,o]}const m1=t=>t!==t;function du(t){if(typeof t!=="object"||t===null)return m1(t)?m1:n=>n===t;if(t instanceof Date){const n=t.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(t)?n=>n?A3(t,n):!1:t instanceof Map?L$(t):Array.isArray(t)?F$(t):t instanceof Ke?$$(t):j$(t,!0)}function F$(t){const e=[];for(let n=-1,r=t.length;++n!1;const r=[];for(let i=-1,s=n.length;++i{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return U$(t,n);case Map:return y1(t,n,n.keys());case g0:case y0:case Object:case void 0:return y1(t,n,e||Object.keys(n))}return n instanceof Ke?z$(t,n):!1}}function U$(t,e){const n=t.length;if(e.length!==n)return!1;for(let r=-1;++r>r}function w0(t,e,n){const r=n.byteLength+7&-8;if(t>0||n.byteLength>3):jd(new _0(n,t,e,null,LD)).subarray(0,r)),i}return n}function jd(t){const e=[];let n=0,r=0,i=0;for(const o of t)o&&(i|=1<0)&&(e[n++]=i);const s=new Uint8Array(e.length+7&-8);return s.set(e),s}class _0{constructor(e,n,r,i,s){this.bytes=e,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=e+(e%8===0?0:8-e%8);return lv(t,e,i)+lv(t,r,n)+K$(t,i>>3,r-i>>3)}function K$(t,e,n){let r=0,i=Math.trunc(e);const s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n===void 0?t.byteLength:i+n;for(;o-i>=4;)r+=Om(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=Om(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=Om(s.getUint8(i)),i+=1;return r}function Om(t){let e=Math.trunc(t);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const W$=-1;class at{constructor(e,n,r,i,s,o=[],a){this.type=e,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof at?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Si(e),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l))),this.nullable=this._nullCount!==0&&this.nullBitmap&&this.nullBitmap.byteLength>0}get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get byteLength(){let e=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,e)}get nullCount(){let e=this._nullCount,n;return e<=W$&&(n=this.nullBitmap)&&(this._nullCount=e=this.length-lv(n,this.offset,this.offset+this.length)),e}getValid(e){if(this.nullable&&this.nullCount>0){const n=this.offset+e;return(this.nullBitmap[n>>3]&1<>3){const{nullBitmap:l}=this._changeLengthAndBackfillNullBitmap(this.length);Object.assign(this,{nullBitmap:l,_nullCount:0})}const{nullBitmap:r,offset:i}=this,s=i+e>>3,o=(i+e)%8,a=r[s]>>o&1;return n?a===0&&(r[s]|=1<>3).fill(255,0,n>>3);i[n>>3]=(1<0&&i.set(w0(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[bi.VALIDITY]=i,this.clone(this.type,0,e,r+(e-n),s)}_sliceBuffers(e,n,r,i){let s;const{buffers:o}=this;return(s=o[bi.TYPE])&&(o[bi.TYPE]=s.subarray(e,e+n)),(s=o[bi.OFFSET])&&(o[bi.OFFSET]=s.subarray(e,e+n+1))||(s=o[bi.DATA])&&(o[bi.DATA]=i===6?s:s.subarray(r*e,r*(e+n))),o}_sliceChildren(e,n,r){return e.map(i=>i.slice(n,r))}}at.prototype.children=Object.freeze([]);class ol extends Be{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=e;return new at(n,r,i,0)}visitBool(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitInt(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitFloat(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitUtf8(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.data),s=Ue(e.nullBitmap),o=Fu(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[o,i,s])}visitBinary(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.data),s=Ue(e.nullBitmap),o=Fu(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[o,i,s])}visitFixedSizeBinary(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitDate(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitTimestamp(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitTime(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitDecimal(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitList(e){const{["type"]:n,["offset"]:r=0,["child"]:i}=e,s=Ue(e.nullBitmap),o=Fu(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[o,void 0,s],[i])}visitStruct(e){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=Ue(e.nullBitmap),{length:o=i.reduce((l,{length:f})=>Math.max(l,f),0),nullCount:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,void 0,s],i)}visitUnion(e){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=Ue(e.nullBitmap),o=rt(n.ArrayType,e.typeIds),{["length"]:a=o.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;if(we.isSparseUnion(n))return new at(n,r,a,l,[void 0,void 0,s,o],i);const f=Fu(e.valueOffsets);return new at(n,r,a,l,[f,void 0,s,o],i)}visitDictionary(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.indices.ArrayType,e.data),{["dictionary"]:o=new Ke([new ol().visit({type:n.dictionary})])}=e,{["length"]:a=s.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[void 0,s,i],[],o)}visitInterval(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitFixedSizeList(e){const{["type"]:n,["offset"]:r=0,["child"]:i=new ol().visit({type:n.valueType})}=e,s=Ue(e.nullBitmap),{["length"]:o=i.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,void 0,s],[i])}visitMap(e){const{["type"]:n,["offset"]:r=0,["child"]:i=new ol().visit({type:n.childType})}=e,s=Ue(e.nullBitmap),o=Fu(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[o,void 0,s],[i])}}function Ne(t){return new ol().visit(t)}class v1{constructor(e=0,n){this.numChunks=e,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe+n.nullCount,0)}function jD(t){return t.reduce((e,n,r)=>(e[r+1]=e[r]+n.length,e),new Uint32Array(t.length+1))}function UD(t,e,n,r){const i=[];for(let s=-1,o=t.length;++s=r)break;if(n>=l+f)continue;if(l>=n&&l+f<=r){i.push(a);continue}const h=Math.max(0,n-l),m=Math.min(r-l,f);i.push(a.slice(h,m-h))}return i.length===0&&i.push(t[0].slice(0,0)),i}function b0(t,e,n,r){let i=0,s=0,o=e.length-1;do{if(i>=o-1)return n0?0:-1}function H$(t,e){const{nullBitmap:n}=t;if(!n||t.nullCount<=0)return-1;let r=0;for(const i of new _0(n,t.offset+(e||0),t.length,n,LD)){if(!i)return r;++r}return-1}function Ce(t,e,n){if(e===void 0)return-1;if(e===null)return H$(t,n);const r=Bn.getVisitFn(t),i=du(e);for(let s=(n||0)-1,o=t.length;++s{const i=t.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new v1(t.data.length,r=>{const s=t.data[r].length,o=t.slice(n,n+s);return n+=s,new Q$(o)})}class Q${constructor(e){this.vector=e,this.index=0}next(){return this.indext+e;class Qs extends Be{visitNull(e,n){return 0}visitInt(e,n){return e.type.bitWidth/8}visitFloat(e,n){return e.type.ArrayType.BYTES_PER_ELEMENT}visitBool(e,n){return 1/8}visitDecimal(e,n){return e.type.bitWidth/8}visitDate(e,n){return(e.type.unit+1)*4}visitTime(e,n){return e.type.bitWidth/8}visitTimestamp(e,n){return e.type.unit===ze.SECOND?4:8}visitInterval(e,n){return(e.type.unit+1)*4}visitStruct(e,n){return e.children.reduce((r,i)=>r+di.visit(i,n),0)}visitFixedSizeBinary(e,n){return e.type.byteWidth}visitMap(e,n){return 8+e.children.reduce((r,i)=>r+di.visit(i,n),0)}visitDictionary(e,n){var r;return e.type.indices.bitWidth/8+(((r=e.dictionary)===null||r===void 0?void 0:r.getByteLength(e.values[n]))||0)}}const G$=({valueOffsets:t},e)=>8+(t[e+1]-t[e]),J$=({valueOffsets:t},e)=>8+(t[e+1]-t[e]),X$=({valueOffsets:t,stride:e,children:n},r)=>{const i=n[0],{[r*e]:s}=t,{[r*e+1]:o}=t,a=di.getVisitFn(i.type),l=i.slice(s,o-s);let f=8;for(let h=-1,m=o-s;++h{const r=e[0],i=r.slice(n*t,t),s=di.getVisitFn(r.type);let o=0;for(let a=-1,l=i.length;++at.type.mode===er.Dense?WD(t,e):qD(t,e),WD=({type:t,children:e,typeIds:n,valueOffsets:r},i)=>{const s=t.typeIdToChildIndex[n[i]];return 8+di.visit(e[s],r[i])},qD=({children:t},e)=>4+di.visitMany(t,t.map(()=>e)).reduce(Y$,0);Qs.prototype.visitUtf8=G$;Qs.prototype.visitBinary=J$;Qs.prototype.visitList=X$;Qs.prototype.visitFixedSizeList=Z$;Qs.prototype.visitUnion=ej;Qs.prototype.visitDenseUnion=WD;Qs.prototype.visitSparseUnion=qD;const di=new Qs;var HD;const QD={},YD={};class Ke{constructor(e){var n,r,i;const s=e[0]instanceof Ke?e.flatMap(a=>a.data):e;if(s.length===0||s.some(a=>!(a instanceof at)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:l,indexOf:f,byteLength:h}=QD[o.typeId],m=s[0];this.isValid=y=>S0(m,y),this.get=y=>a(m,y),this.set=(y,w)=>l(m,y,w),this.indexOf=y=>f(m,y),this.getByteLength=y=>h(m,y),this._offsets=[0,m.length];break}default:Object.setPrototypeOf(this,YD[o.typeId]),this._offsets=jD(s);break}this.data=s,this.type=o,this.stride=Si(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets[this._offsets.length-1]}get byteLength(){return this._byteLength===-1&&(this._byteLength=this.data.reduce((e,n)=>e+n.byteLength,0)),this._byteLength}get nullCount(){return this._nullCount===-1&&(this._nullCount=$D(this.data)),this._nullCount}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${N[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}set(e,n){}indexOf(e,n){return-1}includes(e,n){return this.indexOf(e,n)>0}getByteLength(e){return 0}[Symbol.iterator](){return I0.visit(this)}concat(...e){return new Ke(this.data.concat(e.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(e,n){return new Ke(FD(this,e,n,({data:r,_offsets:i},s,o)=>UD(r,i,s,o)))}toJSON(){return[...this]}toArray(){const{type:e,data:n,length:r,stride:i,ArrayType:s}=this;switch(e.typeId){case N.Int:case N.Float:case N.Decimal:case N.Time:case N.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&en[e])):null}get isMemoized(){return we.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(we.isDictionary(this.type)){const e=new zd(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=e,i});return new Ke(n)}return new zd(this)}unmemoize(){if(we.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=e,i});return new Ke(n)}return this}}HD=Symbol.toStringTag;Ke[HD]=(t=>{t.type=we.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._nullCount=-1,t._byteLength=-1,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;const e=Object.keys(N).map(n=>N[n]).filter(n=>typeof n=="number"&&n!==N.NONE);for(const n of e){const r=Bn.getVisitFnByTypeId(n),i=wr.getVisitFnByTypeId(n),s=Ud.getVisitFnByTypeId(n),o=di.getVisitFnByTypeId(n);QD[n]={get:r,set:i,indexOf:s,byteLength:o},YD[n]=Object.create(t,{isValid:{value:Pa(S0)},get:{value:Pa(Bn.getVisitFnByTypeId(n))},set:{value:zD(wr.getVisitFnByTypeId(n))},indexOf:{value:VD(Ud.getVisitFnByTypeId(n))},getByteLength:{value:Pa(di.getVisitFnByTypeId(n))}})}return"Vector"})(Ke.prototype);class zd extends Ke{constructor(e){super(e.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=s[o];if(a!==void 0)return a;const l=n.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new zd(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Ke(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class cv{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,n,r,i){return e.prep(8,24),e.writeInt64(i),e.pad(4),e.writeInt32(r),e.writeInt64(n),e.offset()}}const km=2,Zr=4,ki=4,st=4,fs=new Int32Array(2),g1=new Float32Array(fs.buffer),w1=new Float64Array(fs.buffer),ff=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;let Ni=class fv{constructor(e,n){this.low=e|0,this.high=n|0}static create(e,n){return e==0&&n==0?fv.ZERO:new fv(e,n)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}};Ni.ZERO=new Ni(0,0);var dv;(function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"})(dv||(dv={}));let Ya=class GD{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new GD(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return new Ni(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new Ni(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return fs[0]=this.readInt32(e),g1[0]}readFloat64(e){return fs[ff?0:1]=this.readInt32(e),fs[ff?1:0]=this.readInt32(e+4),w1[0]}writeInt8(e,n){this.bytes_[e]=n}writeUint8(e,n){this.bytes_[e]=n}writeInt16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeUint16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeInt32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeUint32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeInt64(e,n){this.writeInt32(e,n.low),this.writeInt32(e+4,n.high)}writeUint64(e,n){this.writeUint32(e,n.low),this.writeUint32(e+4,n.high)}writeFloat32(e,n){g1[0]=n,this.writeInt32(e,fs[0])}writeFloat64(e,n){w1[0]=n,this.writeInt32(e,fs[ff?0:1]),this.writeInt32(e+4,fs[ff?1:0])}getBufferIdentifier(){if(this.bytes_.length>10)+55296,(o&1024-1)+56320))}return i}__union_with_string(e,n){return typeof e=="string"?this.__string(n):this.__union(e,n)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+Zr}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=ki)throw new Error("FlatBuffers: file identifier must be length "+ki);for(let n=0;nthis.minalign&&(this.minalign=e);const r=~(this.bb.capacity()-this.space+n)+1&e-1;for(;this.space=0&&this.vtable[n]==0;n--);const r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);const i=2;this.addInt16(e-this.object_start);const s=(r+i)*km;this.addInt16(s);let o=0;const a=this.space;e:for(n=0;n=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,Zr+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,n){this.finish(e,n,!0)}requiredField(e,n){const r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(!(this.bb.readInt16(i+n)!=0))throw new Error("FlatBuffers: field "+n+" must be set")}startVector(e,n,r){this.notNested(),this.vector_num_elems=n,this.prep(Zr,e*n),this.prep(r,e*n)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const n=this.createString(e);return this.string_maps.set(e,n),n}createString(e){if(!e)return 0;let n;if(e instanceof Uint8Array)n=e;else{n=[];let r=0;for(;r=56320)i=s;else{const o=e.charCodeAt(r++);i=(s<<10)+o+(65536-56623104-56320)}i<128?n.push(i):(i<2048?n.push(i>>6&31|192):(i<65536?n.push(i>>12&15|224):n.push(i>>18&7|240,i>>12&63|128),n.push(i>>6&63|128)),n.push(i&63|128))}}this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length);for(let r=0,i=this.space,s=this.bb.bytes();r=0;r--)e.addInt32(n[r]);return e.endVector()}static startTypeIdsVector(e,n){e.startVector(4,n,4)}static endUnion(e){return e.endObject()}static createUnion(e,n,r){return In.startUnion(e),In.addMode(e,n),In.addTypeIds(e,r),In.endUnion(e)}}class bo{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsUtf8(e,n){return(n||new bo).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,n){return e.setPosition(e.position()+st),(n||new bo).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return bo.startUtf8(e),bo.endUtf8(e)}}var _t;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList"})(_t||(_t={}));let lr=class Ff{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsField(e,n){return(n||new Ff).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+st),(n||new Ff).__init(e.readInt32(e.position())+e.position(),e)}name(e){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):_t.NONE}type(e){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(e,this.bb_pos+n):null}dictionary(e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new Di).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(e,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new Ff).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){const r=this.bb.__offset(this.bb_pos,16);return r?(n||new zt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,n){e.addFieldOffset(0,n,0)}static addNullable(e,n){e.addFieldInt8(1,+n,0)}static addTypeType(e,n){e.addFieldInt8(2,n,_t.NONE)}static addType(e,n){e.addFieldOffset(3,n,0)}static addDictionary(e,n){e.addFieldOffset(4,n,0)}static addChildren(e,n){e.addFieldOffset(5,n,0)}static createChildrenVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startChildrenVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(6,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endField(e){return e.endObject()}},qr=class wi{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsSchema(e,n){return(n||new wi).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+st),(n||new wi).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Ja.Little}fields(e,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new lr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new zt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+e*8):this.bb.createLong(0,0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,n){e.addFieldInt16(0,n,Ja.Little)}static addFields(e,n){e.addFieldOffset(1,n,0)}static createFieldsVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startFieldsVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(2,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static addFeatures(e,n){e.addFieldOffset(3,n,0)}static createFeaturesVector(e,n){e.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)e.addInt64(n[r]);return e.endVector()}static startFeaturesVector(e,n){e.startVector(8,n,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,n){e.finish(n)}static finishSizePrefixedSchemaBuffer(e,n){e.finish(n,void 0,!0)}static createSchema(e,n,r,i,s){return wi.startSchema(e),wi.addEndianness(e,n),wi.addFields(e,r),wi.addCustomMetadata(e,i),wi.addFeatures(e,s),wi.endSchema(e)}};class Kn{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsFooter(e,n){return(n||new Kn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,n){return e.setPosition(e.position()+st),(n||new Kn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Ga.V1}schema(e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new qr).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(e,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new cv).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,n){const r=this.bb.__offset(this.bb_pos,10);return r?(n||new cv).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new zt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,Ga.V1)}static addSchema(e,n){e.addFieldOffset(1,n,0)}static addDictionaries(e,n){e.addFieldOffset(2,n,0)}static startDictionariesVector(e,n){e.startVector(24,n,8)}static addRecordBatches(e,n){e.addFieldOffset(3,n,0)}static startRecordBatchesVector(e,n){e.startVector(24,n,8)}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,n){e.finish(n)}static finishSizePrefixedFooterBuffer(e,n){e.finish(n,void 0,!0)}}class We{constructor(e=[],n,r){this.fields=e||[],this.metadata=n||new Map,r||(r=hv(e)),this.dictionaries=r}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,n)=>`${n}: ${e}`).join(", ")} }>`}select(e){const n=new Set(e),r=this.fields.filter(i=>n.has(i.name));return new We(r,this.metadata)}selectAt(e){const n=e.map(r=>this.fields[r]).filter(Boolean);return new We(n,this.metadata)}assign(...e){const n=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),r=[...this.fields],i=df(df(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{const l=r.findIndex(f=>f.name===a.name);return~l?(r[l]=a.clone({metadata:df(df(new Map,r[l].metadata),a.metadata)}))&&!1:!0}),o=hv(s,new Map);return new We([...r,...s],i,new Map([...this.dictionaries,...o]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class yt{constructor(e,n,r=!1,i){this.name=e,this.type=n,this.nullable=r,this.metadata=i||new Map}static new(...e){let[n,r,i,s]=e;return e[0]&&typeof e[0]=="object"&&({name:n}=e[0],r===void 0&&(r=e[0].type),i===void 0&&(i=e[0].nullable),s===void 0&&(s=e[0].metadata)),new yt(`${n}`,r,i,s)}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[n,r,i,s]=e;return!e[0]||typeof e[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=e:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=e[0],yt.new(n,r,i,s)}}yt.prototype.type=null;yt.prototype.name=null;yt.prototype.nullable=null;yt.prototype.metadata=null;function df(t,e){return new Map([...t||new Map,...e||new Map])}function hv(t,e=new Map){for(let n=-1,r=t.length;++n0&&hv(s.children,e)}return e}var _1=Ni,tj=JD,nj=Ya;class jl{constructor(e,n=Qn.V4,r,i){this.schema=e,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}static decode(e){e=new nj(Ue(e));const n=Kn.getRootAsFooter(e),r=We.decode(n.schema());return new rj(r,n)}static encode(e){const n=new tj,r=We.encode(n,e.schema);Kn.startRecordBatchesVector(n,e.numRecordBatches);for(const o of[...e.recordBatches()].slice().reverse())Ls.encode(n,o);const i=n.endVector();Kn.startDictionariesVector(n,e.numDictionaries);for(const o of[...e.dictionaryBatches()].slice().reverse())Ls.encode(n,o);const s=n.endVector();return Kn.startFooter(n),Kn.addSchema(n,r),Kn.addVersion(n,Qn.V4),Kn.addRecordBatches(n,i),Kn.addDictionaries(n,s),Kn.finishFooterBuffer(n,Kn.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}*recordBatches(){for(let e,n=-1,r=this.numRecordBatches;++n=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return ve(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(St);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return cr.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return cr.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return ve(this,void 0,void 0,function*(){return yield this.abort(e),St})}return(e){return ve(this,void 0,void 0,function*(){return yield this.close(),St})}read(e){return ve(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return ve(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(St)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Lf extends ij{write(e){if((e=Ue(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?sv(this.toUint8Array(!0)):this.toUint8Array(!1).then(sv)}toUint8Array(e=!1){return e?fi(this._values)[0]:(()=>ve(this,void 0,void 0,function*(){var n,r;const i=[];let s=0;try{for(var o=Ds(this),a;a=yield o.next(),!a.done;){const l=a.value;i.push(l),s+=l.byteLength}}catch(l){n={error:l}}finally{try{a&&!a.done&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}return fi(i,s)[0]}))()}}class Qd{constructor(e){e&&(this.source=new sj(cr.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class Za{constructor(e){e instanceof Za?this.source=e.source:e instanceof Lf?this.source=new ao(cr.fromAsyncIterable(e)):Mk(e)?this.source=new ao(cr.fromNodeStream(e)):c0(e)?this.source=new ao(cr.fromDOMStream(e)):Tk(e)?this.source=new ao(cr.fromDOMStream(e.body)):uc(e)?this.source=new ao(cr.fromIterable(e)):Ms(e)?this.source=new ao(cr.fromAsyncIterable(e)):fu(e)&&(this.source=new ao(cr.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class sj{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,n="read"){return this.source.next({cmd:n,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||St)}return(e){return Object.create(this.source.return&&this.source.return(e)||St)}}class ao{constructor(e){this.source=e,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(e){return ve(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return ve(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return ve(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e,n="read"){return ve(this,void 0,void 0,function*(){return yield this.source.next({cmd:n,size:e})})}throw(e){return ve(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(e))||St;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(e){return ve(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(e))||St;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class S1 extends Qd{constructor(e,n){super(),this.position=0,this.buffer=Ue(e),this.size=typeof n>"u"?this.buffer.byteLength:n}readInt32(e){const{buffer:n,byteOffset:r}=this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),eve(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending}))()}readInt32(e){return ve(this,void 0,void 0,function*(){const{buffer:n,byteOffset:r}=yield this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)})}seek(e){return ve(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(e){const n=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],n>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(e){return this.buffer[1]>>0,n[2]=this.buffer[2]+e.buffer[2]>>>0,n[1]=this.buffer[1]+e.buffer[1]>>>0,n[0]=this.buffer[0]+e.buffer[0]>>>0,n[0]>>0&&++n[1],n[1]>>0&&++n[2],n[2]>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${_a(this.buffer[3])} ${_a(this.buffer[2])} ${_a(this.buffer[1])} ${_a(this.buffer[0])}`}static multiply(e,n){return new Hr(new Uint32Array(e.buffer)).times(n)}static add(e,n){return new Hr(new Uint32Array(e.buffer)).plus(n)}static from(e,n=new Uint32Array(4)){return Hr.fromString(typeof e=="string"?e:e.toString(),n)}static fromNumber(e,n=new Uint32Array(4)){return Hr.fromString(e.toString(),n)}static fromString(e,n=new Uint32Array(4)){const r=e.startsWith("-"),i=e.length,s=new Hr(n);for(let o=r?1:0;o0&&this.readData(e,r)||new Uint8Array(0)}readOffsets(e,n){return this.readData(e,n)}readTypeIds(e,n){return this.readData(e,n)}readData(e,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(e){return this.dictionaries.get(e.id)}}class aj extends ex{constructor(e,n,r,i){super(new Uint8Array(0),n,r,i),this.sources=e}readNullBitmap(e,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):jd(this.sources[r])}readOffsets(e,{offset:n}=this.nextBufferRange()){return rt(Uint8Array,rt(Int32Array,this.sources[n]))}readTypeIds(e,{offset:n}=this.nextBufferRange()){return rt(Uint8Array,rt(e.ArrayType,this.sources[n]))}readData(e,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return we.isTimestamp(e)||(we.isInt(e)||we.isTime(e))&&e.bitWidth===64||we.isDate(e)&&e.unit===Hi.MILLISECOND?rt(Uint8Array,_n.convertArray(r[n])):we.isDecimal(e)?rt(Uint8Array,Hr.convertArray(r[n])):we.isBinary(e)||we.isFixedSizeBinary(e)?uj(r[n]):we.isBool(e)?jd(r[n]):we.isUtf8(e)?l0(r[n].join("")):rt(Uint8Array,rt(e.ArrayType,r[n].map(i=>+i)))}}function uj(t){const e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=Number.parseInt(e.slice(r,r+2),16);return n}class Ie extends Be{compareSchemas(e,n){return e===n||n instanceof e.constructor&&this.compareManyFields(e.fields,n.fields)}compareManyFields(e,n){return e===n||Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((r,i)=>this.compareFields(r,n[i]))}compareFields(e,n){return e===n||n instanceof e.constructor&&e.name===n.name&&e.nullable===n.nullable&&this.visit(e.type,n.type)}}function jn(t,e){return e instanceof t.constructor}function lc(t,e){return t===e||jn(t,e)}function Ji(t,e){return t===e||jn(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function Uh(t,e){return t===e||jn(t,e)&&t.precision===e.precision}function lj(t,e){return t===e||jn(t,e)&&t.byteWidth===e.byteWidth}function k0(t,e){return t===e||jn(t,e)&&t.unit===e.unit}function cc(t,e){return t===e||jn(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function fc(t,e){return t===e||jn(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function cj(t,e){return t===e||jn(t,e)&&t.children.length===e.children.length&&$s.compareManyFields(t.children,e.children)}function fj(t,e){return t===e||jn(t,e)&&t.children.length===e.children.length&&$s.compareManyFields(t.children,e.children)}function D0(t,e){return t===e||jn(t,e)&&t.mode===e.mode&&t.typeIds.every((n,r)=>n===e.typeIds[r])&&$s.compareManyFields(t.children,e.children)}function dj(t,e){return t===e||jn(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&$s.visit(t.indices,e.indices)&&$s.visit(t.dictionary,e.dictionary)}function x0(t,e){return t===e||jn(t,e)&&t.unit===e.unit}function hj(t,e){return t===e||jn(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&$s.compareManyFields(t.children,e.children)}function pj(t,e){return t===e||jn(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&$s.compareManyFields(t.children,e.children)}Ie.prototype.visitNull=lc;Ie.prototype.visitBool=lc;Ie.prototype.visitInt=Ji;Ie.prototype.visitInt8=Ji;Ie.prototype.visitInt16=Ji;Ie.prototype.visitInt32=Ji;Ie.prototype.visitInt64=Ji;Ie.prototype.visitUint8=Ji;Ie.prototype.visitUint16=Ji;Ie.prototype.visitUint32=Ji;Ie.prototype.visitUint64=Ji;Ie.prototype.visitFloat=Uh;Ie.prototype.visitFloat16=Uh;Ie.prototype.visitFloat32=Uh;Ie.prototype.visitFloat64=Uh;Ie.prototype.visitUtf8=lc;Ie.prototype.visitBinary=lc;Ie.prototype.visitFixedSizeBinary=lj;Ie.prototype.visitDate=k0;Ie.prototype.visitDateDay=k0;Ie.prototype.visitDateMillisecond=k0;Ie.prototype.visitTimestamp=cc;Ie.prototype.visitTimestampSecond=cc;Ie.prototype.visitTimestampMillisecond=cc;Ie.prototype.visitTimestampMicrosecond=cc;Ie.prototype.visitTimestampNanosecond=cc;Ie.prototype.visitTime=fc;Ie.prototype.visitTimeSecond=fc;Ie.prototype.visitTimeMillisecond=fc;Ie.prototype.visitTimeMicrosecond=fc;Ie.prototype.visitTimeNanosecond=fc;Ie.prototype.visitDecimal=lc;Ie.prototype.visitList=cj;Ie.prototype.visitStruct=fj;Ie.prototype.visitUnion=D0;Ie.prototype.visitDenseUnion=D0;Ie.prototype.visitSparseUnion=D0;Ie.prototype.visitDictionary=dj;Ie.prototype.visitInterval=x0;Ie.prototype.visitIntervalDayTime=x0;Ie.prototype.visitIntervalYearMonth=x0;Ie.prototype.visitFixedSizeList=hj;Ie.prototype.visitMap=pj;const $s=new Ie;function pv(t,e){return $s.compareSchemas(t,e)}function Dm(t,e){return mj(t,e.map(n=>n.data.concat()))}function mj(t,e){const n=[...t.fields],r=[],i={numBatches:e.reduce((m,y)=>Math.max(m,y.length),0)};let s=0,o=0,a=-1;const l=e.length;let f,h=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(r[s++]=Ne({type:new pn(n),length:o,nullCount:0,children:h.slice()})))}return[t=t.assign(n),r.map(m=>new En(t,m))]}function yj(t,e,n,r,i){var s;const o=(e+63&-64)>>3;for(let a=-1,l=r.length;++a=e)h===e?n[a]=f:(n[a]=f.slice(0,e),i.numBatches=Math.max(i.numBatches,r[a].unshift(f.slice(e,h-e))));else{const m=t[a];t[a]=m.clone({nullable:!0}),n[a]=(s=f==null?void 0:f._changeLengthAndBackfillNullBitmap(e))!==null&&s!==void 0?s:Ne({type:m.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return n}var tx;class hn{constructor(...e){var n,r;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let i,s;e[0]instanceof We&&(i=e.shift()),e[e.length-1]instanceof Uint32Array&&(s=e.pop());const o=l=>{if(l){if(l instanceof En)return[l];if(l instanceof hn)return l.batches;if(l instanceof at){if(l.type instanceof pn)return[new En(new We(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(f=>o(f));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(f=>o(f));if(typeof l=="object"){const f=Object.keys(l),h=f.map(w=>new Ke([l[w]])),m=new We(f.map((w,I)=>new yt(String(w),h[I].type))),[,y]=Dm(m,h);return y.length===0?[new En(l)]:y}}}return[]},a=e.flatMap(l=>o(l));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new We([]),!(i instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of a){if(!(l instanceof En))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!pv(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??jD(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,n)=>e+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=$D(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}set(e,n){}indexOf(e,n){return-1}getByteLength(e){return 0}[Symbol.iterator](){return this.batches.length>0?I0.visit(new Ke(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ + */var s0=n3,Lr=typeof Symbol=="function"&&Symbol.for,ic=Lr?Symbol.for("react.element"):60103,r3=Lr?Symbol.for("react.portal"):60106,i3=Lr?Symbol.for("react.fragment"):60107,s3=Lr?Symbol.for("react.strict_mode"):60108,o3=Lr?Symbol.for("react.profiler"):60114,a3=Lr?Symbol.for("react.provider"):60109,u3=Lr?Symbol.for("react.context"):60110,l3=Lr?Symbol.for("react.forward_ref"):60112,c3=Lr?Symbol.for("react.suspense"):60113,f3=Lr?Symbol.for("react.memo"):60115,d3=Lr?Symbol.for("react.lazy"):60116,d1=typeof Symbol=="function"&&Symbol.iterator;function sc(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;nDd.length&&Dd.push(t)}function rv(t,e,n,r){var i=typeof t;(i==="undefined"||i==="boolean")&&(t=null);var s=!1;if(t===null)s=!0;else switch(i){case"string":case"number":s=!0;break;case"object":switch(t.$$typeof){case ic:case r3:s=!0}}if(s)return n(r,t,e===""?"."+Sm(t,0):e),1;if(s=0,e=e===""?".":e+":",Array.isArray(t))for(var o=0;ow3.decode(t),_3=new TextEncoder,c0=t=>_3.encode(t),[b4,b3]=(()=>{const t=()=>{throw new Error("BigInt is not available in this environment")};function e(){throw t()}return e.asIntN=()=>{throw t()},e.asUintN=()=>{throw t()},typeof BigInt<"u"?[BigInt,!0]:[e,!1]})(),[oc,S4]=(()=>{const t=()=>{throw new Error("BigInt64Array is not available in this environment")};class e{static get BYTES_PER_ELEMENT(){return 8}static of(){throw t()}static from(){throw t()}constructor(){throw t()}}return typeof BigInt64Array<"u"?[BigInt64Array,!0]:[e,!1]})(),[ac,I4]=(()=>{const t=()=>{throw new Error("BigUint64Array is not available in this environment")};class e{static get BYTES_PER_ELEMENT(){return 8}static of(){throw t()}static from(){throw t()}constructor(){throw t()}}return typeof BigUint64Array<"u"?[BigUint64Array,!0]:[e,!1]})(),S3=t=>typeof t=="number",Pk=t=>typeof t=="boolean",Ut=t=>typeof t=="function",Nn=t=>t!=null&&Object(t)===t,Ms=t=>Nn(t)&&Ut(t.then),uc=t=>Nn(t)&&Ut(t[Symbol.iterator]),fu=t=>Nn(t)&&Ut(t[Symbol.asyncIterator]),av=t=>Nn(t)&&Nn(t.schema),Rk=t=>Nn(t)&&"done"in t&&"value"in t,Tk=t=>Nn(t)&&Ut(t.stat)&&S3(t.fd),Mk=t=>Nn(t)&&f0(t.body),$h=t=>"_getDOMStream"in t&&"_getNodeStream"in t,I3=t=>Nn(t)&&Ut(t.abort)&&Ut(t.getWriter)&&!$h(t),f0=t=>Nn(t)&&Ut(t.cancel)&&Ut(t.getReader)&&!$h(t),E3=t=>Nn(t)&&Ut(t.end)&&Ut(t.write)&&Pk(t.writable)&&!$h(t),Nk=t=>Nn(t)&&Ut(t.read)&&Ut(t.pipe)&&Pk(t.readable)&&!$h(t),O3=t=>Nn(t)&&Ut(t.clear)&&Ut(t.bytes)&&Ut(t.position)&&Ut(t.setPosition)&&Ut(t.capacity)&&Ut(t.getBufferIdentifier)&&Ut(t.createLong),d0=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function k3(t){const e=t[0]?[t[0]]:[];let n,r,i,s;for(let o,a,l=0,f=0,h=t.length;++lh+m.byteLength,0);let i,s,o,a=0,l=-1;const f=Math.min(e||Number.POSITIVE_INFINITY,r);for(const h=n.length;++lrt(Int32Array,t),Ue=t=>rt(Uint8Array,t),uv=t=>(t.next(),t);function*D3(t,e){const n=function*(i){yield i},r=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof d0?n(e):uc(e)?e:n(e);return yield*uv(function*(i){let s=null;do s=i.next(yield rt(t,s));while(!s.done)}(r[Symbol.iterator]())),new t}const x3=t=>D3(Uint8Array,t);function Bk(t,e){return Dr(this,arguments,function*(){if(Ms(e))return yield ge(yield ge(yield*Df(Ds(Bk(t,yield ge(e))))));const r=function(o){return Dr(this,arguments,function*(){yield yield ge(yield ge(o))})},i=function(o){return Dr(this,arguments,function*(){yield ge(yield*Df(Ds(uv(function*(a){let l=null;do l=a.next(yield l==null?void 0:l.value);while(!l.done)}(o[Symbol.iterator]())))))})},s=typeof e=="string"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer||e instanceof d0?r(e):uc(e)?i(e):fu(e)?e:r(e);return yield ge(yield*Df(Ds(uv(function(o){return Dr(this,arguments,function*(){let a=null;do a=yield ge(o.next(yield yield ge(rt(t,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield ge(new t)})}const C3=t=>Bk(Uint8Array,t);function h0(t,e,n){if(t!==0){n=n.slice(0,e+1);for(let r=-1;++r<=e;)n[r]+=t}return n}function A3(t,e){let n=0;const r=t.length;if(r!==e.length)return!1;if(r>0)do if(t[n]!==e[n])return!1;while(++n(t.next(),t);function*P3(t){let e,n=!1,r=[],i,s,o,a=0;function l(){return s==="peek"?fi(r,o)[0]:([i,r,a]=fi(r,o),i)}({cmd:s,size:o}=yield null);const f=x3(t)[Symbol.iterator]();try{do if({done:e,value:i}=Number.isNaN(o-a)?f.next():f.next(o-a),!e&&i.byteLength>0&&(r.push(i),a+=i.byteLength),e||o<=a)do({cmd:s,size:o}=yield l());while(o0&&(i.push(s),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield ge(f()));while(a0&&(i.push(Ue(s)),l+=s.byteLength),n||a<=l)do({cmd:o,size:a}=yield yield ge(f()));while(a{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(e){return ve(this,void 0,void 0,function*(){const{reader:n,source:r}=this;n&&(yield n.cancel(e).catch(()=>{})),r&&r.locked&&this.releaseLock()})}read(e){return ve(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array(0)};const n=yield this.reader.read();return!n.done&&(n.value=Ue(n)),n})}}const Im=(t,e)=>{const n=i=>r([e,i]);let r;return[e,n,new Promise(i=>(r=i)&&t.once(e,n))]};function N3(t){return Dr(this,arguments,function*(){const n=[];let r="error",i=!1,s=null,o,a,l=0,f=[],h;function m(){return o==="peek"?fi(f,a)[0]:([h,f,l]=fi(f,a),h)}if({cmd:o,size:a}=yield yield ge(null),t.isTTY)return yield yield ge(new Uint8Array(0)),yield ge(null);try{n[0]=Im(t,"end"),n[1]=Im(t,"error");do{if(n[2]=Im(t,"readable"),[r,s]=yield ge(Promise.race(n.map(w=>w[2]))),r==="error")break;if((i=r==="end")||(Number.isFinite(a-l)?(h=Ue(t.read(a-l)),h.byteLength0&&(f.push(h),l+=h.byteLength)),i||a<=l)do({cmd:o,size:a}=yield yield ge(m()));while(a{for(const[S,_]of w)t.off(S,_);try{const S=t.destroy;S&&S.call(t,I),I=void 0}catch(S){I=S||I}finally{I!=null?$(I):E()}})}})}var Yn;(function(t){t[t.V1=0]="V1",t[t.V2=1]="V2",t[t.V3=2]="V3",t[t.V4=3]="V4",t[t.V5=4]="V5"})(Yn||(Yn={}));var tr;(function(t){t[t.Sparse=0]="Sparse",t[t.Dense=1]="Dense"})(tr||(tr={}));var An;(function(t){t[t.HALF=0]="HALF",t[t.SINGLE=1]="SINGLE",t[t.DOUBLE=2]="DOUBLE"})(An||(An={}));var Hi;(function(t){t[t.DAY=0]="DAY",t[t.MILLISECOND=1]="MILLISECOND"})(Hi||(Hi={}));var ze;(function(t){t[t.SECOND=0]="SECOND",t[t.MILLISECOND=1]="MILLISECOND",t[t.MICROSECOND=2]="MICROSECOND",t[t.NANOSECOND=3]="NANOSECOND"})(ze||(ze={}));var Ns;(function(t){t[t.YEAR_MONTH=0]="YEAR_MONTH",t[t.DAY_TIME=1]="DAY_TIME",t[t.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(Ns||(Ns={}));var Ve;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(Ve||(Ve={}));var N;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.Float=3]="Float",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct=13]="Struct",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Dictionary=-1]="Dictionary",t[t.Int8=-2]="Int8",t[t.Int16=-3]="Int16",t[t.Int32=-4]="Int32",t[t.Int64=-5]="Int64",t[t.Uint8=-6]="Uint8",t[t.Uint16=-7]="Uint16",t[t.Uint32=-8]="Uint32",t[t.Uint64=-9]="Uint64",t[t.Float16=-10]="Float16",t[t.Float32=-11]="Float32",t[t.Float64=-12]="Float64",t[t.DateDay=-13]="DateDay",t[t.DateMillisecond=-14]="DateMillisecond",t[t.TimestampSecond=-15]="TimestampSecond",t[t.TimestampMillisecond=-16]="TimestampMillisecond",t[t.TimestampMicrosecond=-17]="TimestampMicrosecond",t[t.TimestampNanosecond=-18]="TimestampNanosecond",t[t.TimeSecond=-19]="TimeSecond",t[t.TimeMillisecond=-20]="TimeMillisecond",t[t.TimeMicrosecond=-21]="TimeMicrosecond",t[t.TimeNanosecond=-22]="TimeNanosecond",t[t.DenseUnion=-23]="DenseUnion",t[t.SparseUnion=-24]="SparseUnion",t[t.IntervalDayTime=-25]="IntervalDayTime",t[t.IntervalYearMonth=-26]="IntervalYearMonth"})(N||(N={}));var bi;(function(t){t[t.OFFSET=0]="OFFSET",t[t.DATA=1]="DATA",t[t.VALIDITY=2]="VALIDITY",t[t.TYPE=3]="TYPE"})(bi||(bi={}));const B3=void 0;function Nl(t){if(t===null)return"null";if(t===B3)return"undefined";switch(typeof t){case"number":return`${t}`;case"bigint":return`${t}`;case"string":return`"${t}"`}return typeof t[Symbol.toPrimitive]=="function"?t[Symbol.toPrimitive]("string"):ArrayBuffer.isView(t)?t instanceof oc||t instanceof ac?`[${[...t].map(e=>Nl(e))}]`:`[${t}]`:ArrayBuffer.isView(t)?`[${t}]`:JSON.stringify(t,(e,n)=>typeof n=="bigint"?`${n}`:n)}const F3=Symbol.for("isArrowBigNum");function $r(t,...e){return e.length===0?Object.setPrototypeOf(rt(this.TypedArray,t),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(t,...e),this.constructor.prototype)}$r.prototype[F3]=!0;$r.prototype.toJSON=function(){return`"${xo(this)}"`};$r.prototype.valueOf=function(){return Fk(this)};$r.prototype.toString=function(){return xo(this)};$r.prototype[Symbol.toPrimitive]=function(t="default"){switch(t){case"number":return Fk(this);case"string":return xo(this);case"default":return lv(this)}return xo(this)};function xa(...t){return $r.apply(this,t)}function Ca(...t){return $r.apply(this,t)}function Bl(...t){return $r.apply(this,t)}Object.setPrototypeOf(xa.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Ca.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Bl.prototype,Object.create(Uint32Array.prototype));Object.assign(xa.prototype,$r.prototype,{constructor:xa,signed:!0,TypedArray:Int32Array,BigIntArray:oc});Object.assign(Ca.prototype,$r.prototype,{constructor:Ca,signed:!1,TypedArray:Uint32Array,BigIntArray:ac});Object.assign(Bl.prototype,$r.prototype,{constructor:Bl,signed:!0,TypedArray:Uint32Array,BigIntArray:ac});function Fk(t){const{buffer:e,byteOffset:n,length:r,signed:i}=t,s=new ac(e,n,r),o=i&&s[s.length-1]&BigInt(1)<t.byteLength===8?new t.BigIntArray(t.buffer,t.byteOffset,1)[0]:Em(t),xo=t=>t.byteLength===8?`${new t.BigIntArray(t.buffer,t.byteOffset,1)[0]}`:Em(t)):(xo=Em,lv=xo);function Em(t){let e="";const n=new Uint32Array(2);let r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2);const i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer);let s=-1;const o=r.length-1;do{for(n[0]=r[s=0];s(t.children=null,t.ArrayType=Array,t[Symbol.toStringTag]="DataType"))(we.prototype);let Bs=class extends we{toString(){return"Null"}get typeId(){return N.Null}};$k=Symbol.toStringTag;Bs[$k]=(t=>t[Symbol.toStringTag]="Null")(Bs.prototype);class Fs extends we{constructor(e,n){super(),this.isSigned=e,this.bitWidth=n}get typeId(){return N.Int}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?oc:ac}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}jk=Symbol.toStringTag;Fs[jk]=(t=>(t.isSigned=null,t.bitWidth=null,t[Symbol.toStringTag]="Int"))(Fs.prototype);class Fl extends Fs{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}Object.defineProperty(Fl.prototype,"ArrayType",{value:Int32Array});class Ll extends we{constructor(e){super(),this.precision=e}get typeId(){return N.Float}get ArrayType(){switch(this.precision){case An.HALF:return Uint16Array;case An.SINGLE:return Float32Array;case An.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}}Uk=Symbol.toStringTag;Ll[Uk]=(t=>(t.precision=null,t[Symbol.toStringTag]="Float"))(Ll.prototype);let xd=class extends we{constructor(){super()}get typeId(){return N.Binary}toString(){return"Binary"}};zk=Symbol.toStringTag;xd[zk]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Binary"))(xd.prototype);let Cd=class extends we{constructor(){super()}get typeId(){return N.Utf8}toString(){return"Utf8"}};Vk=Symbol.toStringTag;Cd[Vk]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Utf8"))(Cd.prototype);let Ad=class extends we{constructor(){super()}get typeId(){return N.Bool}toString(){return"Bool"}};Kk=Symbol.toStringTag;Ad[Kk]=(t=>(t.ArrayType=Uint8Array,t[Symbol.toStringTag]="Bool"))(Ad.prototype);let Pd=class extends we{constructor(e,n,r=128){super(),this.scale=e,this.precision=n,this.bitWidth=r}get typeId(){return N.Decimal}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};Wk=Symbol.toStringTag;Pd[Wk]=(t=>(t.scale=null,t.precision=null,t.ArrayType=Uint32Array,t[Symbol.toStringTag]="Decimal"))(Pd.prototype);class Rd extends we{constructor(e){super(),this.unit=e}get typeId(){return N.Date}toString(){return`Date${(this.unit+1)*32}<${Hi[this.unit]}>`}}qk=Symbol.toStringTag;Rd[qk]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Date"))(Rd.prototype);class $l extends we{constructor(e,n){super(),this.unit=e,this.bitWidth=n}get typeId(){return N.Time}toString(){return`Time${this.bitWidth}<${ze[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return oc}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}}Hk=Symbol.toStringTag;$l[Hk]=(t=>(t.unit=null,t.bitWidth=null,t[Symbol.toStringTag]="Time"))($l.prototype);class Td extends we{constructor(e,n){super(),this.unit=e,this.timezone=n}get typeId(){return N.Timestamp}toString(){return`Timestamp<${ze[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}Qk=Symbol.toStringTag;Td[Qk]=(t=>(t.unit=null,t.timezone=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Timestamp"))(Td.prototype);class Md extends we{constructor(e){super(),this.unit=e}get typeId(){return N.Interval}toString(){return`Interval<${Ns[this.unit]}>`}}Yk=Symbol.toStringTag;Md[Yk]=(t=>(t.unit=null,t.ArrayType=Int32Array,t[Symbol.toStringTag]="Interval"))(Md.prototype);let Nd=class extends we{constructor(e){super(),this.children=[e]}get typeId(){return N.List}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};Gk=Symbol.toStringTag;Nd[Gk]=(t=>(t.children=null,t[Symbol.toStringTag]="List"))(Nd.prototype);class pn extends we{constructor(e){super(),this.children=e}get typeId(){return N.Struct}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}Jk=Symbol.toStringTag;pn[Jk]=(t=>(t.children=null,t[Symbol.toStringTag]="Struct"))(pn.prototype);class Bd extends we{constructor(e,n,r){super(),this.mode=e,this.children=r,this.typeIds=n=Int32Array.from(n),this.typeIdToChildIndex=n.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}get typeId(){return N.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(" | ")}>`}}Xk=Symbol.toStringTag;Bd[Xk]=(t=>(t.mode=null,t.typeIds=null,t.children=null,t.typeIdToChildIndex=null,t.ArrayType=Int8Array,t[Symbol.toStringTag]="Union"))(Bd.prototype);let Fd=class extends we{constructor(e){super(),this.byteWidth=e}get typeId(){return N.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};Zk=Symbol.toStringTag;Fd[Zk]=(t=>(t.byteWidth=null,t.ArrayType=Uint8Array,t[Symbol.toStringTag]="FixedSizeBinary"))(Fd.prototype);let Ld=class extends we{constructor(e,n){super(),this.listSize=e,this.children=[n]}get typeId(){return N.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};eD=Symbol.toStringTag;Ld[eD]=(t=>(t.children=null,t.listSize=null,t[Symbol.toStringTag]="FixedSizeList"))(Ld.prototype);class $d extends we{constructor(e,n=!1){super(),this.children=[e],this.keysSorted=n}get typeId(){return N.Map}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(", ")}}>`}}tD=Symbol.toStringTag;$d[tD]=(t=>(t.children=null,t.keysSorted=null,t[Symbol.toStringTag]="Map_"))($d.prototype);const L3=(t=>()=>++t)(-1);class Ya extends we{constructor(e,n,r,i){super(),this.indices=n,this.dictionary=e,this.isOrdered=i||!1,this.id=r==null?L3():typeof r=="number"?r:r.low}get typeId(){return N.Dictionary}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}nD=Symbol.toStringTag;Ya[nD]=(t=>(t.id=null,t.indices=null,t.isOrdered=null,t.dictionary=null,t[Symbol.toStringTag]="Dictionary"))(Ya.prototype);function Si(t){const e=t;switch(t.typeId){case N.Decimal:return t.bitWidth/32;case N.Timestamp:return 2;case N.Date:return 1+e.unit;case N.Interval:return 1+e.unit;case N.FixedSizeList:return e.listSize;case N.FixedSizeBinary:return e.byteWidth;default:return 1}}class Be{visitMany(e,...n){return e.map((r,i)=>this.visit(r,...n.map(s=>s[i])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,n=!0){return $3(this,e,n)}getVisitFnByTypeId(e,n=!0){return sa(this,e,n)}visitNull(e,...n){return null}visitBool(e,...n){return null}visitInt(e,...n){return null}visitFloat(e,...n){return null}visitUtf8(e,...n){return null}visitBinary(e,...n){return null}visitFixedSizeBinary(e,...n){return null}visitDate(e,...n){return null}visitTimestamp(e,...n){return null}visitTime(e,...n){return null}visitDecimal(e,...n){return null}visitList(e,...n){return null}visitStruct(e,...n){return null}visitUnion(e,...n){return null}visitDictionary(e,...n){return null}visitInterval(e,...n){return null}visitFixedSizeList(e,...n){return null}visitMap(e,...n){return null}}function $3(t,e,n=!0){return typeof e=="number"?sa(t,e,n):typeof e=="string"&&e in N?sa(t,N[e],n):e&&e instanceof we?sa(t,p1(e),n):e!=null&&e.type&&e.type instanceof we?sa(t,p1(e.type),n):sa(t,N.NONE,n)}function sa(t,e,n=!0){let r=null;switch(e){case N.Null:r=t.visitNull;break;case N.Bool:r=t.visitBool;break;case N.Int:r=t.visitInt;break;case N.Int8:r=t.visitInt8||t.visitInt;break;case N.Int16:r=t.visitInt16||t.visitInt;break;case N.Int32:r=t.visitInt32||t.visitInt;break;case N.Int64:r=t.visitInt64||t.visitInt;break;case N.Uint8:r=t.visitUint8||t.visitInt;break;case N.Uint16:r=t.visitUint16||t.visitInt;break;case N.Uint32:r=t.visitUint32||t.visitInt;break;case N.Uint64:r=t.visitUint64||t.visitInt;break;case N.Float:r=t.visitFloat;break;case N.Float16:r=t.visitFloat16||t.visitFloat;break;case N.Float32:r=t.visitFloat32||t.visitFloat;break;case N.Float64:r=t.visitFloat64||t.visitFloat;break;case N.Utf8:r=t.visitUtf8;break;case N.Binary:r=t.visitBinary;break;case N.FixedSizeBinary:r=t.visitFixedSizeBinary;break;case N.Date:r=t.visitDate;break;case N.DateDay:r=t.visitDateDay||t.visitDate;break;case N.DateMillisecond:r=t.visitDateMillisecond||t.visitDate;break;case N.Timestamp:r=t.visitTimestamp;break;case N.TimestampSecond:r=t.visitTimestampSecond||t.visitTimestamp;break;case N.TimestampMillisecond:r=t.visitTimestampMillisecond||t.visitTimestamp;break;case N.TimestampMicrosecond:r=t.visitTimestampMicrosecond||t.visitTimestamp;break;case N.TimestampNanosecond:r=t.visitTimestampNanosecond||t.visitTimestamp;break;case N.Time:r=t.visitTime;break;case N.TimeSecond:r=t.visitTimeSecond||t.visitTime;break;case N.TimeMillisecond:r=t.visitTimeMillisecond||t.visitTime;break;case N.TimeMicrosecond:r=t.visitTimeMicrosecond||t.visitTime;break;case N.TimeNanosecond:r=t.visitTimeNanosecond||t.visitTime;break;case N.Decimal:r=t.visitDecimal;break;case N.List:r=t.visitList;break;case N.Struct:r=t.visitStruct;break;case N.Union:r=t.visitUnion;break;case N.DenseUnion:r=t.visitDenseUnion||t.visitUnion;break;case N.SparseUnion:r=t.visitSparseUnion||t.visitUnion;break;case N.Dictionary:r=t.visitDictionary;break;case N.Interval:r=t.visitInterval;break;case N.IntervalDayTime:r=t.visitIntervalDayTime||t.visitInterval;break;case N.IntervalYearMonth:r=t.visitIntervalYearMonth||t.visitInterval;break;case N.FixedSizeList:r=t.visitFixedSizeList;break;case N.Map:r=t.visitMap;break}if(typeof r=="function")return r;if(!n)return()=>null;throw new Error(`Unrecognized type '${N[e]}'`)}function p1(t){switch(t.typeId){case N.Null:return N.Null;case N.Int:{const{bitWidth:e,isSigned:n}=t;switch(e){case 8:return n?N.Int8:N.Uint8;case 16:return n?N.Int16:N.Uint16;case 32:return n?N.Int32:N.Uint32;case 64:return n?N.Int64:N.Uint64}return N.Int}case N.Float:switch(t.precision){case An.HALF:return N.Float16;case An.SINGLE:return N.Float32;case An.DOUBLE:return N.Float64}return N.Float;case N.Binary:return N.Binary;case N.Utf8:return N.Utf8;case N.Bool:return N.Bool;case N.Decimal:return N.Decimal;case N.Time:switch(t.unit){case ze.SECOND:return N.TimeSecond;case ze.MILLISECOND:return N.TimeMillisecond;case ze.MICROSECOND:return N.TimeMicrosecond;case ze.NANOSECOND:return N.TimeNanosecond}return N.Time;case N.Timestamp:switch(t.unit){case ze.SECOND:return N.TimestampSecond;case ze.MILLISECOND:return N.TimestampMillisecond;case ze.MICROSECOND:return N.TimestampMicrosecond;case ze.NANOSECOND:return N.TimestampNanosecond}return N.Timestamp;case N.Date:switch(t.unit){case Hi.DAY:return N.DateDay;case Hi.MILLISECOND:return N.DateMillisecond}return N.Date;case N.Interval:switch(t.unit){case Ns.DAY_TIME:return N.IntervalDayTime;case Ns.YEAR_MONTH:return N.IntervalYearMonth}return N.Interval;case N.Map:return N.Map;case N.List:return N.List;case N.Struct:return N.Struct;case N.Union:switch(t.mode){case tr.Dense:return N.DenseUnion;case tr.Sparse:return N.SparseUnion}return N.Union;case N.FixedSizeBinary:return N.FixedSizeBinary;case N.FixedSizeList:return N.FixedSizeList;case N.Dictionary:return N.Dictionary}throw new Error(`Unrecognized type '${N[t.typeId]}'`)}Be.prototype.visitInt8=null;Be.prototype.visitInt16=null;Be.prototype.visitInt32=null;Be.prototype.visitInt64=null;Be.prototype.visitUint8=null;Be.prototype.visitUint16=null;Be.prototype.visitUint32=null;Be.prototype.visitUint64=null;Be.prototype.visitFloat16=null;Be.prototype.visitFloat32=null;Be.prototype.visitFloat64=null;Be.prototype.visitDateDay=null;Be.prototype.visitDateMillisecond=null;Be.prototype.visitTimestampSecond=null;Be.prototype.visitTimestampMillisecond=null;Be.prototype.visitTimestampMicrosecond=null;Be.prototype.visitTimestampNanosecond=null;Be.prototype.visitTimeSecond=null;Be.prototype.visitTimeMillisecond=null;Be.prototype.visitTimeMicrosecond=null;Be.prototype.visitTimeNanosecond=null;Be.prototype.visitDenseUnion=null;Be.prototype.visitSparseUnion=null;Be.prototype.visitIntervalDayTime=null;Be.prototype.visitIntervalYearMonth=null;const rD=new Float64Array(1),na=new Uint32Array(rD.buffer);function iD(t){const e=(t&31744)>>10,n=(t&1023)/1024,r=Math.pow(-1,(t&32768)>>15);switch(e){case 31:return r*(n?Number.NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*Math.pow(2,e-15)*(1+n)}function j3(t){if(t!==t)return 32256;rD[0]=t;const e=(na[1]&2147483648)>>16&65535;let n=na[1]&2146435072,r=0;return n>=1089470464?na[0]>0?n=31744:(n=(n&2080374784)>>16,r=(na[1]&1048575)>>10):n<=1056964608?(r=1048576+(na[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(na[1]&1048575)+512>>10),e|n|r&65535}class Ee extends Be{}function xe(t){return(e,n,r)=>{if(e.setValid(n,r!=null))return t(e,n,r)}}const U3=(t,e,n)=>{t[e]=Math.trunc(n/864e5)},m0=(t,e,n)=>{t[e]=Math.trunc(n%4294967296),t[e+1]=Math.trunc(n/4294967296)},z3=(t,e,n)=>{t[e]=Math.trunc(n*1e3%4294967296),t[e+1]=Math.trunc(n*1e3/4294967296)},V3=(t,e,n)=>{t[e]=Math.trunc(n*1e6%4294967296),t[e+1]=Math.trunc(n*1e6/4294967296)},sD=(t,e,n,r)=>{if(n+1{const i=t+n;r?e[i>>3]|=1<>3]&=~(1<{t[e]=n},y0=({values:t},e,n)=>{t[e]=n},oD=({values:t},e,n)=>{t[e]=j3(n)},W3=(t,e,n)=>{switch(t.type.precision){case An.HALF:return oD(t,e,n);case An.SINGLE:case An.DOUBLE:return y0(t,e,n)}},aD=({values:t},e,n)=>{U3(t,e,n.valueOf())},uD=({values:t},e,n)=>{m0(t,e*2,n.valueOf())},q3=({stride:t,values:e},n,r)=>{e.set(r.subarray(0,t),t*n)},H3=({values:t,valueOffsets:e},n,r)=>sD(t,e,n,r),Q3=({values:t,valueOffsets:e},n,r)=>{sD(t,e,n,c0(r))},Y3=(t,e,n)=>{t.type.unit===Hi.DAY?aD(t,e,n):uD(t,e,n)},lD=({values:t},e,n)=>m0(t,e*2,n/1e3),cD=({values:t},e,n)=>m0(t,e*2,n),fD=({values:t},e,n)=>z3(t,e*2,n),dD=({values:t},e,n)=>V3(t,e*2,n),G3=(t,e,n)=>{switch(t.type.unit){case ze.SECOND:return lD(t,e,n);case ze.MILLISECOND:return cD(t,e,n);case ze.MICROSECOND:return fD(t,e,n);case ze.NANOSECOND:return dD(t,e,n)}},hD=({values:t},e,n)=>{t[e]=n},pD=({values:t},e,n)=>{t[e]=n},mD=({values:t},e,n)=>{t[e]=n},yD=({values:t},e,n)=>{t[e]=n},J3=(t,e,n)=>{switch(t.type.unit){case ze.SECOND:return hD(t,e,n);case ze.MILLISECOND:return pD(t,e,n);case ze.MICROSECOND:return mD(t,e,n);case ze.NANOSECOND:return yD(t,e,n)}},X3=({values:t,stride:e},n,r)=>{t.set(r.subarray(0,e),e*n)},Z3=(t,e,n)=>{const r=t.children[0],i=t.valueOffsets,s=_r.getVisitFn(r);if(Array.isArray(n))for(let o=-1,a=i[e],l=i[e+1];a{const r=t.children[0],{valueOffsets:i}=t,s=_r.getVisitFn(r);let{[e]:o,[e+1]:a}=i;const l=n instanceof Map?n.entries():Object.entries(n);for(const f of l)if(s(r,o,f),++o>=a)break},t$=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[s]),n$=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(s)),r$=(t,e)=>(n,r,i,s)=>r&&n(r,t,e.get(i.name)),i$=(t,e)=>(n,r,i,s)=>r&&n(r,t,e[i.name]),s$=(t,e,n)=>{const r=t.type.children.map(s=>_r.getVisitFn(s.type)),i=n instanceof Map?r$(e,n):n instanceof Ke?n$(e,n):Array.isArray(n)?t$(e,n):i$(e,n);t.type.children.forEach((s,o)=>i(r[o],t.children[o],s,o))},o$=(t,e,n)=>{t.type.mode===tr.Dense?vD(t,e,n):gD(t,e,n)},vD=(t,e,n)=>{const r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];_r.visit(i,t.valueOffsets[e],n)},gD=(t,e,n)=>{const r=t.type.typeIdToChildIndex[t.typeIds[e]],i=t.children[r];_r.visit(i,e,n)},a$=(t,e,n)=>{var r;(r=t.dictionary)===null||r===void 0||r.set(t.values[e],n)},u$=(t,e,n)=>{t.type.unit===Ns.DAY_TIME?wD(t,e,n):_D(t,e,n)},wD=({values:t},e,n)=>{t.set(n.subarray(0,2),2*e)},_D=({values:t},e,n)=>{t[e]=n[0]*12+n[1]%12},l$=(t,e,n)=>{const{stride:r}=t,i=t.children[0],s=_r.getVisitFn(i);if(Array.isArray(n))for(let o=-1,a=e*r;++o`${Nl(e)}: ${Nl(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new c$(this[Or],this[Aa])}}class c${constructor(e,n){this.childIndex=0,this.children=e.children,this.rowIndex=n,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){const e=this.childIndex;return en.name)}has(e,n){return e[Or].type.children.findIndex(r=>r.name===n)!==-1}getOwnPropertyDescriptor(e,n){if(e[Or].type.children.findIndex(r=>r.name===n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];const r=e[Or].type.children.findIndex(i=>i.name===n);if(r!==-1){const i=Bn.visit(e[Or].children[r],e[Aa]);return Reflect.set(e,n,i),i}}set(e,n,r){const i=e[Or].type.children.findIndex(s=>s.name===n);return i!==-1?(_r.visit(e[Or].children[i],e[Aa],r),Reflect.set(e,n,r)):Reflect.has(e,n)||typeof n=="symbol"?Reflect.set(e,n,r):!1}}class _e extends Be{}function Oe(t){return(e,n)=>e.getValid(n)?t(e,n):null}const d$=(t,e)=>864e5*t[e],g0=(t,e)=>4294967296*t[e+1]+(t[e]>>>0),h$=(t,e)=>4294967296*(t[e+1]/1e3)+(t[e]>>>0)/1e3,p$=(t,e)=>4294967296*(t[e+1]/1e6)+(t[e]>>>0)/1e6,bD=t=>new Date(t),m$=(t,e)=>bD(d$(t,e)),y$=(t,e)=>bD(g0(t,e)),v$=(t,e)=>null,SD=(t,e,n)=>{if(n+1>=e.length)return null;const r=e[n],i=e[n+1];return t.subarray(r,i)},g$=({offset:t,values:e},n)=>{const r=t+n;return(e[r>>3]&1<m$(t,e),ED=({values:t},e)=>y$(t,e*2),Hs=({stride:t,values:e},n)=>e[t*n],w$=({stride:t,values:e},n)=>iD(e[t*n]),OD=({values:t},e)=>t[e],_$=({stride:t,values:e},n)=>e.subarray(t*n,t*(n+1)),b$=({values:t,valueOffsets:e},n)=>SD(t,e,n),S$=({values:t,valueOffsets:e},n)=>{const r=SD(t,e,n);return r!==null?ov(r):null},I$=({values:t},e)=>t[e],E$=({type:t,values:e},n)=>t.precision!==An.HALF?e[n]:iD(e[n]),O$=(t,e)=>t.type.unit===Hi.DAY?ID(t,e):ED(t,e),kD=({values:t},e)=>1e3*g0(t,e*2),DD=({values:t},e)=>g0(t,e*2),xD=({values:t},e)=>h$(t,e*2),CD=({values:t},e)=>p$(t,e*2),k$=(t,e)=>{switch(t.type.unit){case ze.SECOND:return kD(t,e);case ze.MILLISECOND:return DD(t,e);case ze.MICROSECOND:return xD(t,e);case ze.NANOSECOND:return CD(t,e)}},AD=({values:t},e)=>t[e],PD=({values:t},e)=>t[e],RD=({values:t},e)=>t[e],TD=({values:t},e)=>t[e],D$=(t,e)=>{switch(t.type.unit){case ze.SECOND:return AD(t,e);case ze.MILLISECOND:return PD(t,e);case ze.MICROSECOND:return RD(t,e);case ze.NANOSECOND:return TD(t,e)}},x$=({values:t,stride:e},n)=>p0.decimal(t.subarray(e*n,e*(n+1))),C$=(t,e)=>{const{valueOffsets:n,stride:r,children:i}=t,{[e*r]:s,[e*r+1]:o}=n,l=i[0].slice(s,o-s);return new Ke([l])},A$=(t,e)=>{const{valueOffsets:n,children:r}=t,{[e]:i,[e+1]:s}=n,o=r[0];return new w0(o.slice(i,s-i))},P$=(t,e)=>new v0(t,e),R$=(t,e)=>t.type.mode===tr.Dense?MD(t,e):ND(t,e),MD=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Bn.visit(r,t.valueOffsets[e])},ND=(t,e)=>{const n=t.type.typeIdToChildIndex[t.typeIds[e]],r=t.children[n];return Bn.visit(r,e)},T$=(t,e)=>{var n;return(n=t.dictionary)===null||n===void 0?void 0:n.get(t.values[e])},M$=(t,e)=>t.type.unit===Ns.DAY_TIME?BD(t,e):FD(t,e),BD=({values:t},e)=>t.subarray(2*e,2*(e+1)),FD=({values:t},e)=>{const n=t[e],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},N$=(t,e)=>{const{stride:n,children:r}=t,s=r[0].slice(e*n,n);return new Ke([s])};_e.prototype.visitNull=Oe(v$);_e.prototype.visitBool=Oe(g$);_e.prototype.visitInt=Oe(I$);_e.prototype.visitInt8=Oe(Hs);_e.prototype.visitInt16=Oe(Hs);_e.prototype.visitInt32=Oe(Hs);_e.prototype.visitInt64=Oe(OD);_e.prototype.visitUint8=Oe(Hs);_e.prototype.visitUint16=Oe(Hs);_e.prototype.visitUint32=Oe(Hs);_e.prototype.visitUint64=Oe(OD);_e.prototype.visitFloat=Oe(E$);_e.prototype.visitFloat16=Oe(w$);_e.prototype.visitFloat32=Oe(Hs);_e.prototype.visitFloat64=Oe(Hs);_e.prototype.visitUtf8=Oe(S$);_e.prototype.visitBinary=Oe(b$);_e.prototype.visitFixedSizeBinary=Oe(_$);_e.prototype.visitDate=Oe(O$);_e.prototype.visitDateDay=Oe(ID);_e.prototype.visitDateMillisecond=Oe(ED);_e.prototype.visitTimestamp=Oe(k$);_e.prototype.visitTimestampSecond=Oe(kD);_e.prototype.visitTimestampMillisecond=Oe(DD);_e.prototype.visitTimestampMicrosecond=Oe(xD);_e.prototype.visitTimestampNanosecond=Oe(CD);_e.prototype.visitTime=Oe(D$);_e.prototype.visitTimeSecond=Oe(AD);_e.prototype.visitTimeMillisecond=Oe(PD);_e.prototype.visitTimeMicrosecond=Oe(RD);_e.prototype.visitTimeNanosecond=Oe(TD);_e.prototype.visitDecimal=Oe(x$);_e.prototype.visitList=Oe(C$);_e.prototype.visitStruct=Oe(P$);_e.prototype.visitUnion=Oe(R$);_e.prototype.visitDenseUnion=Oe(MD);_e.prototype.visitSparseUnion=Oe(ND);_e.prototype.visitDictionary=Oe(T$);_e.prototype.visitInterval=Oe(M$);_e.prototype.visitIntervalDayTime=Oe(BD);_e.prototype.visitIntervalYearMonth=Oe(FD);_e.prototype.visitFixedSizeList=Oe(N$);_e.prototype.visitMap=Oe(A$);const Bn=new _e,Zr=Symbol.for("keys"),Pa=Symbol.for("vals");class w0{constructor(e){return this[Zr]=new Ke([e.children[0]]).memoize(),this[Pa]=e.children[1],new Proxy(this,new F$)}[Symbol.iterator](){return new B$(this[Zr],this[Pa])}get size(){return this[Zr].length}toArray(){return Object.values(this.toJSON())}toJSON(){const e=this[Zr],n=this[Pa],r={};for(let i=-1,s=e.length;++i`${Nl(e)}: ${Nl(n)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}class B${constructor(e,n){this.keys=e,this.vals=n,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){const e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),Bn.visit(this.vals,e)]})}}class F${isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[Zr].toArray().map(String)}has(e,n){return e[Zr].includes(n)}getOwnPropertyDescriptor(e,n){if(e[Zr].indexOf(n)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,n){if(Reflect.has(e,n))return e[n];const r=e[Zr].indexOf(n);if(r!==-1){const i=Bn.visit(Reflect.get(e,Pa),r);return Reflect.set(e,n,i),i}}set(e,n,r){const i=e[Zr].indexOf(n);return i!==-1?(_r.visit(Reflect.get(e,Pa),i,r),Reflect.set(e,n,r)):Reflect.has(e,n)?Reflect.set(e,n,r):!1}}Object.defineProperties(w0.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Zr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Pa]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let m1;function LD(t,e,n,r){const{length:i=0}=t;let s=typeof e!="number"?0:e,o=typeof n!="number"?i:n;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),oi&&(o=i),r?r(t,s,o):[s,o]}const y1=t=>t!==t;function du(t){if(typeof t!=="object"||t===null)return y1(t)?y1:n=>n===t;if(t instanceof Date){const n=t.valueOf();return r=>r instanceof Date?r.valueOf()===n:!1}return ArrayBuffer.isView(t)?n=>n?A3(t,n):!1:t instanceof Map?$$(t):Array.isArray(t)?L$(t):t instanceof Ke?j$(t):U$(t,!0)}function L$(t){const e=[];for(let n=-1,r=t.length;++n!1;const r=[];for(let i=-1,s=n.length;++i{if(!n||typeof n!="object")return!1;switch(n.constructor){case Array:return z$(t,n);case Map:return v1(t,n,n.keys());case w0:case v0:case Object:case void 0:return v1(t,n,e||Object.keys(n))}return n instanceof Ke?V$(t,n):!1}}function z$(t,e){const n=t.length;if(e.length!==n)return!1;for(let r=-1;++r>r}function _0(t,e,n){const r=n.byteLength+7&-8;if(t>0||n.byteLength>3):jd(new b0(n,t,e,null,$D)).subarray(0,r)),i}return n}function jd(t){const e=[];let n=0,r=0,i=0;for(const o of t)o&&(i|=1<0)&&(e[n++]=i);const s=new Uint8Array(e.length+7&-8);return s.set(e),s}class b0{constructor(e,n,r,i,s){this.bytes=e,this.length=r,this.context=i,this.get=s,this.bit=n%8,this.byteIndex=n>>3,this.byte=e[this.byteIndex++],this.index=0}next(){return this.index>3<<3,i=e+(e%8===0?0:8-e%8);return cv(t,e,i)+cv(t,r,n)+W$(t,i>>3,r-i>>3)}function W$(t,e,n){let r=0,i=Math.trunc(e);const s=new DataView(t.buffer,t.byteOffset,t.byteLength),o=n===void 0?t.byteLength:i+n;for(;o-i>=4;)r+=Om(s.getUint32(i)),i+=4;for(;o-i>=2;)r+=Om(s.getUint16(i)),i+=2;for(;o-i>=1;)r+=Om(s.getUint8(i)),i+=1;return r}function Om(t){let e=Math.trunc(t);return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24}const q$=-1;class at{constructor(e,n,r,i,s,o=[],a){this.type=e,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let l;s instanceof at?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Si(e),s&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l))),this.nullable=this._nullCount!==0&&this.nullBitmap&&this.nullBitmap.byteLength>0}get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get byteLength(){let e=0;const{valueOffsets:n,values:r,nullBitmap:i,typeIds:s}=this;return n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),s&&(e+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,e)}get nullCount(){let e=this._nullCount,n;return e<=q$&&(n=this.nullBitmap)&&(this._nullCount=e=this.length-cv(n,this.offset,this.offset+this.length)),e}getValid(e){if(this.nullable&&this.nullCount>0){const n=this.offset+e;return(this.nullBitmap[n>>3]&1<>3){const{nullBitmap:l}=this._changeLengthAndBackfillNullBitmap(this.length);Object.assign(this,{nullBitmap:l,_nullCount:0})}const{nullBitmap:r,offset:i}=this,s=i+e>>3,o=(i+e)%8,a=r[s]>>o&1;return n?a===0&&(r[s]|=1<>3).fill(255,0,n>>3);i[n>>3]=(1<0&&i.set(_0(this.offset,n,this.nullBitmap),0);const s=this.buffers;return s[bi.VALIDITY]=i,this.clone(this.type,0,e,r+(e-n),s)}_sliceBuffers(e,n,r,i){let s;const{buffers:o}=this;return(s=o[bi.TYPE])&&(o[bi.TYPE]=s.subarray(e,e+n)),(s=o[bi.OFFSET])&&(o[bi.OFFSET]=s.subarray(e,e+n+1))||(s=o[bi.DATA])&&(o[bi.DATA]=i===6?s:s.subarray(r*e,r*(e+n))),o}_sliceChildren(e,n,r){return e.map(i=>i.slice(n,r))}}at.prototype.children=Object.freeze([]);class ol extends Be{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){const{["type"]:n,["offset"]:r=0,["length"]:i=0}=e;return new at(n,r,i,0)}visitBool(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length>>3,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitInt(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitFloat(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length,["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitUtf8(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.data),s=Ue(e.nullBitmap),o=Fu(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[o,i,s])}visitBinary(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.data),s=Ue(e.nullBitmap),o=Fu(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[o,i,s])}visitFixedSizeBinary(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitDate(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitTimestamp(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitTime(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitDecimal(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitList(e){const{["type"]:n,["offset"]:r=0,["child"]:i}=e,s=Ue(e.nullBitmap),o=Fu(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[o,void 0,s],[i])}visitStruct(e){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=Ue(e.nullBitmap),{length:o=i.reduce((l,{length:f})=>Math.max(l,f),0),nullCount:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,void 0,s],i)}visitUnion(e){const{["type"]:n,["offset"]:r=0,["children"]:i=[]}=e,s=Ue(e.nullBitmap),o=rt(n.ArrayType,e.typeIds),{["length"]:a=o.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;if(we.isSparseUnion(n))return new at(n,r,a,l,[void 0,void 0,s,o],i);const f=Fu(e.valueOffsets);return new at(n,r,a,l,[f,void 0,s,o],i)}visitDictionary(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.indices.ArrayType,e.data),{["dictionary"]:o=new Ke([new ol().visit({type:n.dictionary})])}=e,{["length"]:a=s.length,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[void 0,s,i],[],o)}visitInterval(e){const{["type"]:n,["offset"]:r=0}=e,i=Ue(e.nullBitmap),s=rt(n.ArrayType,e.data),{["length"]:o=s.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,s,i])}visitFixedSizeList(e){const{["type"]:n,["offset"]:r=0,["child"]:i=new ol().visit({type:n.valueType})}=e,s=Ue(e.nullBitmap),{["length"]:o=i.length/Si(n),["nullCount"]:a=e.nullBitmap?-1:0}=e;return new at(n,r,o,a,[void 0,void 0,s],[i])}visitMap(e){const{["type"]:n,["offset"]:r=0,["child"]:i=new ol().visit({type:n.childType})}=e,s=Ue(e.nullBitmap),o=Fu(e.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:l=e.nullBitmap?-1:0}=e;return new at(n,r,a,l,[o,void 0,s],[i])}}function Ne(t){return new ol().visit(t)}class g1{constructor(e=0,n){this.numChunks=e,this.getChunkIterator=n,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndexe+n.nullCount,0)}function UD(t){return t.reduce((e,n,r)=>(e[r+1]=e[r]+n.length,e),new Uint32Array(t.length+1))}function zD(t,e,n,r){const i=[];for(let s=-1,o=t.length;++s=r)break;if(n>=l+f)continue;if(l>=n&&l+f<=r){i.push(a);continue}const h=Math.max(0,n-l),m=Math.min(r-l,f);i.push(a.slice(h,m-h))}return i.length===0&&i.push(t[0].slice(0,0)),i}function S0(t,e,n,r){let i=0,s=0,o=e.length-1;do{if(i>=o-1)return n0?0:-1}function Q$(t,e){const{nullBitmap:n}=t;if(!n||t.nullCount<=0)return-1;let r=0;for(const i of new b0(n,t.offset+(e||0),t.length,n,$D)){if(!i)return r;++r}return-1}function Ae(t,e,n){if(e===void 0)return-1;if(e===null)return Q$(t,n);const r=Bn.getVisitFn(t),i=du(e);for(let s=(n||0)-1,o=t.length;++s{const i=t.data[r];return i.values.subarray(0,i.length)[Symbol.iterator]()});let n=0;return new g1(t.data.length,r=>{const s=t.data[r].length,o=t.slice(n,n+s);return n+=s,new Y$(o)})}class Y${constructor(e){this.vector=e,this.index=0}next(){return this.indext+e;class Qs extends Be{visitNull(e,n){return 0}visitInt(e,n){return e.type.bitWidth/8}visitFloat(e,n){return e.type.ArrayType.BYTES_PER_ELEMENT}visitBool(e,n){return 1/8}visitDecimal(e,n){return e.type.bitWidth/8}visitDate(e,n){return(e.type.unit+1)*4}visitTime(e,n){return e.type.bitWidth/8}visitTimestamp(e,n){return e.type.unit===ze.SECOND?4:8}visitInterval(e,n){return(e.type.unit+1)*4}visitStruct(e,n){return e.children.reduce((r,i)=>r+di.visit(i,n),0)}visitFixedSizeBinary(e,n){return e.type.byteWidth}visitMap(e,n){return 8+e.children.reduce((r,i)=>r+di.visit(i,n),0)}visitDictionary(e,n){var r;return e.type.indices.bitWidth/8+(((r=e.dictionary)===null||r===void 0?void 0:r.getByteLength(e.values[n]))||0)}}const J$=({valueOffsets:t},e)=>8+(t[e+1]-t[e]),X$=({valueOffsets:t},e)=>8+(t[e+1]-t[e]),Z$=({valueOffsets:t,stride:e,children:n},r)=>{const i=n[0],{[r*e]:s}=t,{[r*e+1]:o}=t,a=di.getVisitFn(i.type),l=i.slice(s,o-s);let f=8;for(let h=-1,m=o-s;++h{const r=e[0],i=r.slice(n*t,t),s=di.getVisitFn(r.type);let o=0;for(let a=-1,l=i.length;++at.type.mode===tr.Dense?qD(t,e):HD(t,e),qD=({type:t,children:e,typeIds:n,valueOffsets:r},i)=>{const s=t.typeIdToChildIndex[n[i]];return 8+di.visit(e[s],r[i])},HD=({children:t},e)=>4+di.visitMany(t,t.map(()=>e)).reduce(G$,0);Qs.prototype.visitUtf8=J$;Qs.prototype.visitBinary=X$;Qs.prototype.visitList=Z$;Qs.prototype.visitFixedSizeList=ej;Qs.prototype.visitUnion=tj;Qs.prototype.visitDenseUnion=qD;Qs.prototype.visitSparseUnion=HD;const di=new Qs;var QD;const YD={},GD={};class Ke{constructor(e){var n,r,i;const s=e[0]instanceof Ke?e.flatMap(a=>a.data):e;if(s.length===0||s.some(a=>!(a instanceof at)))throw new TypeError("Vector constructor expects an Array of Data instances.");const o=(n=s[0])===null||n===void 0?void 0:n.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{const{get:a,set:l,indexOf:f,byteLength:h}=YD[o.typeId],m=s[0];this.isValid=y=>I0(m,y),this.get=y=>a(m,y),this.set=(y,w)=>l(m,y,w),this.indexOf=y=>f(m,y),this.getByteLength=y=>h(m,y),this._offsets=[0,m.length];break}default:Object.setPrototypeOf(this,GD[o.typeId]),this._offsets=UD(s);break}this.data=s,this.type=o,this.stride=Si(o),this.numChildren=(i=(r=o.children)===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0,this.length=this._offsets[this._offsets.length-1]}get byteLength(){return this._byteLength===-1&&(this._byteLength=this.data.reduce((e,n)=>e+n.byteLength,0)),this._byteLength}get nullCount(){return this._nullCount===-1&&(this._nullCount=jD(this.data)),this._nullCount}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${N[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}set(e,n){}indexOf(e,n){return-1}includes(e,n){return this.indexOf(e,n)>0}getByteLength(e){return 0}[Symbol.iterator](){return E0.visit(this)}concat(...e){return new Ke(this.data.concat(e.flatMap(n=>n.data).flat(Number.POSITIVE_INFINITY)))}slice(e,n){return new Ke(LD(this,e,n,({data:r,_offsets:i},s,o)=>zD(r,i,s,o)))}toJSON(){return[...this]}toArray(){const{type:e,data:n,length:r,stride:i,ArrayType:s}=this;switch(e.typeId){case N.Int:case N.Float:case N.Decimal:case N.Time:case N.Timestamp:switch(n.length){case 0:return new s;case 1:return n[0].values.subarray(0,r*i);default:return n.reduce((o,{values:a,length:l})=>(o.array.set(a.subarray(0,l*i),o.offset),o.offset+=l*i,o),{array:new s(r*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(e){var n;return this.getChildAt((n=this.type.children)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&en[e])):null}get isMemoized(){return we.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(we.isDictionary(this.type)){const e=new zd(this.data[0].dictionary),n=this.data.map(r=>{const i=r.clone();return i.dictionary=e,i});return new Ke(n)}return new zd(this)}unmemoize(){if(we.isDictionary(this.type)&&this.isMemoized){const e=this.data[0].dictionary.unmemoize(),n=this.data.map(r=>{const i=r.clone();return i.dictionary=e,i});return new Ke(n)}return this}}QD=Symbol.toStringTag;Ke[QD]=(t=>{t.type=we.prototype,t.data=[],t.length=0,t.stride=1,t.numChildren=0,t._nullCount=-1,t._byteLength=-1,t._offsets=new Uint32Array([0]),t[Symbol.isConcatSpreadable]=!0;const e=Object.keys(N).map(n=>N[n]).filter(n=>typeof n=="number"&&n!==N.NONE);for(const n of e){const r=Bn.getVisitFnByTypeId(n),i=_r.getVisitFnByTypeId(n),s=Ud.getVisitFnByTypeId(n),o=di.getVisitFnByTypeId(n);YD[n]={get:r,set:i,indexOf:s,byteLength:o},GD[n]=Object.create(t,{isValid:{value:Ra(I0)},get:{value:Ra(Bn.getVisitFnByTypeId(n))},set:{value:VD(_r.getVisitFnByTypeId(n))},indexOf:{value:KD(Ud.getVisitFnByTypeId(n))},getByteLength:{value:Ra(di.getVisitFnByTypeId(n))}})}return"Vector"})(Ke.prototype);class zd extends Ke{constructor(e){super(e.data);const n=this.get,r=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){const a=s[o];if(a!==void 0)return a;const l=n.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,a){r.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new zd(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new Ke(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}}class fv{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(e,n,r,i){return e.prep(8,24),e.writeInt64(i),e.pad(4),e.writeInt32(r),e.writeInt64(n),e.offset()}}const km=2,ei=4,ki=4,st=4,fs=new Int32Array(2),w1=new Float32Array(fs.buffer),_1=new Float64Array(fs.buffer),ff=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;let Ni=class dv{constructor(e,n){this.low=e|0,this.high=n|0}static create(e,n){return e==0&&n==0?dv.ZERO:new dv(e,n)}toFloat64(){return(this.low>>>0)+this.high*4294967296}equals(e){return this.low==e.low&&this.high==e.high}};Ni.ZERO=new Ni(0,0);var hv;(function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"})(hv||(hv={}));let Ga=class JD{constructor(e){this.bytes_=e,this.position_=0}static allocate(e){return new JD(new Uint8Array(e))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return new Ni(this.readInt32(e),this.readInt32(e+4))}readUint64(e){return new Ni(this.readUint32(e),this.readUint32(e+4))}readFloat32(e){return fs[0]=this.readInt32(e),w1[0]}readFloat64(e){return fs[ff?0:1]=this.readInt32(e),fs[ff?1:0]=this.readInt32(e+4),_1[0]}writeInt8(e,n){this.bytes_[e]=n}writeUint8(e,n){this.bytes_[e]=n}writeInt16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeUint16(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8}writeInt32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeUint32(e,n){this.bytes_[e]=n,this.bytes_[e+1]=n>>8,this.bytes_[e+2]=n>>16,this.bytes_[e+3]=n>>24}writeInt64(e,n){this.writeInt32(e,n.low),this.writeInt32(e+4,n.high)}writeUint64(e,n){this.writeUint32(e,n.low),this.writeUint32(e+4,n.high)}writeFloat32(e,n){w1[0]=n,this.writeInt32(e,fs[0])}writeFloat64(e,n){_1[0]=n,this.writeInt32(e,fs[ff?0:1]),this.writeInt32(e+4,fs[ff?1:0])}getBufferIdentifier(){if(this.bytes_.length>10)+55296,(o&1024-1)+56320))}return i}__union_with_string(e,n){return typeof e=="string"?this.__string(n):this.__union(e,n)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+ei}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=ki)throw new Error("FlatBuffers: file identifier must be length "+ki);for(let n=0;nthis.minalign&&(this.minalign=e);const r=~(this.bb.capacity()-this.space+n)+1&e-1;for(;this.space=0&&this.vtable[n]==0;n--);const r=n+1;for(;n>=0;n--)this.addInt16(this.vtable[n]!=0?e-this.vtable[n]:0);const i=2;this.addInt16(e-this.object_start);const s=(r+i)*km;this.addInt16(s);let o=0;const a=this.space;e:for(n=0;n=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,ei+i),this.addOffset(e),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,n){this.finish(e,n,!0)}requiredField(e,n){const r=this.bb.capacity()-e,i=r-this.bb.readInt32(r);if(!(this.bb.readInt16(i+n)!=0))throw new Error("FlatBuffers: field "+n+" must be set")}startVector(e,n,r){this.notNested(),this.vector_num_elems=n,this.prep(ei,e*n),this.prep(r,e*n)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(e))return this.string_maps.get(e);const n=this.createString(e);return this.string_maps.set(e,n),n}createString(e){if(!e)return 0;let n;if(e instanceof Uint8Array)n=e;else{n=[];let r=0;for(;r=56320)i=s;else{const o=e.charCodeAt(r++);i=(s<<10)+o+(65536-56623104-56320)}i<128?n.push(i):(i<2048?n.push(i>>6&31|192):(i<65536?n.push(i>>12&15|224):n.push(i>>18&7|240,i>>12&63|128),n.push(i>>6&63|128)),n.push(i&63|128))}}this.addInt8(0),this.startVector(1,n.length,1),this.bb.setPosition(this.space-=n.length);for(let r=0,i=this.space,s=this.bb.bytes();r=0;r--)e.addInt32(n[r]);return e.endVector()}static startTypeIdsVector(e,n){e.startVector(4,n,4)}static endUnion(e){return e.endObject()}static createUnion(e,n,r){return In.startUnion(e),In.addMode(e,n),In.addTypeIds(e,r),In.endUnion(e)}}class bo{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsUtf8(e,n){return(n||new bo).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsUtf8(e,n){return e.setPosition(e.position()+st),(n||new bo).__init(e.readInt32(e.position())+e.position(),e)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(e){return bo.startUtf8(e),bo.endUtf8(e)}}var _t;(function(t){t[t.NONE=0]="NONE",t[t.Null=1]="Null",t[t.Int=2]="Int",t[t.FloatingPoint=3]="FloatingPoint",t[t.Binary=4]="Binary",t[t.Utf8=5]="Utf8",t[t.Bool=6]="Bool",t[t.Decimal=7]="Decimal",t[t.Date=8]="Date",t[t.Time=9]="Time",t[t.Timestamp=10]="Timestamp",t[t.Interval=11]="Interval",t[t.List=12]="List",t[t.Struct_=13]="Struct_",t[t.Union=14]="Union",t[t.FixedSizeBinary=15]="FixedSizeBinary",t[t.FixedSizeList=16]="FixedSizeList",t[t.Map=17]="Map",t[t.Duration=18]="Duration",t[t.LargeBinary=19]="LargeBinary",t[t.LargeUtf8=20]="LargeUtf8",t[t.LargeList=21]="LargeList"})(_t||(_t={}));let cr=class Ff{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsField(e,n){return(n||new Ff).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsField(e,n){return e.setPosition(e.position()+st),(n||new Ff).__init(e.readInt32(e.position())+e.position(),e)}name(e){const n=this.bb.__offset(this.bb_pos,4);return n?this.bb.__string(this.bb_pos+n,e):null}nullable(){const e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):_t.NONE}type(e){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.__union(e,this.bb_pos+n):null}dictionary(e){const n=this.bb.__offset(this.bb_pos,12);return n?(e||new Di).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}children(e,n){const r=this.bb.__offset(this.bb_pos,14);return r?(n||new Ff).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}childrenLength(){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){const r=this.bb.__offset(this.bb_pos,16);return r?(n||new zt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,n){e.addFieldOffset(0,n,0)}static addNullable(e,n){e.addFieldInt8(1,+n,0)}static addTypeType(e,n){e.addFieldInt8(2,n,_t.NONE)}static addType(e,n){e.addFieldOffset(3,n,0)}static addDictionary(e,n){e.addFieldOffset(4,n,0)}static addChildren(e,n){e.addFieldOffset(5,n,0)}static createChildrenVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startChildrenVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(6,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endField(e){return e.endObject()}},Hr=class wi{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsSchema(e,n){return(n||new wi).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsSchema(e,n){return e.setPosition(e.position()+st),(n||new wi).__init(e.readInt32(e.position())+e.position(),e)}endianness(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Xa.Little}fields(e,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new cr).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}fieldsLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new zt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){const n=this.bb.__offset(this.bb_pos,10);return n?this.bb.readInt64(this.bb.__vector(this.bb_pos+n)+e*8):this.bb.createLong(0,0)}featuresLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,n){e.addFieldInt16(0,n,Xa.Little)}static addFields(e,n){e.addFieldOffset(1,n,0)}static createFieldsVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startFieldsVector(e,n){e.startVector(4,n,4)}static addCustomMetadata(e,n){e.addFieldOffset(2,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static addFeatures(e,n){e.addFieldOffset(3,n,0)}static createFeaturesVector(e,n){e.startVector(8,n.length,8);for(let r=n.length-1;r>=0;r--)e.addInt64(n[r]);return e.endVector()}static startFeaturesVector(e,n){e.startVector(8,n,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,n){e.finish(n)}static finishSizePrefixedSchemaBuffer(e,n){e.finish(n,void 0,!0)}static createSchema(e,n,r,i,s){return wi.startSchema(e),wi.addEndianness(e,n),wi.addFields(e,r),wi.addCustomMetadata(e,i),wi.addFeatures(e,s),wi.endSchema(e)}};class Kn{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsFooter(e,n){return(n||new Kn).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsFooter(e,n){return e.setPosition(e.position()+st),(n||new Kn).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Ja.V1}schema(e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Hr).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}dictionaries(e,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new fv).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}dictionariesLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,n){const r=this.bb.__offset(this.bb_pos,10);return r?(n||new fv).__init(this.bb.__vector(this.bb_pos+r)+e*24,this.bb):null}recordBatchesLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new zt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,Ja.V1)}static addSchema(e,n){e.addFieldOffset(1,n,0)}static addDictionaries(e,n){e.addFieldOffset(2,n,0)}static startDictionariesVector(e,n){e.startVector(24,n,8)}static addRecordBatches(e,n){e.addFieldOffset(3,n,0)}static startRecordBatchesVector(e,n){e.startVector(24,n,8)}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,n){e.finish(n)}static finishSizePrefixedFooterBuffer(e,n){e.finish(n,void 0,!0)}}class We{constructor(e=[],n,r){this.fields=e||[],this.metadata=n||new Map,r||(r=pv(e)),this.dictionaries=r}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,n)=>`${n}: ${e}`).join(", ")} }>`}select(e){const n=new Set(e),r=this.fields.filter(i=>n.has(i.name));return new We(r,this.metadata)}selectAt(e){const n=e.map(r=>this.fields[r]).filter(Boolean);return new We(n,this.metadata)}assign(...e){const n=e[0]instanceof We?e[0]:Array.isArray(e[0])?new We(e[0]):new We(e),r=[...this.fields],i=df(df(new Map,this.metadata),n.metadata),s=n.fields.filter(a=>{const l=r.findIndex(f=>f.name===a.name);return~l?(r[l]=a.clone({metadata:df(df(new Map,r[l].metadata),a.metadata)}))&&!1:!0}),o=pv(s,new Map);return new We([...r,...s],i,new Map([...this.dictionaries,...o]))}}We.prototype.fields=null;We.prototype.metadata=null;We.prototype.dictionaries=null;class yt{constructor(e,n,r=!1,i){this.name=e,this.type=n,this.nullable=r,this.metadata=i||new Map}static new(...e){let[n,r,i,s]=e;return e[0]&&typeof e[0]=="object"&&({name:n}=e[0],r===void 0&&(r=e[0].type),i===void 0&&(i=e[0].nullable),s===void 0&&(s=e[0].metadata)),new yt(`${n}`,r,i,s)}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...e){let[n,r,i,s]=e;return!e[0]||typeof e[0]!="object"?[n=this.name,r=this.type,i=this.nullable,s=this.metadata]=e:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=e[0],yt.new(n,r,i,s)}}yt.prototype.type=null;yt.prototype.name=null;yt.prototype.nullable=null;yt.prototype.metadata=null;function df(t,e){return new Map([...t||new Map,...e||new Map])}function pv(t,e=new Map){for(let n=-1,r=t.length;++n0&&pv(s.children,e)}return e}var b1=Ni,nj=XD,rj=Ga;class jl{constructor(e,n=Yn.V4,r,i){this.schema=e,this.version=n,r&&(this._recordBatches=r),i&&(this._dictionaryBatches=i)}static decode(e){e=new rj(Ue(e));const n=Kn.getRootAsFooter(e),r=We.decode(n.schema());return new ij(r,n)}static encode(e){const n=new nj,r=We.encode(n,e.schema);Kn.startRecordBatchesVector(n,e.numRecordBatches);for(const o of[...e.recordBatches()].slice().reverse())Ls.encode(n,o);const i=n.endVector();Kn.startDictionariesVector(n,e.numDictionaries);for(const o of[...e.dictionaryBatches()].slice().reverse())Ls.encode(n,o);const s=n.endVector();return Kn.startFooter(n),Kn.addSchema(n,r),Kn.addVersion(n,Yn.V4),Kn.addRecordBatches(n,i),Kn.addDictionaries(n,s),Kn.finishFooterBuffer(n,Kn.endFooter(n)),n.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}*recordBatches(){for(let e,n=-1,r=this.numRecordBatches;++n=0&&e=0&&e=0&&e=0&&ethis._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return ve(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){const{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(St);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return fr.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return fr.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return ve(this,void 0,void 0,function*(){return yield this.abort(e),St})}return(e){return ve(this,void 0,void 0,function*(){return yield this.close(),St})}read(e){return ve(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return ve(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(...e){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((n,r)=>{this.resolvers.push({resolve:n,reject:r})}):Promise.resolve(St)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}}class Lf extends sj{write(e){if((e=Ue(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?ov(this.toUint8Array(!0)):this.toUint8Array(!1).then(ov)}toUint8Array(e=!1){return e?fi(this._values)[0]:(()=>ve(this,void 0,void 0,function*(){var n,r;const i=[];let s=0;try{for(var o=Ds(this),a;a=yield o.next(),!a.done;){const l=a.value;i.push(l),s+=l.byteLength}}catch(l){n={error:l}}finally{try{a&&!a.done&&(r=o.return)&&(yield r.call(o))}finally{if(n)throw n.error}}return fi(i,s)[0]}))()}}class Qd{constructor(e){e&&(this.source=new oj(fr.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class eu{constructor(e){e instanceof eu?this.source=e.source:e instanceof Lf?this.source=new ao(fr.fromAsyncIterable(e)):Nk(e)?this.source=new ao(fr.fromNodeStream(e)):f0(e)?this.source=new ao(fr.fromDOMStream(e)):Mk(e)?this.source=new ao(fr.fromDOMStream(e.body)):uc(e)?this.source=new ao(fr.fromIterable(e)):Ms(e)?this.source=new ao(fr.fromAsyncIterable(e)):fu(e)&&(this.source=new ao(fr.fromAsyncIterable(e)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}}class oj{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,"peek").value}read(e){return this.next(e,"read").value}next(e,n="read"){return this.source.next({cmd:n,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||St)}return(e){return Object.create(this.source.return&&this.source.return(e)||St)}}class ao{constructor(e){this.source=e,this._closedPromise=new Promise(n=>this._closedPromiseResolve=n)}cancel(e){return ve(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return ve(this,void 0,void 0,function*(){return(yield this.next(e,"read")).value})}peek(e){return ve(this,void 0,void 0,function*(){return(yield this.next(e,"peek")).value})}next(e,n="read"){return ve(this,void 0,void 0,function*(){return yield this.source.next({cmd:n,size:e})})}throw(e){return ve(this,void 0,void 0,function*(){const n=this.source.throw&&(yield this.source.throw(e))||St;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}return(e){return ve(this,void 0,void 0,function*(){const n=this.source.return&&(yield this.source.return(e))||St;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(n)})}}class I1 extends Qd{constructor(e,n){super(),this.position=0,this.buffer=Ue(e),this.size=typeof n>"u"?this.buffer.byteLength:n}readInt32(e){const{buffer:n,byteOffset:r}=this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),eve(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending}))()}readInt32(e){return ve(this,void 0,void 0,function*(){const{buffer:n,byteOffset:r}=yield this.readAt(e,4);return new DataView(n,r).getInt32(0,!0)})}seek(e){return ve(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(e,this.size),e>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),r=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]);let i=n[3]*r[3];this.buffer[0]=i&65535;let s=i>>>16;return i=n[2]*r[3],s+=i,i=n[3]*r[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0>>16,this.buffer[1]+=n[1]*r[3]+n[2]*r[2]+n[3]*r[1],this.buffer[1]+=n[0]*r[3]+n[1]*r[2]+n[2]*r[1]+n[3]*r[0]<<16,this}_plus(e){const n=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],n>>0&&++this.buffer[1],this.buffer[0]=n}lessThan(e){return this.buffer[1]>>0,n[2]=this.buffer[2]+e.buffer[2]>>>0,n[1]=this.buffer[1]+e.buffer[1]>>>0,n[0]=this.buffer[0]+e.buffer[0]>>>0,n[0]>>0&&++n[1],n[1]>>0&&++n[2],n[2]>>0&&++n[3],this.buffer[3]=n[3],this.buffer[2]=n[2],this.buffer[1]=n[1],this.buffer[0]=n[0],this}hex(){return`${ba(this.buffer[3])} ${ba(this.buffer[2])} ${ba(this.buffer[1])} ${ba(this.buffer[0])}`}static multiply(e,n){return new Qr(new Uint32Array(e.buffer)).times(n)}static add(e,n){return new Qr(new Uint32Array(e.buffer)).plus(n)}static from(e,n=new Uint32Array(4)){return Qr.fromString(typeof e=="string"?e:e.toString(),n)}static fromNumber(e,n=new Uint32Array(4)){return Qr.fromString(e.toString(),n)}static fromString(e,n=new Uint32Array(4)){const r=e.startsWith("-"),i=e.length,s=new Qr(n);for(let o=r?1:0;o0&&this.readData(e,r)||new Uint8Array(0)}readOffsets(e,n){return this.readData(e,n)}readTypeIds(e,n){return this.readData(e,n)}readData(e,{length:n,offset:r}=this.nextBufferRange()){return this.bytes.subarray(r,r+n)}readDictionary(e){return this.dictionaries.get(e.id)}}class uj extends tx{constructor(e,n,r,i){super(new Uint8Array(0),n,r,i),this.sources=e}readNullBitmap(e,n,{offset:r}=this.nextBufferRange()){return n<=0?new Uint8Array(0):jd(this.sources[r])}readOffsets(e,{offset:n}=this.nextBufferRange()){return rt(Uint8Array,rt(Int32Array,this.sources[n]))}readTypeIds(e,{offset:n}=this.nextBufferRange()){return rt(Uint8Array,rt(e.ArrayType,this.sources[n]))}readData(e,{offset:n}=this.nextBufferRange()){const{sources:r}=this;return we.isTimestamp(e)||(we.isInt(e)||we.isTime(e))&&e.bitWidth===64||we.isDate(e)&&e.unit===Hi.MILLISECOND?rt(Uint8Array,_n.convertArray(r[n])):we.isDecimal(e)?rt(Uint8Array,Qr.convertArray(r[n])):we.isBinary(e)||we.isFixedSizeBinary(e)?lj(r[n]):we.isBool(e)?jd(r[n]):we.isUtf8(e)?c0(r[n].join("")):rt(Uint8Array,rt(e.ArrayType,r[n].map(i=>+i)))}}function lj(t){const e=t.join(""),n=new Uint8Array(e.length/2);for(let r=0;r>1]=Number.parseInt(e.slice(r,r+2),16);return n}class Ie extends Be{compareSchemas(e,n){return e===n||n instanceof e.constructor&&this.compareManyFields(e.fields,n.fields)}compareManyFields(e,n){return e===n||Array.isArray(e)&&Array.isArray(n)&&e.length===n.length&&e.every((r,i)=>this.compareFields(r,n[i]))}compareFields(e,n){return e===n||n instanceof e.constructor&&e.name===n.name&&e.nullable===n.nullable&&this.visit(e.type,n.type)}}function jn(t,e){return e instanceof t.constructor}function lc(t,e){return t===e||jn(t,e)}function Ji(t,e){return t===e||jn(t,e)&&t.bitWidth===e.bitWidth&&t.isSigned===e.isSigned}function Uh(t,e){return t===e||jn(t,e)&&t.precision===e.precision}function cj(t,e){return t===e||jn(t,e)&&t.byteWidth===e.byteWidth}function D0(t,e){return t===e||jn(t,e)&&t.unit===e.unit}function cc(t,e){return t===e||jn(t,e)&&t.unit===e.unit&&t.timezone===e.timezone}function fc(t,e){return t===e||jn(t,e)&&t.unit===e.unit&&t.bitWidth===e.bitWidth}function fj(t,e){return t===e||jn(t,e)&&t.children.length===e.children.length&&$s.compareManyFields(t.children,e.children)}function dj(t,e){return t===e||jn(t,e)&&t.children.length===e.children.length&&$s.compareManyFields(t.children,e.children)}function x0(t,e){return t===e||jn(t,e)&&t.mode===e.mode&&t.typeIds.every((n,r)=>n===e.typeIds[r])&&$s.compareManyFields(t.children,e.children)}function hj(t,e){return t===e||jn(t,e)&&t.id===e.id&&t.isOrdered===e.isOrdered&&$s.visit(t.indices,e.indices)&&$s.visit(t.dictionary,e.dictionary)}function C0(t,e){return t===e||jn(t,e)&&t.unit===e.unit}function pj(t,e){return t===e||jn(t,e)&&t.listSize===e.listSize&&t.children.length===e.children.length&&$s.compareManyFields(t.children,e.children)}function mj(t,e){return t===e||jn(t,e)&&t.keysSorted===e.keysSorted&&t.children.length===e.children.length&&$s.compareManyFields(t.children,e.children)}Ie.prototype.visitNull=lc;Ie.prototype.visitBool=lc;Ie.prototype.visitInt=Ji;Ie.prototype.visitInt8=Ji;Ie.prototype.visitInt16=Ji;Ie.prototype.visitInt32=Ji;Ie.prototype.visitInt64=Ji;Ie.prototype.visitUint8=Ji;Ie.prototype.visitUint16=Ji;Ie.prototype.visitUint32=Ji;Ie.prototype.visitUint64=Ji;Ie.prototype.visitFloat=Uh;Ie.prototype.visitFloat16=Uh;Ie.prototype.visitFloat32=Uh;Ie.prototype.visitFloat64=Uh;Ie.prototype.visitUtf8=lc;Ie.prototype.visitBinary=lc;Ie.prototype.visitFixedSizeBinary=cj;Ie.prototype.visitDate=D0;Ie.prototype.visitDateDay=D0;Ie.prototype.visitDateMillisecond=D0;Ie.prototype.visitTimestamp=cc;Ie.prototype.visitTimestampSecond=cc;Ie.prototype.visitTimestampMillisecond=cc;Ie.prototype.visitTimestampMicrosecond=cc;Ie.prototype.visitTimestampNanosecond=cc;Ie.prototype.visitTime=fc;Ie.prototype.visitTimeSecond=fc;Ie.prototype.visitTimeMillisecond=fc;Ie.prototype.visitTimeMicrosecond=fc;Ie.prototype.visitTimeNanosecond=fc;Ie.prototype.visitDecimal=lc;Ie.prototype.visitList=fj;Ie.prototype.visitStruct=dj;Ie.prototype.visitUnion=x0;Ie.prototype.visitDenseUnion=x0;Ie.prototype.visitSparseUnion=x0;Ie.prototype.visitDictionary=hj;Ie.prototype.visitInterval=C0;Ie.prototype.visitIntervalDayTime=C0;Ie.prototype.visitIntervalYearMonth=C0;Ie.prototype.visitFixedSizeList=pj;Ie.prototype.visitMap=mj;const $s=new Ie;function mv(t,e){return $s.compareSchemas(t,e)}function Dm(t,e){return yj(t,e.map(n=>n.data.concat()))}function yj(t,e){const n=[...t.fields],r=[],i={numBatches:e.reduce((m,y)=>Math.max(m,y.length),0)};let s=0,o=0,a=-1;const l=e.length;let f,h=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a0&&(r[s++]=Ne({type:new pn(n),length:o,nullCount:0,children:h.slice()})))}return[t=t.assign(n),r.map(m=>new En(t,m))]}function vj(t,e,n,r,i){var s;const o=(e+63&-64)>>3;for(let a=-1,l=r.length;++a=e)h===e?n[a]=f:(n[a]=f.slice(0,e),i.numBatches=Math.max(i.numBatches,r[a].unshift(f.slice(e,h-e))));else{const m=t[a];t[a]=m.clone({nullable:!0}),n[a]=(s=f==null?void 0:f._changeLengthAndBackfillNullBitmap(e))!==null&&s!==void 0?s:Ne({type:m.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)})}}return n}var nx;class hn{constructor(...e){var n,r;if(e.length===0)return this.batches=[],this.schema=new We([]),this._offsets=[0],this;let i,s;e[0]instanceof We&&(i=e.shift()),e[e.length-1]instanceof Uint32Array&&(s=e.pop());const o=l=>{if(l){if(l instanceof En)return[l];if(l instanceof hn)return l.batches;if(l instanceof at){if(l.type instanceof pn)return[new En(new We(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(f=>o(f));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(f=>o(f));if(typeof l=="object"){const f=Object.keys(l),h=f.map(w=>new Ke([l[w]])),m=new We(f.map((w,I)=>new yt(String(w),h[I].type))),[,y]=Dm(m,h);return y.length===0?[new En(l)]:y}}}return[]},a=e.flatMap(l=>o(l));if(i=(r=i??((n=a[0])===null||n===void 0?void 0:n.schema))!==null&&r!==void 0?r:new We([]),!(i instanceof We))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const l of a){if(!(l instanceof En))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!mv(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??UD(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,n)=>e+n.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=jD(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}set(e,n){}indexOf(e,n){return-1}getByteLength(e){return 0}[Symbol.iterator](){return this.batches.length>0?E0.visit(new Ke(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[ ${this.toArray().join(`, `)} -]`}concat(...e){const n=this.schema,r=this.data.concat(e.flatMap(({data:i})=>i));return new hn(n,r.map(i=>new En(n,i)))}slice(e,n){const r=this.schema;[e,n]=FD({length:this.numRows},e,n);const i=UD(this.data,this._offsets,e,n);return new hn(r,i.map(s=>new En(r,s)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===e))}getChildAt(e){if(e>-1&&er.children[e]);if(n.length===0){const{type:r}=this.schema.fields[e],i=Ne({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new Ke(n)}return null}setChild(e,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===e),n)}setChildAt(e,n){let r=this.schema,i=[...this.batches];if(e>-1&&ethis.getChildAt(f));[s[e],a[e]]=[o,n],[r,i]=Dm(r,a)}return new hn(r,i)}select(e){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(e.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(e){const n=this.schema.selectAt(e),r=this.batches.map(i=>i.selectAt(e));return new hn(n,r)}assign(e){const n=this.schema.fields,[r,i]=e.schema.fields.reduce((a,l,f)=>{const[h,m]=a,y=n.findIndex(w=>w.name===l.name);return~y?m[y]=f:h.push(f),a},[[],[]]),s=this.schema.assign(e.schema),o=[...n.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):e.getChildAt(l)),...r.map(a=>e.getChildAt(a))].filter(Boolean);return new hn(...Dm(s,o))}}tx=Symbol.toStringTag;hn[tx]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=Pa(S0),t.get=Pa(Bn.getVisitFn(N.Struct)),t.set=zD(wr.getVisitFn(N.Struct)),t.indexOf=VD(Ud.getVisitFn(N.Struct)),t.getByteLength=Pa(di.getVisitFn(N.Struct)),"Table"))(hn.prototype);var nx;let En=class Vu{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Ne({nullCount:0,type:new pn(this.schema.fields),children:this.schema.fields.map(n=>Ne({type:n.type,nullCount:0}))})]=e,!(this.data instanceof at))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=I1(this.schema,this.data.children);break}case 1:{const[n]=e,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,f,h)=>(l.children[h]=n[f],l.length=Math.max(l.length,n[f].length),l.fields[h]=yt.new({name:f,type:n[f].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new We(r),a=Ne({type:new pn(r),length:s,children:i,nullCount:0});[this.schema,this.data]=I1(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=rx(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Bn.visit(this.data,e)}set(e,n){return wr.visit(this.data,e,n)}indexOf(e,n){return Ud.visit(this.data,e,n)}getByteLength(e){return di.visit(this.data,e)}[Symbol.iterator](){return I0.visit(new Ke([this.data]))}toArray(){return[...this]}concat(...e){return new hn(this.schema,[this,...e])}slice(e,n){const[r]=new Ke([this.data]).slice(e,n).data;return new Vu(this.schema,r)}getChild(e){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&ei.name===e),n)}setChildAt(e,n){let r=this.schema,i=this.data;if(e>-1&&ea.name===s);~o&&(i[o]=this.data.children[o])}return new Vu(n,Ne({type:r,length:this.numRows,children:i}))}selectAt(e){const n=this.schema.selectAt(e),r=e.map(s=>this.data.children[s]).filter(Boolean),i=Ne({type:new pn(n.fields),length:this.numRows,children:r});return new Vu(n,i)}};nx=Symbol.toStringTag;En[nx]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(En.prototype);function I1(t,e,n=e.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...t.fields],s=[...e],o=(n+63&-64)>>3;for(const[a,l]of t.fields.entries()){const f=e[a];(!f||f.length!==n)&&(i[a]=l.clone({nullable:!0}),s[a]=(r=f==null?void 0:f._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:Ne({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[t.assign(i),Ne({type:new pn(i),length:n,children:s})]}function rx(t,e,n=new Map){for(let r=-1,i=t.length;++r0&&rx(o.children,a.children,n)}return n}class A0 extends En{constructor(e){const n=e.fields.map(i=>Ne({type:i.type})),r=Ne({type:new pn(e.fields),nullCount:0,children:n});super(e,r)}}var Gd;(function(t){t[t.BUFFER=0]="BUFFER"})(Gd||(Gd={}));var Jd;(function(t){t[t.LZ4_FRAME=0]="LZ4_FRAME",t[t.ZSTD=1]="ZSTD"})(Jd||(Jd={}));class ds{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsBodyCompression(e,n){return(n||new ds).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsBodyCompression(e,n){return e.setPosition(e.position()+st),(n||new ds).__init(e.readInt32(e.position())+e.position(),e)}codec(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb_pos+e):Jd.LZ4_FRAME}method(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb_pos+e):Gd.BUFFER}static startBodyCompression(e){e.startObject(2)}static addCodec(e,n){e.addFieldInt8(0,n,Jd.LZ4_FRAME)}static addMethod(e,n){e.addFieldInt8(1,n,Gd.BUFFER)}static endBodyCompression(e){return e.endObject()}static createBodyCompression(e,n,r){return ds.startBodyCompression(e),ds.addCodec(e,n),ds.addMethod(e,r),ds.endBodyCompression(e)}}class ix{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(e,n,r){return e.prep(8,16),e.writeInt64(r),e.writeInt64(n),e.offset()}}let sx=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,n,r){return e.prep(8,16),e.writeInt64(r),e.writeInt64(n),e.offset()}},Ii=class mv{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsRecordBatch(e,n){return(n||new mv).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsRecordBatch(e,n){return e.setPosition(e.position()+st),(n||new mv).__init(e.readInt32(e.position())+e.position(),e)}length(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}nodes(e,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new sx).__init(this.bb.__vector(this.bb_pos+r)+e*16,this.bb):null}nodesLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}buffers(e,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new ix).__init(this.bb.__vector(this.bb_pos+r)+e*16,this.bb):null}buffersLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}compression(e){const n=this.bb.__offset(this.bb_pos,10);return n?(e||new ds).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startRecordBatch(e){e.startObject(4)}static addLength(e,n){e.addFieldInt64(0,n,e.createLong(0,0))}static addNodes(e,n){e.addFieldOffset(1,n,0)}static startNodesVector(e,n){e.startVector(16,n,8)}static addBuffers(e,n){e.addFieldOffset(2,n,0)}static startBuffersVector(e,n){e.startVector(16,n,8)}static addCompression(e,n){e.addFieldOffset(3,n,0)}static endRecordBatch(e){return e.endObject()}},aa=class yv{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsDictionaryBatch(e,n){return(n||new yv).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDictionaryBatch(e,n){return e.setPosition(e.position()+st),(n||new yv).__init(e.readInt32(e.position())+e.position(),e)}id(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}data(e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Ii).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isDelta(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startDictionaryBatch(e){e.startObject(3)}static addId(e,n){e.addFieldInt64(0,n,e.createLong(0,0))}static addData(e,n){e.addFieldOffset(1,n,0)}static addIsDelta(e,n){e.addFieldInt8(2,+n,0)}static endDictionaryBatch(e){return e.endObject()}};var Xd;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(Xd||(Xd={}));let as=class Kr{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsMessage(e,n){return(n||new Kr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+st),(n||new Kr).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Ga.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Xd.NONE}header(e){const n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(e,this.bb_pos+n):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}customMetadata(e,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new zt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,Ga.V1)}static addHeaderType(e,n){e.addFieldInt8(1,n,Xd.NONE)}static addHeader(e,n){e.addFieldOffset(2,n,0)}static addBodyLength(e,n){e.addFieldInt64(3,n,e.createLong(0,0))}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,n){e.finish(n)}static finishSizePrefixedMessageBuffer(e,n){e.finish(n,void 0,!0)}static createMessage(e,n,r,i,s,o){return Kr.startMessage(e),Kr.addVersion(e,n),Kr.addHeaderType(e,r),Kr.addHeader(e,i),Kr.addBodyLength(e,s),Kr.addCustomMetadata(e,o),Kr.endMessage(e)}};var vj=Ni;class gj extends Be{visit(e,n){return e==null||n==null?void 0:super.visit(e,n)}visitNull(e,n){return wo.startNull(n),wo.endNull(n)}visitInt(e,n){return qn.startInt(n),qn.addBitWidth(n,e.bitWidth),qn.addIsSigned(n,e.isSigned),qn.endInt(n)}visitFloat(e,n){return ni.startFloatingPoint(n),ni.addPrecision(n,e.precision),ni.endFloatingPoint(n)}visitBinary(e,n){return yo.startBinary(n),yo.endBinary(n)}visitBool(e,n){return vo.startBool(n),vo.endBool(n)}visitUtf8(e,n){return bo.startUtf8(n),bo.endUtf8(n)}visitDecimal(e,n){return bn.startDecimal(n),bn.addScale(n,e.scale),bn.addPrecision(n,e.precision),bn.addBitWidth(n,e.bitWidth),bn.endDecimal(n)}visitDate(e,n){return Nf.startDate(n),Nf.addUnit(n,e.unit),Nf.endDate(n)}visitTime(e,n){return hr.startTime(n),hr.addUnit(n,e.unit),hr.addBitWidth(n,e.bitWidth),hr.endTime(n)}visitTimestamp(e,n){const r=e.timezone&&n.createString(e.timezone)||void 0;return pr.startTimestamp(n),pr.addUnit(n,e.unit),r!==void 0&&pr.addTimezone(n,r),pr.endTimestamp(n)}visitInterval(e,n){return ri.startInterval(n),ri.addUnit(n,e.unit),ri.endInterval(n)}visitList(e,n){return go.startList(n),go.endList(n)}visitStruct(e,n){return _o.startStruct_(n),_o.endStruct_(n)}visitUnion(e,n){In.startTypeIdsVector(n,e.typeIds.length);const r=In.createTypeIdsVector(n,e.typeIds);return In.startUnion(n),In.addMode(n,e.mode),In.addTypeIds(n,r),In.endUnion(n)}visitDictionary(e,n){const r=this.visit(e.indices,n);return Di.startDictionaryEncoding(n),Di.addId(n,new vj(e.id,0)),Di.addIsOrdered(n,e.isOrdered),r!==void 0&&Di.addIndexType(n,r),Di.endDictionaryEncoding(n)}visitFixedSizeBinary(e,n){return ei.startFixedSizeBinary(n),ei.addByteWidth(n,e.byteWidth),ei.endFixedSizeBinary(n)}visitFixedSizeList(e,n){return ti.startFixedSizeList(n),ti.addListSize(n,e.listSize),ti.endFixedSizeList(n)}visitMap(e,n){return Bf.startMap(n),Bf.addKeysSorted(n,e.keysSorted),Bf.endMap(n)}}const xm=new gj;function wj(t,e=new Map){return new We(bj(t,e),$f(t.customMetadata),e)}function ox(t){return new tr(t.count,ax(t.columns),ux(t.columns))}function _j(t){return new hi(ox(t.data),t.id,t.isDelta)}function bj(t,e){return(t.fields||[]).filter(Boolean).map(n=>yt.fromJSON(n,e))}function E1(t,e){return(t.children||[]).filter(Boolean).map(n=>yt.fromJSON(n,e))}function ax(t){return(t||[]).reduce((e,n)=>[...e,new Wo(n.count,Sj(n.VALIDITY)),...ax(n.children)],[])}function ux(t,e=[]){for(let n=-1,r=(t||[]).length;++ne+ +(n===0),0)}function Ij(t,e){let n,r,i,s,o,a;return!e||!(s=t.dictionary)?(o=k1(t,E1(t,e)),i=new yt(t.name,o,t.nullable,$f(t.customMetadata))):e.has(n=s.id)?(r=(r=s.indexType)?O1(r):new Fl,a=new Qa(e.get(n),r,n,s.isOrdered),i=new yt(t.name,a,t.nullable,$f(t.customMetadata))):(r=(r=s.indexType)?O1(r):new Fl,e.set(n,o=k1(t,E1(t,e))),a=new Qa(o,r,n,s.isOrdered),i=new yt(t.name,a,t.nullable,$f(t.customMetadata))),i||null}function $f(t){return new Map(Object.entries(t||{}))}function O1(t){return new Fs(t.isSigned,t.bitWidth)}function k1(t,e){const n=t.type.name;switch(n){case"NONE":return new Bs;case"null":return new Bs;case"binary":return new xd;case"utf8":return new Ad;case"bool":return new Cd;case"list":return new Nd((e||[])[0]);case"struct":return new pn(e||[]);case"struct_":return new pn(e||[])}switch(n){case"int":{const r=t.type;return new Fs(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=t.type;return new Ll(Cn[r.precision])}case"decimal":{const r=t.type;return new Pd(r.scale,r.precision,r.bitWidth)}case"date":{const r=t.type;return new Rd(Hi[r.unit])}case"time":{const r=t.type;return new $l(ze[r.unit],r.bitWidth)}case"timestamp":{const r=t.type;return new Td(ze[r.unit],r.timezone)}case"interval":{const r=t.type;return new Md(Ns[r.unit])}case"union":{const r=t.type;return new Bd(er[r.mode],r.typeIds||[],e||[])}case"fixedsizebinary":{const r=t.type;return new Fd(r.byteWidth)}case"fixedsizelist":{const r=t.type;return new Ld(r.listSize,(e||[])[0])}case"map":{const r=t.type;return new $d((e||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var jo=Ni,Ej=JD,Oj=Ya;class mn{constructor(e,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=typeof e=="number"?e:e.low}static fromJSON(e,n){const r=new mn(0,Qn.V4,n);return r._createHeader=kj(e,n),r}static decode(e){e=new Oj(Ue(e));const n=as.getRootAsMessage(e),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new mn(r,i,s);return o._createHeader=Dj(n,s),o}static encode(e){const n=new Ej;let r=-1;return e.isSchema()?r=We.encode(n,e.header()):e.isRecordBatch()?r=tr.encode(n,e.header()):e.isDictionaryBatch()&&(r=hi.encode(n,e.header())),as.startMessage(n),as.addVersion(n,Qn.V4),as.addHeader(n,r),as.addHeaderType(n,e.headerType),as.addBodyLength(n,new jo(e.bodyLength,0)),as.finishMessageBuffer(n,as.endMessage(n)),n.asUint8Array()}static from(e,n=0){if(e instanceof We)return new mn(0,Qn.V4,Ve.Schema,e);if(e instanceof tr)return new mn(n,Qn.V4,Ve.RecordBatch,e);if(e instanceof hi)return new mn(n,Qn.V4,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}}class tr{constructor(e,n,r){this._nodes=n,this._buffers=r,this._length=typeof e=="number"?e:e.low}get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}}class hi{constructor(e,n,r=!1){this._data=e,this._isDelta=r,this._id=typeof n=="number"?n:n.low}get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}}class si{constructor(e,n){this.offset=typeof e=="number"?e:e.low,this.length=typeof n=="number"?n:n.low}}class Wo{constructor(e,n){this.length=typeof e=="number"?e:e.low,this.nullCount=typeof n=="number"?n:n.low}}function kj(t,e){return()=>{switch(e){case Ve.Schema:return We.fromJSON(t);case Ve.RecordBatch:return tr.fromJSON(t);case Ve.DictionaryBatch:return hi.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)}}function Dj(t,e){return()=>{switch(e){case Ve.Schema:return We.decode(t.header(new qr));case Ve.RecordBatch:return tr.decode(t.header(new Ii),t.version());case Ve.DictionaryBatch:return hi.decode(t.header(new aa),t.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)}}yt.encode=Lj;yt.decode=Bj;yt.fromJSON=Ij;We.encode=Fj;We.decode=xj;We.fromJSON=wj;tr.encode=$j;tr.decode=Aj;tr.fromJSON=ox;hi.encode=jj;hi.decode=Cj;hi.fromJSON=_j;Wo.encode=Uj;Wo.decode=Rj;si.encode=zj;si.decode=Pj;function xj(t,e=new Map){const n=Nj(t,e);return new We(n,jf(t),e)}function Aj(t,e=Qn.V4){if(t.compression()!==null)throw new Error("Record batch compression not implemented");return new tr(t.length(),Tj(t),Mj(t,e))}function Cj(t,e=Qn.V4){return new hi(tr.decode(t.data(),e),t.id(),t.isDelta())}function Pj(t){return new si(t.offset(),t.length())}function Rj(t){return new Wo(t.length(),t.nullCount())}function Tj(t){const e=[];for(let n,r=-1,i=-1,s=t.nodesLength();++ryt.encode(t,s));qr.startFieldsVector(t,n.length);const r=qr.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?qr.createCustomMetadataVector(t,[...e.metadata].map(([s,o])=>{const a=t.createString(`${s}`),l=t.createString(`${o}`);return zt.startKeyValue(t),zt.addKey(t,a),zt.addValue(t,l),zt.endKeyValue(t)})):-1;return qr.startSchema(t),qr.addFields(t,r),qr.addEndianness(t,Vj?Ja.Little:Ja.Big),i!==-1&&qr.addCustomMetadata(t,i),qr.endSchema(t)}function Lj(t,e){let n=-1,r=-1,i=-1;const s=e.type;let o=e.typeId;we.isDictionary(s)?(o=s.dictionary.typeId,i=xm.visit(s,t),r=xm.visit(s.dictionary,t)):r=xm.visit(s,t);const a=(s.children||[]).map(h=>yt.encode(t,h)),l=lr.createChildrenVector(t,a),f=e.metadata&&e.metadata.size>0?lr.createCustomMetadataVector(t,[...e.metadata].map(([h,m])=>{const y=t.createString(`${h}`),w=t.createString(`${m}`);return zt.startKeyValue(t),zt.addKey(t,y),zt.addValue(t,w),zt.endKeyValue(t)})):-1;return e.name&&(n=t.createString(e.name)),lr.startField(t),lr.addType(t,r),lr.addTypeType(t,o),lr.addChildren(t,l),lr.addNullable(t,!!e.nullable),n!==-1&&lr.addName(t,n),i!==-1&&lr.addDictionary(t,i),f!==-1&&lr.addCustomMetadata(t,f),lr.endField(t)}function $j(t,e){const n=e.nodes||[],r=e.buffers||[];Ii.startNodesVector(t,n.length);for(const o of n.slice().reverse())Wo.encode(t,o);const i=t.endVector();Ii.startBuffersVector(t,r.length);for(const o of r.slice().reverse())si.encode(t,o);const s=t.endVector();return Ii.startRecordBatch(t),Ii.addLength(t,new jo(e.length,0)),Ii.addNodes(t,i),Ii.addBuffers(t,s),Ii.endRecordBatch(t)}function jj(t,e){const n=tr.encode(t,e.data);return aa.startDictionaryBatch(t),aa.addId(t,new jo(e.id,0)),aa.addIsDelta(t,e.isDelta),aa.addData(t,n),aa.endDictionaryBatch(t)}function Uj(t,e){return sx.createFieldNode(t,new jo(e.length,0),new jo(e.nullCount,0))}function zj(t,e){return ix.createBuffer(t,new jo(e.offset,0),new jo(e.length,0))}const Vj=(()=>{const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),new Int16Array(t)[0]===256})(),C0=t=>`Expected ${Ve[t]} Message in stream, but was null or length 0.`,P0=t=>`Header pointer of flatbuffer-encoded ${Ve[t]} Message is null or length 0.`,lx=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,cx=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`;class fx{constructor(e){this.source=e instanceof Qd?e:new Qd(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?St:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(C0(e));return n.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const n=Ue(this.source.read(e));if(n.byteLength[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE&&[s.TYPE]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(C0(e));return n.value}readSchema(){const e=Ve.Schema,n=this.readMessage(e),r=n==null?void 0:n.header();if(!n||!r)throw new Error(P0(e));return r}}const zh=4,vv="ARROW1",Ul=new Uint8Array(vv.length);for(let t=0;tthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return cr.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return cr.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof Bi?e:ov(e)?Gj(e):Rk(e)?Zj(e):Ms(e)?(()=>ve(this,void 0,void 0,function*(){return yield Bi.from(yield e)}))():Tk(e)||c0(e)||Mk(e)||fu(e)?Xj(new Za(e)):Jj(new Qd(e))}static readAll(e){return e instanceof Bi?e.isSync()?C1(e):P1(e):ov(e)||ArrayBuffer.isView(e)||uc(e)||Pk(e)?C1(e):P1(e)}}class Zd extends Bi{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return kr(this,arguments,function*(){yield ge(yield*Df(Ds(this[Symbol.iterator]())))})}}class eh extends Bi{constructor(e){super(e),this._impl=e}readAll(){var e,n;return ve(this,void 0,void 0,function*(){const r=new Array;try{for(var i=Ds(this),s;s=yield i.next(),!s.done;){const o=s.value;r.push(o)}}catch(o){e={error:o}}finally{try{s&&!s.done&&(n=i.return)&&(yield n.call(i))}finally{if(e)throw e.error}}return r})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class hx extends Zd{constructor(e){super(e),this._impl=e}}class Hj extends eh{constructor(e){super(e),this._impl=e}}class px{constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,n){const r=this._loadVectors(e,n,this.schema.fields),i=Ne({type:new pn(this.schema.fields),length:e.length,children:r});return new En(this.schema,i)}_loadDictionaryBatch(e,n){const{id:r,isDelta:i}=e,{dictionaries:s,schema:o}=this,a=s.get(r);if(i||!a){const l=o.dictionaries.get(r),f=this._loadVectors(e.data,n,[l]);return(a&&i?a.concat(new Ke(f)):new Ke(f)).memoize()}return a.memoize()}_loadVectors(e,n,r){return new ex(n,e.nodes,e.buffers,this.dictionaries).visitMany(r)}}class th extends px{constructor(e,n){super(n),this._reader=ov(e)?new Wj(this._handle=e):new fx(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=yx(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):St}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):St}next(){if(this.closed)return St;let e;const{_reader:n}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const r=e.header(),i=n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const r=e.header(),i=n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new A0(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class nh extends px{constructor(e,n){super(n),this._reader=new Kj(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return ve(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return ve(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=yx(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return ve(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):St})}return(e){return ve(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):St})}next(){return ve(this,void 0,void 0,function*(){if(this.closed)return St;let e;const{_reader:n}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const r=e.header(),i=yield n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const r=e.header(),i=yield n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new A0(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return ve(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class mx extends th{constructor(e,n){super(e instanceof S1?e:new S1(e),n)}get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var n;if(this.closed)return null;this._footer||this.open();const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(Ve.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(e){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(Ve.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){const{_handle:e}=this,n=e.size-dx,r=e.readInt32(n),i=e.readAt(n-r,r);return jl.decode(i)}_readNextMessageAndValidate(e){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return ve(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,e)})}readRecordBatch(e){var n;return ve(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(Ve.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(e){var n;return ve(this,void 0,void 0,function*(){const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(Ve.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return ve(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const n=e.size-dx,r=yield e.readInt32(n),i=yield e.readAt(n-r,r);return jl.decode(i)})}_readNextMessageAndValidate(e){return ve(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?R0(e)?new hx(new mx(t.read())):new Zd(new th(t)):new Zd(new th(function*(){}()))}function Xj(t){return ve(this,void 0,void 0,function*(){const e=yield t.peek(dc+7&-8);return e&&e.byteLength>=4?R0(e)?new hx(new mx(yield t.read())):new eh(new nh(t)):new eh(new nh(function(){return kr(this,arguments,function*(){})}()))})}function Zj(t){return ve(this,void 0,void 0,function*(){const{size:e}=yield t.stat(),n=new Yd(t,e);return e>=qj&&R0(yield n.readAt(0,dc+7&-8))?new Hj(new Qj(n)):new eh(new nh(n))})}class $t extends Be{constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}static assemble(...e){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof En?s.data.children:s.data),r=new $t;return r.visitMany(n(e)),r}visit(e){if(e instanceof Ke)return this.visitMany(e.data),this;const{type:n}=e;if(!we.isDictionary(n)){const{length:r,nullCount:i}=e;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");we.isNull(n)||Cr.call(this,i<=0?new Uint8Array(0):w0(e.offset,r,e.nullBitmap)),this.nodes.push(new Wo(r,i))}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function Cr(t){const e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new si(this._byteLength,e)),this._byteLength+=e,this}function e4(t){const{type:e,length:n,typeIds:r,valueOffsets:i}=t;if(Cr.call(this,r),e.mode===er.Sparse)return gv.call(this,t);if(e.mode===er.Dense){if(t.offset<=0)return Cr.call(this,i),gv.call(this,t);{const s=r.reduce((h,m)=>Math.max(h,m),r[0]),o=new Int32Array(s+1),a=new Int32Array(s+1).fill(-1),l=new Int32Array(n),f=d0(-i[0],n,i);for(let h,m,y=-1;++y=t.length?Cr.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?Cr.call(this,w0(t.offset,t.length,e)):Cr.call(this,jd(t.values))}function Ys(t){return Cr.call(this,t.values.subarray(0,t.length*t.stride))}function vx(t){const{length:e,values:n,valueOffsets:r}=t,i=r[0],s=r[e],o=Math.min(s-i,n.byteLength-i);return Cr.call(this,d0(-r[0],e,r)),Cr.call(this,n.subarray(i,i+o)),this}function T0(t){const{length:e,valueOffsets:n}=t;return n&&Cr.call(this,d0(n[0],e,n)),this.visit(t.children[0])}function gv(t){return this.visitMany(t.type.children.map((e,n)=>t.children[n]).filter(Boolean))[0]}$t.prototype.visitBool=t4;$t.prototype.visitInt=Ys;$t.prototype.visitFloat=Ys;$t.prototype.visitUtf8=vx;$t.prototype.visitBinary=vx;$t.prototype.visitFixedSizeBinary=Ys;$t.prototype.visitDate=Ys;$t.prototype.visitTimestamp=Ys;$t.prototype.visitTime=Ys;$t.prototype.visitDecimal=Ys;$t.prototype.visitList=T0;$t.prototype.visitStruct=gv;$t.prototype.visitUnion=e4;$t.prototype.visitInterval=Ys;$t.prototype.visitFixedSizeList=T0;$t.prototype.visitMap=T0;class gx extends E0{constructor(e){super(),this._position=0,this._started=!1,this._sink=new Lf,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,Nn(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Ms(e)?e.then(n=>this.writeAll(n)):fu(e)?F0(this,e):B0(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,n=null){return e===this._sink||e instanceof Lf?this._sink=e:(this._sink=new Lf,e&&S3(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&I3(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,(!n||!pv(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(e){let n=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof hn&&!(n=e.schema))return this.finish()&&void 0;if(e instanceof En&&!(n=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!pv(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}e instanceof En?e instanceof A0||this._writeRecordBatch(e):e instanceof hn?this.writeAll(e.batches):uc(e)&&this.writeAll(e)}_writeMessage(e,n=8){const r=n-1,i=mn.encode(e),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,l=a-s-o;return e.headerType===Ve.RecordBatch?this._recordBatchBlocks.push(new Ls(a,e.bodyLength,this._position)):e.headerType===Ve.DictionaryBatch&&this._dictionaryBlocks.push(new Ls(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(l)}_write(e){if(this._started){const n=Ue(e);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(e){return this._writeMessage(mn.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Ul)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=$t.assemble(e),o=new tr(e.numRows,r,i),a=mn.from(o,n);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(e,n,r=!1){this._dictionaryDeltaOffsets.set(n,e.length+(this._dictionaryDeltaOffsets.get(n)||0));const{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=$t.assemble(new Ke([e])),l=new tr(e.length,s,o),f=new hi(l,n,r),h=mn.from(f,i);return this._writeMessage(h)._writeBodyBuffers(a)}_writeBodyBuffers(e){let n,r,i;for(let s=-1,o=e.length;++s0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(e){for(let[n,r]of e.dictionaries){let i=this._dictionaryDeltaOffsets.get(n)||0;if(i===0||(r=r==null?void 0:r.slice(i)).length>0)for(const s of r.data)this._writeDictionaryBatch(s,n,i>0),i+=s.length}return this}}class M0 extends gx{static writeAll(e,n){const r=new M0(n);return Ms(e)?e.then(i=>r.writeAll(i)):fu(e)?F0(r,e):B0(r,e)}}class N0 extends gx{static writeAll(e){const n=new N0;return Ms(e)?e.then(r=>n.writeAll(r)):fu(e)?F0(n,e):B0(n,e)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeFooter(e){const n=jl.encode(new jl(e,Qn.V4,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function B0(t,e){let n=e;e instanceof hn&&(n=e.batches,t.reset(void 0,e.schema));for(const r of n)t.write(r);return t.finish()}function F0(t,e){var n,r,i,s;return ve(this,void 0,void 0,function*(){try{for(n=Ds(e);r=yield n.next(),!r.done;){const o=r.value;t.write(o)}}catch(o){i={error:o}}finally{try{r&&!r.done&&(s=n.return)&&(yield s.call(n))}finally{if(i)throw i.error}}return t.finish()})}function Ku(t){const e=Bi.from(t);return Ms(e)?e.then(n=>Ku(n)):e.isAsync()?e.readAll().then(n=>new hn(n)):new hn(e.readAll())}function Am(t,e="stream"){return(e==="stream"?M0:N0).writeAll(t).toUint8Array(!0)}var R1=function(){function t(e,n,r,i){var s=this;this.getCell=function(o,a){var l=o=s.headerRows&&a=s.headerColumns;if(l){var m=["blank"];return a>0&&m.push("level"+o),{type:"blank",classNames:m.join(" "),content:""}}else if(h){var y=a-s.headerColumns,m=["col_heading","level"+o,"col"+y];return{type:"columns",classNames:m.join(" "),content:s.getContent(s.columnsTable,y,o)}}else if(f){var w=o-s.headerRows,m=["row_heading","level"+a,"row"+w];return{type:"index",id:"T_".concat(s.uuid,"level").concat(a,"_row").concat(w),classNames:m.join(" "),content:s.getContent(s.indexTable,w,a)}}else{var w=o-s.headerRows,y=a-s.headerColumns,m=["data","row"+w,"col"+y],I=s.styler?s.getContent(s.styler.displayValuesTable,w,y):s.getContent(s.dataTable,w,y);return{type:"data",id:"T_".concat(s.uuid,"row").concat(w,"_col").concat(y),classNames:m.join(" "),content:I}}},this.getContent=function(o,a,l){var f=o.getChildAt(l);if(f===null)return"";var h=s.getColumnTypeId(o,l);switch(h){case N.Timestamp:return s.nanosToDate(f.get(a));default:return f.get(a)}},this.dataTable=Ku(e),this.indexTable=Ku(n),this.columnsTable=Ku(r),this.styler=i?{caption:i.caption,displayValuesTable:Ku(i.displayValues),styles:i.styles,uuid:i.uuid}:void 0}return Object.defineProperty(t.prototype,"rows",{get:function(){return this.indexTable.numRows+this.columnsTable.numCols},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"columns",{get:function(){return this.indexTable.numCols+this.columnsTable.numRows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"headerRows",{get:function(){return this.rows-this.dataRows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"headerColumns",{get:function(){return this.columns-this.dataColumns},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataRows",{get:function(){return this.dataTable.numRows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataColumns",{get:function(){return this.dataTable.numCols},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uuid",{get:function(){return this.styler&&this.styler.uuid},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"caption",{get:function(){return this.styler&&this.styler.caption},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"styles",{get:function(){return this.styler&&this.styler.styles},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"table",{get:function(){return this.dataTable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"index",{get:function(){return this.indexTable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"columnTable",{get:function(){return this.columnsTable},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){return{data:Am(this.dataTable),index:Am(this.indexTable),columns:Am(this.columnsTable)}},t.prototype.getColumnTypeId=function(e,n){return e.schema.fields[n].type.typeId},t.prototype.nanosToDate=function(e){return new Date(e/1e6)},t}(),al=function(){return al=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0?t.argsDataframeToObject(e.dfs):{};n=al(al({},n),r);var i=!!e.disabled,s=e.theme;s&&n4(s);var o={disabled:i,args:n,theme:s},a=new CustomEvent(t.RENDER_EVENT,{detail:o});t.events.dispatchEvent(a)},t.argsDataframeToObject=function(e){var n=e.map(function(r){var i=r.key,s=r.value;return[i,t.toArrowTable(s)]});return Object.fromEntries(n)},t.toArrowTable=function(e){var n,r=(n=e.data,n.data),i=n.index,s=n.columns,o=n.styler;return new R1(r,i,s,o)},t.sendBackMsg=function(e,n){window.parent.postMessage(al({isStreamlitMessage:!0,type:e},n),"*")},t}(),n4=function(t){var e=document.createElement("style");document.head.appendChild(e),e.innerHTML=` +]`}concat(...e){const n=this.schema,r=this.data.concat(e.flatMap(({data:i})=>i));return new hn(n,r.map(i=>new En(n,i)))}slice(e,n){const r=this.schema;[e,n]=LD({length:this.numRows},e,n);const i=zD(this.data,this._offsets,e,n);return new hn(r,i.map(s=>new En(r,s)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(n=>n.name===e))}getChildAt(e){if(e>-1&&er.children[e]);if(n.length===0){const{type:r}=this.schema.fields[e],i=Ne({type:r,length:0,nullCount:0});n.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new Ke(n)}return null}setChild(e,n){var r;return this.setChildAt((r=this.schema.fields)===null||r===void 0?void 0:r.findIndex(i=>i.name===e),n)}setChildAt(e,n){let r=this.schema,i=[...this.batches];if(e>-1&&ethis.getChildAt(f));[s[e],a[e]]=[o,n],[r,i]=Dm(r,a)}return new hn(r,i)}select(e){const n=this.schema.fields.reduce((r,i,s)=>r.set(i.name,s),new Map);return this.selectAt(e.map(r=>n.get(r)).filter(r=>r>-1))}selectAt(e){const n=this.schema.selectAt(e),r=this.batches.map(i=>i.selectAt(e));return new hn(n,r)}assign(e){const n=this.schema.fields,[r,i]=e.schema.fields.reduce((a,l,f)=>{const[h,m]=a,y=n.findIndex(w=>w.name===l.name);return~y?m[y]=f:h.push(f),a},[[],[]]),s=this.schema.assign(e.schema),o=[...n.map((a,l)=>[l,i[l]]).map(([a,l])=>l===void 0?this.getChildAt(a):e.getChildAt(l)),...r.map(a=>e.getChildAt(a))].filter(Boolean);return new hn(...Dm(s,o))}}nx=Symbol.toStringTag;hn[nx]=(t=>(t.schema=null,t.batches=[],t._offsets=new Uint32Array([0]),t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,t.isValid=Ra(I0),t.get=Ra(Bn.getVisitFn(N.Struct)),t.set=VD(_r.getVisitFn(N.Struct)),t.indexOf=KD(Ud.getVisitFn(N.Struct)),t.getByteLength=Ra(di.getVisitFn(N.Struct)),"Table"))(hn.prototype);var rx;let En=class Vu{constructor(...e){switch(e.length){case 2:{if([this.schema]=e,!(this.schema instanceof We))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=Ne({nullCount:0,type:new pn(this.schema.fields),children:this.schema.fields.map(n=>Ne({type:n.type,nullCount:0}))})]=e,!(this.data instanceof at))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=E1(this.schema,this.data.children);break}case 1:{const[n]=e,{fields:r,children:i,length:s}=Object.keys(n).reduce((l,f,h)=>(l.children[h]=n[f],l.length=Math.max(l.length,n[f].length),l.fields[h]=yt.new({name:f,type:n[f].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new We(r),a=Ne({type:new pn(r),length:s,children:i,nullCount:0});[this.schema,this.data]=E1(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=ix(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(e){return this.data.getValid(e)}get(e){return Bn.visit(this.data,e)}set(e,n){return _r.visit(this.data,e,n)}indexOf(e,n){return Ud.visit(this.data,e,n)}getByteLength(e){return di.visit(this.data,e)}[Symbol.iterator](){return E0.visit(new Ke([this.data]))}toArray(){return[...this]}concat(...e){return new hn(this.schema,[this,...e])}slice(e,n){const[r]=new Ke([this.data]).slice(e,n).data;return new Vu(this.schema,r)}getChild(e){var n;return this.getChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(r=>r.name===e))}getChildAt(e){return e>-1&&ei.name===e),n)}setChildAt(e,n){let r=this.schema,i=this.data;if(e>-1&&ea.name===s);~o&&(i[o]=this.data.children[o])}return new Vu(n,Ne({type:r,length:this.numRows,children:i}))}selectAt(e){const n=this.schema.selectAt(e),r=e.map(s=>this.data.children[s]).filter(Boolean),i=Ne({type:new pn(n.fields),length:this.numRows,children:r});return new Vu(n,i)}};rx=Symbol.toStringTag;En[rx]=(t=>(t._nullCount=-1,t[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(En.prototype);function E1(t,e,n=e.reduce((r,i)=>Math.max(r,i.length),0)){var r;const i=[...t.fields],s=[...e],o=(n+63&-64)>>3;for(const[a,l]of t.fields.entries()){const f=e[a];(!f||f.length!==n)&&(i[a]=l.clone({nullable:!0}),s[a]=(r=f==null?void 0:f._changeLengthAndBackfillNullBitmap(n))!==null&&r!==void 0?r:Ne({type:l.type,length:n,nullCount:n,nullBitmap:new Uint8Array(o)}))}return[t.assign(i),Ne({type:new pn(i),length:n,children:s})]}function ix(t,e,n=new Map){for(let r=-1,i=t.length;++r0&&ix(o.children,a.children,n)}return n}class A0 extends En{constructor(e){const n=e.fields.map(i=>Ne({type:i.type})),r=Ne({type:new pn(e.fields),nullCount:0,children:n});super(e,r)}}var Gd;(function(t){t[t.BUFFER=0]="BUFFER"})(Gd||(Gd={}));var Jd;(function(t){t[t.LZ4_FRAME=0]="LZ4_FRAME",t[t.ZSTD=1]="ZSTD"})(Jd||(Jd={}));class ds{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsBodyCompression(e,n){return(n||new ds).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsBodyCompression(e,n){return e.setPosition(e.position()+st),(n||new ds).__init(e.readInt32(e.position())+e.position(),e)}codec(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb_pos+e):Jd.LZ4_FRAME}method(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb_pos+e):Gd.BUFFER}static startBodyCompression(e){e.startObject(2)}static addCodec(e,n){e.addFieldInt8(0,n,Jd.LZ4_FRAME)}static addMethod(e,n){e.addFieldInt8(1,n,Gd.BUFFER)}static endBodyCompression(e){return e.endObject()}static createBodyCompression(e,n,r){return ds.startBodyCompression(e),ds.addCodec(e,n),ds.addMethod(e,r),ds.endBodyCompression(e)}}class sx{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(e,n,r){return e.prep(8,16),e.writeInt64(r),e.writeInt64(n),e.offset()}}let ox=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,n,r){return e.prep(8,16),e.writeInt64(r),e.writeInt64(n),e.offset()}},Ii=class yv{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsRecordBatch(e,n){return(n||new yv).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsRecordBatch(e,n){return e.setPosition(e.position()+st),(n||new yv).__init(e.readInt32(e.position())+e.position(),e)}length(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}nodes(e,n){const r=this.bb.__offset(this.bb_pos,6);return r?(n||new ox).__init(this.bb.__vector(this.bb_pos+r)+e*16,this.bb):null}nodesLength(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}buffers(e,n){const r=this.bb.__offset(this.bb_pos,8);return r?(n||new sx).__init(this.bb.__vector(this.bb_pos+r)+e*16,this.bb):null}buffersLength(){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}compression(e){const n=this.bb.__offset(this.bb_pos,10);return n?(e||new ds).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}static startRecordBatch(e){e.startObject(4)}static addLength(e,n){e.addFieldInt64(0,n,e.createLong(0,0))}static addNodes(e,n){e.addFieldOffset(1,n,0)}static startNodesVector(e,n){e.startVector(16,n,8)}static addBuffers(e,n){e.addFieldOffset(2,n,0)}static startBuffersVector(e,n){e.startVector(16,n,8)}static addCompression(e,n){e.addFieldOffset(3,n,0)}static endRecordBatch(e){return e.endObject()}},ua=class vv{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsDictionaryBatch(e,n){return(n||new vv).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsDictionaryBatch(e,n){return e.setPosition(e.position()+st),(n||new vv).__init(e.readInt32(e.position())+e.position(),e)}id(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}data(e){const n=this.bb.__offset(this.bb_pos,6);return n?(e||new Ii).__init(this.bb.__indirect(this.bb_pos+n),this.bb):null}isDelta(){const e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startDictionaryBatch(e){e.startObject(3)}static addId(e,n){e.addFieldInt64(0,n,e.createLong(0,0))}static addData(e,n){e.addFieldOffset(1,n,0)}static addIsDelta(e,n){e.addFieldInt8(2,+n,0)}static endDictionaryBatch(e){return e.endObject()}};var Xd;(function(t){t[t.NONE=0]="NONE",t[t.Schema=1]="Schema",t[t.DictionaryBatch=2]="DictionaryBatch",t[t.RecordBatch=3]="RecordBatch",t[t.Tensor=4]="Tensor",t[t.SparseTensor=5]="SparseTensor"})(Xd||(Xd={}));let as=class Wr{constructor(){this.bb=null,this.bb_pos=0}__init(e,n){return this.bb_pos=e,this.bb=n,this}static getRootAsMessage(e,n){return(n||new Wr).__init(e.readInt32(e.position())+e.position(),e)}static getSizePrefixedRootAsMessage(e,n){return e.setPosition(e.position()+st),(n||new Wr).__init(e.readInt32(e.position())+e.position(),e)}version(){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Ja.V1}headerType(){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):Xd.NONE}header(e){const n=this.bb.__offset(this.bb_pos,8);return n?this.bb.__union(e,this.bb_pos+n):null}bodyLength(){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):this.bb.createLong(0,0)}customMetadata(e,n){const r=this.bb.__offset(this.bb_pos,12);return r?(n||new zt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+e*4),this.bb):null}customMetadataLength(){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,n){e.addFieldInt16(0,n,Ja.V1)}static addHeaderType(e,n){e.addFieldInt8(1,n,Xd.NONE)}static addHeader(e,n){e.addFieldOffset(2,n,0)}static addBodyLength(e,n){e.addFieldInt64(3,n,e.createLong(0,0))}static addCustomMetadata(e,n){e.addFieldOffset(4,n,0)}static createCustomMetadataVector(e,n){e.startVector(4,n.length,4);for(let r=n.length-1;r>=0;r--)e.addOffset(n[r]);return e.endVector()}static startCustomMetadataVector(e,n){e.startVector(4,n,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,n){e.finish(n)}static finishSizePrefixedMessageBuffer(e,n){e.finish(n,void 0,!0)}static createMessage(e,n,r,i,s,o){return Wr.startMessage(e),Wr.addVersion(e,n),Wr.addHeaderType(e,r),Wr.addHeader(e,i),Wr.addBodyLength(e,s),Wr.addCustomMetadata(e,o),Wr.endMessage(e)}};var gj=Ni;class wj extends Be{visit(e,n){return e==null||n==null?void 0:super.visit(e,n)}visitNull(e,n){return wo.startNull(n),wo.endNull(n)}visitInt(e,n){return Hn.startInt(n),Hn.addBitWidth(n,e.bitWidth),Hn.addIsSigned(n,e.isSigned),Hn.endInt(n)}visitFloat(e,n){return ri.startFloatingPoint(n),ri.addPrecision(n,e.precision),ri.endFloatingPoint(n)}visitBinary(e,n){return yo.startBinary(n),yo.endBinary(n)}visitBool(e,n){return vo.startBool(n),vo.endBool(n)}visitUtf8(e,n){return bo.startUtf8(n),bo.endUtf8(n)}visitDecimal(e,n){return bn.startDecimal(n),bn.addScale(n,e.scale),bn.addPrecision(n,e.precision),bn.addBitWidth(n,e.bitWidth),bn.endDecimal(n)}visitDate(e,n){return Nf.startDate(n),Nf.addUnit(n,e.unit),Nf.endDate(n)}visitTime(e,n){return pr.startTime(n),pr.addUnit(n,e.unit),pr.addBitWidth(n,e.bitWidth),pr.endTime(n)}visitTimestamp(e,n){const r=e.timezone&&n.createString(e.timezone)||void 0;return mr.startTimestamp(n),mr.addUnit(n,e.unit),r!==void 0&&mr.addTimezone(n,r),mr.endTimestamp(n)}visitInterval(e,n){return ii.startInterval(n),ii.addUnit(n,e.unit),ii.endInterval(n)}visitList(e,n){return go.startList(n),go.endList(n)}visitStruct(e,n){return _o.startStruct_(n),_o.endStruct_(n)}visitUnion(e,n){In.startTypeIdsVector(n,e.typeIds.length);const r=In.createTypeIdsVector(n,e.typeIds);return In.startUnion(n),In.addMode(n,e.mode),In.addTypeIds(n,r),In.endUnion(n)}visitDictionary(e,n){const r=this.visit(e.indices,n);return Di.startDictionaryEncoding(n),Di.addId(n,new gj(e.id,0)),Di.addIsOrdered(n,e.isOrdered),r!==void 0&&Di.addIndexType(n,r),Di.endDictionaryEncoding(n)}visitFixedSizeBinary(e,n){return ti.startFixedSizeBinary(n),ti.addByteWidth(n,e.byteWidth),ti.endFixedSizeBinary(n)}visitFixedSizeList(e,n){return ni.startFixedSizeList(n),ni.addListSize(n,e.listSize),ni.endFixedSizeList(n)}visitMap(e,n){return Bf.startMap(n),Bf.addKeysSorted(n,e.keysSorted),Bf.endMap(n)}}const xm=new wj;function _j(t,e=new Map){return new We(Sj(t,e),$f(t.customMetadata),e)}function ax(t){return new nr(t.count,ux(t.columns),lx(t.columns))}function bj(t){return new hi(ax(t.data),t.id,t.isDelta)}function Sj(t,e){return(t.fields||[]).filter(Boolean).map(n=>yt.fromJSON(n,e))}function O1(t,e){return(t.children||[]).filter(Boolean).map(n=>yt.fromJSON(n,e))}function ux(t){return(t||[]).reduce((e,n)=>[...e,new qo(n.count,Ij(n.VALIDITY)),...ux(n.children)],[])}function lx(t,e=[]){for(let n=-1,r=(t||[]).length;++ne+ +(n===0),0)}function Ej(t,e){let n,r,i,s,o,a;return!e||!(s=t.dictionary)?(o=D1(t,O1(t,e)),i=new yt(t.name,o,t.nullable,$f(t.customMetadata))):e.has(n=s.id)?(r=(r=s.indexType)?k1(r):new Fl,a=new Ya(e.get(n),r,n,s.isOrdered),i=new yt(t.name,a,t.nullable,$f(t.customMetadata))):(r=(r=s.indexType)?k1(r):new Fl,e.set(n,o=D1(t,O1(t,e))),a=new Ya(o,r,n,s.isOrdered),i=new yt(t.name,a,t.nullable,$f(t.customMetadata))),i||null}function $f(t){return new Map(Object.entries(t||{}))}function k1(t){return new Fs(t.isSigned,t.bitWidth)}function D1(t,e){const n=t.type.name;switch(n){case"NONE":return new Bs;case"null":return new Bs;case"binary":return new xd;case"utf8":return new Cd;case"bool":return new Ad;case"list":return new Nd((e||[])[0]);case"struct":return new pn(e||[]);case"struct_":return new pn(e||[])}switch(n){case"int":{const r=t.type;return new Fs(r.isSigned,r.bitWidth)}case"floatingpoint":{const r=t.type;return new Ll(An[r.precision])}case"decimal":{const r=t.type;return new Pd(r.scale,r.precision,r.bitWidth)}case"date":{const r=t.type;return new Rd(Hi[r.unit])}case"time":{const r=t.type;return new $l(ze[r.unit],r.bitWidth)}case"timestamp":{const r=t.type;return new Td(ze[r.unit],r.timezone)}case"interval":{const r=t.type;return new Md(Ns[r.unit])}case"union":{const r=t.type;return new Bd(tr[r.mode],r.typeIds||[],e||[])}case"fixedsizebinary":{const r=t.type;return new Fd(r.byteWidth)}case"fixedsizelist":{const r=t.type;return new Ld(r.listSize,(e||[])[0])}case"map":{const r=t.type;return new $d((e||[])[0],r.keysSorted)}}throw new Error(`Unrecognized type: "${n}"`)}var Uo=Ni,Oj=XD,kj=Ga;class mn{constructor(e,n,r,i){this._version=n,this._headerType=r,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=typeof e=="number"?e:e.low}static fromJSON(e,n){const r=new mn(0,Yn.V4,n);return r._createHeader=Dj(e,n),r}static decode(e){e=new kj(Ue(e));const n=as.getRootAsMessage(e),r=n.bodyLength(),i=n.version(),s=n.headerType(),o=new mn(r,i,s);return o._createHeader=xj(n,s),o}static encode(e){const n=new Oj;let r=-1;return e.isSchema()?r=We.encode(n,e.header()):e.isRecordBatch()?r=nr.encode(n,e.header()):e.isDictionaryBatch()&&(r=hi.encode(n,e.header())),as.startMessage(n),as.addVersion(n,Yn.V4),as.addHeader(n,r),as.addHeaderType(n,e.headerType),as.addBodyLength(n,new Uo(e.bodyLength,0)),as.finishMessageBuffer(n,as.endMessage(n)),n.asUint8Array()}static from(e,n=0){if(e instanceof We)return new mn(0,Yn.V4,Ve.Schema,e);if(e instanceof nr)return new mn(n,Yn.V4,Ve.RecordBatch,e);if(e instanceof hi)return new mn(n,Yn.V4,Ve.DictionaryBatch,e);throw new Error(`Unrecognized Message header: ${e}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===Ve.Schema}isRecordBatch(){return this.headerType===Ve.RecordBatch}isDictionaryBatch(){return this.headerType===Ve.DictionaryBatch}}class nr{constructor(e,n,r){this._nodes=n,this._buffers=r,this._length=typeof e=="number"?e:e.low}get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}}class hi{constructor(e,n,r=!1){this._data=e,this._isDelta=r,this._id=typeof n=="number"?n:n.low}get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}}class oi{constructor(e,n){this.offset=typeof e=="number"?e:e.low,this.length=typeof n=="number"?n:n.low}}class qo{constructor(e,n){this.length=typeof e=="number"?e:e.low,this.nullCount=typeof n=="number"?n:n.low}}function Dj(t,e){return()=>{switch(e){case Ve.Schema:return We.fromJSON(t);case Ve.RecordBatch:return nr.fromJSON(t);case Ve.DictionaryBatch:return hi.fromJSON(t)}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)}}function xj(t,e){return()=>{switch(e){case Ve.Schema:return We.decode(t.header(new Hr));case Ve.RecordBatch:return nr.decode(t.header(new Ii),t.version());case Ve.DictionaryBatch:return hi.decode(t.header(new ua),t.version())}throw new Error(`Unrecognized Message type: { name: ${Ve[e]}, type: ${e} }`)}}yt.encode=$j;yt.decode=Fj;yt.fromJSON=Ej;We.encode=Lj;We.decode=Cj;We.fromJSON=_j;nr.encode=jj;nr.decode=Aj;nr.fromJSON=ax;hi.encode=Uj;hi.decode=Pj;hi.fromJSON=bj;qo.encode=zj;qo.decode=Tj;oi.encode=Vj;oi.decode=Rj;function Cj(t,e=new Map){const n=Bj(t,e);return new We(n,jf(t),e)}function Aj(t,e=Yn.V4){if(t.compression()!==null)throw new Error("Record batch compression not implemented");return new nr(t.length(),Mj(t),Nj(t,e))}function Pj(t,e=Yn.V4){return new hi(nr.decode(t.data(),e),t.id(),t.isDelta())}function Rj(t){return new oi(t.offset(),t.length())}function Tj(t){return new qo(t.length(),t.nullCount())}function Mj(t){const e=[];for(let n,r=-1,i=-1,s=t.nodesLength();++ryt.encode(t,s));Hr.startFieldsVector(t,n.length);const r=Hr.createFieldsVector(t,n),i=e.metadata&&e.metadata.size>0?Hr.createCustomMetadataVector(t,[...e.metadata].map(([s,o])=>{const a=t.createString(`${s}`),l=t.createString(`${o}`);return zt.startKeyValue(t),zt.addKey(t,a),zt.addValue(t,l),zt.endKeyValue(t)})):-1;return Hr.startSchema(t),Hr.addFields(t,r),Hr.addEndianness(t,Kj?Xa.Little:Xa.Big),i!==-1&&Hr.addCustomMetadata(t,i),Hr.endSchema(t)}function $j(t,e){let n=-1,r=-1,i=-1;const s=e.type;let o=e.typeId;we.isDictionary(s)?(o=s.dictionary.typeId,i=xm.visit(s,t),r=xm.visit(s.dictionary,t)):r=xm.visit(s,t);const a=(s.children||[]).map(h=>yt.encode(t,h)),l=cr.createChildrenVector(t,a),f=e.metadata&&e.metadata.size>0?cr.createCustomMetadataVector(t,[...e.metadata].map(([h,m])=>{const y=t.createString(`${h}`),w=t.createString(`${m}`);return zt.startKeyValue(t),zt.addKey(t,y),zt.addValue(t,w),zt.endKeyValue(t)})):-1;return e.name&&(n=t.createString(e.name)),cr.startField(t),cr.addType(t,r),cr.addTypeType(t,o),cr.addChildren(t,l),cr.addNullable(t,!!e.nullable),n!==-1&&cr.addName(t,n),i!==-1&&cr.addDictionary(t,i),f!==-1&&cr.addCustomMetadata(t,f),cr.endField(t)}function jj(t,e){const n=e.nodes||[],r=e.buffers||[];Ii.startNodesVector(t,n.length);for(const o of n.slice().reverse())qo.encode(t,o);const i=t.endVector();Ii.startBuffersVector(t,r.length);for(const o of r.slice().reverse())oi.encode(t,o);const s=t.endVector();return Ii.startRecordBatch(t),Ii.addLength(t,new Uo(e.length,0)),Ii.addNodes(t,i),Ii.addBuffers(t,s),Ii.endRecordBatch(t)}function Uj(t,e){const n=nr.encode(t,e.data);return ua.startDictionaryBatch(t),ua.addId(t,new Uo(e.id,0)),ua.addIsDelta(t,e.isDelta),ua.addData(t,n),ua.endDictionaryBatch(t)}function zj(t,e){return ox.createFieldNode(t,new Uo(e.length,0),new Uo(e.nullCount,0))}function Vj(t,e){return sx.createBuffer(t,new Uo(e.offset,0),new Uo(e.length,0))}const Kj=(()=>{const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),new Int16Array(t)[0]===256})(),P0=t=>`Expected ${Ve[t]} Message in stream, but was null or length 0.`,R0=t=>`Header pointer of flatbuffer-encoded ${Ve[t]} Message is null or length 0.`,cx=(t,e)=>`Expected to read ${t} metadata bytes, but only read ${e}.`,fx=(t,e)=>`Expected to read ${t} bytes for message body, but only read ${e}.`;class dx{constructor(e){this.source=e instanceof Qd?e:new Qd(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?St:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(P0(e));return n.value}readMessageBody(e){if(e<=0)return new Uint8Array(0);const n=Ue(this.source.read(e));if(n.byteLength[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE&&[s.TYPE]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...n(s.children)],[])}}readMessage(e){let n;if((n=this.next()).done)return null;if(e!=null&&n.value.headerType!==e)throw new Error(P0(e));return n.value}readSchema(){const e=Ve.Schema,n=this.readMessage(e),r=n==null?void 0:n.header();if(!n||!r)throw new Error(R0(e));return r}}const zh=4,gv="ARROW1",Ul=new Uint8Array(gv.length);for(let t=0;tthis):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return fr.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return fr.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}static from(e){return e instanceof Bi?e:av(e)?Jj(e):Tk(e)?e4(e):Ms(e)?(()=>ve(this,void 0,void 0,function*(){return yield Bi.from(yield e)}))():Mk(e)||f0(e)||Nk(e)||fu(e)?Zj(new eu(e)):Xj(new Qd(e))}static readAll(e){return e instanceof Bi?e.isSync()?P1(e):R1(e):av(e)||ArrayBuffer.isView(e)||uc(e)||Rk(e)?P1(e):R1(e)}}class Zd extends Bi{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Dr(this,arguments,function*(){yield ge(yield*Df(Ds(this[Symbol.iterator]())))})}}class eh extends Bi{constructor(e){super(e),this._impl=e}readAll(){var e,n;return ve(this,void 0,void 0,function*(){const r=new Array;try{for(var i=Ds(this),s;s=yield i.next(),!s.done;){const o=s.value;r.push(o)}}catch(o){e={error:o}}finally{try{s&&!s.done&&(n=i.return)&&(yield n.call(i))}finally{if(e)throw e.error}}return r})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}}class px extends Zd{constructor(e){super(e),this._impl=e}}class Qj extends eh{constructor(e){super(e),this._impl=e}}class mx{constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,n){const r=this._loadVectors(e,n,this.schema.fields),i=Ne({type:new pn(this.schema.fields),length:e.length,children:r});return new En(this.schema,i)}_loadDictionaryBatch(e,n){const{id:r,isDelta:i}=e,{dictionaries:s,schema:o}=this,a=s.get(r);if(i||!a){const l=o.dictionaries.get(r),f=this._loadVectors(e.data,n,[l]);return(a&&i?a.concat(new Ke(f)):new Ke(f)).memoize()}return a.memoize()}_loadVectors(e,n,r){return new tx(n,e.nodes,e.buffers,this.dictionaries).visitMany(r)}}class th extends mx{constructor(e,n){super(n),this._reader=av(e)?new qj(this._handle=e):new dx(this._handle=e)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(e){return this.closed||(this.autoDestroy=vx(this,e),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):St}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):St}next(){if(this.closed)return St;let e;const{_reader:n}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const r=e.header(),i=n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const r=e.header(),i=n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new A0(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}}class nh extends mx{constructor(e,n){super(n),this._reader=new Wj(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return ve(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return ve(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=vx(this,e),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return ve(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):St})}return(e){return ve(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):St})}next(){return ve(this,void 0,void 0,function*(){if(this.closed)return St;let e;const{_reader:n}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;const r=e.header(),i=yield n.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(r,i)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;const r=e.header(),i=yield n.readMessageBody(e.bodyLength),s=this._loadDictionaryBatch(r,i);this.dictionaries.set(r.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new A0(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return ve(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}}class yx extends th{constructor(e,n){super(e instanceof I1?e:new I1(e),n)}get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}isSync(){return!0}isFile(){return!0}open(e){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(const n of this._footer.dictionaryBatches())n&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(e)}readRecordBatch(e){var n;if(this.closed)return null;this._footer||this.open();const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(Ve.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(e){var n;const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&this._handle.seek(r.offset)){const i=this._reader.readMessage(Ve.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){const{_handle:e}=this,n=e.size-hx,r=e.readInt32(n),i=e.readAt(n-r,r);return jl.decode(i)}_readNextMessageAndValidate(e){var n;if(this._footer||this.open(),this._footer&&this._recordBatchIndexsuper.open}});return ve(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(const r of this._footer.dictionaryBatches())r&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,e)})}readRecordBatch(e){var n;return ve(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());const r=(n=this._footer)===null||n===void 0?void 0:n.getRecordBatch(e);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(Ve.RecordBatch);if(i!=null&&i.isRecordBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(e){var n;return ve(this,void 0,void 0,function*(){const r=(n=this._footer)===null||n===void 0?void 0:n.getDictionaryBatch(e);if(r&&(yield this._handle.seek(r.offset))){const i=yield this._reader.readMessage(Ve.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){const s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return ve(this,void 0,void 0,function*(){const{_handle:e}=this;e._pending&&(yield e._pending);const n=e.size-hx,r=yield e.readInt32(n),i=yield e.readAt(n-r,r);return jl.decode(i)})}_readNextMessageAndValidate(e){return ve(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex=4?T0(e)?new px(new yx(t.read())):new Zd(new th(t)):new Zd(new th(function*(){}()))}function Zj(t){return ve(this,void 0,void 0,function*(){const e=yield t.peek(dc+7&-8);return e&&e.byteLength>=4?T0(e)?new px(new yx(yield t.read())):new eh(new nh(t)):new eh(new nh(function(){return Dr(this,arguments,function*(){})}()))})}function e4(t){return ve(this,void 0,void 0,function*(){const{size:e}=yield t.stat(),n=new Yd(t,e);return e>=Hj&&T0(yield n.readAt(0,dc+7&-8))?new Qj(new Yj(n)):new eh(new nh(n))})}class $t extends Be{constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}static assemble(...e){const n=i=>i.flatMap(s=>Array.isArray(s)?n(s):s instanceof En?s.data.children:s.data),r=new $t;return r.visitMany(n(e)),r}visit(e){if(e instanceof Ke)return this.visitMany(e.data),this;const{type:n}=e;if(!we.isDictionary(n)){const{length:r,nullCount:i}=e;if(r>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");we.isNull(n)||Pr.call(this,i<=0?new Uint8Array(0):_0(e.offset,r,e.nullBitmap)),this.nodes.push(new qo(r,i))}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}}function Pr(t){const e=t.byteLength+7&-8;return this.buffers.push(t),this.bufferRegions.push(new oi(this._byteLength,e)),this._byteLength+=e,this}function t4(t){const{type:e,length:n,typeIds:r,valueOffsets:i}=t;if(Pr.call(this,r),e.mode===tr.Sparse)return wv.call(this,t);if(e.mode===tr.Dense){if(t.offset<=0)return Pr.call(this,i),wv.call(this,t);{const s=r.reduce((h,m)=>Math.max(h,m),r[0]),o=new Int32Array(s+1),a=new Int32Array(s+1).fill(-1),l=new Int32Array(n),f=h0(-i[0],n,i);for(let h,m,y=-1;++y=t.length?Pr.call(this,new Uint8Array(0)):(e=t.values)instanceof Uint8Array?Pr.call(this,_0(t.offset,t.length,e)):Pr.call(this,jd(t.values))}function Ys(t){return Pr.call(this,t.values.subarray(0,t.length*t.stride))}function gx(t){const{length:e,values:n,valueOffsets:r}=t,i=r[0],s=r[e],o=Math.min(s-i,n.byteLength-i);return Pr.call(this,h0(-r[0],e,r)),Pr.call(this,n.subarray(i,i+o)),this}function M0(t){const{length:e,valueOffsets:n}=t;return n&&Pr.call(this,h0(n[0],e,n)),this.visit(t.children[0])}function wv(t){return this.visitMany(t.type.children.map((e,n)=>t.children[n]).filter(Boolean))[0]}$t.prototype.visitBool=n4;$t.prototype.visitInt=Ys;$t.prototype.visitFloat=Ys;$t.prototype.visitUtf8=gx;$t.prototype.visitBinary=gx;$t.prototype.visitFixedSizeBinary=Ys;$t.prototype.visitDate=Ys;$t.prototype.visitTimestamp=Ys;$t.prototype.visitTime=Ys;$t.prototype.visitDecimal=Ys;$t.prototype.visitList=M0;$t.prototype.visitStruct=wv;$t.prototype.visitUnion=t4;$t.prototype.visitInterval=Ys;$t.prototype.visitFixedSizeList=M0;$t.prototype.visitMap=M0;class wx extends O0{constructor(e){super(),this._position=0,this._started=!1,this._sink=new Lf,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,Nn(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy=="boolean"?e.autoDestroy:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat=="boolean"?e.writeLegacyIpcFormat:!1}static throughNode(e){throw new Error('"throughNode" not available in this environment')}static throughDOM(e,n){throw new Error('"throughDOM" not available in this environment')}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return Ms(e)?e.then(n=>this.writeAll(n)):fu(e)?L0(this,e):F0(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,n=null){return e===this._sink||e instanceof Lf?this._sink=e:(this._sink=new Lf,e&&I3(e)?this.toDOMStream({type:"bytes"}).pipeTo(e):e&&E3(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,(!n||!mv(n,this._schema))&&(n==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=n,this._writeSchema(n))),this}write(e){let n=null;if(this._sink){if(e==null)return this.finish()&&void 0;if(e instanceof hn&&!(n=e.schema))return this.finish()&&void 0;if(e instanceof En&&!(n=e.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(n&&!mv(n,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,n)}e instanceof En?e instanceof A0||this._writeRecordBatch(e):e instanceof hn?this.writeAll(e.batches):uc(e)&&this.writeAll(e)}_writeMessage(e,n=8){const r=n-1,i=mn.encode(e),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+r&~r,l=a-s-o;return e.headerType===Ve.RecordBatch?this._recordBatchBlocks.push(new Ls(a,e.bodyLength,this._position)):e.headerType===Ve.DictionaryBatch&&this._dictionaryBlocks.push(new Ls(a,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(l)}_write(e){if(this._started){const n=Ue(e);n&&n.byteLength>0&&(this._sink.write(n),this._position+=n.byteLength)}return this}_writeSchema(e){return this._writeMessage(mn.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Ul)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){const{byteLength:n,nodes:r,bufferRegions:i,buffers:s}=$t.assemble(e),o=new nr(e.numRows,r,i),a=mn.from(o,n);return this._writeDictionaries(e)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(e,n,r=!1){this._dictionaryDeltaOffsets.set(n,e.length+(this._dictionaryDeltaOffsets.get(n)||0));const{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=$t.assemble(new Ke([e])),l=new nr(e.length,s,o),f=new hi(l,n,r),h=mn.from(f,i);return this._writeMessage(h)._writeBodyBuffers(a)}_writeBodyBuffers(e){let n,r,i;for(let s=-1,o=e.length;++s0&&(this._write(n),(i=(r+7&-8)-r)>0&&this._writePadding(i));return this}_writeDictionaries(e){for(let[n,r]of e.dictionaries){let i=this._dictionaryDeltaOffsets.get(n)||0;if(i===0||(r=r==null?void 0:r.slice(i)).length>0)for(const s of r.data)this._writeDictionaryBatch(s,n,i>0),i+=s.length}return this}}class N0 extends wx{static writeAll(e,n){const r=new N0(n);return Ms(e)?e.then(i=>r.writeAll(i)):fu(e)?L0(r,e):F0(r,e)}}class B0 extends wx{static writeAll(e){const n=new B0;return Ms(e)?e.then(r=>n.writeAll(r)):fu(e)?L0(n,e):F0(n,e)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeFooter(e){const n=jl.encode(new jl(e,Yn.V4,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(n)._write(Int32Array.of(n.byteLength))._writeMagic()}}function F0(t,e){let n=e;e instanceof hn&&(n=e.batches,t.reset(void 0,e.schema));for(const r of n)t.write(r);return t.finish()}function L0(t,e){var n,r,i,s;return ve(this,void 0,void 0,function*(){try{for(n=Ds(e);r=yield n.next(),!r.done;){const o=r.value;t.write(o)}}catch(o){i={error:o}}finally{try{r&&!r.done&&(s=n.return)&&(yield s.call(n))}finally{if(i)throw i.error}}return t.finish()})}function Ku(t){const e=Bi.from(t);return Ms(e)?e.then(n=>Ku(n)):e.isAsync()?e.readAll().then(n=>new hn(n)):new hn(e.readAll())}function Cm(t,e="stream"){return(e==="stream"?N0:B0).writeAll(t).toUint8Array(!0)}var T1=function(){function t(e,n,r,i){var s=this;this.getCell=function(o,a){var l=o=s.headerRows&&a=s.headerColumns;if(l){var m=["blank"];return a>0&&m.push("level"+o),{type:"blank",classNames:m.join(" "),content:""}}else if(h){var y=a-s.headerColumns,m=["col_heading","level"+o,"col"+y];return{type:"columns",classNames:m.join(" "),content:s.getContent(s.columnsTable,y,o)}}else if(f){var w=o-s.headerRows,m=["row_heading","level"+a,"row"+w];return{type:"index",id:"T_".concat(s.uuid,"level").concat(a,"_row").concat(w),classNames:m.join(" "),content:s.getContent(s.indexTable,w,a)}}else{var w=o-s.headerRows,y=a-s.headerColumns,m=["data","row"+w,"col"+y],I=s.styler?s.getContent(s.styler.displayValuesTable,w,y):s.getContent(s.dataTable,w,y);return{type:"data",id:"T_".concat(s.uuid,"row").concat(w,"_col").concat(y),classNames:m.join(" "),content:I}}},this.getContent=function(o,a,l){var f=o.getChildAt(l);if(f===null)return"";var h=s.getColumnTypeId(o,l);switch(h){case N.Timestamp:return s.nanosToDate(f.get(a));default:return f.get(a)}},this.dataTable=Ku(e),this.indexTable=Ku(n),this.columnsTable=Ku(r),this.styler=i?{caption:i.caption,displayValuesTable:Ku(i.displayValues),styles:i.styles,uuid:i.uuid}:void 0}return Object.defineProperty(t.prototype,"rows",{get:function(){return this.indexTable.numRows+this.columnsTable.numCols},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"columns",{get:function(){return this.indexTable.numCols+this.columnsTable.numRows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"headerRows",{get:function(){return this.rows-this.dataRows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"headerColumns",{get:function(){return this.columns-this.dataColumns},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataRows",{get:function(){return this.dataTable.numRows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataColumns",{get:function(){return this.dataTable.numCols},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uuid",{get:function(){return this.styler&&this.styler.uuid},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"caption",{get:function(){return this.styler&&this.styler.caption},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"styles",{get:function(){return this.styler&&this.styler.styles},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"table",{get:function(){return this.dataTable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"index",{get:function(){return this.indexTable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"columnTable",{get:function(){return this.columnsTable},enumerable:!1,configurable:!0}),t.prototype.serialize=function(){return{data:Cm(this.dataTable),index:Cm(this.indexTable),columns:Cm(this.columnsTable)}},t.prototype.getColumnTypeId=function(e,n){return e.schema.fields[n].type.typeId},t.prototype.nanosToDate=function(e){return new Date(e/1e6)},t}(),al=function(){return al=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0?t.argsDataframeToObject(e.dfs):{};n=al(al({},n),r);var i=!!e.disabled,s=e.theme;s&&r4(s);var o={disabled:i,args:n,theme:s},a=new CustomEvent(t.RENDER_EVENT,{detail:o});t.events.dispatchEvent(a)},t.argsDataframeToObject=function(e){var n=e.map(function(r){var i=r.key,s=r.value;return[i,t.toArrowTable(s)]});return Object.fromEntries(n)},t.toArrowTable=function(e){var n,r=(n=e.data,n.data),i=n.index,s=n.columns,o=n.styler;return new T1(r,i,s,o)},t.sendBackMsg=function(e,n){window.parent.postMessage(al({isStreamlitMessage:!0,type:e},n),"*")},t}(),r4=function(t){var e=document.createElement("style");document.head.appendChild(e),e.innerHTML=` :root { --primary-color: `.concat(t.primaryColor,`; --background-color: `).concat(t.backgroundColor,`; @@ -88,4 +88,4 @@ object-assign background-color: var(--background-color); color: var(--text-color); } - `)};function r4(t){var e=!1;try{e=t instanceof BigInt64Array||t instanceof BigUint64Array}catch{}return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array||e}var wx=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(r[s]=i[s])},t(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}();(function(t){wx(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.componentDidMount=function(){On.setFrameHeight()},e.prototype.componentDidUpdate=function(){On.setFrameHeight()},e})(ra.PureComponent);function i4(t){var e=function(n){wx(r,n);function r(i){var s=n.call(this,i)||this;return s.componentDidMount=function(){On.events.addEventListener(On.RENDER_EVENT,s.onRenderEvent),On.setComponentReady()},s.componentDidUpdate=function(){s.state.componentError!=null&&On.setFrameHeight()},s.componentWillUnmount=function(){On.events.removeEventListener(On.RENDER_EVENT,s.onRenderEvent)},s.onRenderEvent=function(o){s.setState({renderData:o.detail})},s.state={renderData:void 0,componentError:void 0},s}return r.prototype.render=function(){return this.state.componentError!=null?ra.createElement("div",null,ra.createElement("h1",null,"Component Error"),ra.createElement("span",null,this.state.componentError.message)):this.state.renderData==null?null:ra.createElement(t,{width:window.innerWidth,disabled:this.state.renderData.disabled,args:this.state.renderData.args,theme:this.state.renderData.theme})},r.getDerivedStateFromError=function(i){return{componentError:i}},r}(ra.PureComponent);return GL(e,t)}var s4=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var o=s[i];if(!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n};const o4=rh(s4);let hf;const a4=new Uint8Array(16);function u4(){if(!hf&&(hf=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!hf))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return hf(a4)}const Jt=[];for(let t=0;t<256;++t)Jt.push((t+256).toString(16).slice(1));function l4(t,e=0){return Jt[t[e+0]]+Jt[t[e+1]]+Jt[t[e+2]]+Jt[t[e+3]]+"-"+Jt[t[e+4]]+Jt[t[e+5]]+"-"+Jt[t[e+6]]+Jt[t[e+7]]+"-"+Jt[t[e+8]]+Jt[t[e+9]]+"-"+Jt[t[e+10]]+Jt[t[e+11]]+Jt[t[e+12]]+Jt[t[e+13]]+Jt[t[e+14]]+Jt[t[e+15]]}const c4=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),T1={randomUUID:c4};function f4(t,e,n){if(T1.randomUUID&&!e&&!t)return T1.randomUUID();t=t||{};const r=t.random||(t.rng||u4)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(let i=0;i<16;++i)e[n+i]=r[i];return e}return l4(r)}const{isEmpty:pf}=Br,d4=(t,e)=>{const[n,r]=oi.useState(),i=oi.useRef(t);return oi.useEffect(()=>{if(!(!n||pf(t)||o4(t,i.current))){if(i.current=t,!pf(t.added_rows)){const s=t.added_rows.map(o=>({...o,id:f4(),createdAt:new Date().toISOString(),last_modified:Date.now()}));e.upsertBulk(s)}if(!pf(t.deleted_rows)){const s=[];t.deleted_rows.forEach(o=>{const a=n.at(o);a&&s.push(a.id)}),e.removeBulk(s)}pf(t.edited_rows)||Object.entries(t.edited_rows).forEach(([s,o])=>{const a=n.at(parseInt(s));a&&e.set(a.id,o)})}},[t,n]),[n,r]},h4=()=>{const[t,e]=oi.useState(),n=new su;return oi.useEffect(()=>{const r=s=>{e(s.detail)};return On.events.addEventListener(On.RENDER_EVENT,r),On.setComponentReady(),()=>{On.events.removeEventListener(On.RENDER_EVENT,r),n.unsubscribe()}},[]),[t,n]},{logger:M1,isEmptyObject:p4}=Br,m4=t=>{const[e,n]=oi.useState(),[r,i]=h4(),{editing_state:s,collection_config:o,db_config:a,query:l,with_rev:f}=(r==null?void 0:r.args)||{},h=oi.useRef(),m=oi.useRef();h.current||(h.current=new NL);const y=()=>m.current,[,w]=d4(s,y());async function I(F){const S=wF(F);return h.current.initDb(S)}async function E(F){m.current||(m.current=new Je(F,h.current)),await y().info(),n(!0);const S=y().docs(l,f).subscribe(_=>{_&&(M1.table(_),w(_),On.setComponentValue(_))});i.add(S)}if(p4(r))return null;if(!e)try{I(a).then(()=>E(o))}catch(F){M1.log("Error initializing database",F)}return t.args.element},y4=i4(m4),v4=QI(document.getElementById("root"));v4.render(_A.jsx(y4,{})); + `)};function i4(t){var e=!1;try{e=t instanceof BigInt64Array||t instanceof BigUint64Array}catch{}return t instanceof Int8Array||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array||e}var _x=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(r[s]=i[s])},t(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");t(e,n);function r(){this.constructor=e}e.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}}();(function(t){_x(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}return e.prototype.componentDidMount=function(){On.setFrameHeight()},e.prototype.componentDidUpdate=function(){On.setFrameHeight()},e})(ia.PureComponent);function s4(t){var e=function(n){_x(r,n);function r(i){var s=n.call(this,i)||this;return s.componentDidMount=function(){On.events.addEventListener(On.RENDER_EVENT,s.onRenderEvent),On.setComponentReady()},s.componentDidUpdate=function(){s.state.componentError!=null&&On.setFrameHeight()},s.componentWillUnmount=function(){On.events.removeEventListener(On.RENDER_EVENT,s.onRenderEvent)},s.onRenderEvent=function(o){s.setState({renderData:o.detail})},s.state={renderData:void 0,componentError:void 0},s}return r.prototype.render=function(){return this.state.componentError!=null?ia.createElement("div",null,ia.createElement("h1",null,"Component Error"),ia.createElement("span",null,this.state.componentError.message)):this.state.renderData==null?null:ia.createElement(t,{width:window.innerWidth,disabled:this.state.renderData.disabled,args:this.state.renderData.args,theme:this.state.renderData.theme})},r.getDerivedStateFromError=function(i){return{componentError:i}},r}(ia.PureComponent);return JL(e,t)}var o4=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){var o=s[i];if(!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n};const a4=rh(o4);let hf;const u4=new Uint8Array(16);function l4(){if(!hf&&(hf=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!hf))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return hf(u4)}const Jt=[];for(let t=0;t<256;++t)Jt.push((t+256).toString(16).slice(1));function c4(t,e=0){return Jt[t[e+0]]+Jt[t[e+1]]+Jt[t[e+2]]+Jt[t[e+3]]+"-"+Jt[t[e+4]]+Jt[t[e+5]]+"-"+Jt[t[e+6]]+Jt[t[e+7]]+"-"+Jt[t[e+8]]+Jt[t[e+9]]+"-"+Jt[t[e+10]]+Jt[t[e+11]]+Jt[t[e+12]]+Jt[t[e+13]]+Jt[t[e+14]]+Jt[t[e+15]]}const f4=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),M1={randomUUID:f4};function d4(t,e,n){if(M1.randomUUID&&!e&&!t)return M1.randomUUID();t=t||{};const r=t.random||(t.rng||l4)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,e){n=n||0;for(let i=0;i<16;++i)e[n+i]=r[i];return e}return c4(r)}const{logger:Am,isEmpty:pf}=Fr,h4=(t,e)=>{const[n,r]=qn.useState(),i=qn.useRef(t);return qn.useEffect(()=>{if(!n||pf(t)||a4(t,i.current))return;i.current=t;const{added_rows:s,edited_rows:o,deleted_rows:a}=t;if(!pf(s)){const l=s.map(f=>({...f,id:d4(),createdAt:new Date().toISOString(),last_modified:Date.now()}));if(!l.length)return;e.upsertBulk(l).catch(f=>Am.log("upsertBulk",f))}if(!pf(a)){const l=[];if(a.forEach(f=>{const h=n.at(f);h&&l.push(h.id)}),!l.length)return;e.removeBulk(l).catch(f=>Am.log("removeBulk",f))}if(!pf(o)){const l=Object.entries(o).map(([f,h])=>({...n.at(parseInt(f)),...h,last_modified:Date.now()}));if(!l.length)return;e.upsertBulk(l).catch(f=>Am.log("upsertBulk",f))}},[t,n,e]),[n,r]},p4=t=>{const[e,n]=qn.useState();return qn.useEffect(()=>{const r=s=>{n(s.detail)};return On.events.addEventListener(On.RENDER_EVENT,r),On.setComponentReady(),()=>{On.events.removeEventListener(On.RENDER_EVENT,r),t.unsubscribe()}},[]),e},{logger:N1,isEmptyObject:m4}=Fr,y4=t=>{const[e,n]=qn.useState(),r=new Bo,i=qn.useRef();i.current||(i.current=new Bo);const s=p4(i.current),{editing_state:o,collection_config:a,db_config:l,query:f,with_rev:h}=(s==null?void 0:s.args)||{},m=qn.useRef(),y=qn.useRef();m.current||(m.current=new BL);const w=()=>y.current,[,I]=h4(o,w()),E=qn.useCallback(S=>{const _=_F(S);return m.current.initDb(_)},[]),$=qn.useCallback(async S=>{y.current||(y.current=new Je(S,m.current)),await w().info(),n(!0);const _=w().docs(f,h).subscribe(O=>{O&&(N1.table(O),I(O),On.setComponentValue(O))});r.add(_)},[]);return m4(s)?null:(e||E(l).then(()=>$(a)).catch(N1.log),t.args.element)},v4=s4(y4),g4=YI(document.getElementById("root"));g4.render(bC.jsx(v4,{})); diff --git a/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/RxDBDataframe.tsx b/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/RxDBDataframe.tsx index 358a025..122aaa0 100644 --- a/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/RxDBDataframe.tsx +++ b/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/RxDBDataframe.tsx @@ -16,6 +16,7 @@ import { import { RxDBDataframeArgs } from './RxDBDataframeArgs'; import { useEditedState } from './useEditingState'; import { useNullableRenderData } from './useNullableRenderData'; +import { Subscription } from 'rxjs'; const { logger, isEmptyObject } = NgxRxdbUtils; @@ -24,7 +25,12 @@ const { logger, isEmptyObject } = NgxRxdbUtils; */ const RxDBDataframe: React.FC = props => { const [inited, setInited] = useState(); - const [renderData, sub] = useNullableRenderData(); + const sub = new Subscription(); + const subRef = useRef(); + if (!subRef.current) { + subRef.current = new Subscription(); + } + const renderData = useNullableRenderData(subRef.current); // Parse the render data const { editing_state, collection_config, db_config, query, with_rev } = renderData?.['args'] || ({} as RxDBDataframeArgs); diff --git a/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/useEditingState.ts b/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/useEditingState.ts index 5f5e754..975cd53 100644 --- a/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/useEditingState.ts +++ b/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/useEditingState.ts @@ -32,8 +32,10 @@ export const useEditedState = ( } editingStateRef.current = editingState; - if (!isEmpty(editingState.added_rows)) { - const docs = editingState.added_rows.map(item => ({ + const { added_rows: added, edited_rows: edited, deleted_rows: deleted } = editingState; + + if (!isEmpty(added)) { + const docs = added.map(item => ({ ...item, id: uuid(), createdAt: new Date().toISOString(), @@ -43,9 +45,9 @@ export const useEditedState = ( collectionService.upsertBulk(docs).catch(error => logger.log('upsertBulk', error)); } - if (!isEmpty(editingState.deleted_rows)) { + if (!isEmpty(deleted)) { const ids: string[] = []; - editingState.deleted_rows.forEach(rowIndex => { + deleted.forEach(rowIndex => { const entity = entities.at(rowIndex); if (entity) { ids.push(entity.id); @@ -55,8 +57,8 @@ export const useEditedState = ( collectionService.removeBulk(ids).catch(error => logger.log('removeBulk', error)); } - if (!isEmpty(editingState.edited_rows)) { - const docs = Object.entries(editingState.edited_rows).map(([rowIndex, change]) => { + if (!isEmpty(edited)) { + const docs = Object.entries(edited).map(([rowIndex, change]) => { const entity = entities.at(parseInt(rowIndex)); return { ...entity, @@ -67,7 +69,7 @@ export const useEditedState = ( if (!docs.length) return; collectionService.upsertBulk(docs).catch(error => logger.log('upsertBulk', error)); } - }, [editingState, entities]); + }, [editingState, entities, collectionService]); return [entities, setEntities]; }; diff --git a/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/useNullableRenderData.ts b/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/useNullableRenderData.ts index 0f28b09..63d3d10 100644 --- a/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/useNullableRenderData.ts +++ b/packages/streamlit-rxdb-dataframe/rxdb_dataframe/frontend/src/lib/useNullableRenderData.ts @@ -5,13 +5,12 @@ import { RxDBDataframeArgs } from './RxDBDataframeArgs'; /** * Returns `RenderData` received from Streamlit after the first render event received. + * @param sub Subscriptions holder */ -export const useNullableRenderData = (): [ - RenderData | undefined, - Subscription, -] => { +export const useNullableRenderData = ( + sub: Subscription +): RenderData | undefined => { const [renderData, setRenderData] = useState>(); - const sub = new Subscription(); useEffect(() => { const onRenderEvent = (event: Event): void => { @@ -31,5 +30,5 @@ export const useNullableRenderData = (): [ return cleanup; }, []); - return [renderData, sub]; + return renderData; };