@squidcloud/client 1.0.338 → 1.0.340
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +287 -62
- package/dist/internal-common/src/public-types/ai-assistant.public-types.d.ts +9 -2
- package/dist/internal-common/src/public-types/ai-matchmaking.types.d.ts +6 -0
- package/dist/internal-common/src/public-types/backend.public-types.d.ts +13 -0
- package/dist/internal-common/src/public-types/communication.public-types.d.ts +7 -0
- package/dist/internal-common/src/public-types/context.public-types.d.ts +12 -1
- package/dist/internal-common/src/public-types/document.public-types.d.ts +42 -12
- package/dist/internal-common/src/public-types/extraction.public-types.d.ts +21 -0
- package/dist/internal-common/src/public-types/integration.public-types.d.ts +16 -2
- package/dist/internal-common/src/public-types/integrations/api.public-types.d.ts +0 -11
- package/dist/internal-common/src/public-types/query.public-types.d.ts +35 -7
- package/dist/internal-common/src/public-types/scheduler.public-types.d.ts +13 -4
- package/dist/internal-common/src/public-types/secret.public-types.d.ts +24 -7
- package/dist/internal-common/src/public-types/serialized-query.public-types.d.ts +12 -0
- package/dist/internal-common/src/public-types/typescript.public-types.d.ts +0 -3
- package/dist/typescript-client/src/admin-client.d.ts +1 -0
- package/dist/typescript-client/src/agent/ai-agent-client-reference.d.ts +73 -2
- package/dist/typescript-client/src/agent/ai-agent-client.d.ts +1 -0
- package/dist/typescript-client/src/agent/ai-agent-client.types.d.ts +8 -1
- package/dist/typescript-client/src/ai-assistant-client.d.ts +3 -2
- package/dist/typescript-client/src/ai-audio-client.d.ts +15 -0
- package/dist/typescript-client/src/ai-client.d.ts +5 -0
- package/dist/typescript-client/src/ai-image-client.d.ts +16 -1
- package/dist/typescript-client/src/ai-matchmaking-client.d.ts +57 -11
- package/dist/typescript-client/src/ai.types.d.ts +24 -30
- package/dist/typescript-client/src/api-client.d.ts +1 -0
- package/dist/typescript-client/src/auth.manager.d.ts +4 -1
- package/dist/typescript-client/src/collection-reference.d.ts +2 -0
- package/dist/typescript-client/src/connection-details.d.ts +1 -0
- package/dist/typescript-client/src/destruct.manager.d.ts +1 -21
- package/dist/typescript-client/src/distributed-lock.manager.d.ts +4 -1
- package/dist/typescript-client/src/document-reference.d.ts +1 -0
- package/dist/typescript-client/src/document-store.d.ts +1 -17
- package/dist/typescript-client/src/extraction-client.d.ts +1 -0
- package/dist/typescript-client/src/integration-client.d.ts +1 -0
- package/dist/typescript-client/src/observability-client.d.ts +5 -1
- package/dist/typescript-client/src/personal-storage-client.d.ts +23 -4
- package/dist/typescript-client/src/public-types.d.ts +1 -4
- package/dist/typescript-client/src/query/deserializer.d.ts +1 -0
- package/dist/typescript-client/src/query/join-query-builder.factory.d.ts +34 -8
- package/dist/typescript-client/src/query/pagination.d.ts +10 -10
- package/dist/typescript-client/src/query/query-builder.factory.d.ts +12 -4
- package/dist/typescript-client/src/query/query-subscription.manager.d.ts +1 -12
- package/dist/typescript-client/src/query/query.types.d.ts +2 -93
- package/dist/typescript-client/src/query/snapshot-emitter.d.ts +1 -0
- package/dist/typescript-client/src/query-utils.d.ts +5 -1
- package/dist/typescript-client/src/queue.manager.d.ts +1 -0
- package/dist/typescript-client/src/scheduler-client.d.ts +1 -0
- package/dist/typescript-client/src/secret.client.d.ts +2 -0
- package/dist/typescript-client/src/squid.d.ts +16 -4
- package/dist/typescript-client/src/storage-client.d.ts +9 -9
- package/dist/typescript-client/src/types.d.ts +4 -1
- package/dist/typescript-client/src/version.d.ts +2 -2
- package/package.json +6 -2
- package/dist/internal-common/src/metric-name.d.ts +0 -9
- package/dist/internal-common/src/public-types/application.public-types.d.ts +0 -94
- package/dist/internal-common/src/public-types/bundle-data.public-types.d.ts +0 -33
- package/dist/internal-common/src/public-types/mutation.public-types.d.ts +0 -54
- package/dist/internal-common/src/public-types/storage.types.d.ts +0 -9
- package/dist/internal-common/src/public-types-backend/api-call.public-context.d.ts +0 -21
- package/dist/internal-common/src/public-types-backend/native-query.public-context.d.ts +0 -18
- package/dist/internal-common/src/public-types-backend/query.public-context.d.ts +0 -127
- package/dist/internal-common/src/types/ai-agent.types.d.ts +0 -1
- package/dist/internal-common/src/types/ai-assistant.types.d.ts +0 -1
- package/dist/internal-common/src/types/ai-matchmaking.types.d.ts +0 -53
- package/dist/internal-common/src/types/backend-function.types.d.ts +0 -1
- package/dist/internal-common/src/types/communication.types.d.ts +0 -1
- package/dist/internal-common/src/types/document.types.d.ts +0 -1
- package/dist/internal-common/src/types/mutation.types.d.ts +0 -1
- package/dist/internal-common/src/types/observability.types.d.ts +0 -71
- package/dist/internal-common/src/types/query.types.d.ts +0 -10
- package/dist/internal-common/src/types/secret.types.d.ts +0 -2
- package/dist/internal-common/src/types/socket.types.d.ts +0 -1
- package/dist/internal-common/src/types/time-units.d.ts +0 -1
- package/dist/internal-common/src/utils/array.d.ts +0 -1
- package/dist/internal-common/src/utils/e2e-test-utils.d.ts +0 -2
- package/dist/internal-common/src/utils/global.utils.d.ts +0 -1
- package/dist/internal-common/src/utils/http.d.ts +0 -1
- package/dist/internal-common/src/utils/lock.manager.d.ts +0 -14
- package/dist/internal-common/src/utils/metric-utils.d.ts +0 -4
- package/dist/internal-common/src/utils/metrics.types.d.ts +0 -7
- package/dist/internal-common/src/utils/object.d.ts +0 -49
- package/dist/internal-common/src/utils/serialization.d.ts +0 -5
- package/dist/internal-common/src/utils/squid.constants.d.ts +0 -1
- package/dist/internal-common/src/utils/validation.d.ts +0 -19
- package/dist/internal-common/src/websocket.impl.d.ts +0 -26
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={11:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.selectUniquePaths=t.selectUniquePathPrefixes=t.sortPaths=t.isPathPrefix=t.extractPaths=t.deepCloneOnPath=t.deleteInPath=t.setInPath=t.apply=void 0;const n=r(5036);function i(e,t,r){if(void 0===r)return o(e,t);if(0===t.length)return(0,n.assertTruthy)("object"==typeof r&&null!==r&&!Array.isArray(r),(()=>`Root state must be a record. Trying to set '${r}', type: ${typeof r}`)),r;function i(e){const t=Number(e);return!isNaN(t)&&t>=0&&t!==1/0}let a=e;for(let e=0;e<t.length-1&&void 0!==a;e++){const r=t[e];(0,n.assertTruthy)(!Array.isArray(a)||i(r),(()=>`Invalid array index. Path: '${t.slice(0,e+1)}', index: '${r}'`)),a=a[r],(0,n.assertTruthy)(void 0===a||"object"==typeof a&&null!==a,(()=>`Cannot set a property to a non-record parent. Path: '${t.slice(0,e+1)}', type: '${null===a?"<null>":typeof a}'`))}const u=t[t.length-1];return(0,n.assertTruthy)(!Array.isArray(a)||i(u),(()=>`Invalid array index Path: '${t}`)),(null==a?void 0:a[u])===r?e:s(e,t,r)}function o(e,t){(0,n.assertTruthy)(0!==t.length,"Can't delete an empty path");let r=e;for(let i=0;i<t.length-1;i++){const o=t[i];if(r=r[o],void 0===r)return e;(0,n.assertTruthy)("object"==typeof r&&null!==r,(()=>`Cannot delete a property from a non-record parent. Path: '${t.slice(0,i+1)}', type: ${null===r?"<null>":typeof r}`))}const i=t[t.length-1];return void 0===r[i]?e:s(e,t,void 0)}function s(e,t,r){function i(e,r){(0,n.assertTruthy)(!Array.isArray(e),(()=>`Can't delete element of array. Path: '${t}'`)),delete e[r]}const o=Object.assign({},e);let s=o;for(let e=0;e<t.length-1;e++){const o=t[e],a=s[o];(0,n.assertTruthy)(void 0===a||"object"==typeof a&&null!==a,(()=>`Internal error: sub-path has an invalid type and can't be patched: '${t.slice(0,e+1)}', type: '${null===a?null:typeof a}'`));const u=void 0===a?void 0===r?void 0:{}:Array.isArray(a)?[...a]:Object.assign({},a);if(void 0===u)return i(s,o),s;s[o]=u,s=u}const a=t[t.length-1];return void 0===r?i(s,a):s[a]=r,o}function a(e,t){if(e.length<t.length)return!1;for(let r=0;r<t.length;r++)if(e[r]!==t[r])return!1;return!0}function u(e){const t=[...e];return t.sort(((e,t)=>{for(let r=0;r<e.length;r++){if(r===t.length)return 1;const n=e[r].localeCompare(t[r]);if(0!==n)return n}return e.length-t.length})),t}function c(e){const t=u(e),r=t;for(let e=0;e<t.length-1;e++){const n=t[e];for(let i=e+1;i<t.length;i++){const o=t[i];n.length===o.length&&a(n,o)&&(r[i]=void 0,e++)}}return r.filter((e=>void 0!==e))}t.apply=function e(t,r){switch(r.type){case"set":return i(t,r.path,r.value);case"delete":return o(t,r.path);case"batch":return r.actions.reduce(((t,r)=>e(t,r)),t)}},t.setInPath=i,t.deleteInPath=o,t.deepCloneOnPath=s,t.extractPaths=function e(t,r){const n=[];if("set"===t.type||"delete"===t.type)n.push(t.path);else if("batch"===t.type)for(const r of t.actions)n.push(...e(r,"as-is"));return"unique-and-sorted"===r?c(n):n},t.isPathPrefix=a,t.sortPaths=u,t.selectUniquePathPrefixes=function(e){if(1===e.length)return[...e];if(e.some((e=>0===e.length)))return[[]];const t=u(e),r=t;for(let e=0;e<r.length-1;e++){const n=t[e];for(let i=e+1;i<t.length;i++)a(t[i],n)&&(r[i]=void 0,e++)}return r.filter((e=>void 0!==e))},t.selectUniquePaths=c},20:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.AnonymousSubject=t.Subject=void 0;var o=r(2023),s=r(7491),a=r(8083),u=r(7394),c=r(9916),l=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return n(t,e),t.prototype.lift=function(e){var t=new d(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new a.ObjectUnsubscribedError},t.prototype.next=function(e){var t=this;c.errorContext((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=i(t.currentObservers),s=o.next();!s.done;s=o.next())s.value.next(e)}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;c.errorContext((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;c.errorContext((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?s.EMPTY_SUBSCRIPTION:(this.currentObservers=null,o.push(e),new s.Subscription((function(){t.currentObservers=null,u.arrRemove(o,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,i=t.isStopped;r?e.error(n):i&&e.complete()},t.prototype.asObservable=function(){var e=new o.Observable;return e.source=this,e},t.create=function(e,t){return new d(e,t)},t}(o.Observable);t.Subject=l;var d=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return n(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:s.EMPTY_SUBSCRIPTION},t}(l);t.AnonymousSubject=d},118:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferToggle=void 0;var i=r(7491),o=r(5416),s=r(2296),a=r(1266),u=r(6129),c=r(7394);t.bufferToggle=function(e,t){return o.operate((function(r,o){var l=[];s.innerFrom(e).subscribe(a.createOperatorSubscriber(o,(function(e){var r=[];l.push(r);var n=new i.Subscription;n.add(s.innerFrom(t(e)).subscribe(a.createOperatorSubscriber(o,(function(){c.arrRemove(l,r),o.next(r),n.unsubscribe()}),u.noop)))}),u.noop)),r.subscribe(a.createOperatorSubscriber(o,(function(e){var t,r;try{for(var i=n(l),o=i.next();!o.done;o=i.next())o.value.push(e)}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}),(function(){for(;l.length>0;)o.next(l.shift());o.complete()})))}))}},160:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.argsOrArgArray=void 0;var r=Array.isArray;t.argsOrArgArray=function(e){return 1===e.length&&r(e[0])?e[0]:e}},177:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.raceWith=void 0;var o=r(4143),s=r(5416),a=r(9391);t.raceWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length?s.operate((function(t,r){o.raceInit(i([t],n(e)))(r)})):a.identity}},183:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.distinctUntilKeyChanged=void 0;var n=r(9939);t.distinctUntilKeyChanged=function(e,t){return n.distinctUntilChanged((function(r,n){return t?t(r[e],n[e]):r[e]===n[e]}))}},234:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromisePoolExecutor=void 0;const n=r(5642),i=r(1172),o=r(7837),s=r(6858);t.PromisePoolExecutor=class{constructor(){this.meta={tasks:[],items:[],errors:[],results:[],stopped:!1,concurrency:10,shouldResultsCorrespond:!1,processedItems:[],taskTimeout:0},this.handler=e=>e,this.errorHandler=void 0,this.onTaskStartedHandlers=[],this.onTaskFinishedHandlers=[]}useConcurrency(e){if(!this.isValidConcurrency(e))throw i.ValidationError.createFrom(`"concurrency" must be a number, 1 or up. Received "${e}" (${typeof e})`);return this.meta.concurrency=e,this}isValidConcurrency(e){return"number"==typeof e&&e>=1}withTaskTimeout(e){return this.meta.taskTimeout=e,this}concurrency(){return this.meta.concurrency}useCorrespondingResults(e){return this.meta.shouldResultsCorrespond=e,this}shouldUseCorrespondingResults(){return this.meta.shouldResultsCorrespond}taskTimeout(){return this.meta.taskTimeout}for(e){return this.meta.items=e,this}items(){return this.meta.items}itemsCount(){const e=this.items();return Array.isArray(e)?e.length:NaN}tasks(){return this.meta.tasks}activeTaskCount(){return this.activeTasksCount()}activeTasksCount(){return this.tasks().length}processedItems(){return this.meta.processedItems}processedCount(){return this.processedItems().length}processedPercentage(){return this.processedCount()/this.itemsCount()*100}results(){return this.meta.results}errors(){return this.meta.errors}withHandler(e){return this.handler=e,this}hasErrorHandler(){return!!this.errorHandler}handleError(e){return this.errorHandler=e,this}onTaskStarted(e){return this.onTaskStartedHandlers=e,this}onTaskFinished(e){return this.onTaskFinishedHandlers=e,this}hasReachedConcurrencyLimit(){return this.activeTasksCount()>=this.concurrency()}stop(){throw this.markAsStopped(),new s.StopThePromisePoolError}markAsStopped(){return this.meta.stopped=!0,this}isStopped(){return this.meta.stopped}async start(){return await this.validateInputs().prepareResultsArray().process()}validateInputs(){if("function"!=typeof this.handler)throw i.ValidationError.createFrom("The first parameter for the .process(fn) method must be a function");const e=this.taskTimeout();if(!(null==e||"number"==typeof e&&e>=0))throw i.ValidationError.createFrom(`"timeout" must be undefined or a number. A number must be 0 or up. Received "${String(e)}" (${typeof e})`);if(!this.areItemsValid())throw i.ValidationError.createFrom(`"items" must be an array, an iterable or an async iterable. Received "${typeof this.items()}"`);if(this.errorHandler&&"function"!=typeof this.errorHandler)throw i.ValidationError.createFrom(`The error handler must be a function. Received "${typeof this.errorHandler}"`);return this.onTaskStartedHandlers.forEach((e=>{if(e&&"function"!=typeof e)throw i.ValidationError.createFrom(`The onTaskStarted handler must be a function. Received "${typeof e}"`)})),this.onTaskFinishedHandlers.forEach((e=>{if(e&&"function"!=typeof e)throw i.ValidationError.createFrom(`The error handler must be a function. Received "${typeof e}"`)})),this}areItemsValid(){const e=this.items();return!!Array.isArray(e)||"function"==typeof e[Symbol.iterator]||"function"==typeof e[Symbol.asyncIterator]}prepareResultsArray(){const e=this.items();return Array.isArray(e)&&this.shouldUseCorrespondingResults()?(this.meta.results=Array(e.length).fill(n.PromisePool.notRun),this):this}async process(){let e=0;for await(const t of this.items()){if(this.isStopped())break;this.shouldUseCorrespondingResults()&&(this.results()[e]=n.PromisePool.notRun),this.startProcessing(t,e),e+=1,await this.waitForProcessingSlot()}return await this.drained()}async waitForProcessingSlot(){for(;this.hasReachedConcurrencyLimit();)await this.waitForActiveTaskToFinish()}async waitForActiveTaskToFinish(){await Promise.race(this.tasks())}startProcessing(e,t){const r=this.createTaskFor(e,t).then((e=>{this.save(e,t).removeActive(r)})).catch((async n=>{await this.handleErrorFor(n,e,t),this.removeActive(r)})).finally((()=>{this.processedItems().push(e),this.runOnTaskFinishedHandlers(e)}));this.tasks().push(r),this.runOnTaskStartedHandlers(e)}async createTaskFor(e,t){if(void 0===this.taskTimeout())return this.handler(e,t,this);const[r,n]=this.createTaskTimeout(e);return Promise.race([this.handler(e,t,this),r()]).finally(n)}createTaskTimeout(e){let t;return[async()=>new Promise(((r,n)=>{t=setTimeout((()=>{n(new o.PromisePoolError(`Task in promise pool timed out after ${this.taskTimeout()}ms`,e))}),this.taskTimeout())})),()=>clearTimeout(t)]}save(e,t){return this.shouldUseCorrespondingResults()?this.results()[t]=e:this.results().push(e),this}removeActive(e){return this.tasks().splice(this.tasks().indexOf(e),1),this}async handleErrorFor(e,t,r){if(this.shouldUseCorrespondingResults()&&(this.results()[r]=n.PromisePool.failed),!this.isStoppingThePoolError(e)){if(this.isValidationError(e))throw this.markAsStopped(),e;this.hasErrorHandler()?await this.runErrorHandlerFor(e,t):this.saveErrorFor(e,t)}}isStoppingThePoolError(e){return e instanceof s.StopThePromisePoolError}isValidationError(e){return e instanceof i.ValidationError}async runErrorHandlerFor(e,t){try{await(this.errorHandler?.(e,t,this))}catch(e){this.rethrowIfNotStoppingThePool(e)}}runOnTaskStartedHandlers(e){this.onTaskStartedHandlers.forEach((t=>{t(e,this)}))}runOnTaskFinishedHandlers(e){this.onTaskFinishedHandlers.forEach((t=>{t(e,this)}))}rethrowIfNotStoppingThePool(e){if(!this.isStoppingThePoolError(e))throw e}saveErrorFor(e,t){this.errors().push(o.PromisePoolError.createFrom(e,t))}async drained(){return await this.drainActiveTasks(),{errors:this.errors(),results:this.results()}}async drainActiveTasks(){await Promise.all(this.tasks())}}},264:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryWhen=void 0;var n=r(2296),i=r(20),o=r(5416),s=r(1266);t.retryWhen=function(e){return o.operate((function(t,r){var o,a,u=!1,c=function(){o=t.subscribe(s.createOperatorSubscriber(r,void 0,void 0,(function(t){a||(a=new i.Subject,n.innerFrom(e(a)).subscribe(s.createOperatorSubscriber(r,(function(){return o?c():u=!0})))),a&&a.next(t)}))),u&&(o.unsubscribe(),o=null,u=!1,c())};c()}))}},297:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.publish=void 0;var n=r(20),i=r(9924),o=r(2216);t.publish=function(e){return e?function(t){return o.connect(e)(t)}:function(e){return i.multicast(new n.Subject)(e)}}},452:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPromise=void 0;var n=r(4717);t.isPromise=function(e){return n.isFunction(null==e?void 0:e.then)}},469:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Scheduler=void 0;var n=r(4575),i=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=n.dateTimestampProvider.now,e}();t.Scheduler=i},573:e=>{e.exports=require("rxjs")},587:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.joinAllInternals=void 0;var n=r(9391),i=r(8240),o=r(2393),s=r(1282),a=r(2984);t.joinAllInternals=function(e,t){return o.pipe(a.toArray(),s.mergeMap((function(t){return e(t)})),t?i.mapOneOrManyArgs(t):n.identity)}},665:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnsubscriptionError=void 0;var n=r(6871);t.UnsubscriptionError=n.createErrorClass((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}))},787:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.takeLast=void 0;var i=r(7209),o=r(5416),s=r(1266);t.takeLast=function(e){return e<=0?function(){return i.EMPTY}:o.operate((function(t,r){var i=[];t.subscribe(s.createOperatorSubscriber(r,(function(t){i.push(t),e<i.length&&i.shift()}),(function(){var e,t;try{for(var o=n(i),s=o.next();!s.done;s=o.next()){var a=s.value;r.next(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}r.complete()}),void 0,(function(){i=null})))}))}},795:(e,t)=>{function r(e,t,r){return{kind:e,value:t,error:r}}Object.defineProperty(t,"__esModule",{value:!0}),t.createNotification=t.nextNotification=t.errorNotification=t.COMPLETE_NOTIFICATION=void 0,t.COMPLETE_NOTIFICATION=r("C",void 0,void 0),t.errorNotification=function(e){return r("E",void 0,e)},t.nextNotification=function(e){return r("N",e,void 0)},t.createNotification=r},861:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatAll=void 0;var n=r(1867);t.concatAll=function(){return n.mergeAll(1)}},884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.single=void 0;var n=r(7676),i=r(8168),o=r(2318),s=r(5416),a=r(1266);t.single=function(e){return s.operate((function(t,r){var s,u=!1,c=!1,l=0;t.subscribe(a.createOperatorSubscriber(r,(function(n){c=!0,e&&!e(n,l++,t)||(u&&r.error(new i.SequenceError("Too many matching values")),u=!0,s=n)}),(function(){u?(r.next(s),r.complete()):r.error(c?new o.NotFoundError("No matching values"):new n.EmptyError)})))}))}},973:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.zipWith=void 0;var o=r(2681);t.zipWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.zip.apply(void 0,i([],n(e)))}},994:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatestInit=t.combineLatest=void 0;var n=r(2023),i=r(3787),o=r(5294),s=r(9391),a=r(8240),u=r(1824),c=r(4950),l=r(1266),d=r(5031);function h(e,t,r){return void 0===r&&(r=s.identity),function(n){f(t,(function(){for(var i=e.length,s=new Array(i),a=i,u=i,c=function(i){f(t,(function(){var c=o.from(e[i],t),d=!1;c.subscribe(l.createOperatorSubscriber(n,(function(e){s[i]=e,d||(d=!0,u--),u||n.next(r(s.slice()))}),(function(){--a||n.complete()})))}),n)},d=0;d<i;d++)c(d)}),n)}}function f(e,t,r){e?d.executeSchedule(r,e,t):t()}t.combineLatest=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=u.popScheduler(e),l=u.popResultSelector(e),d=i.argsArgArrayOrObject(e),f=d.args,p=d.keys;if(0===f.length)return o.from([],r);var y=new n.Observable(h(f,r,p?function(e){return c.createObject(p,e)}:s.identity));return l?y.pipe(a.mapOneOrManyArgs(l)):y},t.combineLatestInit=h},1012:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatMap=void 0;var n=r(1282),i=r(4717);t.concatMap=function(e,t){return i.isFunction(t)?n.mergeMap(e,t,1):n.mergeMap(e,1)}},1017:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncScheduler=void 0;var i=r(469),o=function(e){function t(t,r){void 0===r&&(r=i.Scheduler.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return n(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}(i.Scheduler);t.AsyncScheduler=o},1080:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncAction=void 0;var i=r(7638),o=r(2320),s=r(7394),a=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return n(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),o.intervalProvider.setInterval(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&o.intervalProvider.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,s.arrRemove(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(i.Action);t.AsyncAction=a},1157:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatMapTo=void 0;var n=r(1012),i=r(4717);t.concatMapTo=function(e,t){return i.isFunction(t)?n.concatMap((function(){return e}),t):n.concatMap((function(){return e}))}},1172:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ValidationError=void 0;class r extends Error{constructor(e){super(e),Error.captureStackTrace&&"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static createFrom(e){return new this(e)}}t.ValidationError=r},1195:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.elementAt=void 0;var n=r(9148),i=r(2914),o=r(5956),s=r(7507),a=r(6803);t.elementAt=function(e,t){if(e<0)throw new n.ArgumentOutOfRangeError;var r=arguments.length>=2;return function(u){return u.pipe(i.filter((function(t,r){return r===e})),a.take(1),r?s.defaultIfEmpty(t):o.throwIfEmpty((function(){return new n.ArgumentOutOfRangeError})))}}},1222:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.BehaviorSubject=void 0;var i=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return n(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){var e=this,t=e.hasError,r=e.thrownError,n=e._value;if(t)throw r;return this._throwIfClosed(),n},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(r(20).Subject);t.BehaviorSubject=i},1266:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.OperatorSubscriber=t.createOperatorSubscriber=void 0;var i=r(4512);t.createOperatorSubscriber=function(e,t,r,n,i){return new o(e,t,r,n,i)};var o=function(e){function t(t,r,n,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return n(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(i.Subscriber);t.OperatorSubscriber=o},1276:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.not=void 0,t.not=function(e,t){return function(r,n){return!e.call(t,r,n)}}},1282:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeMap=void 0;var n=r(4828),i=r(2296),o=r(5416),s=r(3754),a=r(4717);t.mergeMap=function e(t,r,u){return void 0===u&&(u=1/0),a.isFunction(r)?e((function(e,o){return n.map((function(t,n){return r(e,t,o,n)}))(i.innerFrom(t(e,o)))}),u):("number"==typeof r&&(u=r),o.operate((function(e,r){return s.mergeInternals(e,r,t,u)})))}},1306:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.min=void 0;var n=r(3818),i=r(4717);t.min=function(e){return n.reduce(i.isFunction(e)?function(t,r){return e(t,r)<0?t:r}:function(e,t){return e<t?e:t})}},1333:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.assertDate=t.assertEmail=t.assertHexString=t.assertUuid=t.assertBoolean=t.assertNumber=t.assertString=void 0,t.formatError=s,t.assertNonNullable=function(e,t){(0,n.assertTruthy)((0,i.isNonNullable)(e),(()=>s(t,"Value is "+(void 0===e?"undefined":"null"),e)))};const n=r(6373),i=r(4665),o=r(6663);function s(e,t,r){const i=(0,n.getAssertionErrorFromProvider)(e);if("object"==typeof i)throw i;return`${i?`${i}: `:""}${t} ${(0,o.formatValue)(r)}`}t.assertString=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isString)(e),(()=>s(t,"Not a string",e)))},t.assertNumber=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isNumber)(e),(()=>s(t,"Not a number",e)))},t.assertBoolean=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isBoolean)(e),(()=>s(t,"Not a boolean",e)))},t.assertUuid=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isUuid)(e),(()=>s(t,"Invalid uuid",e)))},t.assertHexString=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isHexString)(e),(()=>s(t,"Invalid hex string",e)))},t.assertEmail=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isEmail)(e),(()=>s(t,"Invalid email",e)))},t.assertDate=(e,t=void 0)=>{(0,n.assertTruthy)(e instanceof Date,(()=>s(t,"Invalid Date",e)))}},1357:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mapTo=void 0;var n=r(4828);t.mapTo=function(e){return n.map((function(){return e}))}},1424:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.combineAll=void 0;var n=r(2945);t.combineAll=n.combineLatestAll},1432:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.first=void 0;var n=r(7676),i=r(2914),o=r(6803),s=r(7507),a=r(5956),u=r(9391);t.first=function(e,t){var r=arguments.length>=2;return function(c){return c.pipe(e?i.filter((function(t,r){return e(t,r,c)})):u.identity,o.take(1),r?s.defaultIfEmpty(t):a.throwIfEmpty((function(){return new n.EmptyError})))}}},1507:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectableObservable=void 0;var i=r(2023),o=r(7491),s=r(5884),a=r(1266),u=r(5416),c=function(e){function t(t,r){var n=e.call(this)||this;return n.source=t,n.subjectFactory=r,n._subject=null,n._refCount=0,n._connection=null,u.hasLift(t)&&(n.lift=t.lift),n}return n(t,e),t.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},t.prototype.getSubject=function(){var e=this._subject;return e&&!e.isStopped||(this._subject=this.subjectFactory()),this._subject},t.prototype._teardown=function(){this._refCount=0;var e=this._connection;this._subject=this._connection=null,null==e||e.unsubscribe()},t.prototype.connect=function(){var e=this,t=this._connection;if(!t){t=this._connection=new o.Subscription;var r=this.getSubject();t.add(this.source.subscribe(a.createOperatorSubscriber(r,void 0,(function(){e._teardown(),r.complete()}),(function(t){e._teardown(),r.error(t)}),(function(){return e._teardown()})))),t.closed&&(this._connection=null,t=o.Subscription.EMPTY)}return t},t.prototype.refCount=function(){return s.refCount()(this)},t}(i.Observable);t.ConnectableObservable=c},1550:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;var o=r(5416),s=r(160),a=r(1867),u=r(1824),c=r(5294);t.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=u.popScheduler(e),l=u.popNumber(e,1/0);return e=s.argsOrArgArray(e),o.operate((function(t,o){a.mergeAll(l)(c.from(i([t],n(e)),r)).subscribe(o)}))}},1689:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.switchScan=void 0;var n=r(6300),i=r(5416);t.switchScan=function(e,t){return i.operate((function(r,i){var o=t;return n.switchMap((function(t,r){return e(o,t,r)}),(function(e,t){return o=t,t}))(r).subscribe(i),function(){o=null}}))}},1738:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shareReplay=void 0;var n=r(5129),i=r(3329);t.shareReplay=function(e,t,r){var o,s,a,u,c=!1;return e&&"object"==typeof e?(o=e.bufferSize,u=void 0===o?1/0:o,s=e.windowTime,t=void 0===s?1/0:s,c=void 0!==(a=e.refCount)&&a,r=e.scheduler):u=null!=e?e:1/0,i.share({connector:function(){return new n.ReplaySubject(u,t,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}},1763:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.zip=void 0;var o=r(2023),s=r(2296),a=r(160),u=r(7209),c=r(1266),l=r(1824);t.zip=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l.popResultSelector(e),d=a.argsOrArgArray(e);return d.length?new o.Observable((function(e){var t=d.map((function(){return[]})),o=d.map((function(){return!1}));e.add((function(){t=o=null}));for(var a=function(a){s.innerFrom(d[a]).subscribe(c.createOperatorSubscriber(e,(function(s){if(t[a].push(s),t.every((function(e){return e.length}))){var u=t.map((function(e){return e.shift()}));e.next(r?r.apply(void 0,i([],n(u))):u),t.some((function(e,t){return!e.length&&o[t]}))&&e.complete()}}),(function(){o[a]=!0,!t[a].length&&e.complete()})))},u=0;!e.closed&&u<d.length;u++)a(u);return function(){t=o=null}})):u.EMPTY}},1801:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInteropObservable=void 0;var n=r(2131),i=r(4717);t.isInteropObservable=function(e){return i.isFunction(e[n.observable])}},1812:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.concat=void 0;var o=r(5416),s=r(861),a=r(1824),u=r(5294);t.concat=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=a.popScheduler(e);return o.operate((function(t,o){s.concatAll()(u.from(i([t],n(e)),r)).subscribe(o)}))}},1824:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popNumber=t.popScheduler=t.popResultSelector=void 0;var n=r(4717),i=r(4568);function o(e){return e[e.length-1]}t.popResultSelector=function(e){return n.isFunction(o(e))?e.pop():void 0},t.popScheduler=function(e){return i.isScheduler(o(e))?e.pop():void 0},t.popNumber=function(e,t){return"number"==typeof o(e)?e.pop():t}},1867:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAll=void 0;var n=r(1282),i=r(9391);t.mergeAll=function(e){return void 0===e&&(e=1/0),n.mergeMap(i.identity,e)}},1909:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.every=void 0;var n=r(5416),i=r(1266);t.every=function(e,t){return n.operate((function(r,n){var o=0;r.subscribe(i.createOperatorSubscriber(n,(function(i){e.call(t,i,o++,r)||(n.next(!1),n.complete())}),(function(){n.next(!0),n.complete()})))}))}},1933:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.switchMapTo=void 0;var n=r(6300),i=r(4717);t.switchMapTo=function(e,t){return i.isFunction(t)?n.switchMap((function(){return e}),t):n.switchMap((function(){return e}))}},1997:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.onErrorResumeNext=t.onErrorResumeNextWith=void 0;var o=r(160),s=r(6467);function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=o.argsOrArgArray(e);return function(e){return s.onErrorResumeNext.apply(void 0,i([e],n(r)))}}t.onErrorResumeNextWith=a,t.onErrorResumeNext=a},2e3:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatest=void 0;var o=r(994),s=r(5416),a=r(160),u=r(8240),c=r(2393),l=r(1824);t.combineLatest=function e(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var d=l.popResultSelector(t);return d?c.pipe(e.apply(void 0,i([],n(t))),u.mapOneOrManyArgs(d)):s.operate((function(e,r){o.combineLatestInit(i([e],n(a.argsOrArgArray(t))))(r)}))}},2001:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timeoutWith=void 0;var n=r(4386),i=r(6349),o=r(7517);t.timeoutWith=function(e,t,r){var s,a,u;if(r=null!=r?r:n.async,i.isValidDate(e)?s=e:"number"==typeof e&&(a=e),!t)throw new TypeError("No observable provided to switch to");if(u=function(){return t},null==s&&null==a)throw new TypeError("No timeout provided.");return o.timeout({first:s,each:a,scheduler:r,with:u})}},2023:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Observable=void 0;var n=r(4512),i=r(7491),o=r(2131),s=r(2393),a=r(7820),u=r(4717),c=r(9916),l=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var o,s=this,a=(o=e)&&o instanceof n.Subscriber||function(e){return e&&u.isFunction(e.next)&&u.isFunction(e.error)&&u.isFunction(e.complete)}(o)&&i.isSubscription(o)?e:new n.SafeSubscriber(e,t,r);return c.errorContext((function(){var e=s,t=e.operator,r=e.source;a.add(t?t.call(a,r):r?s._subscribe(a):s._trySubscribe(a))})),a},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=d(t))((function(t,i){var o=new n.SafeSubscriber({next:function(t){try{e(t)}catch(e){i(e),o.unsubscribe()}},error:i,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[o.observable]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.pipeFromArray(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=d(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function d(e){var t;return null!==(t=null!=e?e:a.config.Promise)&&void 0!==t?t:Promise}t.Observable=l},2070:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concat=void 0;var n=r(861),i=r(1824),o=r(5294);t.concat=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.concatAll()(o.from(e,i.popScheduler(e)))}},2131:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.observable=void 0,t.observable="function"==typeof Symbol&&Symbol.observable||"@@observable"},2216:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.connect=void 0;var n=r(20),i=r(2296),o=r(5416),s=r(3123),a={connector:function(){return new n.Subject}};t.connect=function(e,t){void 0===t&&(t=a);var r=t.connector;return o.operate((function(t,n){var o=r();i.innerFrom(e(s.fromSubscribable(o))).subscribe(n),n.add(t.subscribe(o))}))}},2296:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},o=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof s?s(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.fromReadableStreamLike=t.fromAsyncIterable=t.fromIterable=t.fromPromise=t.fromArrayLike=t.fromInteropObservable=t.innerFrom=void 0;var a=r(5547),u=r(452),c=r(2023),l=r(1801),d=r(9451),h=r(3533),f=r(6847),p=r(3026),y=r(4717),b=r(4696),v=r(2131);function g(e){return new c.Observable((function(t){var r=e[v.observable]();if(y.isFunction(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}))}function m(e){return new c.Observable((function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()}))}function _(e){return new c.Observable((function(t){e.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,b.reportUnhandledError)}))}function S(e){return new c.Observable((function(t){var r,n;try{for(var i=s(e),o=i.next();!o.done;o=i.next()){var a=o.value;if(t.next(a),t.closed)return}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}t.complete()}))}function O(e){return new c.Observable((function(t){(function(e,t){var r,s,a,u;return n(this,void 0,void 0,(function(){var n,c;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,5,6,11]),r=o(e),i.label=1;case 1:return[4,r.next()];case 2:if((s=i.sent()).done)return[3,4];if(n=s.value,t.next(n),t.closed)return[2];i.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=i.sent(),a={error:c},[3,11];case 6:return i.trys.push([6,,9,10]),s&&!s.done&&(u=r.return)?[4,u.call(r)]:[3,8];case 7:i.sent(),i.label=8;case 8:return[3,10];case 9:if(a)throw a.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function w(e){return O(p.readableStreamLikeToAsyncGenerator(e))}t.innerFrom=function(e){if(e instanceof c.Observable)return e;if(null!=e){if(l.isInteropObservable(e))return g(e);if(a.isArrayLike(e))return m(e);if(u.isPromise(e))return _(e);if(d.isAsyncIterable(e))return O(e);if(f.isIterable(e))return S(e);if(p.isReadableStreamLike(e))return w(e)}throw h.createInvalidObservableTypeError(e)},t.fromInteropObservable=g,t.fromArrayLike=m,t.fromPromise=_,t.fromIterable=S,t.fromAsyncIterable=O,t.fromReadableStreamLike=w},2318:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NotFoundError=void 0;var n=r(6871);t.NotFoundError=n.createErrorClass((function(e){return function(t){e(this),this.name="NotFoundError",this.message=t}}))},2320:function(e,t){var r=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},n=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.intervalProvider=void 0,t.intervalProvider={setInterval:function(e,i){for(var o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];var a=t.intervalProvider.delegate;return(null==a?void 0:a.setInterval)?a.setInterval.apply(a,n([e,i],r(o))):setInterval.apply(void 0,n([e,i],r(o)))},clearInterval:function(e){var r=t.intervalProvider.delegate;return((null==r?void 0:r.clearInterval)||clearInterval)(e)},delegate:void 0}},2366:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.schedulePromise=void 0;var n=r(2296),i=r(2803),o=r(4027);t.schedulePromise=function(e,t){return n.innerFrom(e).pipe(o.subscribeOn(t),i.observeOn(t))}},2393:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pipeFromArray=t.pipe=void 0;var n=r(9391);function i(e){return 0===e.length?n.identity:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}t.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i(e)},t.pipeFromArray=i},2409:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.delay=void 0;var n=r(4386),i=r(5137),o=r(5461);t.delay=function(e,t){void 0===t&&(t=n.asyncScheduler);var r=o.timer(e,t);return i.delayWhen((function(){return r}))}},2426:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},2457:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scan=void 0;var n=r(5416),i=r(7071);t.scan=function(e,t){return n.operate(i.scanInternals(e,t,arguments.length>=2,!0))}},2507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ignoreElements=void 0;var n=r(5416),i=r(1266),o=r(6129);t.ignoreElements=function(){return n.operate((function(e,t){e.subscribe(i.createOperatorSubscriber(t,o.noop))}))}},2681:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.zip=void 0;var o=r(1763),s=r(5416);t.zip=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.operate((function(t,r){o.zip.apply(void 0,i([t],n(e))).subscribe(r)}))}},2747:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;var n=r(5416),i=r(6129),o=r(1266),s=r(2296);t.debounce=function(e){return n.operate((function(t,r){var n=!1,a=null,u=null,c=function(){if(null==u||u.unsubscribe(),u=null,n){n=!1;var e=a;a=null,r.next(e)}};t.subscribe(o.createOperatorSubscriber(r,(function(t){null==u||u.unsubscribe(),n=!0,a=t,u=o.createOperatorSubscriber(r,c,i.noop),s.innerFrom(e(t)).subscribe(u)}),(function(){c(),r.complete()}),void 0,(function(){a=u=null})))}))}},2778:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.startWith=void 0;var n=r(2070),i=r(1824),o=r(5416);t.startWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=i.popScheduler(e);return o.operate((function(t,i){(r?n.concat(e,t,r):n.concat(e,t)).subscribe(i)}))}},2803:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.observeOn=void 0;var n=r(5031),i=r(5416),o=r(1266);t.observeOn=function(e,t){return void 0===t&&(t=0),i.operate((function(r,i){r.subscribe(o.createOperatorSubscriber(i,(function(r){return n.executeSchedule(i,e,(function(){return i.next(r)}),t)}),(function(){return n.executeSchedule(i,e,(function(){return i.complete()}),t)}),(function(r){return n.executeSchedule(i,e,(function(){return i.error(r)}),t)})))}))}},2819:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createFind=t.find=void 0;var n=r(5416),i=r(1266);function o(e,t,r){var n="index"===r;return function(r,o){var s=0;r.subscribe(i.createOperatorSubscriber(o,(function(i){var a=s++;e.call(t,i,a,r)&&(o.next(n?a:i),o.complete())}),(function(){o.next(n?-1:void 0),o.complete()})))}}t.find=function(e,t){return n.operate(o(e,t,"value"))},t.createFind=o},2914:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filter=void 0;var n=r(5416),i=r(1266);t.filter=function(e,t){return n.operate((function(r,n){var o=0;r.subscribe(i.createOperatorSubscriber(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}},2945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatestAll=void 0;var n=r(994),i=r(587);t.combineLatestAll=function(e){return i.joinAllInternals(n.combineLatest,e)}},2947:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.skipUntil=void 0;var n=r(5416),i=r(1266),o=r(2296),s=r(6129);t.skipUntil=function(e){return n.operate((function(t,r){var n=!1,a=i.createOperatorSubscriber(r,(function(){null==a||a.unsubscribe(),n=!0}),s.noop);o.innerFrom(e).subscribe(a),t.subscribe(i.createOperatorSubscriber(r,(function(e){return n&&r.next(e)})))}))}},2984:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toArray=void 0;var n=r(3818),i=r(5416),o=function(e,t){return e.push(t),e};t.toArray=function(){return i.operate((function(e,t){n.reduce(o,[])(e).subscribe(t)}))}},3016:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.windowWhen=void 0;var n=r(20),i=r(5416),o=r(1266),s=r(2296);t.windowWhen=function(e){return i.operate((function(t,r){var i,a,u=function(e){i.error(e),r.error(e)},c=function(){var t;null==a||a.unsubscribe(),null==i||i.complete(),i=new n.Subject,r.next(i.asObservable());try{t=s.innerFrom(e())}catch(e){return void u(e)}t.subscribe(a=o.createOperatorSubscriber(r,c,c,u))};c(),t.subscribe(o.createOperatorSubscriber(r,(function(e){return i.next(e)}),(function(){i.complete(),r.complete()}),u,(function(){null==a||a.unsubscribe(),i=null})))}))}},3026:function(e,t,r){var n=this&&this.__generator||function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},i=this&&this.__await||function(e){return this instanceof i?(this.v=e,this):new i(e)},o=this&&this.__asyncGenerator||function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||u(e,t)}))})}function u(e,t){try{(r=o[e](t)).value instanceof i?Promise.resolve(r.value.v).then(c,l):d(s[0][2],r)}catch(e){d(s[0][3],e)}var r}function c(e){u("next",e)}function l(e){u("throw",e)}function d(e,t){e(t),s.shift(),s.length&&u(s[0][0],s[0][1])}};Object.defineProperty(t,"__esModule",{value:!0}),t.isReadableStreamLike=t.readableStreamLikeToAsyncGenerator=void 0;var s=r(4717);t.readableStreamLikeToAsyncGenerator=function(e){return o(this,arguments,(function(){var t,r,o;return n(this,(function(n){switch(n.label){case 0:t=e.getReader(),n.label=1;case 1:n.trys.push([1,,9,10]),n.label=2;case 2:return[4,i(t.read())];case 3:return r=n.sent(),o=r.value,r.done?[4,i(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,i(o)];case 6:return[4,n.sent()];case 7:return n.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))},t.isReadableStreamLike=function(e){return s.isFunction(null==e?void 0:e.getReader)}},3123:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fromSubscribable=void 0;var n=r(2023);t.fromSubscribable=function(e){return new n.Observable((function(t){return e.subscribe(t)}))}},3329:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.share=void 0;var o=r(2296),s=r(20),a=r(4512),u=r(5416);function c(e,t){for(var r=[],s=2;s<arguments.length;s++)r[s-2]=arguments[s];if(!0!==t){if(!1!==t){var u=new a.SafeSubscriber({next:function(){u.unsubscribe(),e()}});return o.innerFrom(t.apply(void 0,i([],n(r)))).subscribe(u)}}else e()}t.share=function(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new s.Subject}:t,n=e.resetOnError,i=void 0===n||n,l=e.resetOnComplete,d=void 0===l||l,h=e.resetOnRefCountZero,f=void 0===h||h;return function(e){var t,n,s,l=0,h=!1,p=!1,y=function(){null==n||n.unsubscribe(),n=void 0},b=function(){y(),t=s=void 0,h=p=!1},v=function(){var e=t;b(),null==e||e.unsubscribe()};return u.operate((function(e,u){l++,p||h||y();var g=s=null!=s?s:r();u.add((function(){0!=--l||p||h||(n=c(v,f))})),g.subscribe(u),!t&&l>0&&(t=new a.SafeSubscriber({next:function(e){return g.next(e)},error:function(e){p=!0,y(),n=c(b,i,e),g.error(e)},complete:function(){h=!0,y(),n=c(b,d),g.complete()}}),o.innerFrom(e).subscribe(t))}))(e)}}},3367:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndex=void 0;var n=r(5416),i=r(2819);t.findIndex=function(e,t){return n.operate(i.createFind(e,t,"index"))}},3391:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pluck=void 0;var n=r(4828);t.pluck=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length;if(0===r)throw new Error("list of properties cannot be empty.");return n.map((function(t){for(var n=t,i=0;i<r;i++){var o=null==n?void 0:n[e[i]];if(void 0===o)return;n=o}return n}))}},3484:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.last=void 0;var n=r(7676),i=r(2914),o=r(787),s=r(5956),a=r(7507),u=r(9391);t.last=function(e,t){var r=arguments.length>=2;return function(c){return c.pipe(e?i.filter((function(t,r){return e(t,r,c)})):u.identity,o.takeLast(1),r?a.defaultIfEmpty(t):s.throwIfEmpty((function(){return new n.EmptyError})))}}},3533:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createInvalidObservableTypeError=void 0,t.createInvalidObservableTypeError=function(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}},3585:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleIterable=void 0;var n=r(2023),i=r(3967),o=r(4717),s=r(5031);t.scheduleIterable=function(e,t){return new n.Observable((function(r){var n;return s.executeSchedule(r,t,(function(){n=e[i.iterator](),s.executeSchedule(r,t,(function(){var e,t,i;try{t=(e=n.next()).value,i=e.done}catch(e){return void r.error(e)}i?r.complete():r.next(t)}),0,!0)})),function(){return o.isFunction(null==n?void 0:n.return)&&n.return()}}))}},3692:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.concatWith=void 0;var o=r(1812);t.concatWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.concat.apply(void 0,i([],n(e)))}},3704:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromError=function(e,t){return e instanceof Error?e.message:null!=t?t:`${e}`}},3723:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.endWith=void 0;var o=r(2070),s=r(8743);t.endWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return o.concat(t,s.of.apply(void 0,i([],n(e))))}}},3741:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleAsyncIterable=void 0;var n=r(2023),i=r(5031);t.scheduleAsyncIterable=function(e,t){if(!e)throw new Error("Iterable cannot be null");return new n.Observable((function(r){i.executeSchedule(r,t,(function(){var n=e[Symbol.asyncIterator]();i.executeSchedule(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}},3754:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeInternals=void 0;var n=r(2296),i=r(5031),o=r(1266);t.mergeInternals=function(e,t,r,s,a,u,c,l){var d=[],h=0,f=0,p=!1,y=function(){!p||d.length||h||t.complete()},b=function(e){return h<s?v(e):d.push(e)},v=function(e){u&&t.next(e),h++;var l=!1;n.innerFrom(r(e,f++)).subscribe(o.createOperatorSubscriber(t,(function(e){null==a||a(e),u?b(e):t.next(e)}),(function(){l=!0}),void 0,(function(){if(l)try{h--;for(var e=function(){var e=d.shift();c?i.executeSchedule(t,c,(function(){return v(e)})):v(e)};d.length&&h<s;)e();y()}catch(e){t.error(e)}})))};return e.subscribe(o.createOperatorSubscriber(t,b,(function(){p=!0,y()}))),function(){null==l||l()}}},3787:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.argsArgArrayOrObject=void 0;var r=Array.isArray,n=Object.getPrototypeOf,i=Object.prototype,o=Object.keys;t.argsArgArrayOrObject=function(e){if(1===e.length){var t=e[0];if(r(t))return{args:t,keys:null};if((a=t)&&"object"==typeof a&&n(a)===i){var s=o(t);return{args:s.map((function(e){return t[e]})),keys:s}}}var a;return{args:e,keys:null}}},3818:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reduce=void 0;var n=r(7071),i=r(5416);t.reduce=function(e,t){return i.operate(n.scanInternals(e,t,arguments.length>=2,!1,!0))}},3870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debounceTime=void 0;var n=r(4386),i=r(5416),o=r(1266);t.debounceTime=function(e,t){return void 0===t&&(t=n.asyncScheduler),i.operate((function(r,n){var i=null,s=null,a=null,u=function(){if(i){i.unsubscribe(),i=null;var e=s;s=null,n.next(e)}};function c(){var r=a+e,o=t.now();if(o<r)return i=this.schedule(void 0,r-o),void n.add(i);u()}r.subscribe(o.createOperatorSubscriber(n,(function(r){s=r,a=t.now(),i||(i=t.schedule(c,e),n.add(i))}),(function(){u(),n.complete()}),void 0,(function(){s=i=null})))}))}},3928:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatestWith=void 0;var o=r(2e3);t.combineLatestWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.combineLatest.apply(void 0,i([],n(e)))}},3967:(e,t)=>{function r(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}Object.defineProperty(t,"__esModule",{value:!0}),t.iterator=t.getSymbolIterator=void 0,t.getSymbolIterator=r,t.iterator=r()},4027:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.subscribeOn=void 0;var n=r(5416);t.subscribeOn=function(e,t){return void 0===t&&(t=0),n.operate((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}},4077:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(6373),t),i(r(8596),t),i(r(1333),t),i(r(4665),t),i(r(6663),t),i(r(8630),t),i(r(3704),t)},4116:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.auditTime=void 0;var n=r(4386),i=r(6993),o=r(5461);t.auditTime=function(e,t){return void 0===t&&(t=n.asyncScheduler),i.audit((function(){return o.timer(e,t)}))}},4123:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(7243),t)},4126:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dematerialize=void 0;var n=r(6145),i=r(5416),o=r(1266);t.dematerialize=function(){return i.operate((function(e,t){e.subscribe(o.createOperatorSubscriber(t,(function(e){return n.observeNotification(e,t)})))}))}},4143:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.raceInit=t.race=void 0;var n=r(2023),i=r(2296),o=r(160),s=r(1266);function a(e){return function(t){for(var r=[],n=function(n){r.push(i.innerFrom(e[n]).subscribe(s.createOperatorSubscriber(t,(function(e){if(r){for(var i=0;i<r.length;i++)i!==n&&r[i].unsubscribe();r=null}t.next(e)}))))},o=0;r&&!t.closed&&o<e.length;o++)n(o)}}t.race=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===(e=o.argsOrArgArray(e)).length?i.innerFrom(e[0]):new n.Observable(a(e))},t.raceInit=a},4386:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.async=t.asyncScheduler=void 0;var n=r(1080),i=r(1017);t.asyncScheduler=new i.AsyncScheduler(n.AsyncAction),t.async=t.asyncScheduler},4388:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.max=void 0;var n=r(3818),i=r(4717);t.max=function(e){return n.reduce(i.isFunction(e)?function(t,r){return e(t,r)>0?t:r}:function(e,t){return e>t?e:t})}},4411:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.skip=void 0;var n=r(2914);t.skip=function(e){return n.filter((function(t,r){return e<=r}))}},4463:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduled=void 0;var n=r(4502),i=r(2366),o=r(8762),s=r(3585),a=r(3741),u=r(1801),c=r(452),l=r(5547),d=r(6847),h=r(9451),f=r(3533),p=r(3026),y=r(9136);t.scheduled=function(e,t){if(null!=e){if(u.isInteropObservable(e))return n.scheduleObservable(e,t);if(l.isArrayLike(e))return o.scheduleArray(e,t);if(c.isPromise(e))return i.schedulePromise(e,t);if(h.isAsyncIterable(e))return a.scheduleAsyncIterable(e,t);if(d.isIterable(e))return s.scheduleIterable(e,t);if(p.isReadableStreamLike(e))return y.scheduleReadableStreamLike(e,t)}throw f.createInvalidObservableTypeError(e)}},4492:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pairwise=void 0;var n=r(5416),i=r(1266);t.pairwise=function(){return n.operate((function(e,t){var r,n=!1;e.subscribe(i.createOperatorSubscriber(t,(function(e){var i=r;r=e,n&&t.next([i,e]),n=!0})))}))}},4502:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleObservable=void 0;var n=r(2296),i=r(2803),o=r(4027);t.scheduleObservable=function(e,t){return n.innerFrom(e).pipe(o.subscribeOn(t),i.observeOn(t))}},4512:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.EMPTY_OBSERVER=t.SafeSubscriber=t.Subscriber=void 0;var i=r(4717),o=r(7491),s=r(7820),a=r(4696),u=r(6129),c=r(795),l=r(6476),d=r(9916),h=function(e){function r(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,o.isSubscription(r)&&r.add(n)):n.destination=t.EMPTY_OBSERVER,n}return n(r,e),r.create=function(e,t,r){return new b(e,t,r)},r.prototype.next=function(e){this.isStopped?g(c.nextNotification(e),this):this._next(e)},r.prototype.error=function(e){this.isStopped?g(c.errorNotification(e),this):(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped?g(c.COMPLETE_NOTIFICATION,this):(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(o.Subscription);t.Subscriber=h;var f=Function.prototype.bind;function p(e,t){return f.call(e,t)}var y=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){v(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){v(e)}else v(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){v(e)}},e}(),b=function(e){function t(t,r,n){var o,a,u=e.call(this)||this;return i.isFunction(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:u&&s.config.useDeprecatedNextContext?((a=Object.create(t)).unsubscribe=function(){return u.unsubscribe()},o={next:t.next&&p(t.next,a),error:t.error&&p(t.error,a),complete:t.complete&&p(t.complete,a)}):o=t,u.destination=new y(o),u}return n(t,e),t}(h);function v(e){s.config.useDeprecatedSynchronousErrorHandling?d.captureError(e):a.reportUnhandledError(e)}function g(e,t){var r=s.config.onStoppedNotification;r&&l.timeoutProvider.setTimeout((function(){return r(e,t)}))}t.SafeSubscriber=b,t.EMPTY_OBSERVER={closed:!0,next:u.noop,error:function(e){throw e},complete:u.noop}},4568:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isScheduler=void 0;var n=r(4717);t.isScheduler=function(e){return e&&n.isFunction(e.schedule)}},4575:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateTimestampProvider=void 0,t.dateTimestampProvider={now:function(){return(t.dateTimestampProvider.delegate||Date).now()},delegate:void 0}},4665:(e,t)=>{function r(e){return"string"==typeof e}function n(e,t,r){if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.isBoolean=function(e){return"boolean"==typeof e},t.isString=r,t.isNumber=function(e){return"number"==typeof e},t.isDate=function(e){return e instanceof Date},t.checkArrayHasUniqueElements=function(e,t){if(e.length<=1)return!0;const r=new Set;for(const n of e){const e=t(n);if(r.has(e))return!1;r.add(e)}return!0},t.checkArraysHaveEqualElements=function(e,t){return n(e,t,((e,t)=>e===t))},t.checkArraysHasEqualElementsByComparator=n,t.isEmail=function(e,t={allowInternationalDomains:!1}){if(!r(e)||0===e.length||e.length>254)return!1;if(!(t.allowInternationalDomains?o:i).test(e))return!1;const n=e.split("@");return!(n[0].length>64)&&!n[1].split(".").some((e=>e.length>63))},t.isUuid=function(e){return r(e)&&s.test(e)},t.isHexString=function(e){return r(e)&&a.test(e)},t.isNonNullable=function(e){return null!=e};const i=/^[-!#$%&'*+/\d=?A-Z^_a-z{|}~](\.?[-!#$%&'*+/\d=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z\d])*\.[a-zA-Z](-?[a-zA-Z\d])+$/,o=/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF.!#$%&'*+-/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF\-.\d]+)((\.([a-zA-Z\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF]){2,63})+)$/i,s=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,a=/^[0-9a-fA-F]*$/},4696:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reportUnhandledError=void 0;var n=r(7820),i=r(6476);t.reportUnhandledError=function(e){i.timeoutProvider.setTimeout((function(){var t=n.config.onUnhandledError;if(!t)throw e;t(e)}))}},4717:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},4740:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retry=void 0;var n=r(5416),i=r(1266),o=r(9391),s=r(5461),a=r(2296);t.retry=function(e){var t;void 0===e&&(e=1/0);var r=(t=e&&"object"==typeof e?e:{count:e}).count,u=void 0===r?1/0:r,c=t.delay,l=t.resetOnSuccess,d=void 0!==l&&l;return u<=0?o.identity:n.operate((function(e,t){var r,n=0,o=function(){var l=!1;r=e.subscribe(i.createOperatorSubscriber(t,(function(e){d&&(n=0),t.next(e)}),void 0,(function(e){if(n++<u){var d=function(){r?(r.unsubscribe(),r=null,o()):l=!0};if(null!=c){var h="number"==typeof c?s.timer(c):a.innerFrom(c(e,n)),f=i.createOperatorSubscriber(t,(function(){f.unsubscribe(),d()}),(function(){t.complete()}));h.subscribe(f)}else d()}else t.error(e)}))),l&&(r.unsubscribe(),r=null,o())};o()}))}},4811:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.takeUntil=void 0;var n=r(5416),i=r(1266),o=r(2296),s=r(6129);t.takeUntil=function(e){return n.operate((function(t,r){o.innerFrom(e).subscribe(i.createOperatorSubscriber(r,(function(){return r.complete()}),s.noop)),!r.closed&&t.subscribe(r)}))}},4828:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;var n=r(5416),i=r(1266);t.map=function(e,t){return n.operate((function(r,n){var o=0;r.subscribe(i.createOperatorSubscriber(n,(function(r){n.next(e.call(t,r,o++))})))}))}},4880:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.windowToggle=void 0;var i=r(20),o=r(7491),s=r(5416),a=r(2296),u=r(1266),c=r(6129),l=r(7394);t.windowToggle=function(e,t){return s.operate((function(r,s){var d=[],h=function(e){for(;0<d.length;)d.shift().error(e);s.error(e)};a.innerFrom(e).subscribe(u.createOperatorSubscriber(s,(function(e){var r=new i.Subject;d.push(r);var n,f=new o.Subscription;try{n=a.innerFrom(t(e))}catch(e){return void h(e)}s.next(r.asObservable()),f.add(n.subscribe(u.createOperatorSubscriber(s,(function(){l.arrRemove(d,r),r.complete(),f.unsubscribe()}),c.noop,h)))}),c.noop)),r.subscribe(u.createOperatorSubscriber(s,(function(e){var t,r,i=d.slice();try{for(var o=n(i),s=o.next();!s.done;s=o.next())s.value.next(e)}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}}),(function(){for(;0<d.length;)d.shift().complete();s.complete()}),h,(function(){for(;0<d.length;)d.shift().unsubscribe()})))}))}},4908:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(7129),t)},4950:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createObject=void 0,t.createObject=function(e,t){return e.reduce((function(e,r,n){return e[r]=t[n],e}),{})}},4956:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupBy=void 0;var n=r(2023),i=r(2296),o=r(20),s=r(5416),a=r(1266);t.groupBy=function(e,t,r,u){return s.operate((function(s,c){var l;t&&"function"!=typeof t?(r=t.duration,l=t.element,u=t.connector):l=t;var d=new Map,h=function(e){d.forEach(e),e(c)},f=function(e){return h((function(t){return t.error(e)}))},p=0,y=!1,b=new a.OperatorSubscriber(c,(function(t){try{var s=e(t),h=d.get(s);if(!h){d.set(s,h=u?u():new o.Subject);var v=(m=s,_=h,(S=new n.Observable((function(e){p++;var t=_.subscribe(e);return function(){t.unsubscribe(),0==--p&&y&&b.unsubscribe()}}))).key=m,S);if(c.next(v),r){var g=a.createOperatorSubscriber(h,(function(){h.complete(),null==g||g.unsubscribe()}),void 0,void 0,(function(){return d.delete(s)}));b.add(i.innerFrom(r(v)).subscribe(g))}}h.next(l?l(t):t)}catch(e){f(e)}var m,_,S}),(function(){return h((function(e){return e.complete()}))}),f,(function(){return d.clear()}),(function(){return y=!0,0===p}));s.subscribe(b)}))}},5031:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.executeSchedule=void 0,t.executeSchedule=function(e,t,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var o=t.schedule((function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(o),!i)return o}},5036:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(4077),t)},5086:e=>{e.exports=require("ws")},5109:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sequenceEqual=void 0;var n=r(5416),i=r(1266),o=r(2296);t.sequenceEqual=function(e,t){return void 0===t&&(t=function(e,t){return e===t}),n.operate((function(r,n){var s={buffer:[],complete:!1},a={buffer:[],complete:!1},u=function(e){n.next(e),n.complete()},c=function(e,r){var o=i.createOperatorSubscriber(n,(function(n){var i=r.buffer,o=r.complete;0===i.length?o?u(!1):e.buffer.push(n):!t(n,i.shift())&&u(!1)}),(function(){e.complete=!0;var t=r.complete,n=r.buffer;t&&u(0===n.length),null==o||o.unsubscribe()}));return o};r.subscribe(c(s,a)),o.innerFrom(e).subscribe(c(a,s))}))}},5129:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.ReplaySubject=void 0;var i=r(20),o=r(4575),s=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=o.dateTimestampProvider);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,r),i}return n(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,i=r._buffer,o=r._infiniteTimeWindow,s=r._timestampProvider,a=r._windowTime;n||(i.push(t),!o&&i.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!e.closed;i+=r?1:2)e.next(n[i]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,i=e._infiniteTimeWindow,o=(i?1:2)*t;if(t<1/0&&o<n.length&&n.splice(0,n.length-o),!i){for(var s=r.now(),a=0,u=1;u<n.length&&n[u]<=s;u+=2)a=u;a&&n.splice(0,a+1)}},t}(i.Subject);t.ReplaySubject=s},5137:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.delayWhen=void 0;var n=r(2070),i=r(6803),o=r(2507),s=r(1357),a=r(1282),u=r(2296);t.delayWhen=function e(t,r){return r?function(s){return n.concat(r.pipe(i.take(1),o.ignoreElements()),s.pipe(e(t)))}:a.mergeMap((function(e,r){return u.innerFrom(t(e,r)).pipe(i.take(1),s.mapTo(e))}))}},5150:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0});const o=r(5642);t.default=o.PromisePool,i(r(9273),t),i(r(5642),t),i(r(7837),t),i(r(2426),t),i(r(6858),t),i(r(1172),t)},5208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.distinct=void 0;var n=r(5416),i=r(1266),o=r(6129),s=r(2296);t.distinct=function(e,t){return n.operate((function(r,n){var a=new Set;r.subscribe(i.createOperatorSubscriber(n,(function(t){var r=e?e(t):t;a.has(r)||(a.add(r),n.next(t))}))),t&&s.innerFrom(t).subscribe(i.createOperatorSubscriber(n,(function(){return a.clear()}),o.noop))}))}},5219:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferTime=void 0;var i=r(7491),o=r(5416),s=r(1266),a=r(7394),u=r(4386),c=r(1824),l=r(5031);t.bufferTime=function(e){for(var t,r,d=[],h=1;h<arguments.length;h++)d[h-1]=arguments[h];var f=null!==(t=c.popScheduler(d))&&void 0!==t?t:u.asyncScheduler,p=null!==(r=d[0])&&void 0!==r?r:null,y=d[1]||1/0;return o.operate((function(t,r){var o=[],u=!1,c=function(e){var t=e.buffer;e.subs.unsubscribe(),a.arrRemove(o,e),r.next(t),u&&d()},d=function(){if(o){var t=new i.Subscription;r.add(t);var n={buffer:[],subs:t};o.push(n),l.executeSchedule(t,f,(function(){return c(n)}),e)}};null!==p&&p>=0?l.executeSchedule(r,f,d,p,!0):u=!0,d();var h=s.createOperatorSubscriber(r,(function(e){var t,r,i=o.slice();try{for(var s=n(i),a=s.next();!a.done;a=s.next()){var u=a.value,l=u.buffer;l.push(e),y<=l.length&&c(u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}),(function(){for(;null==o?void 0:o.length;)r.next(o.shift().buffer);null==h||h.unsubscribe(),r.complete(),r.unsubscribe()}),void 0,(function(){return o=null}));t.subscribe(h)}))}},5294:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.from=void 0;var n=r(4463),i=r(2296);t.from=function(e,t){return t?n.scheduled(e,t):i.innerFrom(e)}},5352:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.partition=void 0;var n=r(1276),i=r(2914);t.partition=function(e,t){return function(r){return[i.filter(e,t)(r),i.filter(n.not(e,t))(r)]}}},5366:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncSubject=void 0;var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._value=null,t._hasValue=!1,t._isComplete=!1,t}return n(t,e),t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t._hasValue,i=t._value,o=t.thrownError,s=t.isStopped,a=t._isComplete;r?e.error(o):(s||a)&&(n&&e.next(i),e.complete())},t.prototype.next=function(e){this.isStopped||(this._value=e,this._hasValue=!0)},t.prototype.complete=function(){var t=this,r=t._hasValue,n=t._value;t._isComplete||(this._isComplete=!0,r&&e.prototype.next.call(this,n),e.prototype.complete.call(this))},t}(r(20).Subject);t.AsyncSubject=i},5411:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sampleTime=void 0;var n=r(4386),i=r(6870),o=r(8767);t.sampleTime=function(e,t){return void 0===t&&(t=n.asyncScheduler),i.sample(o.interval(e,t))}},5416:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.operate=t.hasLift=void 0;var n=r(4717);function i(e){return n.isFunction(null==e?void 0:e.lift)}t.hasLift=i,t.operate=function(e){return function(t){if(i(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}},5461:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timer=void 0;var n=r(2023),i=r(4386),o=r(4568),s=r(6349);t.timer=function(e,t,r){void 0===e&&(e=0),void 0===r&&(r=i.async);var a=-1;return null!=t&&(o.isScheduler(t)?r=t:a=t),new n.Observable((function(t){var n=s.isValidDate(e)?+e-r.now():e;n<0&&(n=0);var i=0;return r.schedule((function(){t.closed||(t.next(i++),0<=a?this.schedule(void 0,a):t.complete())}),n)}))}},5492:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.window=void 0;var n=r(20),i=r(5416),o=r(1266),s=r(6129),a=r(2296);t.window=function(e){return i.operate((function(t,r){var i=new n.Subject;r.next(i.asObservable());var u=function(e){i.error(e),r.error(e)};return t.subscribe(o.createOperatorSubscriber(r,(function(e){return null==i?void 0:i.next(e)}),(function(){i.complete(),r.complete()}),u)),a.innerFrom(e).subscribe(o.createOperatorSubscriber(r,(function(){i.complete(),r.next(i=new n.Subject)}),s.noop,u)),function(){null==i||i.unsubscribe(),i=null}}))}},5547:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isArrayLike=void 0,t.isArrayLike=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}},5567:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.repeatWhen=void 0;var n=r(2296),i=r(20),o=r(5416),s=r(1266);t.repeatWhen=function(e){return o.operate((function(t,r){var o,a,u=!1,c=!1,l=!1,d=function(){return l&&c&&(r.complete(),!0)},h=function(){l=!1,o=t.subscribe(s.createOperatorSubscriber(r,void 0,(function(){l=!0,!d()&&(a||(a=new i.Subject,n.innerFrom(e(a)).subscribe(s.createOperatorSubscriber(r,(function(){o?h():u=!0}),(function(){c=!0,d()})))),a).next()}))),u&&(o.unsubscribe(),o=null,u=!1,h())};h()}))}},5606:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.zipAll=void 0;var n=r(1763),i=r(587);t.zipAll=function(e){return i.joinAllInternals(n.zip,e)}},5642:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromisePool=void 0;const n=r(234);class i{constructor(e){this.timeout=void 0,this.concurrency=10,this.items=e??[],this.errorHandler=void 0,this.onTaskStartedHandlers=[],this.onTaskFinishedHandlers=[],this.shouldResultsCorrespond=!1}withConcurrency(e){return this.concurrency=e,this}static withConcurrency(e){return(new this).withConcurrency(e)}withTaskTimeout(e){return this.timeout=e,this}static withTaskTimeout(e){return(new this).withTaskTimeout(e)}for(e){const t=new i(e).withConcurrency(this.concurrency);return"function"==typeof this.errorHandler&&t.handleError(this.errorHandler),"number"==typeof this.timeout?t.withTaskTimeout(this.timeout):t}static for(e){return(new this).for(e)}handleError(e){return this.errorHandler=e,this}onTaskStarted(e){return this.onTaskStartedHandlers.push(e),this}onTaskFinished(e){return this.onTaskFinishedHandlers.push(e),this}useCorrespondingResults(){return this.shouldResultsCorrespond=!0,this}async process(e){return(new n.PromisePoolExecutor).useConcurrency(this.concurrency).useCorrespondingResults(this.shouldResultsCorrespond).withTaskTimeout(this.timeout).withHandler(e).handleError(this.errorHandler).onTaskStarted(this.onTaskStartedHandlers).onTaskFinished(this.onTaskFinishedHandlers).for(this.items).start()}}t.PromisePool=i,i.notRun=Symbol("notRun"),i.failed=Symbol("failed")},5834:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.mergeWith=void 0;var o=r(1550);t.mergeWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.merge.apply(void 0,i([],n(e)))}},5884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.refCount=void 0;var n=r(5416),i=r(1266);t.refCount=function(){return n.operate((function(e,t){var r=null;e._refCount++;var n=i.createOperatorSubscriber(t,void 0,void 0,void 0,(function(){if(!e||e._refCount<=0||0<--e._refCount)r=null;else{var n=e._connection,i=r;r=null,!n||i&&n!==i||n.unsubscribe(),t.unsubscribe()}}));e.subscribe(n),n.closed||(r=e.connect())}))}},5945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.throttleTime=void 0;var n=r(4386),i=r(6516),o=r(5461);t.throttleTime=function(e,t,r){void 0===t&&(t=n.asyncScheduler);var s=o.timer(e,t);return i.throttle((function(){return s}),r)}},5956:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.throwIfEmpty=void 0;var n=r(7676),i=r(5416),o=r(1266);function s(){return new n.EmptyError}t.throwIfEmpty=function(e){return void 0===e&&(e=s),i.operate((function(t,r){var n=!1;t.subscribe(o.createOperatorSubscriber(r,(function(e){n=!0,r.next(e)}),(function(){return n?r.complete():r.error(e())})))}))}},6022:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAll=t.merge=t.max=t.materialize=t.mapTo=t.map=t.last=t.isEmpty=t.ignoreElements=t.groupBy=t.first=t.findIndex=t.find=t.finalize=t.filter=t.expand=t.exhaustMap=t.exhaustAll=t.exhaust=t.every=t.endWith=t.elementAt=t.distinctUntilKeyChanged=t.distinctUntilChanged=t.distinct=t.dematerialize=t.delayWhen=t.delay=t.defaultIfEmpty=t.debounceTime=t.debounce=t.count=t.connect=t.concatWith=t.concatMapTo=t.concatMap=t.concatAll=t.concat=t.combineLatestWith=t.combineLatest=t.combineLatestAll=t.combineAll=t.catchError=t.bufferWhen=t.bufferToggle=t.bufferTime=t.bufferCount=t.buffer=t.auditTime=t.audit=void 0,t.timeInterval=t.throwIfEmpty=t.throttleTime=t.throttle=t.tap=t.takeWhile=t.takeUntil=t.takeLast=t.take=t.switchScan=t.switchMapTo=t.switchMap=t.switchAll=t.subscribeOn=t.startWith=t.skipWhile=t.skipUntil=t.skipLast=t.skip=t.single=t.shareReplay=t.share=t.sequenceEqual=t.scan=t.sampleTime=t.sample=t.refCount=t.retryWhen=t.retry=t.repeatWhen=t.repeat=t.reduce=t.raceWith=t.race=t.publishReplay=t.publishLast=t.publishBehavior=t.publish=t.pluck=t.partition=t.pairwise=t.onErrorResumeNext=t.observeOn=t.multicast=t.min=t.mergeWith=t.mergeScan=t.mergeMapTo=t.mergeMap=t.flatMap=void 0,t.zipWith=t.zipAll=t.zip=t.withLatestFrom=t.windowWhen=t.windowToggle=t.windowTime=t.windowCount=t.window=t.toArray=t.timestamp=t.timeoutWith=t.timeout=void 0;var n=r(6993);Object.defineProperty(t,"audit",{enumerable:!0,get:function(){return n.audit}});var i=r(4116);Object.defineProperty(t,"auditTime",{enumerable:!0,get:function(){return i.auditTime}});var o=r(7190);Object.defineProperty(t,"buffer",{enumerable:!0,get:function(){return o.buffer}});var s=r(6835);Object.defineProperty(t,"bufferCount",{enumerable:!0,get:function(){return s.bufferCount}});var a=r(5219);Object.defineProperty(t,"bufferTime",{enumerable:!0,get:function(){return a.bufferTime}});var u=r(118);Object.defineProperty(t,"bufferToggle",{enumerable:!0,get:function(){return u.bufferToggle}});var c=r(7514);Object.defineProperty(t,"bufferWhen",{enumerable:!0,get:function(){return c.bufferWhen}});var l=r(8251);Object.defineProperty(t,"catchError",{enumerable:!0,get:function(){return l.catchError}});var d=r(1424);Object.defineProperty(t,"combineAll",{enumerable:!0,get:function(){return d.combineAll}});var h=r(2945);Object.defineProperty(t,"combineLatestAll",{enumerable:!0,get:function(){return h.combineLatestAll}});var f=r(2e3);Object.defineProperty(t,"combineLatest",{enumerable:!0,get:function(){return f.combineLatest}});var p=r(3928);Object.defineProperty(t,"combineLatestWith",{enumerable:!0,get:function(){return p.combineLatestWith}});var y=r(1812);Object.defineProperty(t,"concat",{enumerable:!0,get:function(){return y.concat}});var b=r(861);Object.defineProperty(t,"concatAll",{enumerable:!0,get:function(){return b.concatAll}});var v=r(1012);Object.defineProperty(t,"concatMap",{enumerable:!0,get:function(){return v.concatMap}});var g=r(1157);Object.defineProperty(t,"concatMapTo",{enumerable:!0,get:function(){return g.concatMapTo}});var m=r(3692);Object.defineProperty(t,"concatWith",{enumerable:!0,get:function(){return m.concatWith}});var _=r(2216);Object.defineProperty(t,"connect",{enumerable:!0,get:function(){return _.connect}});var S=r(8041);Object.defineProperty(t,"count",{enumerable:!0,get:function(){return S.count}});var O=r(2747);Object.defineProperty(t,"debounce",{enumerable:!0,get:function(){return O.debounce}});var w=r(3870);Object.defineProperty(t,"debounceTime",{enumerable:!0,get:function(){return w.debounceTime}});var I=r(7507);Object.defineProperty(t,"defaultIfEmpty",{enumerable:!0,get:function(){return I.defaultIfEmpty}});var M=r(2409);Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return M.delay}});var E=r(5137);Object.defineProperty(t,"delayWhen",{enumerable:!0,get:function(){return E.delayWhen}});var A=r(4126);Object.defineProperty(t,"dematerialize",{enumerable:!0,get:function(){return A.dematerialize}});var T=r(5208);Object.defineProperty(t,"distinct",{enumerable:!0,get:function(){return T.distinct}});var F=r(9939);Object.defineProperty(t,"distinctUntilChanged",{enumerable:!0,get:function(){return F.distinctUntilChanged}});var j=r(183);Object.defineProperty(t,"distinctUntilKeyChanged",{enumerable:!0,get:function(){return j.distinctUntilKeyChanged}});var P=r(1195);Object.defineProperty(t,"elementAt",{enumerable:!0,get:function(){return P.elementAt}});var D=r(3723);Object.defineProperty(t,"endWith",{enumerable:!0,get:function(){return D.endWith}});var k=r(1909);Object.defineProperty(t,"every",{enumerable:!0,get:function(){return k.every}});var C=r(9228);Object.defineProperty(t,"exhaust",{enumerable:!0,get:function(){return C.exhaust}});var x=r(9765);Object.defineProperty(t,"exhaustAll",{enumerable:!0,get:function(){return x.exhaustAll}});var R=r(8748);Object.defineProperty(t,"exhaustMap",{enumerable:!0,get:function(){return R.exhaustMap}});var N=r(8324);Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return N.expand}});var q=r(2914);Object.defineProperty(t,"filter",{enumerable:!0,get:function(){return q.filter}});var L=r(9822);Object.defineProperty(t,"finalize",{enumerable:!0,get:function(){return L.finalize}});var B=r(2819);Object.defineProperty(t,"find",{enumerable:!0,get:function(){return B.find}});var U=r(3367);Object.defineProperty(t,"findIndex",{enumerable:!0,get:function(){return U.findIndex}});var Q=r(1432);Object.defineProperty(t,"first",{enumerable:!0,get:function(){return Q.first}});var $=r(4956);Object.defineProperty(t,"groupBy",{enumerable:!0,get:function(){return $.groupBy}});var V=r(2507);Object.defineProperty(t,"ignoreElements",{enumerable:!0,get:function(){return V.ignoreElements}});var Y=r(6095);Object.defineProperty(t,"isEmpty",{enumerable:!0,get:function(){return Y.isEmpty}});var W=r(3484);Object.defineProperty(t,"last",{enumerable:!0,get:function(){return W.last}});var H=r(4828);Object.defineProperty(t,"map",{enumerable:!0,get:function(){return H.map}});var z=r(1357);Object.defineProperty(t,"mapTo",{enumerable:!0,get:function(){return z.mapTo}});var G=r(7967);Object.defineProperty(t,"materialize",{enumerable:!0,get:function(){return G.materialize}});var J=r(4388);Object.defineProperty(t,"max",{enumerable:!0,get:function(){return J.max}});var K=r(1550);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return K.merge}});var Z=r(1867);Object.defineProperty(t,"mergeAll",{enumerable:!0,get:function(){return Z.mergeAll}});var X=r(6977);Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return X.flatMap}});var ee=r(1282);Object.defineProperty(t,"mergeMap",{enumerable:!0,get:function(){return ee.mergeMap}});var te=r(6295);Object.defineProperty(t,"mergeMapTo",{enumerable:!0,get:function(){return te.mergeMapTo}});var re=r(9527);Object.defineProperty(t,"mergeScan",{enumerable:!0,get:function(){return re.mergeScan}});var ne=r(5834);Object.defineProperty(t,"mergeWith",{enumerable:!0,get:function(){return ne.mergeWith}});var ie=r(1306);Object.defineProperty(t,"min",{enumerable:!0,get:function(){return ie.min}});var oe=r(9924);Object.defineProperty(t,"multicast",{enumerable:!0,get:function(){return oe.multicast}});var se=r(2803);Object.defineProperty(t,"observeOn",{enumerable:!0,get:function(){return se.observeOn}});var ae=r(1997);Object.defineProperty(t,"onErrorResumeNext",{enumerable:!0,get:function(){return ae.onErrorResumeNext}});var ue=r(4492);Object.defineProperty(t,"pairwise",{enumerable:!0,get:function(){return ue.pairwise}});var ce=r(5352);Object.defineProperty(t,"partition",{enumerable:!0,get:function(){return ce.partition}});var le=r(3391);Object.defineProperty(t,"pluck",{enumerable:!0,get:function(){return le.pluck}});var de=r(297);Object.defineProperty(t,"publish",{enumerable:!0,get:function(){return de.publish}});var he=r(6383);Object.defineProperty(t,"publishBehavior",{enumerable:!0,get:function(){return he.publishBehavior}});var fe=r(8229);Object.defineProperty(t,"publishLast",{enumerable:!0,get:function(){return fe.publishLast}});var pe=r(8226);Object.defineProperty(t,"publishReplay",{enumerable:!0,get:function(){return pe.publishReplay}});var ye=r(8973);Object.defineProperty(t,"race",{enumerable:!0,get:function(){return ye.race}});var be=r(177);Object.defineProperty(t,"raceWith",{enumerable:!0,get:function(){return be.raceWith}});var ve=r(3818);Object.defineProperty(t,"reduce",{enumerable:!0,get:function(){return ve.reduce}});var ge=r(7775);Object.defineProperty(t,"repeat",{enumerable:!0,get:function(){return ge.repeat}});var me=r(5567);Object.defineProperty(t,"repeatWhen",{enumerable:!0,get:function(){return me.repeatWhen}});var _e=r(4740);Object.defineProperty(t,"retry",{enumerable:!0,get:function(){return _e.retry}});var Se=r(264);Object.defineProperty(t,"retryWhen",{enumerable:!0,get:function(){return Se.retryWhen}});var Oe=r(5884);Object.defineProperty(t,"refCount",{enumerable:!0,get:function(){return Oe.refCount}});var we=r(6870);Object.defineProperty(t,"sample",{enumerable:!0,get:function(){return we.sample}});var Ie=r(5411);Object.defineProperty(t,"sampleTime",{enumerable:!0,get:function(){return Ie.sampleTime}});var Me=r(2457);Object.defineProperty(t,"scan",{enumerable:!0,get:function(){return Me.scan}});var Ee=r(5109);Object.defineProperty(t,"sequenceEqual",{enumerable:!0,get:function(){return Ee.sequenceEqual}});var Ae=r(3329);Object.defineProperty(t,"share",{enumerable:!0,get:function(){return Ae.share}});var Te=r(1738);Object.defineProperty(t,"shareReplay",{enumerable:!0,get:function(){return Te.shareReplay}});var Fe=r(884);Object.defineProperty(t,"single",{enumerable:!0,get:function(){return Fe.single}});var je=r(4411);Object.defineProperty(t,"skip",{enumerable:!0,get:function(){return je.skip}});var Pe=r(9355);Object.defineProperty(t,"skipLast",{enumerable:!0,get:function(){return Pe.skipLast}});var De=r(2947);Object.defineProperty(t,"skipUntil",{enumerable:!0,get:function(){return De.skipUntil}});var ke=r(9842);Object.defineProperty(t,"skipWhile",{enumerable:!0,get:function(){return ke.skipWhile}});var Ce=r(2778);Object.defineProperty(t,"startWith",{enumerable:!0,get:function(){return Ce.startWith}});var xe=r(4027);Object.defineProperty(t,"subscribeOn",{enumerable:!0,get:function(){return xe.subscribeOn}});var Re=r(9061);Object.defineProperty(t,"switchAll",{enumerable:!0,get:function(){return Re.switchAll}});var Ne=r(6300);Object.defineProperty(t,"switchMap",{enumerable:!0,get:function(){return Ne.switchMap}});var qe=r(1933);Object.defineProperty(t,"switchMapTo",{enumerable:!0,get:function(){return qe.switchMapTo}});var Le=r(1689);Object.defineProperty(t,"switchScan",{enumerable:!0,get:function(){return Le.switchScan}});var Be=r(6803);Object.defineProperty(t,"take",{enumerable:!0,get:function(){return Be.take}});var Ue=r(787);Object.defineProperty(t,"takeLast",{enumerable:!0,get:function(){return Ue.takeLast}});var Qe=r(4811);Object.defineProperty(t,"takeUntil",{enumerable:!0,get:function(){return Qe.takeUntil}});var $e=r(7770);Object.defineProperty(t,"takeWhile",{enumerable:!0,get:function(){return $e.takeWhile}});var Ve=r(9967);Object.defineProperty(t,"tap",{enumerable:!0,get:function(){return Ve.tap}});var Ye=r(6516);Object.defineProperty(t,"throttle",{enumerable:!0,get:function(){return Ye.throttle}});var We=r(5945);Object.defineProperty(t,"throttleTime",{enumerable:!0,get:function(){return We.throttleTime}});var He=r(5956);Object.defineProperty(t,"throwIfEmpty",{enumerable:!0,get:function(){return He.throwIfEmpty}});var ze=r(9712);Object.defineProperty(t,"timeInterval",{enumerable:!0,get:function(){return ze.timeInterval}});var Ge=r(7517);Object.defineProperty(t,"timeout",{enumerable:!0,get:function(){return Ge.timeout}});var Je=r(2001);Object.defineProperty(t,"timeoutWith",{enumerable:!0,get:function(){return Je.timeoutWith}});var Ke=r(8158);Object.defineProperty(t,"timestamp",{enumerable:!0,get:function(){return Ke.timestamp}});var Ze=r(2984);Object.defineProperty(t,"toArray",{enumerable:!0,get:function(){return Ze.toArray}});var Xe=r(5492);Object.defineProperty(t,"window",{enumerable:!0,get:function(){return Xe.window}});var et=r(6817);Object.defineProperty(t,"windowCount",{enumerable:!0,get:function(){return et.windowCount}});var tt=r(6841);Object.defineProperty(t,"windowTime",{enumerable:!0,get:function(){return tt.windowTime}});var rt=r(4880);Object.defineProperty(t,"windowToggle",{enumerable:!0,get:function(){return rt.windowToggle}});var nt=r(3016);Object.defineProperty(t,"windowWhen",{enumerable:!0,get:function(){return nt.windowWhen}});var it=r(9163);Object.defineProperty(t,"withLatestFrom",{enumerable:!0,get:function(){return it.withLatestFrom}});var ot=r(2681);Object.defineProperty(t,"zip",{enumerable:!0,get:function(){return ot.zip}});var st=r(5606);Object.defineProperty(t,"zipAll",{enumerable:!0,get:function(){return st.zipAll}});var at=r(973);Object.defineProperty(t,"zipWith",{enumerable:!0,get:function(){return at.zipWith}})},6095:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isEmpty=void 0;var n=r(5416),i=r(1266);t.isEmpty=function(){return n.operate((function(e,t){e.subscribe(i.createOperatorSubscriber(t,(function(){t.next(!1),t.complete()}),(function(){t.next(!0),t.complete()})))}))}},6129:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.noop=void 0,t.noop=function(){}},6145:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.observeNotification=t.Notification=t.NotificationKind=void 0;var n,i=r(7209),o=r(8743),s=r(6612),a=r(4717);(n=t.NotificationKind||(t.NotificationKind={})).NEXT="N",n.ERROR="E",n.COMPLETE="C";var u=function(){function e(e,t,r){this.kind=e,this.value=t,this.error=r,this.hasValue="N"===e}return e.prototype.observe=function(e){return c(this,e)},e.prototype.do=function(e,t,r){var n=this,i=n.kind,o=n.value,s=n.error;return"N"===i?null==e?void 0:e(o):"E"===i?null==t?void 0:t(s):null==r?void 0:r()},e.prototype.accept=function(e,t,r){var n;return a.isFunction(null===(n=e)||void 0===n?void 0:n.next)?this.observe(e):this.do(e,t,r)},e.prototype.toObservable=function(){var e=this,t=e.kind,r=e.value,n=e.error,a="N"===t?o.of(r):"E"===t?s.throwError((function(){return n})):"C"===t?i.EMPTY:0;if(!a)throw new TypeError("Unexpected notification kind "+t);return a},e.createNext=function(t){return new e("N",t)},e.createError=function(t){return new e("E",void 0,t)},e.createComplete=function(){return e.completeNotification},e.completeNotification=new e("C"),e}();function c(e,t){var r,n,i,o=e,s=o.kind,a=o.value,u=o.error;if("string"!=typeof s)throw new TypeError('Invalid notification, missing "kind"');"N"===s?null===(r=t.next)||void 0===r||r.call(t,a):"E"===s?null===(n=t.error)||void 0===n||n.call(t,u):null===(i=t.complete)||void 0===i||i.call(t)}t.Notification=u,t.observeNotification=c},6295:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeMapTo=void 0;var n=r(1282),i=r(4717);t.mergeMapTo=function(e,t,r){return void 0===r&&(r=1/0),i.isFunction(t)?n.mergeMap((function(){return e}),t,r):("number"==typeof t&&(r=t),n.mergeMap((function(){return e}),r))}},6300:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.switchMap=void 0;var n=r(2296),i=r(5416),o=r(1266);t.switchMap=function(e,t){return i.operate((function(r,i){var s=null,a=0,u=!1,c=function(){return u&&!s&&i.complete()};r.subscribe(o.createOperatorSubscriber(i,(function(r){null==s||s.unsubscribe();var u=0,l=a++;n.innerFrom(e(r,l)).subscribe(s=o.createOperatorSubscriber(i,(function(e){return i.next(t?t(r,e,l,u++):e)}),(function(){s=null,c()})))}),(function(){u=!0,c()})))}))}},6349:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isValidDate=void 0,t.isValidDate=function(e){return e instanceof Date&&!isNaN(e)}},6373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDefaultAssertionErrorFactory=function(e){s=e||o},t.assertTruthy=a,t.truthy=function(e,t,...r){return a(e,t,...r),e},t.fail=u,t.getAssertionErrorFromProvider=c,t.getErrorMessage=l,t.assertObject=d,t.assertArray=function(e,t,r={},i=void 0){var o,s;const u=f(i);a(Array.isArray(e),(()=>`${u()}value is not an array: ${e}`));const c=null!==(o=r.minLength)&&void 0!==o?o:0,l=null!==(s=r.maxLength)&&void 0!==s?s:1/0;a(e.length>=c,(()=>`${u()}array length < minLength. Array length: ${e.length}, minLength: ${c}`)),a(e.length<=l,(()=>`${u()}array length > maxLength. Array length: ${e.length}, maxLength: ${l}`)),r.uniqueByIdentity&&a((0,n.checkArrayHasUniqueElements)(e,r.uniqueByIdentity),(()=>`${u()}array contains non-unique elements`));let d=0;const h=()=>`${u("no-space-separator")}[${d}]`;for(;d<e.length;d++)p(e[d],t,h)},t.assertRecord=function(e,t,r={},n=void 0){const o=f(n);a("object"==typeof e,(()=>`${o()}value is not an object: ${(0,i.formatValue)(e)}`)),a(null!==e,(()=>`${o()}value is null`)),a(!Array.isArray(e),(()=>`${o()}the value is not a record, but is an array`));for(const[n,s]of Object.entries(e)){const e=()=>`${o("no-space-separator")}['${n}']`;r.keyAssertion&&p(n,r.keyAssertion,(()=>`${e()}, key assertion failed:`)),p(s,t,e);const{keyField:u}=r;if(u){a("object"==typeof s&&null!==s,(()=>`${e()} is not an object: ${(0,i.formatValue)(s)}`));const t=s[u];a(t===n,(()=>`${e()} key value does not match object field '${u}' value: ${(0,i.formatValue)(t)}`))}}r.$o&&r.$o(e,n)},t.callValueAssertion=h;const n=r(4665),i=r(6663),o=e=>new Error(e);let s=o;function a(e,t,...r){e||u(t,...r)}function u(e,...t){const r=c(e);if("object"==typeof r)throw r;throw s(r||"Assertion error",...t)}function c(e){return void 0===e?"":"string"==typeof e?e:e()}function l(e){const t=c(e);return"string"==typeof t?t:t.message||"<no error message>"}function d(e,t,r=void 0,n={}){const i=()=>l(r),o=e=>{const t=i();return 0===t.length?e:`${t} ${e}`};a("object"==typeof e,(()=>o("is not an object: "+typeof e))),a(void 0!==e,(()=>o("is not defined"))),a(null!==e,(()=>o("is null"))),a(!Array.isArray(e),(()=>o("is an array.")));const s=Object.entries(t);if(n.failOnUnknownFields){const t=n.allowedUnknownFieldNames||[];for(const r in e)a(t.includes(r)||s.some((([e])=>r===e)),o(`property can't be checked: ${r}`))}let u;for(const[t,r]of s){a("function"==typeof r||"object"==typeof r&&null!==r,(()=>`${i()}.${t} assertion is not an object or a function: ${typeof r}`));const n=e[t],o=()=>`${i()}.${t}`;if("object"==typeof r)a(!Array.isArray(n),(()=>`${i()}.${o()} use arrayAssertion() to create a ValueAssertion for an array`)),d(n,r,o);else if(a("function"==typeof r,(()=>`${i()}.${o()} assertion is not a function`)),"$o"===t)u=r;else{const e=r(n,o);a(void 0===e,`Assertion function must assert (void) but it returns a value: ${e}. Wrap with $u()?`)}}u&&u(e,r)}function h(e,t,r){t(e,r)}function f(e){return(t="with-space-separator")=>{const r=l(e);return r?`${r}${"with-space-separator"===t?" ":""}`:""}}function p(e,t,r){"object"==typeof t?(a(!Array.isArray(e),(()=>`${r}: use arrayAssertion() to create a ValueAssertion for an array`)),d(e,t,r)):h(e,t,r)}},6383:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.publishBehavior=void 0;var n=r(1222),i=r(1507);t.publishBehavior=function(e){return function(t){var r=new n.BehaviorSubject(e);return new i.ConnectableObservable(t,(function(){return r}))}}},6467:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onErrorResumeNext=void 0;var n=r(2023),i=r(160),o=r(1266),s=r(6129),a=r(2296);t.onErrorResumeNext=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=i.argsOrArgArray(e);return new n.Observable((function(e){var t=0,n=function(){if(t<r.length){var i=void 0;try{i=a.innerFrom(r[t++])}catch(e){return void n()}var u=new o.OperatorSubscriber(e,void 0,s.noop,s.noop);i.subscribe(u),u.add(n)}else e.complete()};n()}))}},6476:function(e,t){var r=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},n=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.timeoutProvider=void 0,t.timeoutProvider={setTimeout:function(e,i){for(var o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];var a=t.timeoutProvider.delegate;return(null==a?void 0:a.setTimeout)?a.setTimeout.apply(a,n([e,i],r(o))):setTimeout.apply(void 0,n([e,i],r(o)))},clearTimeout:function(e){var r=t.timeoutProvider.delegate;return((null==r?void 0:r.clearTimeout)||clearTimeout)(e)},delegate:void 0}},6516:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.throttle=void 0;var n=r(5416),i=r(1266),o=r(2296);t.throttle=function(e,t){return n.operate((function(r,n){var s=null!=t?t:{},a=s.leading,u=void 0===a||a,c=s.trailing,l=void 0!==c&&c,d=!1,h=null,f=null,p=!1,y=function(){null==f||f.unsubscribe(),f=null,l&&(g(),p&&n.complete())},b=function(){f=null,p&&n.complete()},v=function(t){return f=o.innerFrom(e(t)).subscribe(i.createOperatorSubscriber(n,y,b))},g=function(){if(d){d=!1;var e=h;h=null,n.next(e),!p&&v(e)}};r.subscribe(i.createOperatorSubscriber(n,(function(e){d=!0,h=e,(!f||f.closed)&&(u?g():v(e))}),(function(){p=!0,(!(l&&d&&f)||f.closed)&&n.complete()})))}))}},6612:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.throwError=void 0;var n=r(2023),i=r(4717);t.throwError=function(e,t){var r=i.isFunction(e)?e:function(){return e},o=function(e){return e.error(r())};return new n.Observable(t?function(e){return t.schedule(o,0,e)}:o)}},6663:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.formatValue=function(e){return void 0===e?"<undefined>":"symbol"==typeof e?e.toString():null===e?"<null>":`<${typeof e}:${e}>`}},6803:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.take=void 0;var n=r(7209),i=r(5416),o=r(1266);t.take=function(e){return e<=0?function(){return n.EMPTY}:i.operate((function(t,r){var n=0;t.subscribe(o.createOperatorSubscriber(r,(function(t){++n<=e&&(r.next(t),e<=n&&r.complete())})))}))}},6817:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.windowCount=void 0;var i=r(20),o=r(5416),s=r(1266);t.windowCount=function(e,t){void 0===t&&(t=0);var r=t>0?t:e;return o.operate((function(t,o){var a=[new i.Subject],u=0;o.next(a[0].asObservable()),t.subscribe(s.createOperatorSubscriber(o,(function(t){var s,c;try{for(var l=n(a),d=l.next();!d.done;d=l.next())d.value.next(t)}catch(e){s={error:e}}finally{try{d&&!d.done&&(c=l.return)&&c.call(l)}finally{if(s)throw s.error}}var h=u-e+1;if(h>=0&&h%r==0&&a.shift().complete(),++u%r==0){var f=new i.Subject;a.push(f),o.next(f.asObservable())}}),(function(){for(;a.length>0;)a.shift().complete();o.complete()}),(function(e){for(;a.length>0;)a.shift().error(e);o.error(e)}),(function(){a=null})))}))}},6835:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferCount=void 0;var i=r(5416),o=r(1266),s=r(7394);t.bufferCount=function(e,t){return void 0===t&&(t=null),t=null!=t?t:e,i.operate((function(r,i){var a=[],u=0;r.subscribe(o.createOperatorSubscriber(i,(function(r){var o,c,l,d,h=null;u++%t==0&&a.push([]);try{for(var f=n(a),p=f.next();!p.done;p=f.next())(v=p.value).push(r),e<=v.length&&(h=null!=h?h:[]).push(v)}catch(e){o={error:e}}finally{try{p&&!p.done&&(c=f.return)&&c.call(f)}finally{if(o)throw o.error}}if(h)try{for(var y=n(h),b=y.next();!b.done;b=y.next()){var v=b.value;s.arrRemove(a,v),i.next(v)}}catch(e){l={error:e}}finally{try{b&&!b.done&&(d=y.return)&&d.call(y)}finally{if(l)throw l.error}}}),(function(){var e,t;try{for(var r=n(a),o=r.next();!o.done;o=r.next()){var s=o.value;i.next(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}i.complete()}),void 0,(function(){a=null})))}))}},6841:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.windowTime=void 0;var n=r(20),i=r(4386),o=r(7491),s=r(5416),a=r(1266),u=r(7394),c=r(1824),l=r(5031);t.windowTime=function(e){for(var t,r,d=[],h=1;h<arguments.length;h++)d[h-1]=arguments[h];var f=null!==(t=c.popScheduler(d))&&void 0!==t?t:i.asyncScheduler,p=null!==(r=d[0])&&void 0!==r?r:null,y=d[1]||1/0;return s.operate((function(t,r){var i=[],s=!1,c=function(e){var t=e.window,r=e.subs;t.complete(),r.unsubscribe(),u.arrRemove(i,e),s&&d()},d=function(){if(i){var t=new o.Subscription;r.add(t);var s=new n.Subject,a={window:s,subs:t,seen:0};i.push(a),r.next(s.asObservable()),l.executeSchedule(t,f,(function(){return c(a)}),e)}};null!==p&&p>=0?l.executeSchedule(r,f,d,p,!0):s=!0,d();var h=function(e){return i.slice().forEach(e)},b=function(e){h((function(t){var r=t.window;return e(r)})),e(r),r.unsubscribe()};return t.subscribe(a.createOperatorSubscriber(r,(function(e){h((function(t){t.window.next(e),y<=++t.seen&&c(t)}))}),(function(){return b((function(e){return e.complete()}))}),(function(e){return b((function(t){return t.error(e)}))}))),function(){i=null}}))}},6847:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isIterable=void 0;var n=r(3967),i=r(4717);t.isIterable=function(e){return i.isFunction(null==e?void 0:e[n.iterator])}},6858:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StopThePromisePoolError=void 0;class r extends Error{}t.StopThePromisePoolError=r},6870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sample=void 0;var n=r(2296),i=r(5416),o=r(6129),s=r(1266);t.sample=function(e){return i.operate((function(t,r){var i=!1,a=null;t.subscribe(s.createOperatorSubscriber(r,(function(e){i=!0,a=e}))),n.innerFrom(e).subscribe(s.createOperatorSubscriber(r,(function(){if(i){i=!1;var e=a;a=null,r.next(e)}}),o.noop))}))}},6871:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createErrorClass=void 0,t.createErrorClass=function(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}},6977:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatMap=void 0;var n=r(1282);t.flatMap=n.mergeMap},6993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.audit=void 0;var n=r(5416),i=r(2296),o=r(1266);t.audit=function(e){return n.operate((function(t,r){var n=!1,s=null,a=null,u=!1,c=function(){if(null==a||a.unsubscribe(),a=null,n){n=!1;var e=s;s=null,r.next(e)}u&&r.complete()},l=function(){a=null,u&&r.complete()};t.subscribe(o.createOperatorSubscriber(r,(function(t){n=!0,s=t,a||i.innerFrom(e(t)).subscribe(a=o.createOperatorSubscriber(r,c,l))}),(function(){u=!0,(!n||!a||a.closed)&&r.complete()})))}))}},7071:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scanInternals=void 0;var n=r(1266);t.scanInternals=function(e,t,r,i,o){return function(s,a){var u=r,c=t,l=0;s.subscribe(n.createOperatorSubscriber(a,(function(t){var r=l++;c=u?e(c,t,r):(u=!0,t),i&&a.next(c)}),o&&function(){u&&a.next(c),a.complete()}))}}},7129:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Trie=void 0;class r{constructor(){this.root={children:new Map,childrenWithValue:0}}get(e){var t;return null===(t=this.getNode(e))||void 0===t?void 0:t.value}getOrSet(e,t){const r=this._buildPath(e);if(void 0!==r.value)return r.value;const n=t(e);return this._setNodeValue(r,n,void 0===n),n}set(e,t){const r=void 0===t?this._findNode(e):this._buildPath(e);r&&this._setNodeValue(r,t,!0)}delete(e){const t=this._findNode(e);if(void 0===t)return;if(void 0===t.parent){if(t!==this.root)throw new Error("Only root node can have no parent.");return this.root.value=void 0,this.root.children.clear(),void(this.root.childrenWithValue=0)}const r=(void 0===t.value?0:1)+t.childrenWithValue;r>0&&this._updateChildrenWithValue(t,-r),t.parent.children.delete(e[e.length-1]),this._runGc(t.parent)}clear(){this.delete([])}count(e=[],t="node-and-children"){const r=this.getNode(e);return void 0===r?0:r.childrenWithValue+("node-and-children"===t&&void 0!==r.value?1:0)}get isEmpty(){return 0===this.count()}fillPath(e,t){const n=[];let i=this.root,o=t(i.value,n);if(o!==r.StopFillToken){this._setNodeValue(i,o,!1);for(let s=0;s<e.length;s++){const a=e[s];n.push(a);let u=i.children.get(a);if(o=t(null==u?void 0:u.value,n),o===r.StopFillToken)break;u||(u={children:new Map,parent:i,childrenWithValue:0},i.children.set(a,u)),this._setNodeValue(u,o,!1),i=u}this._runGc(i)}}visitDfs(e,t,r=[]){const n=this.getNode(r);void 0!==n&&this._visitDfs(e,n,t,[...r])}_visitDfs(e,t,r,n){if("pre-order"===e&&!1===r(t.value,n))return!1;for(const[i,o]of t.children){if(n.push(i),!this._visitDfs(e,o,r,n))return!1;n.pop()}return"in-order"!==e||!1!==r(t.value,n)}getNode(e){return this._getNode(e)}_getNode(e){let t=this.root;for(const r of e)if(t=t.children.get(r),!t)return;return t}_findNode(e){let t=this.root;for(let r=0;r<e.length&&t;r++)t=t.children.get(e[r]);return t}_buildPath(e){let t=this.root;for(let r=0;r<e.length;r++){const n=e[r];let i=t.children.get(n);i||(i={children:new Map,parent:t,childrenWithValue:0},t.children.set(n,i)),t=i}return t}_setNodeValue(e,t,r){if(e.value!==t){const r=void 0===t?-1:void 0===e.value?1:0;e.value=t,this._updateChildrenWithValue(e,r)}r&&this._runGc(e)}_updateChildrenWithValue(e,t){if(0!==t)for(let r=e.parent;r;r=r.parent)if(r.childrenWithValue+=t,r.childrenWithValue<0)throw new Error("Internal error: negative counter value!")}_runGc(e){void 0===e.value&&(0===e.childrenWithValue&&e.children.clear(),e.parent&&this._runGc(e.parent))}}t.Trie=r,r.StopFillToken=Symbol("Trie.StopFillToken")},7190:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buffer=void 0;var n=r(5416),i=r(6129),o=r(1266),s=r(2296);t.buffer=function(e){return n.operate((function(t,r){var n=[];return t.subscribe(o.createOperatorSubscriber(r,(function(e){return n.push(e)}),(function(){r.next(n),r.complete()}))),s.innerFrom(e).subscribe(o.createOperatorSubscriber(r,(function(){var e=n;n=[],r.next(e)}),i.noop)),function(){n=null}}))}},7209:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.empty=t.EMPTY=void 0;var n=r(2023);t.EMPTY=new n.Observable((function(e){return e.complete()})),t.empty=function(e){return e?function(e){return new n.Observable((function(t){return e.schedule((function(){return t.complete()}))}))}(e):t.EMPTY}},7243:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TrieStore=void 0;const n=r(11),i=r(573),o=r(6022),s=r(4908);class a extends i.Subject{constructor(){super(...arguments),this.isAllDetailsMode=!1}}t.TrieStore=class{constructor(e){this.observersTrie=new s.Trie,this.batchDepth=0,this.appliedBatchActions=[],this.stubForUnusedPaths=[],this.rootState=e,this.rootStateBeforeBatchStart=this.rootState}get state(){return this.rootState}get state$(){return this.observe([])}get(e){return this._get(this.rootState,e)}observe(e,t=[]){return this._observeChanges(e,t,"new-value-only").pipe((0,o.map)((e=>e.value)))}observeChanges(e,t=[]){return this._observeChanges(e,t,"all-details")}set(e,t,r){(null==r?void 0:r(this.get(e),t,e))||this._apply({type:"set",path:e,value:t})}delete(e){this._apply({type:"delete",path:e})}reset(e){this.observersTrie.visitDfs("pre-order",(e=>null==e?void 0:e.complete())),this.observersTrie.delete([]),this.rootState=e}runInBatch(e){this.batchDepth++;try{e()}finally{if(this.batchDepth--,0===this.batchDepth&&this.appliedBatchActions.length>0){const e={type:"batch",actions:this.appliedBatchActions};this.appliedBatchActions=[],this._notify(e)}}}_apply(e){0===this.batchDepth&&(this.rootStateBeforeBatchStart=this.rootState),this.rootState=(0,n.apply)(this.rootState,e),this.rootState===this.rootStateBeforeBatchStart||this.observersTrie.isEmpty||(this.batchDepth>0?this.appliedBatchActions.push(e):this._notify(e))}_notify(e){const t=(0,n.extractPaths)(e,"unique-and-sorted"),r=this.selectChildPathsWithObservers(t),i=(0,n.selectUniquePaths)([...t,...r]),o=new s.Trie;for(const e of i)o.fillPath(e,(()=>!0));o.visitDfs("pre-order",((t,r)=>{const n=this.observersTrie.get(r);if(n){const t=this.get(r),i=n.isAllDetailsMode?this._get(this.rootStateBeforeBatchStart,r):void 0;n.next({action:e,value:t,oldValue:i})}}))}_observeChanges(e,t=[],r){const u=0===t.length?void 0:new s.Trie;for(const e of t)null==u||u.set(e,!0);return new i.Observable((t=>{const i=this.observersTrie.getOrSet(e,(()=>new a));i.isAllDetailsMode=i.isAllDetailsMode||"all-details"===r;const s={oldValue:void 0,value:this.get(e),paths:[[]]};t.next(s);const c=i.pipe((0,o.filter)((({action:e})=>void 0===u||(0,n.extractPaths)(e,"as-is").some((e=>!u.get(e))))),(0,o.map)((({action:t,value:r,oldValue:o})=>{let s=this.stubForUnusedPaths;if(i.isAllDetailsMode){const r=(0,n.extractPaths)(t,"as-is"),i=e.length>0?r.filter((t=>(0,n.isPathPrefix)(t,e))).map((t=>t.slice(e.length))):r;s=(0,n.selectUniquePathPrefixes)(i)}return{value:r,oldValue:o,paths:s}}))).subscribe(t);return()=>{c.unsubscribe(),i.observed||this.observersTrie.delete(e)}}))}_get(e,t){let r=e;for(let e=0;e<t.length&&void 0!==r;e++){const n=t[e];r=null==r?void 0:r[n]}return r}selectChildPathsWithObservers(e){const t=[];for(const r of e)this.observersTrie.count(r,"children-only")>0&&this.observersTrie.visitDfs("pre-order",((e,r)=>{e&&t.push([...r])}),r);return t}}},7394:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.arrRemove=void 0,t.arrRemove=function(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}},7491:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.isSubscription=t.EMPTY_SUBSCRIPTION=t.Subscription=void 0;var s=r(4717),a=r(665),u=r(7394),c=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,u,c;if(!this.closed){this.closed=!0;var d=this._parentage;if(d)if(this._parentage=null,Array.isArray(d))try{for(var h=n(d),f=h.next();!f.done;f=h.next())f.value.remove(this)}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=h.return)&&t.call(h)}finally{if(e)throw e.error}}else d.remove(this);var p=this.initialTeardown;if(s.isFunction(p))try{p()}catch(e){c=e instanceof a.UnsubscriptionError?e.errors:[e]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var b=n(y),v=b.next();!v.done;v=b.next()){var g=v.value;try{l(g)}catch(e){c=null!=c?c:[],e instanceof a.UnsubscriptionError?c=o(o([],i(c)),i(e.errors)):c.push(e)}}}catch(e){r={error:e}}finally{try{v&&!v.done&&(u=b.return)&&u.call(b)}finally{if(r)throw r.error}}}if(c)throw new a.UnsubscriptionError(c)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)l(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&u.arrRemove(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&u.arrRemove(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function l(e){s.isFunction(e)?e():e.unsubscribe()}t.Subscription=c,t.EMPTY_SUBSCRIPTION=c.EMPTY,t.isSubscription=function(e){return e instanceof c||e&&"closed"in e&&s.isFunction(e.remove)&&s.isFunction(e.add)&&s.isFunction(e.unsubscribe)}},7507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultIfEmpty=void 0;var n=r(5416),i=r(1266);t.defaultIfEmpty=function(e){return n.operate((function(t,r){var n=!1;t.subscribe(i.createOperatorSubscriber(r,(function(e){n=!0,r.next(e)}),(function(){n||r.next(e),r.complete()})))}))}},7514:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferWhen=void 0;var n=r(5416),i=r(6129),o=r(1266),s=r(2296);t.bufferWhen=function(e){return n.operate((function(t,r){var n=null,a=null,u=function(){null==a||a.unsubscribe();var t=n;n=[],t&&r.next(t),s.innerFrom(e()).subscribe(a=o.createOperatorSubscriber(r,u,i.noop))};u(),t.subscribe(o.createOperatorSubscriber(r,(function(e){return null==n?void 0:n.push(e)}),(function(){n&&r.next(n),r.complete()}),void 0,(function(){return n=a=null})))}))}},7517:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timeout=t.TimeoutError=void 0;var n=r(4386),i=r(6349),o=r(5416),s=r(2296),a=r(6871),u=r(1266),c=r(5031);function l(e){throw new t.TimeoutError(e)}t.TimeoutError=a.createErrorClass((function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}})),t.timeout=function(e,t){var r=i.isValidDate(e)?{first:e}:"number"==typeof e?{each:e}:e,a=r.first,d=r.each,h=r.with,f=void 0===h?l:h,p=r.scheduler,y=void 0===p?null!=t?t:n.asyncScheduler:p,b=r.meta,v=void 0===b?null:b;if(null==a&&null==d)throw new TypeError("No timeout provided.");return o.operate((function(e,t){var r,n,i=null,o=0,l=function(e){n=c.executeSchedule(t,y,(function(){try{r.unsubscribe(),s.innerFrom(f({meta:v,lastValue:i,seen:o})).subscribe(t)}catch(e){t.error(e)}}),e)};r=e.subscribe(u.createOperatorSubscriber(t,(function(e){null==n||n.unsubscribe(),o++,t.next(i=e),d>0&&l(d)}),void 0,void 0,(function(){(null==n?void 0:n.closed)||null==n||n.unsubscribe(),i=null}))),!o&&l(null!=a?"number"==typeof a?a:+a-y.now():d)}))}},7638:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.Action=void 0;var i=function(e){function t(t,r){return e.call(this)||this}return n(t,e),t.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},t}(r(7491).Subscription);t.Action=i},7676:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EmptyError=void 0;var n=r(6871);t.EmptyError=n.createErrorClass((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}))},7770:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.takeWhile=void 0;var n=r(5416),i=r(1266);t.takeWhile=function(e,t){return void 0===t&&(t=!1),n.operate((function(r,n){var o=0;r.subscribe(i.createOperatorSubscriber(n,(function(r){var i=e(r,o++);(i||t)&&n.next(r),!i&&n.complete()})))}))}},7775:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.repeat=void 0;var n=r(7209),i=r(5416),o=r(1266),s=r(2296),a=r(5461);t.repeat=function(e){var t,r,u=1/0;return null!=e&&("object"==typeof e?(t=e.count,u=void 0===t?1/0:t,r=e.delay):u=e),u<=0?function(){return n.EMPTY}:i.operate((function(e,t){var n,i=0,c=function(){if(null==n||n.unsubscribe(),n=null,null!=r){var e="number"==typeof r?a.timer(r):s.innerFrom(r(i)),u=o.createOperatorSubscriber(t,(function(){u.unsubscribe(),l()}));e.subscribe(u)}else l()},l=function(){var r=!1;n=e.subscribe(o.createOperatorSubscriber(t,void 0,(function(){++i<u?n?c():r=!0:t.complete()}))),r&&c()};l()}))}},7820:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.config=void 0,t.config={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1}},7837:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromisePoolError=void 0;class r extends Error{constructor(e,t){super(),this.raw=e,this.item=t,this.name=this.constructor.name,this.message=this.messageFrom(e),Error.captureStackTrace&&"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static createFrom(e,t){return new this(e,t)}messageFrom(e){return e instanceof Error||"object"==typeof e?e.message:"string"==typeof e||"number"==typeof e?e.toString():""}}t.PromisePoolError=r},7967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.materialize=void 0;var n=r(6145),i=r(5416),o=r(1266);t.materialize=function(){return i.operate((function(e,t){e.subscribe(o.createOperatorSubscriber(t,(function(e){t.next(n.Notification.createNext(e))}),(function(){t.next(n.Notification.createComplete()),t.complete()}),(function(e){t.next(n.Notification.createError(e)),t.complete()})))}))}},8041:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.count=void 0;var n=r(3818);t.count=function(e){return n.reduce((function(t,r,n){return!e||e(r,n)?t+1:t}),0)}},8083:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ObjectUnsubscribedError=void 0;var n=r(6871);t.ObjectUnsubscribedError=n.createErrorClass((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}))},8158:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timestamp=void 0;var n=r(4575),i=r(4828);t.timestamp=function(e){return void 0===e&&(e=n.dateTimestampProvider),i.map((function(t){return{value:t,timestamp:e.now()}}))}},8168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SequenceError=void 0;var n=r(6871);t.SequenceError=n.createErrorClass((function(e){return function(t){e(this),this.name="SequenceError",this.message=t}}))},8226:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.publishReplay=void 0;var n=r(5129),i=r(9924),o=r(4717);t.publishReplay=function(e,t,r,s){r&&!o.isFunction(r)&&(s=r);var a=o.isFunction(r)?r:void 0;return function(r){return i.multicast(new n.ReplaySubject(e,t,s),a)(r)}}},8229:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.publishLast=void 0;var n=r(5366),i=r(1507);t.publishLast=function(){return function(e){var t=new n.AsyncSubject;return new i.ConnectableObservable(e,(function(){return t}))}}},8240:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.mapOneOrManyArgs=void 0;var o=r(4828),s=Array.isArray;t.mapOneOrManyArgs=function(e){return o.map((function(t){return function(e,t){return s(t)?e.apply(void 0,i([],n(t))):e(t)}(e,t)}))}},8251:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.catchError=void 0;var n=r(2296),i=r(1266),o=r(5416);t.catchError=function e(t){return o.operate((function(r,o){var s,a=null,u=!1;a=r.subscribe(i.createOperatorSubscriber(o,void 0,void 0,(function(i){s=n.innerFrom(t(i,e(t)(r))),a?(a.unsubscribe(),a=null,s.subscribe(o)):u=!0}))),u&&(a.unsubscribe(),a=null,s.subscribe(o))}))}},8324:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.expand=void 0;var n=r(5416),i=r(3754);t.expand=function(e,t,r){return void 0===t&&(t=1/0),t=(t||0)<1?1/0:t,n.operate((function(n,o){return i.mergeInternals(n,o,e,t,void 0,!0,r)}))}},8596:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringAssertion=void 0,t.objectAssertion=function(e,t=void 0){return r=>(0,n.assertObject)(r,e,t)},t.arrayAssertion=function(e,t={}){const{minLength:r,maxLength:i}=t;return(0,n.assertTruthy)((null!=r?r:0)<=(null!=i?i:1/0),`minLength must be < maxLength! minLength ${r}, maxLength: ${i}`),(0,n.assertTruthy)((null!=r?r:0)>=0,`minLength must be a positive number: ${r}`),(0,n.assertTruthy)((null!=i?i:0)>=0,`maxLength must be a positive number: ${i}`),(r,i=void 0)=>{(0,n.assertArray)(r,e,t,i)}},t.recordAssertion=function(e,t={}){return(r,i=void 0)=>{(0,n.assertRecord)(r,e,t,i)}},t.$a=o,t.$u=function(e,t){return o(e,t)},t.valueOr=s,t.undefinedOr=function(e){return s(void 0,e)},t.nullOr=function(e){return s(null,e)};const n=r(6373),i=r(1333);function o(e,t){return(0,n.assertTruthy)("function"==typeof e,`"check" is not a function: ${e}`),(r,i=void 0)=>(0,n.assertTruthy)(e(r),(()=>{let e=(0,n.getErrorMessage)(i)||"Check is failed";return e.endsWith(":")||(e+=":"),`${e} ${(0,n.getErrorMessage)(t)||("object"==typeof r?"[object]":`'${r}'`)}`}))}function s(e,t){return(r,i=void 0)=>{r!==e&&("object"==typeof t?(0,n.assertObject)(r,t,i):(0,n.callValueAssertion)(r,t,i))}}t.stringAssertion=e=>(t,r=void 0)=>{var o,s;(0,i.assertString)(t,r),(0,n.assertTruthy)(t.length>=(null!==(o=e.minLength)&&void 0!==o?o:0),`${(0,n.getErrorMessage)(r)} length is too small: ${t.length} < ${e.minLength}`),(0,n.assertTruthy)(t.length<=(null!==(s=e.maxLength)&&void 0!==s?s:1/0),`${(0,n.getErrorMessage)(r)} length is too large ${t.length} > ${e.maxLength}`)}},8630:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatch=i,t.validateObject=function(e,t,r=void 0,o={}){return i((()=>(0,n.assertObject)(e,t,r,o)))},t.validateArray=function(e,t,r={},o=void 0){return i((()=>(0,n.assertArray)(e,t,r,o)))},t.validateRecord=function(e,t,r={},o=void 0){return i((()=>(0,n.assertRecord)(e,t,r,o)))};const n=r(6373);function i(e){try{e()}catch(e){return e instanceof Error&&e.message||`${e}`}}},8743:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.of=void 0;var n=r(1824),i=r(5294);t.of=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=n.popScheduler(e);return i.from(e,r)}},8748:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.exhaustMap=void 0;var n=r(4828),i=r(2296),o=r(5416),s=r(1266);t.exhaustMap=function e(t,r){return r?function(o){return o.pipe(e((function(e,o){return i.innerFrom(t(e,o)).pipe(n.map((function(t,n){return r(e,t,o,n)})))})))}:o.operate((function(e,r){var n=0,o=null,a=!1;e.subscribe(s.createOperatorSubscriber(r,(function(e){o||(o=s.createOperatorSubscriber(r,void 0,(function(){o=null,a&&r.complete()})),i.innerFrom(t(e,n++)).subscribe(o))}),(function(){a=!0,!o&&r.complete()})))}))}},8762:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleArray=void 0;var n=r(2023);t.scheduleArray=function(e,t){return new n.Observable((function(r){var n=0;return t.schedule((function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())}))}))}},8767:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.interval=void 0;var n=r(4386),i=r(5461);t.interval=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=n.asyncScheduler),e<0&&(e=0),i.timer(e,e,t)}},8973:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.race=void 0;var o=r(160),s=r(177);t.race=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.raceWith.apply(void 0,i([],n(o.argsOrArgArray(e))))}},9061:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.switchAll=void 0;var n=r(6300),i=r(9391);t.switchAll=function(){return n.switchMap(i.identity)}},9136:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleReadableStreamLike=void 0;var n=r(3741),i=r(3026);t.scheduleReadableStreamLike=function(e,t){return n.scheduleAsyncIterable(i.readableStreamLikeToAsyncGenerator(e),t)}},9148:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ArgumentOutOfRangeError=void 0;var n=r(6871);t.ArgumentOutOfRangeError=n.createErrorClass((function(e){return function(){e(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}}))},9163:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.withLatestFrom=void 0;var o=r(5416),s=r(1266),a=r(2296),u=r(9391),c=r(6129),l=r(1824);t.withLatestFrom=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l.popResultSelector(e);return o.operate((function(t,o){for(var l=e.length,d=new Array(l),h=e.map((function(){return!1})),f=!1,p=function(t){a.innerFrom(e[t]).subscribe(s.createOperatorSubscriber(o,(function(e){d[t]=e,f||h[t]||(h[t]=!0,(f=h.every(u.identity))&&(h=null))}),c.noop))},y=0;y<l;y++)p(y);t.subscribe(s.createOperatorSubscriber(o,(function(e){if(f){var t=i([e],n(d));o.next(r?r.apply(void 0,i([],n(t))):t)}})))}))}},9228:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.exhaust=void 0;var n=r(9765);t.exhaust=n.exhaustAll},9273:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},9355:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.skipLast=void 0;var n=r(9391),i=r(5416),o=r(1266);t.skipLast=function(e){return e<=0?n.identity:i.operate((function(t,r){var n=new Array(e),i=0;return t.subscribe(o.createOperatorSubscriber(r,(function(t){var o=i++;if(o<e)n[o]=t;else{var s=o%e,a=n[s];n[s]=t,r.next(a)}}))),function(){n=null}}))}},9391:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.identity=void 0,t.identity=function(e){return e}},9451:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isAsyncIterable=void 0;var n=r(4717);t.isAsyncIterable=function(e){return Symbol.asyncIterator&&n.isFunction(null==e?void 0:e[Symbol.asyncIterator])}},9527:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeScan=void 0;var n=r(5416),i=r(3754);t.mergeScan=function(e,t,r){return void 0===r&&(r=1/0),n.operate((function(n,o){var s=t;return i.mergeInternals(n,o,(function(t,r){return e(s,t,r)}),r,(function(e){s=e}),!1,void 0,(function(){return s=null}))}))}},9712:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeInterval=t.timeInterval=void 0;var n=r(4386),i=r(5416),o=r(1266);t.timeInterval=function(e){return void 0===e&&(e=n.asyncScheduler),i.operate((function(t,r){var n=e.now();t.subscribe(o.createOperatorSubscriber(r,(function(t){var i=e.now(),o=i-n;n=i,r.next(new s(t,o))})))}))};var s=function(e,t){this.value=e,this.interval=t};t.TimeInterval=s},9765:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.exhaustAll=void 0;var n=r(8748),i=r(9391);t.exhaustAll=function(){return n.exhaustMap(i.identity)}},9822:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.finalize=void 0;var n=r(5416);t.finalize=function(e){return n.operate((function(t,r){try{t.subscribe(r)}finally{r.add(e)}}))}},9842:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.skipWhile=void 0;var n=r(5416),i=r(1266);t.skipWhile=function(e){return n.operate((function(t,r){var n=!1,o=0;t.subscribe(i.createOperatorSubscriber(r,(function(t){return(n||(n=!e(t,o++)))&&r.next(t)})))}))}},9916:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.captureError=t.errorContext=void 0;var n=r(7820),i=null;t.errorContext=function(e){if(n.config.useDeprecatedSynchronousErrorHandling){var t=!i;if(t&&(i={errorThrown:!1,error:null}),e(),t){var r=i,o=r.errorThrown,s=r.error;if(i=null,o)throw s}}else e()},t.captureError=function(e){n.config.useDeprecatedSynchronousErrorHandling&&i&&(i.errorThrown=!0,i.error=e)}},9924:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multicast=void 0;var n=r(1507),i=r(4717),o=r(2216);t.multicast=function(e,t){var r=i.isFunction(e)?e:function(){return e};return i.isFunction(t)?o.connect(t,{connector:r}):function(e){return new n.ConnectableObservable(e,r)}}},9939:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.distinctUntilChanged=void 0;var n=r(9391),i=r(5416),o=r(1266);function s(e,t){return e===t}t.distinctUntilChanged=function(e,t){return void 0===t&&(t=n.identity),e=null!=e?e:s,i.operate((function(r,n){var i,s=!0;r.subscribe(o.createOperatorSubscriber(n,(function(r){var o=t(r);!s&&e(i,o)||(s=!1,i=o,n.next(r))})))}))}},9967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tap=void 0;var n=r(4717),i=r(5416),o=r(1266),s=r(9391);t.tap=function(e,t,r){var a=n.isFunction(e)||t||r?{next:e,error:t,complete:r}:e;return a?i.operate((function(e,t){var r;null===(r=a.subscribe)||void 0===r||r.call(a);var n=!0;e.subscribe(o.createOperatorSubscriber(t,(function(e){var r;null===(r=a.next)||void 0===r||r.call(a,e),t.next(e)}),(function(){var e;n=!1,null===(e=a.complete)||void 0===e||e.call(a),t.complete()}),(function(e){var r;n=!1,null===(r=a.error)||void 0===r||r.call(a,e),t.error(e)}),(function(){var e,t;n&&(null===(e=a.unsubscribe)||void 0===e||e.call(a)),null===(t=a.finalize)||void 0===t||t.call(a)})))})):s.identity}}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{AI_AGENTS_INTEGRATION_ID:()=>Ve,AI_AUDIO_CREATE_SPEECH_MODEL_NAMES:()=>K,AI_AUDIO_TRANSCRIPTION_MODEL_NAMES:()=>J,AI_CHAT_MODEL_NAMES:()=>B,AI_EMBEDDINGS_MODEL_NAMES:()=>Q,AI_IMAGE_MODEL_NAMES:()=>G,ALL_OPERATORS:()=>ut,ANTHROPIC_CHAT_MODEL_NAMES:()=>L,API_INJECTION_FIELD_TYPES:()=>et,ARRAY_OPERATORS:()=>at,AUTH_INTEGRATION_TYPES:()=>He,AdminClient:()=>rn,AiAgentClient:()=>de,AiAgentReference:()=>le,AiAssistantClient:()=>i,AiAudioClient:()=>fe,AiClient:()=>sn,AiImageClient:()=>he,AiMatchMakingClient:()=>nn,ApiClient:()=>ye,ApiKeysSecretClient:()=>Qr,AuthManager:()=>be,BUILT_IN_AGENT_ID:()=>C,BUILT_IN_DB_INTEGRATION_ID:()=>Ke,BUILT_IN_QUEUE_INTEGRATION_ID:()=>Ze,BUILT_IN_STORAGE_INTEGRATION_ID:()=>Xe,BackendFunctionManager:()=>xe,BaseQueryBuilder:()=>vt,CLIENT_CONNECTION_STATES:()=>lt,CLIENT_ID_GENERATOR_KEY:()=>Le,CLIENT_REQUEST_ID_GENERATOR_KEY:()=>Be,Changes:()=>_t,ClientIdService:()=>qe,CollectionReference:()=>Tt,CollectionReferenceFactory:()=>jt,ConnectionDetails:()=>Pt,CronExpression:()=>Ue,DATA_INTEGRATION_TYPES:()=>We,DEFAULT_CHAT_OPTIONS:()=>P,DEFAULT_SHORT_ID_LENGTH:()=>se,DataManager:()=>Lt,DestructManager:()=>Ut,DistributedLockImpl:()=>$t,DistributedLockManager:()=>Qt,DocumentReference:()=>pt,DocumentReferenceFactory:()=>Yt,DocumentStore:()=>Wt,EMPTY_CHAT_ID:()=>D,ENVIRONMENT_IDS:()=>k,ExtractionClient:()=>en,FETCH_BEYOND_LIMIT:()=>yr,FLUX_MODEL_NAMES:()=>z,GEMINI_CHAT_MODEL_NAMES:()=>q,GRAPHQL_INTEGRATION_TYPES:()=>ze,HTTP_INTEGRATION_TYPES:()=>Ge,HttpStatus:()=>$e,INTEGRATION_SCHEMA_TYPES:()=>Je,INTEGRATION_TYPES:()=>Ye,IntegrationClient:()=>Yr,JoinQueryBuilder:()=>St,LIMIT_UNDERFLOW_TRIGGER:()=>br,LimitUnderflowState:()=>lr,LocalQueryManager:()=>ar,METRIC_DOMAIN:()=>nt,METRIC_FUNCTIONS:()=>rt,METRIC_INTERVAL_ALIGNMENT:()=>it,MUTATION_TYPES:()=>ot,MatchMaker:()=>on,MutationSender:()=>Ht,NOOP_FN:()=>Wr,NativeQueryManager:()=>zt,OPENAI_AUDIO_CREATE_SPEECH_MODEL_NAMES:()=>Y,OPENAI_AUDIO_MODEL_NAMES:()=>W,OPENAI_AUDIO_TRANSCRIPTION_MODEL_NAMES:()=>V,OPENAI_CHAT_MODEL_NAMES:()=>N,OPENAI_EMBEDDINGS_MODEL_NAMES:()=>U,OPENAI_IMAGE_MODEL_NAMES:()=>$,OPENAI_O1_CHAT_MODEL_NAMES:()=>x,OPENAI_REASONING_CHAT_MODEL_NAMES:()=>R,OPEN_AI_CREATE_SPEECH_FORMATS:()=>Z,ObservabilityClient:()=>qr,Pagination:()=>yt,PersonalStorageClient:()=>tn,QueryBuilder:()=>mt,QueryBuilderFactory:()=>bt,QuerySender:()=>cr,QuerySubscriptionManager:()=>vr,QueueManagerFactory:()=>Sr,QueueManagerImpl:()=>wr,RateLimiter:()=>Ir,RpcError:()=>Tr,RpcManager:()=>Rr,SQUID_METRIC_NAMES:()=>tt,SQUID_REGIONS:()=>ct,STABLE_DIFFUSION_MODEL_NAMES:()=>H,SchedulerClient:()=>$r,SecretClient:()=>Ur,SecureAiAgentContext:()=>ee,SocketManager:()=>Gr,Squid:()=>an,StorageClient:()=>Xr,VECTOR_DB_TYPES:()=>X,base64ToFile:()=>ce,deserializeQuery:()=>Jt,generateId:()=>oe,generateShortId:()=>ue,getConsoleBaseUrl:()=>Vr,isPlaceholderParam:()=>Qe,isSimpleCondition:()=>st,rawSquidHttpDelete:()=>kr,rawSquidHttpGet:()=>jr,rawSquidHttpPatch:()=>Dr,rawSquidHttpPost:()=>Fr,rawSquidHttpPut:()=>Pr,tryDeserializing:()=>xr,validateAiContextMetadata:()=>re,validateAiContextMetadataFilter:()=>ne,visitQueryResults:()=>Gt});class i{constructor(e){this.rpcManager=e}async createAssistant(e,t,r,n){const i={name:e,instructions:t,functions:r,toolTypes:n};return(await this.rpcManager.post("ai/assistant/createAssistant",i)).assistantId}async deleteAssistant(e){const t={assistantId:e};await this.rpcManager.post("ai/assistant/deleteAssistant",t)}async createThread(e){const t={assistantId:e};return(await this.rpcManager.post("ai/assistant/createThread",t)).threadId}async deleteThread(e){const t={threadId:e};await this.rpcManager.post("ai/assistant/deleteThread",t)}async queryAssistant(e,t,r,n,i){const o={assistantId:e,threadId:t,prompt:r,fileIds:n,options:i};return(await this.rpcManager.post("ai/assistant/queryAssistant",o)).answer}async addFileToAssistant(e,t){const r={assistantId:e};return(await this.rpcManager.post("ai/assistant/addFileToAssistant",r,[t],"file")).fileId}async removeFileFromAssistant(e,t){const r={assistantId:e,fileId:t};await this.rpcManager.post("ai/assistant/removeFileFromAssistant",r)}async addFileToThread(e,t){const r={threadId:e};return(await this.rpcManager.post("ai/assistant/addFileToThread",r,[t],"file")).fileId}}var o=r(573);function s(e){return"function"==typeof e}function a(e){return function(t){if(function(e){return s(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}var u=function(e,t){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},u(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function h(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var f,p=((f=function(e){var t;t=this,Error.call(t),t.stack=(new Error).stack,this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}).prototype=Object.create(Error.prototype),f.prototype.constructor=f,f);function y(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var b=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=l(o),u=a.next();!u.done;u=a.next())u.value.remove(this)}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else o.remove(this);var c=this.initialTeardown;if(s(c))try{c()}catch(e){i=e instanceof p?e.errors:[e]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var y=l(f),b=y.next();!b.done;b=y.next()){var g=b.value;try{v(g)}catch(e){i=null!=i?i:[],e instanceof p?i=h(h([],d(i)),d(e.errors)):i.push(e)}}}catch(e){r={error:e}}finally{try{b&&!b.done&&(n=y.return)&&n.call(y)}finally{if(r)throw r.error}}}if(i)throw new p(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)v(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&y(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&y(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function v(e){s(e)?e():e.unsubscribe()}b.EMPTY;var g={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=g.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,h([e,t],d(r))):setTimeout.apply(void 0,h([e,t],d(r)))},clearTimeout:function(e){var t=g.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function m(){}var _=S("C",void 0,void 0);function S(e,t,r){return{kind:e,value:t,error:r}}var O=function(e){function t(t){var r,n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,((r=t)instanceof b||r&&"closed"in r&&s(r.remove)&&s(r.add)&&s(r.unsubscribe))&&t.add(n)):n.destination=A,n}return c(t,e),t.create=function(e,t,r){return new I(e,t,r)},t.prototype.next=function(e){this.isStopped?E(function(e){return S("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?E(S("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?E(_,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(b);Function.prototype.bind;var w=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){M(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){M(e)}else M(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){M(e)}},e}(),I=function(e){function t(t,r,n){var i,o=e.call(this)||this;return i=s(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,o.destination=new w(i),o}return c(t,e),t}(O);function M(e){!function(e){g.setTimeout((function(){throw e}))}(e)}function E(e,t){var r=null;r&&g.setTimeout((function(){return r(e,t)}))}var A={closed:!0,next:m,error:function(e){throw e},complete:m};function T(e,t,r,n,i){return new F(e,t,r,n,i)}var F=function(e){function t(t,r,n,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return c(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(O);function j(e,t){return a((function(r,n){var i=0;r.subscribe(T(n,(function(r){n.next(e.call(t,r,i++))})))}))}const P={smoothTyping:!0,responseFormat:"text"},D="__squid_empty_chat_id",k=["dev","prod"],C="built_in_agent",x=["o1","o1-mini"],R=[...x,"o3-mini"],N=["gpt-4o","gpt-4o-mini",...R],q=["gemini-1.5-pro","gemini-2.0-flash"],L=["claude-3-5-haiku-latest","claude-3-5-sonnet-latest"],B=[...N,...L,...q],U=["text-embedding-3-small","text-embedding-3-large","text-embedding-ada-002"],Q=[...U],$=["dall-e-3"],V=["whisper-1"],Y=["tts-1","tts-1-hd"],W=[...V,...Y],H=["stable-diffusion-core"],z=["flux-pro-1.1"],G=[...$,...H,...z],J=[...V],K=[...Y],Z=["mp3","opus","aac","flac","wav","pcm"],X=["postgres"];class ee{constructor(e){this.agentId=e.agentId,this.prompt=e.prompt}}const te=["groupId","appId","integrationId","profileId","index","text","filePathInBucket"];function re(e){for(const t in e){const r=e[t];if("string"!=typeof r&&"number"!=typeof r&&"boolean"!=typeof r&&void 0!==r)throw new Error(`Invalid metadata value for key ${t} - cannot be of type ${typeof r}`);if(te.includes(t))throw new Error(`Invalid metadata key ${t} - cannot be an internal key. Internal keys: ${te.join(", ")}`);if(!/^[a-zA-Z0-9_]+$/.test(t))throw new Error(`Invalid metadata key ${t} - can only contain letters, numbers, and underscores`)}}function ne(e){if(function(e){return"$and"in e}(e))for(const t of e.$and)ne(t);else if(function(e){return"$or"in e}(e))for(const t of e.$or)ne(t);else for(const t in e){if(!/^[a-zA-Z0-9_]+$/.test(t))throw new Error(`Invalid metadata filter key ${t} - can only contain letters, numbers, and underscores`);if(te.includes(t))throw new Error(`Invalid metadata filter key ${t} - cannot be an internal key. Internal keys: ${te.join(", ")}`);const r=e[t];if("object"!=typeof r&&"string"!=typeof r&&"number"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid metadata filter value for key ${t} - cannot be of type ${typeof r}`)}}var ie=r(5036);function oe(){let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)}))}const se=18,ae="abcdefghijklmnopqrstuvwxyz0123456789";function ue(e=se,t=""){(0,ie.assertTruthy)(t.length<e,"ID prefix is too long");let r="";for(let t=0;t<e;t++)r+=ae.charAt(Math.floor(Math.random()*ae.length));return t.length>0&&(r=t+r.substring(t.length)),r}function ce(e,t,r){const n=atob(e),i=new Uint8Array(n.length);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);const o=r||"application/octet-stream",s=new Blob([i],{type:o});return new File([s],t,{type:o})}class le{constructor(e,t,r,n,i){this.agentId=e,this.ongoingChatSequences=t,this.statusUpdates=r,this.rpcManager=n,this.socketManager=i}async get(){const e=await this.rpcManager.post("ai/agent/getAgent",{agentId:this.agentId});return e?.agent}async upsert(e){await this.rpcManager.post("ai/agent/upsertAgent",{...e,id:this.agentId})}async delete(){await this.rpcManager.post("ai/agent/deleteAgent",{agentId:this.agentId})}async updateInstructions(e){const t=await this.get();(0,ie.assertTruthy)(t,"Agent not found"),await this.upsert({...t,options:{...t.options,instructions:e}})}async updateModel(e){const t=await this.get();(0,ie.assertTruthy)(t,"Agent not found"),await this.upsert({...t,options:{...t.options,model:e}})}async updateConnectedAgents(e){const t=await this.get();(0,ie.assertTruthy)(t,"Agent not found"),await this.upsert({...t,options:{...t.options,connectedAgents:e}})}async getContext(e){return await this.rpcManager.post("ai/agent/getContext",{agentId:this.agentId,contextId:e})}async listContexts(){return(await this.rpcManager.post("ai/agent/listContexts",{agentId:this.agentId})).contexts||[]}async deleteContext(e){await this.deleteContexts([e])}async deleteContexts(e){await this.rpcManager.post("ai/agent/deleteContexts",{agentId:this.agentId,contextIds:e})}async upsertContext(e,t){await this.upsertContexts([e],t?[t]:void 0)}async upsertContexts(e,t){for(const t of e)t.metadata&&re(t.metadata);await this.rpcManager.post("ai/agent/upsertContexts",{agentId:this.agentId,contextRequests:e},t)}async provideFeedback(e){await this.rpcManager.post("ai/agent/provideFeedback",{agentId:this.agentId,feedback:e})}async resetFeedback(){await this.rpcManager.post("ai/agent/resetFeedback",{agentId:this.agentId})}chat(e,t){return this.chatInternal(e,t).responseStream}async transcribeAndChat(e,t){const r=this.chatInternal(e,t),n=await(0,ie.truthy)(r.serverResponse,"TRANSCRIPTION_RESPONSE_NOT_FOUND");return{responseStream:r.responseStream,transcribedPrompt:n.transcribedPrompt}}search(e){(0,ie.assertTruthy)(this.agentId!==C,"Cannot search the built-in agent");const t={options:e,agentId:this.agentId};return this.rpcManager.post("ai/chatbot/search",t)}async ask(e,t){return(await this.askInternal(e,!1,t)).responseString}observeStatusUpdates(e){const{chatId:t}=e||{};return this.createStatusSubject(t),t?this.statusUpdates[this.agentId][t].asObservable():(0,o.merge)(...Object.values(this.statusUpdates[this.agentId]))}async transcribeAndAsk(e,t){return await this.askInternal(e,!1,t)}async transcribeAndAskWithVoiceResponse(e,t){const r=await this.askInternal(e,!0,t),n=r.voiceResponse;return{responseString:r.responseString,transcribedPrompt:r.transcribedPrompt,voiceResponseFile:ce(n.base64File,`voice.${n.extension}`,n.mimeType)}}async askWithVoiceResponse(e,t){const r=await this.askInternal(e,!0,t),n=r.voiceResponse;return{responseString:r.responseString,voiceResponseFile:ce(n.base64File,`voice.${n.extension}`,n.mimeType)}}async askInternal(e,t,r){r?.contextMetadataFilter&&ne(r.contextMetadataFilter),r={...P,...r||{}};const n="string"==typeof e;let i="ai/chatbot/";i+=n||t?!n&&t?"transcribeAndAskWithVoiceResponse":n&&t?"askWithVoiceResponse":"ask":"transcribeAndAsk";const o={agentId:this.agentId,prompt:n?e:void 0,options:r},s=n?void 0:[e];return await this.rpcManager.post(i,o,s,"file")}createStatusSubject(e){this.statusUpdates[this.agentId]||(this.statusUpdates[this.agentId]={});const t=e||D;this.statusUpdates[this.agentId][t]||(this.statusUpdates[this.agentId][t]=new o.Subject)}chatInternal(e,t){this.socketManager.notifyWebSocketIsNeeded(),t?.contextMetadataFilter&&ne(t.contextMetadataFilter);const r=oe(),n=void 0===(t={...P,...t||{}}).smoothTyping||t.smoothTyping;let i="";const s=new o.Subject,a=new o.Subject;this.ongoingChatSequences[r]=a;let u=-1;a.pipe((0,o.tap)((({tokenIndex:e})=>{void 0!==e&&e<u&&console.warn("Received token index out of order",e,u),void 0!==e&&(u=e)})),(0,o.concatMap)((({value:e,complete:t})=>t?(0,o.of)({value:e,complete:t}):(0,o.of)(e).pipe(n?(0,o.delay)(0):(0,o.tap)(),j((e=>({value:e,complete:!1})))))),(0,o.takeWhile)((({complete:e})=>!e),!0)).subscribe({next:({value:e})=>{i+=e,s.next(i)},error:e=>{console.error(e)},complete:()=>{s.complete()}});const c="string"==typeof e,l={agentId:this.agentId,prompt:c?e:void 0,options:t,clientRequestId:r},d={responseStream:s.pipe((0,o.finalize)((()=>{delete this.ongoingChatSequences[r]})),(0,o.share)())};return c?this.rpcManager.post("ai/chatbot/chat",l).catch((e=>{s.error(e),s.complete()})):d.serverResponse=this.rpcManager.post("ai/chatbot/transcribeAndChat",l,[e],"file").catch((e=>{throw s.error(e),s.complete(),e})),d}}class de{constructor(e,t){this.rpcManager=e,this.socketManager=t,this.ongoingChatSequences={},this.statusUpdates={},this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"aiChatbot"===e.type)),j((e=>e))).subscribe((e=>{this.handleChatResponse(e).then()})),this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"aiStatus"===e.type)),j((e=>e))).subscribe((e=>{this.handleStatusMessage(e).then()}))}agent(e){return new le(e,this.ongoingChatSequences,this.statusUpdates,this.rpcManager,this.socketManager)}async listAgents(){return(await this.rpcManager.post("ai/agent/listAgents",{})).agents}async handleChatResponse(e){const t=this.ongoingChatSequences[e.clientRequestId];if(!t)return;const{token:r,complete:n,tokenIndex:i}=e.payload;if(n&&!r.length)t.next({value:"",complete:!0,tokenIndex:void 0});else if(r.match(/\[.*?]\((.*?)\)/g))t.next({value:r,complete:n,tokenIndex:void 0===i?void 0:i});else for(let e=0;e<r.length;e++)t.next({value:r[e],complete:n&&e===r.length-1,tokenIndex:void 0===i?void 0:i})}async handleStatusMessage(e){const{agentId:t,chatId:r,payload:n}=e,{title:i,tags:o}=n,s=this.getStatusSubject(t,r);s?.next({agentId:t,chatId:r,title:i,tags:o})}getStatusSubject(e,t){if(!this.statusUpdates[e])return;const r=t||D;return this.statusUpdates[e][r]}}class he{constructor(e){this.rpcManager=e}async generate(e,t){const r={prompt:e,options:t};return await this.rpcManager.post("ai/image/generate",r)}async removeBackground(e){return await this.rpcManager.post("ai/image/removeBackground",{},[e])}}class fe{constructor(e){this.rpcManager=e}async transcribe(e,t={modelName:"whisper-1"}){return this.rpcManager.post("ai/audio/transcribe",t,[e])}async createSpeech(e,t){const r={input:e,options:t},n=await this.rpcManager.post("ai/audio/createSpeech",r);return ce(n.base64File,`audio.${n.extension}`,n.mimeType)}}const pe={headers:{},queryParams:{},pathParams:{}};class ye{constructor(e){this.rpcManager=e}async get(e,t,r){return this.request(e,t,void 0,r,"get")}async post(e,t,r,n){return this.request(e,t,r,n,"post")}async delete(e,t,r,n){return this.request(e,t,r,n,"delete")}async patch(e,t,r,n){return this.request(e,t,r,n,"patch")}async put(e,t,r,n){return this.request(e,t,r,n,"put")}async request(e,t,r,n,i){const o={integrationId:e,endpointId:t,body:r,options:{...pe,...this.convertOptionsToStrings(n||{})},overrideMethod:i};return await this.rpcManager.rawPost("api/callApi",o,void 0,void 0,!1)}convertOptionsToStrings(e){return{headers:this.convertToStrings(e.headers),queryParams:this.convertToStrings(e.queryParams),pathParams:this.convertToStrings(e.pathParams)}}convertToStrings(e){if(!e)return{};const t=Object.entries(e).filter((([,e])=>void 0!==e)).map((([e,t])=>[e,String(t)]));return Object.fromEntries(t)}}class be{constructor(e,t){this.apiKey=e,this.authProvider=t}setAuthProvider(e){this.authProvider=e}async getAuthData(){return{token:await this.getTokenFromAuthProvider(),integrationId:this.authProvider?.integrationId}}async getTokenFromAuthProvider(){const e=this.authProvider?.getToken();return"object"==typeof e?await e:e}getApiKey(){return this.apiKey}async getToken(){if(this.apiKey)return{type:"ApiKey",token:this.apiKey};const e=await this.getTokenFromAuthProvider();return e?{type:"Bearer",token:e,integrationId:this.authProvider?.integrationId}:void 0}}const ve=/[.\[\]]/;function ge(e,t){if(!e)return;const r=t.split(ve);let n,i=e;for(;i&&r.length;){const e=r.shift();if(e){if("object"!=typeof i||!(e in i))return;n=i[e],i=n}}return n}function me(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function _e(e,t,r,n="."){const i=t.split(n);let o=e;for(;i.length;){const e=(0,ie.truthy)(i.shift());if(i.length){const t=o[e],r=me(t)?Ae(t)??{}:{};o[e]=r,o=r}else o[e]=r}}function Se(e,t,r="."){const n=t.split(r);let i=e;for(;n.length;){const e=(0,ie.truthy)(n.shift());if(n.length){const t=me(i[e])?Ae(i[e])??{}:{};i[e]=t,i=t}else delete i[e]}}function Oe(e,t,r){if(e.has(t)){const n=e.get(t);e.delete(t),e.set(r,n)}}function we(e){return null==e}function Ie(e,t){if(e===t)return!0;if(null===e||null===t)return!1;const r=typeof e;if(r!==typeof t)return!1;if("object"!==r)return e===t;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const r of n)if(!i.includes(r)||!Ie(e[r],t[r]))return!1;return!0}function Me(e,t){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=Ee(e[n],t);return r}function Ee(e,t){const r=t?t(e):void 0;if(void 0!==r)return r;if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return Me(e,t);if(e instanceof Map)return new Map(Me(Array.from(e),t));if(e instanceof Set)return new Set(Me(Array.from(e),t));if(ArrayBuffer.isView(e))return(n=e)instanceof Buffer?Buffer.from(n):new n.constructor(n.buffer.slice(),n.byteOffset,n.length);var n;const i={};for(const r in e)Object.hasOwnProperty.call(e,r)&&(i[r]=Ee(e[r],t));return i}function Ae(e){return"object"!=typeof e||null===e?e:e instanceof Date?new Date(e):Array.isArray(e)?[...e]:e instanceof Map?new Map(Array.from(e)):e instanceof Set?new Set(Array.from(e)):{...e}}function Te(e,t){if(e===t||we(e)&&we(t))return 0;if(we(e))return-1;if(we(t))return 1;const r=typeof e,n=typeof t;return r!==n?r<n?-1:1:"number"==typeof e?((0,ie.assertTruthy)("number"==typeof t),isNaN(e)&&isNaN(t)?0:isNaN(e)?-1:isNaN(t)?1:e<t?-1:1):"boolean"==typeof e?((0,ie.assertTruthy)("boolean"==typeof t),e<t?-1:1):"bigint"==typeof e?((0,ie.assertTruthy)("bigint"==typeof t),e<t?-1:1):"string"==typeof e?((0,ie.assertTruthy)("string"==typeof t),e<t?-1:1):e instanceof Date&&t instanceof Date?Math.sign(e.getTime()-t.getTime()):0}function Fe(e,t){return e.reduce(((e,r)=>{const n=t(r);return e[n]?e[n].push(r):e[n]=[r],e}),{})}function je(e){if(Array.isArray(e))return e.map((e=>je(e)));if("object"!=typeof e||null===e||e instanceof Date)return e;const t=Object.keys(e),r={};return t.sort().forEach((t=>{r[t]=je(e[t])})),r}function Pe(e){return De(je(e))}function De(e){if(void 0===e)return null;const t=Ee(e,(e=>function(e){return"[object Date]"===Object.prototype.toString.call(e)}(e)?{$date:e.toISOString()}:void 0));return JSON.stringify(t)}function ke(e){return Ee(JSON.parse(e),(e=>{if(null===e||"object"!=typeof e)return;const t=e,r=t.$date;return r&&1===Object.keys(t).length?new Date(r):void 0}))}function Ce(e){if(void 0===e)throw new Error("INVALID_ENCODE_VALUE");const t=De(e);if("undefined"!=typeof Buffer)return Buffer.from(t,"utf8").toString("base64");{const e=(new TextEncoder).encode(t);let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return btoa(r)}}class xe{constructor(e){this.rpcManager=e}executeFunctionAndSubscribe(e,...t){const r=[],n=[];let i=0;t.forEach((e=>{if("undefined"!=typeof File)if(e instanceof File){r.push(e);const t={type:"file",__squid_placeholder__:!0,fileIndex:i++};n.push(t)}else if(this.isArrayOfFiles(e)){const t={type:"fileArray",__squid_placeholder__:!0,fileIndexes:e.map(((t,n)=>(r.push(e[n]),i++)))};n.push(t)}else n.push(e);else n.push(e)}));const s={functionName:e,paramsArrayStr:De(n)},a=`backend-function/execute?${encodeURIComponent(e)}`;return(0,o.race)((0,o.from)(this.rpcManager.post(a,s,r.length>0?r:[])).pipe(j((e=>{if(!e.success)throw new Error(e.payload);return ke(e.payload)}))))}isArrayOfFiles(e){return"undefined"!=typeof File&&Array.isArray(e)&&e.every((e=>e instanceof File))}}function Re(){if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;if("undefined"!=typeof self)return self;throw new Error("Unable to locate global object")}!function(e=!0){Re().SQUID_LOG_DEBUG_ENABLED=e}(function(){let e="";return"undefined"!=typeof window&&window.location?e=new URLSearchParams(window.location.search).get("SQUID_DEBUG")||"":"undefined"!=typeof process&&process.env&&(e=process.env.SQUID_DEBUG||""),"1"===e||"true"===e}());class Ne{static debug(...e){(function(){const e=Re();return!0===e?.SQUID_LOG_DEBUG_ENABLED})()&&console.debug(`${function(){if(function(){const e=Re();return!0===e?.SQUID_LOG_TIMESTAMPS_DISABLED}()){const e=new Date;return`[${e.toLocaleTimeString()}.${e.getMilliseconds()}] squid`}return"squid"}()} DEBUG`,...e)}}class qe{constructor(e){this.destructManager=e,this.clientTooOldSubject=new o.BehaviorSubject(!1),this.isTenant=!0===Re().squidTenant,this.clientIdSubject=new o.BehaviorSubject(this.generateClientId()),this.destructManager.onDestruct((()=>{this.clientTooOldSubject.complete(),this.clientIdSubject.complete()}))}observeClientId(){return this.clientIdSubject}observeClientTooOld(){return this.clientTooOldSubject.pipe((0,o.filter)((e=>e)),(0,o.map)((()=>{})))}notifyClientTooOld(){this.clientTooOldSubject.next(!0),this.clientIdSubject.next(this.generateClientId())}notifyClientNotTooOld(){this.clientTooOldSubject.next(!1)}observeClientReadyToBeRegenerated(){return this.clientTooOldSubject.pipe((0,o.skip)(1),(0,o.filter)((e=>!e)),(0,o.map)((()=>{})))}getClientId(){return this.clientIdSubject.value}isClientTooOld(){return this.clientTooOldSubject.value}generateClientId(){const e=Re()[Le];if(e)return e();let t=`${this.isTenant?"tenant-":""}${oe()}`;return"object"==typeof navigator&&!0===navigator.userAgent?.toLowerCase()?.includes("playwright")&&(t=`e2e${t.substring(3)}`),t}generateClientRequestId(){const e=Re()[Be];return e?e():oe()}}const Le="SQUID_CLIENT_ID_GENERATOR",Be="SQUID_CLIENT_REQUEST_ID_GENERATOR";var Ue;function Qe(e){return!!e&&"object"==typeof e&&"__squid_placeholder__"in e}!function(e){e.EVERY_SECOND="* * * * * *",e.EVERY_5_SECONDS="*/5 * * * * *",e.EVERY_10_SECONDS="*/10 * * * * *",e.EVERY_30_SECONDS="*/30 * * * * *",e.EVERY_MINUTE="*/1 * * * *",e.EVERY_5_MINUTES="0 */5 * * * *",e.EVERY_10_MINUTES="0 */10 * * * *",e.EVERY_30_MINUTES="0 */30 * * * *",e.EVERY_HOUR="0 0-23/1 * * *",e.EVERY_2_HOURS="0 0-23/2 * * *",e.EVERY_3_HOURS="0 0-23/3 * * *",e.EVERY_4_HOURS="0 0-23/4 * * *",e.EVERY_5_HOURS="0 0-23/5 * * *",e.EVERY_6_HOURS="0 0-23/6 * * *",e.EVERY_7_HOURS="0 0-23/7 * * *",e.EVERY_8_HOURS="0 0-23/8 * * *",e.EVERY_9_HOURS="0 0-23/9 * * *",e.EVERY_10_HOURS="0 0-23/10 * * *",e.EVERY_11_HOURS="0 0-23/11 * * *",e.EVERY_12_HOURS="0 0-23/12 * * *",e.EVERY_DAY_AT_1AM="0 01 * * *",e.EVERY_DAY_AT_2AM="0 02 * * *",e.EVERY_DAY_AT_3AM="0 03 * * *",e.EVERY_DAY_AT_4AM="0 04 * * *",e.EVERY_DAY_AT_5AM="0 05 * * *",e.EVERY_DAY_AT_6AM="0 06 * * *",e.EVERY_DAY_AT_7AM="0 07 * * *",e.EVERY_DAY_AT_8AM="0 08 * * *",e.EVERY_DAY_AT_9AM="0 09 * * *",e.EVERY_DAY_AT_10AM="0 10 * * *",e.EVERY_DAY_AT_11AM="0 11 * * *",e.EVERY_DAY_AT_NOON="0 12 * * *",e.EVERY_DAY_AT_1PM="0 13 * * *",e.EVERY_DAY_AT_2PM="0 14 * * *",e.EVERY_DAY_AT_3PM="0 15 * * *",e.EVERY_DAY_AT_4PM="0 16 * * *",e.EVERY_DAY_AT_5PM="0 17 * * *",e.EVERY_DAY_AT_6PM="0 18 * * *",e.EVERY_DAY_AT_7PM="0 19 * * *",e.EVERY_DAY_AT_8PM="0 20 * * *",e.EVERY_DAY_AT_9PM="0 21 * * *",e.EVERY_DAY_AT_10PM="0 22 * * *",e.EVERY_DAY_AT_11PM="0 23 * * *",e.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",e.EVERY_WEEK="0 0 * * 7",e.EVERY_WEEKDAY="0 0 * * 1-5",e.EVERY_WEEKEND="0 0 * * 6,7",e.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",e.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",e.EVERY_2ND_HOUR="0 */2 * * *",e.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",e.EVERY_2ND_MONTH="0 0 1 */2 *",e.EVERY_QUARTER="0 0 1 */3 *",e.EVERY_6_MONTHS="0 0 1 */6 *",e.EVERY_YEAR="0 0 1 1 *",e.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",e.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",e.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",e.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",e.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",e.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",e.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",e.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",e.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",e.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",e.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",e.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",e.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",e.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",e.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",e.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",e.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",e.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",e.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",e.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",e.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",e.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",e.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",e.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",e.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",e.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",e.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",e.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5"}(Ue||(Ue={}));const $e={CONTINUE:100,SWITCHING_PROTOCOLS:101,PROCESSING:102,EARLY_HINTS:103,OK:200,CREATED:201,ACCEPTED:202,NON_AUTHORITATIVE_INFORMATION:203,NO_CONTENT:204,RESET_CONTENT:205,PARTIAL_CONTENT:206,MULTI_STATUS:207,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,MOVED_TEMPORARILY:302,SEE_OTHER:303,NOT_MODIFIED:304,USE_PROXY:305,TEMPORARY_REDIRECT:307,PERMANENT_REDIRECT:308,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,REQUEST_TOO_LONG:413,REQUEST_URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,REQUESTED_RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,IM_A_TEAPOT:418,INSUFFICIENT_SPACE_ON_RESOURCE:419,METHOD_FAILURE:420,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,INSUFFICIENT_STORAGE:507,NETWORK_AUTHENTICATION_REQUIRED:511},Ve="ai_agents",Ye=["active_directory","ai_agents","ai_chatbot","algolia","alloydb","api","auth0","azure_cosmosdb","azure_postgresql","azure_sql","bigquery","built_in_db","built_in_gcs","built_in_queue","built_in_s3","cassandra","clickhouse","cloudsql","cockroach","cognito","confluence","confluent","datadog","db2","descope","documentdb","dynamodb","elastic_enterprise_search","elastic_observability","elastic_search","firebase_auth","firestore","gcs","google_docs","google_drive","graphql","hubspot","jira","jwt_hmac","jwt_rsa","kafka","linear","mariadb","monday","mongo","mssql","mysql","newrelic","okta","onedrive","oracledb","pinecone","postgres","redis","s3","salesforce_crm","sap_hana","sentry","servicenow","snowflake","spanner","xata","zendesk","mail","slack"],We=["bigquery","built_in_db","clickhouse","cockroach","mongo","mssql","mysql","oracledb","postgres","sap_hana","snowflake"],He=["auth0","jwt_rsa","jwt_hmac","cognito","okta","descope","firebase_auth"],ze=["graphql","linear"],Ge=["api","confluence"],Je=["data","api","graphql"],Ke="built_in_db",Ze="built_in_queue",Xe="built_in_storage",et=["secret","regular"],tt=["squid_functionExecution_count","squid_functionExecution_time"],rt=["sum","max","min","average","median","p95","p99","count"],nt=["user","squid"],it=["align-by-start-time","align-by-end-time"],ot=["insert","update","delete"];function st(e){return"fieldName"in e}const at=["in","not in","array_includes_some","array_includes_all","array_not_includes"],ut=[...at,"==","!=",">=","<=",">","<","like","not like","like_cs","not like_cs"],ct=["us-east-1.aws","ap-south-1.aws","us-central1.gcp"],lt=["CONNECTED","DISCONNECTED","REMOVED"],dt="__squidId";function ht(e){return ke(e)}function ft(...e){const[t,r,n]=e,i="object"==typeof t?t:{docId:t,collectionName:r,integrationId:n};return i.integrationId||(i.integrationId=void 0),Pe(i)}class pt{constructor(e,t,r){this._squidDocId=e,this.dataManager=t,this.queryBuilderFactory=r,this.refId=oe()}get squidDocId(){return this._squidDocId}get data(){return Ee(this.dataRef)}get dataRef(){return(0,ie.truthy)(this.dataManager.getProperties(this.squidDocId),(()=>{const{collectionName:e,integrationId:t,docId:r}=ht(this.squidDocId);return`No data found for document reference: ${JSON.stringify({docId:r,collectionName:e,integrationId:t},null,2)}`}))}get hasData(){return!!this.dataManager.getProperties(this.squidDocId)}async snapshot(){if(this.hasSquidPlaceholderId())throw new Error("Cannot invoke snapshot of a document that was created locally without storing it on the server.");if(this.isTracked()&&this.hasData)return this.data;const e=await this.queryBuilderFactory.getForDocument(this.squidDocId).dereference().snapshot();return(0,ie.truthy)(e.length<=1,"Got more than one doc for the same id:"+this.squidDocId),e.length?e[0]:void 0}snapshots(){return this.queryBuilderFactory.getForDocument(this.squidDocId).dereference().snapshots().pipe((0,o.map)((e=>((0,ie.truthy)(e.length<=1,"Got more than one doc for the same id:"+this.squidDocId),e.length?e[0]:void 0))))}peek(){return this.isTracked()&&this.hasData?this.data:void 0}isDirty(){return this.dataManager.isDirty(this.squidDocId)}isTracked(){return this.dataManager.isTracked(this.squidDocId)}async update(e,t){const r={};Object.entries(e).forEach((([e,t])=>{const n=void 0!==t?{type:"update",value:t}:{type:"removeProperty"};r[e]=[n]}));const n={type:"update",squidDocIdObj:ht(this.squidDocId),properties:r};return this.dataManager.applyOutgoingMutation(n,t)}async setInPath(e,t,r){return this.update({[e]:Ee(t)},r)}async deleteInPath(e,t){return this.update({[e]:void 0},t)}incrementInPath(e,t,r){const n={type:"applyNumericFn",fn:"increment",value:t},i={type:"update",squidDocIdObj:ht(this.squidDocId),properties:{[e]:[n]}};return this.dataManager.applyOutgoingMutation(i,r)}decrementInPath(e,t,r){return this.incrementInPath(e,-t,r)}async insert(e,t){const r=ht(this.squidDocId),n=r.integrationId;let i=ke(r.docId);if(i[dt]&&(i={}),n===Ke&&i.__id)try{const e=ke(i.__id);i={...i,...e}}catch{}const o={type:"insert",squidDocIdObj:r,properties:{...e,__docId__:r.docId,...i}};return this.dataManager.applyOutgoingMutation(o,t)}async delete(e){const t={type:"delete",squidDocIdObj:ht(this.squidDocId)};return this.dataManager.applyOutgoingMutation(t,e)}migrateDocIds(e){const t=e[this.squidDocId];t&&(this._squidDocId=t)}hasSquidPlaceholderId(){const e=ke(this._squidDocId);if("object"==typeof e&&e.docId){const t=ke(e.docId);if("object"==typeof t&&Object.keys(t).includes(dt))return!0}return!1}}Error;class yt{constructor(e,t={}){this.internalStateObserver=new o.BehaviorSubject(null),this.firstElement=null,this.isDestroyed=new o.BehaviorSubject(!1),this.snapshotSubject=new o.Subject,this.onFirstPage=!0,this.navigatingToLastPage=!1,this.lastElement=null,(0,ie.assertTruthy)(e.getSortOrders().length>0,"Unable to paginate results. Please specify a sort order."),this.snapshotSubject.pipe((0,o.switchAll)()).subscribe((e=>this.dataReceived(e))),this.templateSnapshotEmitter=e.clone(),this.paginateOptions={pageSize:100,subscribe:!0,...t},this.goToFirstPage()}goToFirstPage(){this.onFirstPage=!0;const e=this.templateSnapshotEmitter.clone().limit(3*this.paginateOptions.pageSize).snapshots(this.paginateOptions.subscribe);this.snapshotSubject.next(e)}compareObjects(e,t){if(e===t||we(e)&&we(t))return 0;if(we(e))return-1;if(we(t))return 1;const r=this.templateSnapshotEmitter.getSortOrders();for(const{fieldName:n,asc:i}of r){const r=Te(ge(e,n),ge(t,n));if(0!==r)return i?r:-r}return 0}async dataReceived(e){const t=e.map((e=>this.templateSnapshotEmitter.extractData(e)));if(0===e.length)return void(this.onFirstPage?this.internalStateObserver.next({numBefore:0,numAfter:0,data:e,extractedData:t}):this.goToFirstPage());if(null===this.firstElement)if(null!==this.lastElement){const r=t.filter((e=>1===this.compareObjects(e,this.lastElement))).length;this.firstElement=t[e.length-r-this.paginateOptions.pageSize],this.lastElement=null}else this.navigatingToLastPage&&(this.firstElement=t[e.length-this.paginateOptions.pageSize],this.navigatingToLastPage=!1);const r=t.filter((e=>-1===this.compareObjects(e,this.firstElement))).length,n=Math.max(0,e.length-r-this.paginateOptions.pageSize);r!==e.length?this.internalStateObserver.next({numBefore:r,numAfter:n,data:e,extractedData:t}):this.prevInternal({numBefore:r,numAfter:n,data:e,extractedData:t})}doNewQuery(e,t){if(this.onFirstPage=!1,t){const t=this.templateSnapshotEmitter.clone().limit(3*this.paginateOptions.pageSize).flipSortOrder();e&&t.addCompositeCondition(this.templateSnapshotEmitter.getSortOrders().map((t=>({fieldName:t.fieldName,operator:t.asc?"<=":">=",value:ge(e,t.fieldName)||null})))),this.snapshotSubject.next(t.snapshots(this.paginateOptions.subscribe).pipe((0,o.map)((e=>e.reverse()))))}else{const t=this.templateSnapshotEmitter.clone().limit(3*this.paginateOptions.pageSize);e&&t.addCompositeCondition(this.templateSnapshotEmitter.getSortOrders().map((t=>({fieldName:t.fieldName,operator:t.asc?">=":"<=",value:ge(e,t.fieldName)||null})))),this.snapshotSubject.next(t.snapshots(this.paginateOptions.subscribe))}}async waitForInternalState(){const e=this.internalStateObserver.value;return null!==e?e:await(0,o.firstValueFrom)((0,o.race)(this.isDestroyed.pipe((0,o.filter)(Boolean),(0,o.map)((()=>({data:[],extractedData:[],numBefore:0,numAfter:0})))),this.internalStateObserver.pipe((0,o.filter)((e=>null!==e)),(0,o.take)(1))))}internalStateToState(e){const{data:t,numBefore:r,numAfter:n,extractedData:i}=e;return{data:t.filter(((e,t)=>-1!==this.compareObjects(i[t],this.firstElement))).slice(0,this.paginateOptions.pageSize),hasNext:n>0,hasPrev:r>0}}unsubscribe(){this.isDestroyed.next(!0),this.isDestroyed.complete(),this.internalStateObserver.complete(),this.snapshotSubject.complete()}prevInternal(e){const{numBefore:t,numAfter:r,extractedData:n}=e;this.firstElement=null,this.lastElement=n[t-1],this.internalStateObserver.next(null),this.doNewQuery(n[n.length-r-1],!0)}async prev(){return this.prevInternal(await this.waitForInternalState()),await this.waitForData()}async next(){const{numBefore:e,extractedData:t}=await this.waitForInternalState();return e+this.paginateOptions.pageSize<t.length&&(this.firstElement=t[e+this.paginateOptions.pageSize]),this.internalStateObserver.next(null),this.doNewQuery(t[e],!1),await this.waitForData()}async waitForData(){return this.internalStateToState(await this.waitForInternalState())}observeState(){return this.internalStateObserver.pipe((0,o.filter)((e=>null!==e)),(0,o.map)((e=>this.internalStateToState(e))))}async first(){return await this.waitForInternalState(),this.internalStateObserver.next(null),this.firstElement=null,this.lastElement=null,this.goToFirstPage(),await this.waitForData()}async refreshPage(){const{extractedData:e}=await this.waitForInternalState();return this.internalStateObserver.next(null),this.onFirstPage?this.goToFirstPage():this.doNewQuery(e[0],!1),await this.waitForData()}async last(){await this.waitForInternalState(),this.internalStateObserver.next(null),this.firstElement=null,this.lastElement=null,this.navigatingToLastPage=!0;const e=this.templateSnapshotEmitter.clone().limit(3*this.paginateOptions.pageSize).flipSortOrder().snapshots(this.paginateOptions.subscribe).pipe((0,o.map)((e=>e.reverse())));return this.snapshotSubject.next(e),await this.waitForData()}}class bt{constructor(e,t,r,n){this.querySubscriptionManager=e,this.localQueryManager=t,this.documentReferenceFactory=r,this.documentIdentityService=n}getForDocument(e){const{collectionName:t,integrationId:r,docId:n}=ht(e),i=ke(n),o=this.get(t,r);for(const[e,t]of Object.entries(i))o.where(e,"==",t);return o}get(e,t){return new mt(e,t,this.querySubscriptionManager,this.localQueryManager,this.documentReferenceFactory,this,this.documentIdentityService)}}class vt{constructor(){this.containsEmptyInCondition=!1}eq(e,t){return this.where(e,"==",t)}neq(e,t){return this.where(e,"!=",t)}in(e,t){return this.where(e,"in",t)}nin(e,t){return this.where(e,"not in",t)}gt(e,t){return this.where(e,">",t)}gte(e,t){return this.where(e,">=",t)}lt(e,t){return this.where(e,"<",t)}lte(e,t){return this.where(e,"<=",t)}like(e,t,r){return this.throwIfInvalidLikePattern(t),this.where(e,r?"like_cs":"like",t)}notLike(e,t,r){return this.throwIfInvalidLikePattern(t),this.where(e,r?"not like_cs":"not like",t)}arrayIncludesSome(e,t){return this.where(e,"array_includes_some",t)}arrayIncludesAll(e,t){return this.where(e,"array_includes_all",t)}arrayNotIncludes(e,t){return this.where(e,"array_not_includes",t)}throwIfInvalidLikePattern(e){if(/\\(?![%_\\])/.test(e))throw new Error("Invalid pattern. Cannot have any \\ which are not followed by _, % or \\")}}class gt{constructor(e){this.queryBuilder=e}peek(){return this.queryBuilder.peek().map((e=>e.data))}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1).pipe((0,o.defaultIfEmpty)([])))}snapshots(e){return this.queryBuilder.snapshots(e).pipe(j((e=>e.map((e=>e.data)))))}getSortOrders(){return this.queryBuilder.getSortOrders()}clone(){return new gt(this.queryBuilder.clone())}addCompositeCondition(e){return this.queryBuilder.addCompositeCondition(e),this}limit(e){return this.queryBuilder.limit(e),this}getLimit(){return this.queryBuilder.getLimit()}flipSortOrder(){return this.queryBuilder.flipSortOrder(),this}extractData(e){return e}serialize(){return{...this.queryBuilder.serialize(),dereference:!0}}paginate(e){return new yt(this,e)}}class mt extends vt{constructor(e,t,r,n,i,o,s){super(),this.collectionName=e,this.integrationId=t,this.querySubscriptionManager=r,this.localQueryManager=n,this.documentReferenceFactory=i,this.queryBuilderFactory=o,this.documentIdentityService=s,this.forceFetchFromServer=!1,this.query={integrationId:t,collectionName:e,conditions:[],limit:-1,sortOrder:[]}}where(e,t,r){if((0,ie.assertTruthy)(ut.includes(t),`Invalid operator: ${t}`),(0,ie.assertTruthy)(void 0!==r,"Condition value cannot be undefined"),"in"===t||"not in"===t){const n=Array.isArray(r)?[...r]:[r];"in"===t&&0===n.length&&(this.containsEmptyInCondition=!0);for(const r of n)this.query.conditions.push({fieldName:e,operator:"in"===t?"==":"!=",value:r});return this}return this.query.conditions.push({fieldName:e,operator:t,value:r}),this}limit(e){return function(e){(0,ie.assertNumber)(e,"Limit needs to be a number"),-1!==e&&((0,ie.assertTruthy)(e>0,"query limit has to be greater than 0"),(0,ie.assertTruthy)(Math.floor(e)===e,"query limit has to be an integer"),(0,ie.assertTruthy)(e<=2e4,"Limit can be maximum 20000"))}(e),this.query.limit=e,this}getLimit(){return this.query.limit}limitBy(e,...t){const r=this.query.sortOrder.map((e=>e.fieldName));return(0,ie.assertTruthy)(Ie(t.sort(),r.slice(0,t.length).sort()),"All fields in limitBy must be appear in the first fields in the sortBy list."),this.query.limitBy={limit:e,fields:t,reverseSort:!1},this}sortBy(e,t=!0){const r={asc:t,fieldName:e};return function(e){if(!(e instanceof Object))throw new Error("Field sort has to be an object");const t=e;var r,n,i,o;(0,ie.assertTruthy)((r=t,n=["fieldName","asc"],!Array.isArray(r)&&[...Object.keys(r)].every((e=>n.includes(e)))),"Field sort should only contain a fieldName and asc"),(0,ie.assertTruthy)((i=t.asc,o="boolean",Array.isArray(i)?i.every((e=>typeof e===o)):typeof i===o),"Asc needs to be boolean")}(r),(0,ie.assertTruthy)(!this.query.sortOrder.some((t=>t.fieldName===e)),`${e} already in the sort list.`),this.query.sortOrder.push(r),this}build(){const e=this.mergeConditions();return{...this.query,conditions:e}}mergeConditions(){const e=[],t=Fe(this.query.conditions.filter(st)||[],(e=>e.fieldName));for(const r of Object.values(t)){const t=Fe(r,(e=>e.operator));for(const[r,n]of Object.entries(t)){if("=="===r||"!="===r){e.push(...n);continue}const t=[...n];t.sort(((e,t)=>Te(e.value,t.value))),">"===r||">="===r?e.push(t[t.length-1]):e.push(t[0])}}return[...this.query.conditions.filter((e=>!st(e))),...e]}getSortOrder(){return this.query.sortOrder}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1).pipe((0,o.defaultIfEmpty)([])))}setForceFetchFromServer(){return this.forceFetchFromServer=!0,this}peek(){return this.localQueryManager.peek(this.build())}snapshots(e=!0){if(this.containsEmptyInCondition)return new o.BehaviorSubject([]);const t=this.build();return this.querySubscriptionManager.processQuery(t,this.collectionName,{},{},e,this.forceFetchFromServer).pipe(j((e=>e.map((e=>{(0,ie.assertTruthy)(1===Object.keys(e).length);const t=e[this.collectionName],r=ft((0,ie.truthy)(t).__docId__,this.collectionName,this.integrationId);return this.documentReferenceFactory.create(r,this.queryBuilderFactory)})))))}changes(){let e,t=new Set;return this.snapshots().pipe((0,o.combineLatestWith)(this.documentIdentityService.observeChanges().pipe((0,o.switchMap)((t=>(Object.entries(t).forEach((([t,r])=>{!function(e,t,r){const n=e[t];void 0!==n&&(e[r]=n,delete e[t])}(e||{},t,r)})),o.NEVER))),(0,o.startWith)({}))),j((([r])=>{let n=[];const i=[],o=[];if(e){for(const o of r){const r=o.squidDocId,s=o.dataRef;if(t.has(s))delete e[r],t.delete(s);else if(e[r]){i.push(o);const n=e[r];delete e[r],t.delete(n)}else n.push(o)}for(const e of t)o.push(e)}else n=r;e={},t=new Set;for(const n of r){const r=n.dataRef;e[n.squidDocId]=r,t.add(r)}return new _t(n,i,o)})))}get hash(){return Ce(this.build())}dereference(){return new gt(this)}getSortOrders(){return this.query.sortOrder}clone(){const e=new mt(this.collectionName,this.integrationId,this.querySubscriptionManager,this.localQueryManager,this.documentReferenceFactory,this.queryBuilderFactory,this.documentIdentityService);return e.query=Ee(this.query),e.containsEmptyInCondition=this.containsEmptyInCondition,e}addCompositeCondition(e){return e.length?(this.query.conditions.push({fields:e}),this):this}flipSortOrder(){return this.query.sortOrder=this.query.sortOrder.map((e=>({...e,asc:!e.asc}))),this.query.limitBy&&(this.query.limitBy.reverseSort=!this.query.limitBy.reverseSort),this}serialize(){return{type:"simple",dereference:!1,query:this.build()}}extractData(e){return e.dataRef}paginate(e){return new yt(this,e)}}class _t{constructor(e,t,r){this.inserts=e,this.updates=t,this.deletes=r}}class St extends vt{constructor(e,t,r,n,i,o,s,a,u,c,l){super(),this.collectionName=e,this.integrationId=t,this.querySubscriptionManager=r,this.documentReferenceFactory=n,this.queryBuilderFactory=i,this.rootAlias=o,this.latestAlias=s,this.leftToRight=a,this.joins=u,this.joinConditions=c,this.queryBuilder=l}where(e,t,r){return this.queryBuilder.where(e,t,r),this}limit(e){return this.queryBuilder.limit(e),this}getLimit(){return this.queryBuilder.getLimit()}sortBy(e,t=!0){return this.queryBuilder.sortBy(e,t),this}join(e,t,r,n){const i=n?.leftAlias??this.latestAlias,o={...r,leftAlias:i,isInner:n?.isInner??!1},s={...this.leftToRight,[t]:[]};return s[i].push(t),new St(this.collectionName,this.integrationId,this.querySubscriptionManager,this.documentReferenceFactory,this.queryBuilderFactory,this.rootAlias,t,s,{...this.joins,[t]:e.build()},{...this.joinConditions,[t]:o},this.queryBuilder)}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e=!0){return this.queryBuilder.containsEmptyInCondition?new o.BehaviorSubject([]):this.querySubscriptionManager.processQuery(this.build(),this.rootAlias,Ee(this.joins),Ee(this.joinConditions),e,!1).pipe(j((e=>e.map((e=>{const t={};for(const[r,n]of Object.entries(e)){const e=r===this.rootAlias?this.collectionName:this.joins[r].collectionName,i=r===this.rootAlias?this.integrationId:this.joins[r].integrationId,o=n?ft(n.__docId__,e,i):void 0;t[r]=o?this.documentReferenceFactory.create(o,this.queryBuilderFactory):void 0}return t})))))}peek(){throw new Error("peek is not currently supported for join queries")}grouped(){return new It(this)}dereference(){return new Ot(this)}build(){return this.queryBuilder.build()}getSortOrders(){return this.queryBuilder.getSortOrders()}clone(){return new St(this.collectionName,this.integrationId,this.querySubscriptionManager,this.documentReferenceFactory,this.queryBuilderFactory,this.rootAlias,this.latestAlias,Ee(this.leftToRight),Ee(this.joins),Ee(this.joinConditions),this.queryBuilder.clone())}addCompositeCondition(e){return this.queryBuilder.addCompositeCondition(e),this}flipSortOrder(){return this.queryBuilder.flipSortOrder(),this}extractData(e){return e[this.rootAlias].dataRef}serialize(){return{type:"join",grouped:!1,dereference:!1,root:{alias:this.rootAlias,query:this.build()},leftToRight:this.leftToRight,joins:this.joins,joinConditions:this.joinConditions}}paginate(e){if(this.hasIsInner())throw Error("Cannot paginate on joins when isInner is enabled.");return new yt(this,e)}hasIsInner(){return!!Object.values(this.joinConditions).find((e=>e.isInner))}}class Ot{constructor(e){this.joinQueryBuilder=e}grouped(){return this.joinQueryBuilder.grouped().dereference()}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e){return this.joinQueryBuilder.snapshots(e).pipe(j((e=>e.map((e=>function(e){const t={},r=Object.keys(e);for(const i of r){const r=e[i];t[i]=(n=r,n?.data)}var n;return t}(e))))))}peek(){throw new Error("peek is not currently supported for join queries")}getSortOrders(){return this.joinQueryBuilder.getSortOrders()}clone(){return new Ot(this.joinQueryBuilder.clone())}addCompositeCondition(e){return this.joinQueryBuilder.addCompositeCondition(e),this}flipSortOrder(){return this.joinQueryBuilder.flipSortOrder(),this}limit(e){return this.joinQueryBuilder.limit(e),this}extractData(e){return e[this.joinQueryBuilder.rootAlias]}paginate(e){if(this.joinQueryBuilder.hasIsInner())throw Error("Cannot paginate on joins when isInner is enabled.");return new yt(this,e)}serialize(){return{...this.joinQueryBuilder.serialize(),dereference:!0}}getLimit(){return this.joinQueryBuilder.getLimit()}}class wt{constructor(e){this.groupedJoin=e}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e){return this.groupedJoin.snapshots(e).pipe(j((e=>e.map((e=>this.dereference(e,this.groupedJoin.joinQueryBuilder.rootAlias))))))}peek(){throw new Error("peek is not currently supported for join queries")}dereference(e,t){const r=this.groupedJoin.joinQueryBuilder.leftToRight[t];if(r.length){const n={[t]:e[t].data};for(const t of r)n[t]=e[t].map((e=>this.dereference(e,t)));return n}return e.data}getSortOrders(){return this.groupedJoin.getSortOrders()}clone(){return new wt(this.groupedJoin.clone())}addCompositeCondition(e){return this.groupedJoin.addCompositeCondition(e),this}flipSortOrder(){return this.groupedJoin.flipSortOrder(),this}limit(e){return this.groupedJoin.limit(e),this}getLimit(){return this.groupedJoin.getLimit()}extractData(e){return e[this.groupedJoin.joinQueryBuilder.rootAlias]}serialize(){return{...this.groupedJoin.joinQueryBuilder.serialize(),dereference:!0,grouped:!0}}paginate(e){if(this.groupedJoin.joinQueryBuilder.hasIsInner())throw Error("Cannot paginate on joins when isInner is enabled.");return new yt(this,e)}}class It{constructor(e){this.joinQueryBuilder=e}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e){return this.joinQueryBuilder.snapshots(e).pipe(j((e=>this.groupData(e,this.joinQueryBuilder.rootAlias))))}peek(){throw new Error("peek is not currently supported for join queries")}dereference(){return new wt(this)}groupData(e,t){const r=Fe(e,(e=>e[t]?.squidDocId));return Object.values(r).filter((e=>void 0!==e[0][t])).map((e=>{const r=this.joinQueryBuilder.leftToRight[t],n=e[0][t];if(0===r.length)return n;const i={[t]:n};for(const t of r)i[t]=this.groupData(e,t);return i}))}getSortOrders(){return this.joinQueryBuilder.getSortOrders()}clone(){return new It(this.joinQueryBuilder.clone())}addCompositeCondition(e){return this.joinQueryBuilder.addCompositeCondition(e),this}flipSortOrder(){return this.joinQueryBuilder.flipSortOrder(),this}limit(e){return this.joinQueryBuilder.limit(e),this}getLimit(){return this.joinQueryBuilder.getLimit()}extractData(e){return Object.keys(this.joinQueryBuilder.leftToRight).length>1?e[this.joinQueryBuilder.rootAlias].dataRef:e.dataRef}serialize(){return{...this.joinQueryBuilder.serialize(),grouped:!0}}paginate(e){if(this.joinQueryBuilder.hasIsInner())throw Error("Cannot paginate on joins when isInner is enabled.");return new yt(this,e)}}function Mt(e,t,r){if(e=e instanceof Date?e.getTime():e??null,t=t instanceof Date?t.getTime():t??null,"=="===r)return Ie(e,t);if("!="===r)return!Ie(e,t);switch(r){case"<":return!we(e)&&(!!we(t)||t<e);case"<=":return!!we(t)||!we(e)&&t<=e;case">":return!we(t)&&(!!we(e)||t>e);case">=":return!!we(e)||!we(t)&&t>=e;case"like":return"string"==typeof t&&"string"==typeof e&&Et(t,e,!1);case"not like":return!("string"==typeof t&&"string"==typeof e&&Et(t,e,!1));case"like_cs":return"string"==typeof t&&"string"==typeof e&&Et(t,e,!0);case"not like_cs":return!("string"==typeof t&&"string"==typeof e&&Et(t,e,!0));case"array_includes_some":{const r=t;return Array.isArray(t)&&Array.isArray(e)&&e.some((e=>(0,ie.truthy)(r,"VALUE_CANNOT_BE_NULL").some((t=>Ie(t,e)))))}case"array_includes_all":{const r=t;return Array.isArray(e)&&Array.isArray(t)&&e.every((e=>(0,ie.truthy)(r,"VALUE_CANNOT_BE_NULL").some((t=>Ie(t,e)))))}case"array_not_includes":{const r=t;return Array.isArray(t)&&Array.isArray(e)&&e.every((e=>!(0,ie.truthy)(r,"VALUE_CANNOT_BE_NULL").some((t=>Ie(t,e)))))}default:throw new Error(`Unsupported operator comparison: ${r}`)}}function Et(e,t,r){r||(e=e.toLowerCase(),t=t.toLowerCase());const n=function(e){let t="";for(let r=0;r<e.length;++r)"\\"===e[r]?r+1<e.length&&["%","_"].includes(e[r+1])?(t+=e[r+1],r++):r+1<e.length&&"\\"===e[r+1]?(t+="\\\\",r++):t+="\\":"%"===e[r]?t+="[\\s\\S]*":"_"===e[r]?t+="[\\s\\S]":("/-\\^$*+?.()[]{}|".includes(e[r])&&(t+="\\"),t+=e[r]);return t}(t);return new RegExp(`^${n}$`).test(e)}function At(e,t){return`${e}_${t}`}class Tt{constructor(e,t,r,n,i,o){this.collectionName=e,this.integrationId=t,this.documentReferenceFactory=r,this.queryBuilderFactory=n,this.querySubscriptionManager=i,this.dataManager=o,this.refId=oe()}doc(e){if(e&&"string"!=typeof e&&"object"!=typeof e&&!Array.isArray(e))throw new Error("Invalid doc id. Can be only object or string.");if(this.integrationId!==Ke)if(e){if("object"!=typeof e)throw new Error("Invalid doc id. String doc ids are only supported for the built_in_db integration. For all other integrations, the doc id must be an object.")}else e={[dt]:oe()};else e=e&&"string"!=typeof e?{__id:Pe(e)}:{__id:e||oe()};const t=ft(Pe(e),this.collectionName,this.integrationId);return this.documentReferenceFactory.create(t,this.queryBuilderFactory)}async insertMany(e,t){0!==e.length&&await this.dataManager.runInTransaction((async t=>{for(const r of e)await this.doc(r.id).insert(r.data,t)}),t)}async deleteMany(e,t){0!==e.length&&await this.dataManager.runInTransaction((async t=>{for(const r of e)r instanceof pt?await r.delete(t):await this.doc(r).delete(t)}),t)}query(){return this.queryBuilderFactory.get(this.collectionName,this.integrationId)}joinQuery(e){return new St(this.collectionName,this.integrationId,this.querySubscriptionManager,this.documentReferenceFactory,this.queryBuilderFactory,e,e,{[e]:[]},{},{},this.query())}or(...e){return new Ft(...e)}}class Ft{constructor(...e){if(0===e.length)throw new Error("At least one query builder must be provided");this.snapshotEmitters=e.map((e=>e.clone()));const t=Math.max(...this.snapshotEmitters.map((e=>{const t=e.getLimit();return-1===t?1e3:t})));this.snapshotEmitters.forEach((e=>e.limit(t)));const r=this.snapshotEmitters[0].getSortOrders();for(const e of this.snapshotEmitters){const t=e.getSortOrders();if(t.length!==r.length)throw new Error("All the queries must have the same sort order");for(let e=0;e<r.length;e++)if(t[e].fieldName!==r[e].fieldName||t[e].asc!==r[e].asc)throw new Error("All the queries must have the same sort order")}}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e=!0){const t=this.snapshotEmitters.map((t=>t.snapshots(e)));return this.or(this.snapshotEmitters[0].getSortOrders(),...t)}peek(){throw new Error("peek is not currently supported for merged queries")}or(e,...t){return(0,o.combineLatest)([...t]).pipe((0,o.map)((t=>{const r=new Set,n=t.flat(),i=[];for(const e of n)r.has(this.extractData(e))||(r.add(this.extractData(e)),i.push(e));return i.sort(((t,r)=>{for(const{fieldName:n,asc:i}of e){const e=ge(this.extractData(t),n),o=ge(this.extractData(r),n);if(!Mt(e,o,"=="))return Mt(o,e,"<")?i?-1:1:i?1:-1}return 0})).slice(0,this.getLimit())})))}clone(){return new Ft(...this.snapshotEmitters.map((e=>e.clone())))}getSortOrders(){return this.snapshotEmitters[0].getSortOrders()}addCompositeCondition(e){for(const t of this.snapshotEmitters)t.addCompositeCondition(e);return this}limit(e){return this.snapshotEmitters.forEach((t=>t.limit(e))),this}getLimit(){return this.snapshotEmitters[0].getLimit()}flipSortOrder(){return this.snapshotEmitters.forEach((e=>e.flipSortOrder())),this}serialize(){return{type:"merged",queries:this.snapshotEmitters.map((e=>e.serialize()))}}extractData(e){return this.snapshotEmitters[0].extractData(e)}paginate(e){return new yt(this,e)}}class jt{constructor(e,t,r,n){this.documentReferenceFactory=e,this.queryBuilderFactory=t,this.querySubscriptionManager=r,this.dataManager=n,this.collections=new Map}get(e,t){let r=this.collections.get(t);r||(r=new Map,this.collections.set(t,r));let n=r.get(e);return n||(n=new Tt(e,t,this.documentReferenceFactory,this.queryBuilderFactory,this.querySubscriptionManager,this.dataManager),r.set(e,n)),n}}class Pt{constructor(e,t){this.clientIdService=e,this.socketManager=t,this.isConnected=!1,this.socketManager.observeConnectionReady().subscribe((e=>{this.isConnected=e}))}get connected(){return this.isConnected}get clientId(){return this.clientIdService.getClientId()}observeConnected(){return this.socketManager.observeConnectionReady()}}var Dt=r(5150);function kt(e,t){switch(t.type){case"applyNumericFn":return function(e,t){if("increment"===t.fn)return null==e?t.value:e+t.value;throw new Error("Unknown numeric function: "+JSON.stringify(t))}(e,t);case"applyStringFn":return function(e,t){switch(t.fn){case"trim":return"string"!=typeof e?e:e.trim();case"extendString":return null==e?t.value:e+t.value;default:throw new Error("Unknown string function: "+JSON.stringify(t))}}(e,t);case"update":return"object"==typeof t.value?Ee(t.value):t.value;case"removeProperty":return;default:throw new Error("Unknown property mutation type: "+JSON.stringify(t))}}function Ct(e){return Object.entries(e.properties).sort((([e],[t])=>e.split(".").length-t.split(".").length))}function xt(e,t){if("insert"===t.type)return t;if("delete"===t.type)return t;if("delete"===e.type)return e;if((0,ie.assertTruthy)("update"===t.type,"Invalid mutation type"),"update"===e.type)return function(e,t){const r=Ee(e);t=Ee(t);for(const[e]of Ct(r)){const n=e.split(".").length;Object.entries(t.properties).some((([t])=>e.startsWith(t+".")&&n>t.split(".").length))&&delete r.properties[e]}for(const[e,n]of Ct(t))r.properties[e]=Rt([...r.properties[e]||[],...n]);return r}(e,t);const r=Ee(e);for(const[e,n]of Ct(t)){const t=n;for(const n of t){const t=kt(ge(r.properties,e),n);void 0===t?Se(r.properties,e):_e(r.properties,e,t)}}return r}function Rt(e){let t=0;for(;t+1<e.length;){const i=(r=e[t],"removeProperty"===(n=e[t+1]).type||"update"===n.type?n:"applyNumericFn"===n.type?((0,ie.assertTruthy)("increment"===n.fn,"Unrecognized applyNumericFn"),"applyNumericFn"===r.type?((0,ie.assertTruthy)("increment"===r.fn,"Unrecognized applyNumericFn"),{type:"applyNumericFn",fn:"increment",value:r.value+n.value}):"update"===r.type?{type:"update",value:r.value+n.value}:n):"extendString"===n.fn?"update"===r.type?{type:"update",value:r.value+n.value}:"applyStringFn"===r.type?"trim"===r.fn?null:{type:"applyStringFn",fn:"extendString",value:r.value+n.value}:n:null);i?e.splice(t,2,i):++t}var r,n;return e}function Nt(e){const t={};for(const r of e){const e=`${r.squidDocIdObj.integrationId}/${r.squidDocIdObj.collectionName}/${r.squidDocIdObj.docId}`;t[e]||(t[e]=[]),t[e].push(r)}const r=[];for(const e in t){const n=t[e].reduce(((e,t)=>(0,ie.truthy)(xt(e,t),"Merge result cannot be null")));r.push(n)}return r}const qt="dataManager_runInTransaction";class Lt{constructor(e,t,r,n,i,s,a,u,c){this.documentStore=e,this.mutationSender=t,this.socketManager=r,this.querySubscriptionManager=n,this.queryBuilderFactory=i,this.lockManager=s,this.destructManager=a,this.documentIdentityService=u,this.querySender=c,this.docIdToLocalTimestamp=new Map,this.batchClientRequestIds=new Set,this.docIdToServerTimestamp=new Map,this.pendingIncomingUpdates=new Map,this.pendingOutgoingMutations=new Map,this.pendingOutgoingMutationsChanged=new o.Subject,this.outgoingMutationsEmpty=new o.BehaviorSubject(!0),this.knownDirtyDocs=new Set,this.failedDocsToResync=[],this.refreshDocIdToTimestamp=new Map,this.handleIncomingMessagesForTests=!0,this.destructManager.onDestruct((()=>{this.destruct()})),this.documentIdentityService.observeChanges().subscribe(this.migrateDocIds.bind(this)),this.handleNotifications(),this.startDeleteExpiredTimestampsJob(),this.handleOrphanDocs(),this.outgoingMutationsEmpty.subscribe((e=>{this.querySender.safeToSendQueriesToServer.next(e)}))}getProperties(e){return this.documentStore.getDocumentOrUndefined(e)}isDirty(e){if(this.knownDirtyDocs.has(e))return!0;if(this.pendingOutgoingMutations.get(e)?.length)return!0;const t=this.docIdToServerTimestamp.get(e),r=t&&!t.expireTimestamp?t.timestamp:void 0,n=this.docIdToLocalTimestamp.get(e);return!((!n||r)&&!this.isForgotten(e)&&!this.isLocalOnly(e)&&n===r)}async runInTransaction(e,t){if(t)return(0,ie.assertTruthy)(t===this.currentTransactionId,(()=>`Invalid transaction ID: ${t}`)),e(t).then((e=>Promise.resolve(e)));this.lockManager.canGetLock(qt)?this.lockManager.lockSync(qt):await this.lockManager.lock(qt);let r=Bt;const n=()=>r!==Bt;return new Promise((async(t,i)=>{try{let o;this.currentTransactionId=oe();try{o=await e(this.currentTransactionId)}catch(e){r=e}finally{this.finishTransaction(n()?void 0:{resolve:()=>t(o),reject:i})}}catch(e){r=n()?r:e}finally{try{this.lockManager.release(qt)}catch(e){r=n()?r:e}}n()&&i(r)}))}async applyOutgoingMutation(e,t){const r=ft(e.squidDocIdObj);this.knownDirtyDocs.add(r),t||this.lockManager.canGetLock(qt)||(await this.lockManager.lock(qt),this.lockManager.release(qt)),this.knownDirtyDocs.delete(r);const n=this.pendingOutgoingMutations.get(r)?.slice(-1)[0];if(n&&!n.sentToServer)n.mutation=(0,ie.truthy)(Nt([n.mutation,this.removeInternalProperties(e)])[0],"Failed to reduce mutations"),this.outgoingMutationsEmpty.next(!1);else{const t={mutation:this.removeInternalProperties(e),sentToServer:!1},n=this.pendingOutgoingMutations.get(r)||[];n.push(t),this.pendingOutgoingMutations.set(r,n),this.outgoingMutationsEmpty.next(!1),this.pendingOutgoingMutationsChanged.next()}return this.runInTransaction((async()=>{const t=this.documentStore.getDocumentOrUndefined(r),n="delete"===e.type?void 0:"update"===e.type?function(e,t){if(!e)return;const r={...e},n=Ct(t);for(const[e,t]of n){const n=t;for(const t of n){const n=kt(ge(r,e),t);void 0===n?Se(r,e):_e(r,e,n)}}return r}(t,e):{...e.properties};this.updateDocumentFromSnapshot(r,n)&&("insert"===e.type&&this.docIdToLocalTimestamp.set(r,(new Date).getTime()),this.querySubscriptionManager.setClientRequestIdsForLocalDoc(r,n).forEach((e=>this.batchClientRequestIds.add(e))))}),t)}async runInTransactionSync(e,t){if(t)return(0,ie.assertTruthy)(t===this.currentTransactionId,(()=>`Invalid transaction ID: ${t}`)),void e(t);await this.lockManager.lock(qt);try{this.currentTransactionId=oe();try{return e(this.currentTransactionId)}catch(e){console.error("error while executing callback function in transaction",e)}finally{this.finishTransaction()}}catch(e){console.error("error while executing transaction",e)}finally{this.lockManager.release(qt)}}removeInternalProperties(e){if("delete"===e.type)return e;const t={...e,properties:{...e.properties}};return delete t.properties.__docId__,delete t.properties.__ts__,t}handleNotifications(){this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"mutations"===e.type)),j((e=>e))).subscribe((e=>{this.outgoingMutationsEmpty.pipe((0,o.filter)(Boolean),(0,o.take)(1)).subscribe((()=>{this.handleIncomingMutations(e.payload)}))})),this.querySubscriptionManager.observeQueryResults().subscribe((e=>{this.outgoingMutationsEmpty.pipe((0,o.filter)(Boolean),(0,o.take)(1)).subscribe((()=>{this.handleIncomingQuerySnapshots(e)}))}))}handleIncomingMutations(e){if(!this.handleIncomingMessagesForTests)return;const t=e.reduce(((e,t)=>this.querySubscriptionManager.hasOngoingQuery(t.clientRequestId)?(e[t.squidDocId]={properties:t.doc,timestamp:t.mutationTimestamp},e):e),{});this.applyIncomingUpdates(t)}handleIncomingQuerySnapshots(e){if(!this.handleIncomingMessagesForTests)return;if(!this.querySubscriptionManager.hasOngoingQuery(e.clientRequestId))return;const t=this.querySubscriptionManager.getQuery(e.clientRequestId),r={};for(const n of e.docs){const e=ft(n.__docId__,t.collectionName,t.integrationId);r[e]={properties:n,timestamp:n.__ts__}}this.runInTransactionSync((t=>{this.querySubscriptionManager.setGotInitialResult(e.clientRequestId),this.batchClientRequestIds.add(e.clientRequestId),this.applyIncomingUpdates(r,t)&&this.querySubscriptionManager.hasSubscription(e.clientRequestId)&&this.batchClientRequestIds.delete(e.clientRequestId)})).then()}applyIncomingUpdates(e,t){let r=!1;const n=new Set,i=new Set;for(const[t,o]of Object.entries(e)){const e=this.pendingIncomingUpdates.get(t),s=this.docIdToServerTimestamp.get(t);e&&e.timestamp>o.timestamp?r=!0:s&&s.timestamp>o.timestamp?i.add(t):(this.pendingIncomingUpdates.set(t,o),n.add(t))}return this.runInTransactionSync((()=>{for(const e of n)this.maybeApplyIncomingUpdate(e);for(const e of i)this.refreshQueryMapping(e)}),t).then(),r}maybeApplyIncomingUpdate(e){const t=this.pendingIncomingUpdates.get(e);if(!t)return;const r=this.pendingOutgoingMutations.get(e);r&&r.length||(this.updateDocumentFromSnapshot(e,t.properties),this.acknowledgeDocument(e,t.timestamp,!t.properties),this.docIdToLocalTimestamp.set(e,t.timestamp),this.pendingIncomingUpdates.delete(e),this.refreshQueryMapping(e))}refreshQueryMapping(e){const t=this.documentStore.getDocumentOrUndefined(e);this.querySubscriptionManager.setClientRequestIdsForLocalDoc(e,t).forEach((e=>{this.batchClientRequestIds.add(e)})),t&&(this.querySubscriptionManager.findQueriesForDocument(t,e).length||this.forgetDocument(e,!1))}destruct(){this.stopDeleteExpiredTimestampsJob()}stopDeleteExpiredTimestampsJob(){void 0!==this.deleteExpiredTimestampsInterval&&(clearInterval(this.deleteExpiredTimestampsInterval),this.deleteExpiredTimestampsInterval=void 0)}startDeleteExpiredTimestampsJob(){this.deleteExpiredTimestampsInterval=setInterval((()=>{const e=[...this.docIdToServerTimestamp.entries()].filter((([e,t])=>!(!t.expireTimestamp||t.expireTimestamp>Date.now()||this.isTracked(e))));for(const[t]of e)this.docIdToServerTimestamp.delete(t),this.forgetDocument(t,!0)}),1e4)}isTracked(e){if(this.pendingIncomingUpdates.get(e))return!0;const t=this.pendingOutgoingMutations.get(e);return!(!t||!t.length)||this.querySubscriptionManager.hasOngoingQueryForDocId(e)}isForgotten(e){return this.documentStore.hasData(e)&&!this.isTracked(e)}isLocalOnly(e){return!this.hasBeenAcknowledged(e)&&this.documentStore.hasData(e)}hasBeenAcknowledged(e){return this.docIdToServerTimestamp.has(e)}updateDocumentFromSnapshot(e,t){const r=this.documentStore.getDocumentOrUndefined(e);return!(!r&&!t||r===t)&&((!r||!t||Pe({...t,__ts__:void 0})!==Pe(r))&&(this.documentStore.saveDocument(e,t),!0))}finishTransaction(e){this.currentTransactionId=void 0;const t=[...this.batchClientRequestIds.values()];this.batchClientRequestIds.clear(),this.querySubscriptionManager.notifyAllSubscriptions(t),this.sendAllUnsentOutgoingMutations(e).then()}async sendAllUnsentOutgoingMutations(e){const t=this.groupOutgoingMutationsByIntegrationId();try{await Dt.PromisePool.for(t).withConcurrency(t.length||1).handleError((e=>{throw e})).process((async([e,t])=>{await this.sendMutationsForIntegration([...t],e)})),this.pendingOutgoingMutations.size||this.outgoingMutationsEmpty.next(!0),await this.refreshUpdatedDocuments(),this.hasPendingSentMutations()?(await(0,o.firstValueFrom)(this.pendingOutgoingMutationsChanged.pipe((0,o.filter)((()=>!this.hasPendingSentMutations())))),e?.resolve()):e?.resolve()}catch(t){this.pendingOutgoingMutations.size||(this.outgoingMutationsEmpty.next(!0),await this.resyncFailedUpdates()),e?.reject(t)}}async sendMutationsForIntegration(e,t){try{const{timestamp:r,idResolutionMap:n={},refreshList:i=[]}=await this.mutationSender.sendMutations(e.map((e=>e.mutation)),t);this.documentIdentityService.migrate(n),i.forEach((e=>{this.refreshDocIdToTimestamp.set(n[e]||e,r)}));for(const t of e){let e=this.removeOutgoingMutation(t);n[e]&&(e=n[e]),this.acknowledgeDocument(e,r),this.isTracked(e)||(this.setExpiration(e,!0),this.forgetDocument(e,!1))}}catch(t){for(const t of e){const e=this.removeOutgoingMutation(t);this.forgetDocument(e,!1),(this.hasBeenAcknowledged(e)||"insert"===t.mutation.type)&&this.failedDocsToResync.push(e)}throw t}}removeOutgoingMutation(e){const t=ft(e.mutation.squidDocIdObj),r=(0,ie.truthy)(this.pendingOutgoingMutations.get(t));return r.splice(r.indexOf(e),1),r.length||this.pendingOutgoingMutations.delete(t),this.pendingOutgoingMutationsChanged.next(),t}async resyncFailedUpdates(){const e=[...this.failedDocsToResync];this.failedDocsToResync.splice(0);for(const t of e){const{docId:e}=ht(t);this.setExpiration(t,!0);try{const r=e.includes(dt)?[]:await this.queryBuilderFactory.getForDocument(t).setForceFetchFromServer().snapshot();if((0,ie.truthy)(r.length<=1,"Got more than one doc for the same id:"+t),!r.length){this.forgetDocument(t,!1);const e=this.querySubscriptionManager.setClientRequestIdsForLocalDoc(t,void 0);this.querySubscriptionManager.notifyAllSubscriptions(e)}}catch(e){this.querySubscriptionManager.errorOutAllQueries(t,e)}}}async refreshUpdatedDocuments(){const e=[];for(const[t,r]of this.refreshDocIdToTimestamp.entries()){const n=this.docIdToServerTimestamp.get(t)?.timestamp;n&&n>r||e.push(t)}this.refreshDocIdToTimestamp.clear(),await Promise.allSettled(e.map((e=>this.queryBuilderFactory.getForDocument(e).snapshot())))}groupOutgoingMutationsByIntegrationId(){const e={};for(const[,t]of[...this.pendingOutgoingMutations.entries()]){const r=t[t.length-1];if(r&&!r.sentToServer){const t=r.mutation.squidDocIdObj.integrationId;(e[t]||=[]).push(r),r.sentToServer=!0}}return Object.entries(e)}handleOrphanDocs(){this.querySubscriptionManager.onOrphanDocuments.subscribe((e=>{for(const t of e)this.isTracked(t)||this.forgetDocument(t,!1)}))}acknowledgeDocument(e,t,r=!1){this.docIdToServerTimestamp.set(e,{timestamp:t}),this.setExpiration(e,r)}setExpiration(e,t){const r=this.docIdToServerTimestamp.get(e);r&&(r.expireTimestamp=t?Date.now()+2e4:void 0)}forgetDocument(e,t){this.docIdToLocalTimestamp.delete(e),t&&this.documentStore.saveDocument(e,void 0),this.setExpiration(e,!0)}migrateDocIds(e){this.pendingOutgoingMutations.forEach((t=>{t.forEach((t=>{const r=ft(t.mutation.squidDocIdObj),n=e[r];n&&(t.mutation.squidDocIdObj=ht(n))}))})),Object.entries(e).forEach((([e,t])=>{Oe(this.pendingOutgoingMutations,e,t),Oe(this.docIdToLocalTimestamp,e,t),Oe(this.docIdToServerTimestamp,e,t)}))}hasPendingSentMutations(){for(const e of this.pendingOutgoingMutations.values())for(const t of e)if(t.sentToServer)return!0;return!1}}const Bt=Symbol("undefined");class Ut{constructor(){this.preDestructors=[],this.destructors=[],this.isDestructedSubject=new o.BehaviorSubject(!1)}get isDestructing(){return this.isDestructedSubject.value}observeIsDestructing(){return this.isDestructedSubject.asObservable().pipe((0,o.filter)(Boolean),j((()=>{})))}onPreDestruct(e){this.preDestructors.push(e)}onDestruct(e){this.destructors.push(e)}async destruct(){this.reportDestructed();const e=this.preDestructors.concat(this.destructors);let t=e.shift();for(;t;){try{await t()}catch(e){console.error("Error while destructing Squid",e)}t=e.shift()}}reportDestructed(){this.isDestructing||this.isDestructedSubject.next(!0)}}class Qt{constructor(e,t){this.socketManager=e,this.destructManager=t,this.ongoingLocks={},this.acquireLockMessagesFromServer=this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"lockAcquired"===e.type))),this.releaseLockMessagesFromServer=this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"lockReleased"===e.type))),this.lockWaitForConnectionThreshold=2e3,t.onPreDestruct((()=>{this.releaseAllLocks()})),this.socketManager.observeConnectionReady().subscribe((e=>{e||this.releaseAllLocks()})),this.releaseLockMessagesFromServer.subscribe((e=>{const t=this.ongoingLocks[e.payload.clientRequestId];void 0!==t&&t.release()}))}async lock(e,t=1e3){if(this.socketManager.notifyWebSocketIsNeeded(),!await(0,o.firstValueFrom)((0,o.race)((0,o.timer)(this.lockWaitForConnectionThreshold).pipe(j((()=>!1))),this.socketManager.observeConnectionReady().pipe((0,o.filter)(Boolean)),this.destructManager.observeIsDestructing())))return Promise.reject("CLIENT_NOT_CONNECTED");const r=oe(),n={type:"acquireLock",payload:{mutex:e,timeoutMillis:t,clientRequestId:r}};this.socketManager.sendMessage(n);const i=await(0,o.firstValueFrom)((0,o.race)((0,o.timer)(t+4e3).pipe((0,o.take)(1),j((()=>({payload:{error:"TIMEOUT_GETTING_LOCK",lockId:void 0}})))),this.acquireLockMessagesFromServer.pipe((0,o.filter)((e=>e.payload.clientRequestId===r)))));if(this.destructManager.isDestructing)throw new Error("Destructing");if(!i.payload.lockId)throw new Error(`Failed to acquire lock: ${i.payload.error}`);const s=i.payload.lockId,a=new $t(s,r,this.ongoingLocks,this.socketManager);return this.ongoingLocks[s]=a,a}releaseAllLocks(){for(const[e,t]of Object.entries(this.ongoingLocks))t.release(),delete this.ongoingLocks[e]}}class $t{constructor(e,t,r,n){this.lockId=e,this.clientRequestId=t,this.ongoingLocks=r,this.socketManager=n,this.released=!1,this.onReleaseSubject=new o.Subject}release(){if(this.released)return;this.released=!0,delete this.ongoingLocks[this.lockId];const e={type:"releaseLock",payload:{lockId:this.lockId,clientRequestId:this.clientRequestId}};this.socketManager.sendMessage(e),this.onReleaseSubject.next()}observeRelease(){return this.onReleaseSubject.asObservable()}isReleased(){return this.released}}class Vt{constructor(e,t){this.documentStore=e,this.destructManager=t,this.changeNotifier=new o.BehaviorSubject({}),this.destructManager.onDestruct((()=>{this.changeNotifier.complete()}))}migrate(e){Object.entries(e).forEach((([e,t])=>{this.documentStore.migrateDocId(e,t)})),this.changeNotifier.next(e)}observeChanges(){return this.changeNotifier.asObservable()}}class Yt{constructor(e){this.documentIdentityService=e,this.documents=new Map,this.documentsForCollection=new Map,this.documentIdentityService.observeChanges().subscribe(this.migrateDocIds.bind(this))}create(e,t){let r=this.documents.get(e);if(r)return r;r=new pt(e,(0,ie.truthy)(this.dataManager,"dataManager not found"),t);const{integrationId:n,collectionName:i}=ht(e);this.documents.set(e,r);const o=this.getCollectionKey(n,i),s=this.documentsForCollection.get(o)||[];return this.documentsForCollection.set(o,s.concat(r)),r}setDataManager(e){this.dataManager=e}getDocumentsForCollection(e,t){const r=this.getCollectionKey(e,t);return(this.documentsForCollection.get(r)||[]).filter((e=>e.hasData))}migrateDocIds(e){for(const[,t]of this.documents)t.migrateDocIds(e);Object.entries(e).forEach((([e,t])=>{const r=ht(e),n=ht(t);Oe(this.documents,r.docId,n.docId)}))}getCollectionKey(e,t){return`${e}_${t}`}}class Wt{constructor(){this.squidDocIdToDoc=new Map}saveDocument(e,t){const r=this.squidDocIdToDoc.get(e);if(void 0===r&&!t)return;if(void 0!==r){if(t){const r=Ee(t),n=this.removeInternalProperties(r);return this.squidDocIdToDoc.set(e,n),n}return void this.squidDocIdToDoc.delete(e)}const n=this.removeInternalProperties(t);return this.squidDocIdToDoc.set(e,n),t}hasData(e){return void 0!==this.squidDocIdToDoc.get(e)}getDocument(e){return(0,ie.truthy)(this.getDocumentOrUndefined(e))}getDocumentOrUndefined(e){return this.squidDocIdToDoc.get(e)}compareSquidDocs(e,t,r){for(const{fieldName:n,asc:i}of r){const r=Te(ge(e,n),ge(t,n));if(0!==r)return i?r:-r}return 0}group(e,t){return Object.values(Fe(e,(e=>Pe(t.map((t=>ge(e,t)))))))}sortAndLimitDocs(e,t){if(0===e.size)return[];const r=[...e].map((e=>this.squidDocIdToDoc.get(e))).filter(ie.isNonNullable),{sortOrder:n,limitBy:i}=t,o=r.sort(((e,t)=>this.compareSquidDocs(e,t,n))),s=t.limit<0?2e3:t.limit;if(!i)return o.slice(0,s);const{limit:a,fields:u,reverseSort:c}=i,l=this.group(o,u);let d;return d=c?l.map((e=>e.slice(-a))):l.map((e=>e.slice(0,a))),d.flat().slice(0,s)}removeInternalProperties(e){if(!e)return;const t={...e};return delete t.__ts__,t}migrateDocId(e,t){const r=this.getDocumentOrUndefined(e);if(!r)return;Oe(this.squidDocIdToDoc,e,t);const n=ht(t),i=ke(n.docId);this.saveDocument(t,{...r,...i,__docId__:n.docId})}}class Ht{constructor(e,t,r){this.rpcManager=e,this.lockManager=t,this.querySender=r}async sendMutations(e,t){const r=Nt(e),n=r.map((e=>`sendMutation_${ft(e.squidDocIdObj)}`));await this.lockManager.lock(...n),await this.querySender.waitForAllQueriesToFinish();try{const e={mutations:r,integrationId:t};return await this.rpcManager.post("mutation/mutate",e)}catch(e){throw Ne.debug("Error while sending mutations",{error:e,mutations:JSON.stringify(r,null,2)}),e}finally{this.lockManager.release(...n)}}}class zt{constructor(e){this.rpcManager=e}async executeNativeQuery(e){return this.rpcManager.post("native-query/execute",e)}}async function Gt(e,t,r=500){const n=Date.now(),i=e.paginate({pageSize:r,subscribe:!1});let o=0,s=await i.waitForData();for(;;){for(const e of s.data)o++,await t(e.data);if(!s.hasNext)break;s=await i.next()}return{count:o,time:Date.now()-n}}function Jt(e,t){switch(t.type){case"simple":return function(e,t){const{query:r,dereference:n}=t,{collectionName:i,integrationId:o}=r;let s=e.collection(i,o).query();return s=Kt(s,r),n?s.dereference():s}(e,t);case"join":return function(e,t){const{root:r,joins:n,joinConditions:i,dereference:o,grouped:s}=t,{collectionName:a,integrationId:u}=r.query;let c=e.collection(a,u).joinQuery(r.alias);return c=Kt(c,r.query),Object.entries(n).map((([t,r])=>{const{collectionName:n,integrationId:o}=r,{left:s,right:a,leftAlias:u}=i[t];let l=e.collection(n,o).query();l=Kt(l,r),c=c.join(l,t,{left:s,right:a},{leftAlias:u})})),o&&s?c.grouped().dereference():o?c.dereference():s?c.grouped():c}(e,t);case"merged":return function(e,t){const{queries:r}=t,{collectionName:n,integrationId:i}=Zt(r[0]),o=r.map((t=>Jt(e,t)));return e.collection(n,i).or(...o)}(e,t)}}function Kt(e,t){const{conditions:r,limit:n,sortOrder:i}=t;for(const t of r){if(!("operator"in t))throw new Error("Composite conditions are not support in query serialization.");const{fieldName:r,operator:n,value:i}=t;e.where(r,n,i)}e.limit(n);for(const{fieldName:t,asc:r}of i)e.sortBy(t,r);return e}function Zt(e){switch(e.type){case"simple":{const{collectionName:t,integrationId:r}=e.query;return{collectionName:t,integrationId:r}}case"join":{const{collectionName:t,integrationId:r}=e.root.query;return{collectionName:t,integrationId:r}}case"merged":return Zt(e.queries[0])}}const Xt={"in:in":(e,t)=>e.every((e=>t.includes(e))),"in:not in":(e,t)=>e.every((e=>!t.includes(e))),"not in:not in":(e,t)=>t.every((t=>e.includes(t))),">:not in":(e,t)=>t.every((t=>e>=t)),">=:not in":(e,t)=>t.every((t=>e>t)),"<:not in":(e,t)=>t.every((t=>e<=t)),"<=:not in":(e,t)=>t.every((t=>e<t)),">:>":(e,t)=>e>=t,">=:>":(e,t)=>e>t,"in:>":(e,t)=>e.every((e=>e>t)),">:>=":(e,t)=>e>=t,">=:>=":(e,t)=>e>=t,"in:>=":(e,t)=>e.every((e=>e>=t)),"<:<":(e,t)=>e<=t,"<=:<":(e,t)=>e<t,"in:<":(e,t)=>e.every((e=>e<t)),"<:<=":(e,t)=>e<=t,"<=:<=":(e,t)=>e<=t,"in:<=":(e,t)=>e.every((e=>e<=t)),"like:like":(e,t)=>er(e.toLowerCase(),t.toLowerCase()),"like_cs:like":(e,t)=>er(e.toLowerCase(),t.toLowerCase()),"like:like_cs":(e,t)=>er(e,t)&&rr(t),"like_cs:like_cs":(e,t)=>er(e,t),"like:not like":(e,t)=>!tr(e.toLowerCase(),t.toLowerCase()),"like_cs:not like":(e,t)=>!tr(e.toLowerCase(),t.toLowerCase()),"like:not like_cs":(e,t)=>!tr(e.toLowerCase(),t.toLowerCase()),"like_cs:not like_cs":(e,t)=>!tr(e,t),"not like:like":(e,t)=>ir(e,t),"not like_cs:like":(e,t)=>ir(e,t),"not like:like_cs":(e,t)=>ir(e,t),"not like_cs:like_cs":(e,t)=>ir(e,t),"not like:not like":(e,t)=>er(t.toLowerCase(),e.toLowerCase()),"not like_cs:not like":(e,t)=>er(t,e)&&rr(e),"not like:not like_cs":(e,t)=>er(t.toLowerCase(),e.toLowerCase()),"not like_cs:not like_cs":(e,t)=>er(t,e),"in:like":(e,t)=>e.every((e=>Mt(t,e,"like"))),"in:like_cs":(e,t)=>e.every((e=>Mt(t,e,"like_cs"))),"in:not like":(e,t)=>e.every((e=>Mt(t,e,"not like"))),"in:not like_cs":(e,t)=>e.every((e=>Mt(t,e,"not like_cs"))),"like:in":(e,t)=>!e.includes("%")&&!e.includes("_")&&!!t.find((t=>t.toLowerCase()===e.toLowerCase())),"like_cs:in":(e,t)=>!e.includes("%")&&!e.includes("_")&&t.includes(e),"not like:in":(e,t)=>e.length>0&&nr(e)||or(e)&&t.includes(""),"not like_cs:in":(e,t)=>e.length>0&&nr(e)||or(e)&&t.includes(""),"not in:like":(e,t)=>t.length>0&&nr(t)||or(t)&&e.includes(""),"not in:like_cs":(e,t)=>t.length>0&&nr(t)||or(t)&&e.includes(""),"not in:not like":(e,t)=>!t.includes("%")&&!t.includes("_")&&!!e.find((e=>e.toLowerCase()===t.toLowerCase())),"not in:not like_cs":(e,t)=>!t.includes("%")&&!t.includes("_")&&e.includes(t),"like:not in":(e,t)=>t.every((t=>Mt(e,t,"not like"))),"like_cs:not in":(e,t)=>t.every((t=>Mt(e,t,"not like_cs"))),"not like:not in":(e,t)=>t.every((t=>Mt(e,t,"like"))),"not like_cs:not in":(e,t)=>t.every((t=>Mt(e,t,"like_cs"))),"array_includes_some:array_includes_some":(e,t)=>e.every((e=>t.includes(e))),"array_includes_all:array_includes_all":(e,t)=>e.every((e=>t.includes(e))),"array_not_includes:array_not_includes":(e,t)=>t.every((t=>e.includes(t))),"array_includes_some:array_not_includes":(e,t)=>e.every((e=>!t.includes(e))),"array_not_includes:array_includes_some":(e,t)=>t.every((t=>!e.includes(t))),"array_includes_all:array_includes_some":(e,t)=>e.every((e=>t.includes(e))),"array_includes_some:array_includes_all":(e,t)=>e.every((e=>t.includes(e))),"array_not_includes:array_includes_all":(e,t)=>t.every((t=>!e.includes(t))),"array_includes_all:array_not_includes":(e,t)=>e.every((e=>!t.includes(e)))};function er(e,t,r=0,n=0){if(n>=t.length)return r>=e.length;if(r>=e.length)return nr(t.substring(n));const i=e[r],o=t[n];return"%"===i&&"%"===o?er(e,t,r+1,n+1)||er(e,t,r+1,n):"%"!==i&&("%"===o?er(e,t,r,n+1)||er(e,t,r+1,n):(i===o||"_"===o)&&er(e,t,r+1,n+1))}function tr(e,t,r=0,n=0){if(r>=e.length&&n>=t.length)return!0;if(r>=e.length)return nr(t.substring(n));if(n>=t.length)return nr(e.substring(r));const i=r<e.length?e[r]:"",o=n<t.length?t[n]:"";return"%"===i&&"%"===o?tr(e,t,r+1,n+1)||tr(e,t,r,n+1)||tr(e,t,r+1,n):"%"===i||"%"===o?tr(e,t,r,n+1)||tr(e,t,r+1,n):(i===o||"_"===i||"_"===o)&&tr(e,t,r+1,n+1)}function rr(e){return!/[a-zA-Z]/.test(e)}function nr(e){return e.split("").every((e=>"%"===e))}function ir(e,t){return e.length>0&&nr(e)||t.length>0&&nr(t)||or(e)&&0===t.length}function or(e){let t=!1,r=!1;for(const n of e)switch(n){case"%":t=!0;break;case"_":if(r)return!1;r=!0;break;default:return!1}return t&&r}class sr{constructor(e){this.query=e,this.query=e,this.parsedConditions=this.parseConditions(this.query.conditions.filter(st))}get integrationId(){return this.query.integrationId}get collectionName(){return this.query.collectionName}get limit(){return this.query.limit}sortedBy(e){return!e.find(((e,t)=>!Ie(this.query.sortOrder[t],{...e,asc:e.asc??!0})))}sortedByExact(e){return e.length===this.query.sortOrder.length&&this.sortedBy(e)}isSubqueryOf(e,t,r){return this.isSubqueryOfCondition({fieldName:e,operator:t,value:r})}isSubqueryOfCondition(e){return!!this.parsedConditions.filter((t=>t.fieldName===e.fieldName)).find((t=>this.evaluateSubset(t,e)))}isSubqueryOfConditions(e){return this.parseConditions(e).every((e=>this.isSubqueryOfCondition(e)))}isSubqueryOfQuery(e){if(e.collectionName!==this.collectionName||e.integrationId!==this.integrationId)return!1;const t=e.conditions.filter(st),r=this.isSubqueryOfConditions(t),n=this.sortedBy(e.sortOrder),i=-1===e.limit||this.limit>-1&&this.limit<e.limit;return r&&n&&i}getConditionsFor(...e){return this.parsedConditions.filter((t=>e.includes(t.fieldName)))}getConditionsForField(e){return this.parsedConditions.filter((t=>t.fieldName===e))}documentMatchesQuery(e){for(const t of this.parsedConditions){const r=t.fieldName,n=t.operator,i=ge(e,r);if("in"===n){if(t.value.includes(i))continue;return!1}if("not in"!==n){if(!Mt(t.value,i,n))return!1}else if(t.value.includes(i))return!1}return!0}evaluateSubset(e,t){const{operator:r,value:n}=e,{operator:i,value:o}=this.parseConditions([t])[0],s=Xt[`${r}:${i}`];return!!s&&s(n,o)}parseConditions(e){const t=[],r=new Map,n=new Map;return e.forEach((e=>{switch(e.operator){case"==":case"in":r.set(e.fieldName,(r.get(e.fieldName)||[]).concat(e.value));break;case"!=":case"not in":n.set(e.fieldName,(n.get(e.fieldName)||[]).concat(e.value));break;default:t.push(e)}})),r.forEach(((e,r)=>{t.push({fieldName:r,operator:"in",value:e})})),n.forEach(((e,r)=>{t.push({fieldName:r,operator:"not in",value:e})})),t}}class ar{constructor(e,t,r){this.documentStore=e,this.documentReferenceFactory=t,this.querySubscriptionManager=r}peek(e){if(!this.querySubscriptionManager.findValidParentOfQuery(e))return[];const{integrationId:t,collectionName:r}=e,n=new sr(e),i=this.documentReferenceFactory.getDocumentsForCollection(t,r).filter((e=>n.documentMatchesQuery(e.data))),o={};return i.forEach((e=>{o[e.squidDocId]=e})),this.documentStore.sortAndLimitDocs(new Set(Object.keys(o)),e).map((e=>o[ft(e.__docId__,r,t)]))}}function ur(e,t){return a((function(r,n){var i=0;r.subscribe(T(n,(function(r){return e.call(t,r,i++)&&n.next(r)})))}))}class cr{constructor(e,t){this.rpcManager=e,this.destructManager=t,this.pendingQueryRequests=[],this.safeToSendQueriesToServer=new o.BehaviorSubject(!0),this.inflightQueriesCount=new o.BehaviorSubject(0),this.destructManager.onPreDestruct((()=>{this.preDestruct()}))}async sendQuery(e){const t=new o.Subject,r=(0,o.firstValueFrom)(t);return this.pendingQueryRequests.push({queryRequest:e,responseSubject:t}),this.pendingQueryBatchTimeout&&(clearTimeout(this.pendingQueryBatchTimeout),this.pendingQueryBatchTimeout=void 0),this.pendingQueryRequests.length>=10?(this.processQueryBatch(),r):(this.pendingQueryBatchTimeout=setTimeout((()=>{this.safeToSendQueriesToServer.pipe(ur(Boolean),(0,o.take)(1)).subscribe((()=>{this.processQueryBatch()}))}),0),r)}async processQueryBatch(){const e=this.pendingQueryRequests.splice(0);if(!e.length)return;const t=Array.from(e.map((({queryRequest:e})=>e)).reduce(((e,t)=>(e.set(t.clientRequestId,t),e)),new Map).values()),r=e.map((({responseSubject:e})=>e));this.inflightQueriesCount.next(this.inflightQueriesCount.value+t.length);try{const r=await this.rpcManager.post("query/batchQueries",t);for(const{queryRequest:t,responseSubject:n}of e){const e=t.clientRequestId,i=r.errors[e],o=r.results[e];i?n.error(i):n.next(o)}}catch(e){r.forEach((t=>t.error(e)))}finally{this.inflightQueriesCount.next(this.inflightQueriesCount.value-t.length)}}async waitForAllQueriesToFinish(){return(0,o.firstValueFrom)(this.inflightQueriesCount.pipe(ur((e=>0===e)))).then((()=>{}))}preDestruct(){this.safeToSendQueriesToServer.next(!1),this.safeToSendQueriesToServer.complete()}}var lr,dr=r(4123);function hr(e,t,r=(e,t)=>e>t?1:e<t?-1:0,n=0,i=e.length-1){if(i<n)return-1;const o=Math.trunc((n+i)/2);return 0===r(t,e[o])?o:r(t,e[o])>0?hr(e,t,r,o+1,i):hr(e,t,r,n,o-1)}function fr(e,t,r=(e,t)=>e>t?1:e<t?-1:0){if(-1!==hr(e,t,r))return;let n;for(n=e.length-1;n>=0&&r(e[n],t)>0;n--)e[n+1]=e[n];e[n+1]=t}function pr(e,t,r=(e,t)=>e>t?1:e<t?-1:0){const n=hr(e,t,r);n>-1&&e.splice(n,1)}!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.DISABLED=1]="DISABLED",e[e.ENABLED=2]="ENABLED"}(lr||(lr={}));const yr=100,br=20;class vr{constructor(e,t,r,n,i,s,a){this.rpcManager=e,this.clientIdService=t,this.documentStore=r,this.destructManager=n,this.documentIdentityService=i,this.querySender=s,this.socketManager=a,this.onOrphanDocuments=new o.Subject,this.ongoingQueries=new Map,this.clientRequestIdToLocalDocuments=new Map,this.localDocumentToClientRequestIds=new Map,this.queryMappingManager=new mr,this.queryResultsSubject=new o.Subject,this.documentIdentityService.observeChanges().subscribe(this.migrateDocIds.bind(this)),this.clientIdService.observeClientReadyToBeRegenerated().subscribe((()=>{this.refreshOngoingQueries()})),this.destructManager.onPreDestruct((()=>{this.preDestruct()}))}dumpSubscriptionInfo(){console.log("Ongoing queries:",this.ongoingQueries),console.log("ClientRequestId to local documents:",this.clientRequestIdToLocalDocuments),console.log("Local documents to clientRequestId:",this.localDocumentToClientRequestIds)}observeQueryResults(){return this.queryResultsSubject.asObservable()}hasOngoingQuery(e){return this.ongoingQueries.has(e)}getQuery(e){return(0,ie.truthy)(this.ongoingQueries.get(e),"UNKNOWN_QUERY").query}setGotInitialResult(e){const t=this.ongoingQueries.get(e);t?.gotInitialResponse&&this.removeClientRequestIdMapping(e),t&&(t.gotInitialResponse=!0,t.isInFlight=!1)}findQueriesForDocument(e,t){const{collectionName:r,integrationId:n}=ht(t),i=this.queryMappingManager.getMapping(r,n);return i?function(e,t){const r=[...e.unconditional||[]],n=new Map;for(const[r,i]of Object.entries(e.conditional||{})){const e=ke(r);let o;if(st(e)){const r=ge(t,e.fieldName)??null;o=Mt(e.value,r,e.operator)}else o=gr(e,t);if(o)for(const e of i)n.set(e,(n.get(e)||0)+1)}for(const[t,i]of n.entries())i>=e.queriesMetadata[t].condCount&&r.push(t);return r}(i,e):[]}setClientRequestIdsForLocalDoc(e,t){const r=this.localDocumentToClientRequestIds.get(e)||new Set,n=new Set(t?this.findQueriesForDocument(t,e).map((e=>function(e){const t=e.split("_");return{clientId:t[0],clientRequestId:t[1]}}(e).clientRequestId)):[]),i=new Set([...r,...n]);for(const t of[...r]){if(n.has(t))continue;r.delete(t);const i=this.clientRequestIdToLocalDocuments.get(t);i&&(i.delete(e),i.size||this.clientRequestIdToLocalDocuments.delete(t)),r.size||this.localDocumentToClientRequestIds.delete(e)}for(const t of n){let r=this.localDocumentToClientRequestIds.get(e);r||(r=new Set,this.localDocumentToClientRequestIds.set(e,r)),r.add(t);let n=this.clientRequestIdToLocalDocuments.get(t);n||(n=new Set,this.clientRequestIdToLocalDocuments.set(t,n)),n.add(e)}return[...i]}errorOutAllQueries(e,t){const r=this.localDocumentToClientRequestIds.get(e)||new Set;for(const e of r){const r=this.ongoingQueries.get(e);r&&(this.destructManager.isDestructing?r.dataSubject.complete():r.dataSubject.error(t),r.done=!0)}}notifyAllSubscriptions(e){const t=new Set;for(const r of e){const e=this.ongoingQueries.get(r);if(!e)continue;if(!e.gotInitialResponse||!e.activated||e.isInFlight)continue;const n=this.clientRequestIdToLocalDocuments.get(r)||new Set,i=this.documentStore.sortAndLimitDocs(n,e.query),o=e.supportedQueries.map((e=>this.updateOngoingQueryWithNewDataFromSupportingQuery(i,e))).some(Boolean);let s=e;for(;!s.allObservables;)s=(0,ie.truthy)(s?.supportingOngoingQuery);if(o&&t.add(s),e.query.limit>0)switch(e.limitUnderflowState){case lr.UNKNOWN:e.limitUnderflowState=n.size===e.query.limit+yr?lr.ENABLED:lr.DISABLED;break;case lr.DISABLED:break;case lr.ENABLED:if(n.size<e.query.limit+br){e.limitUnderflowState=lr.UNKNOWN,this.sendQueryToServerOrUseParentQuery(e);continue}}e.dataSubject.next(i)}for(const e of t){const t=this.collectAllObservables(e);(0,ie.truthy)(e.allObservables).next(t)}}isValidParent(e){if(!e.activated||e.isInFlight||e.isEmptyForJoin||e.done||!e.subscribe||!e.gotInitialResponse||!e.dataSubject.value)return!1;const t=-1===e.query.limit?1e3:e.query.limit;return e.dataSubject.value.length<t}findValidParentOfOngoingQuery(e){if(e.forceFetchFromServer)return;const t=new sr(e.query);for(const r of this.ongoingQueries.values()){if(e===r)return;if(this.isValidParent(r)&&t.isSubqueryOfQuery(r.query))return r}}findValidParentOfQuery(e){const t=new sr(e);for(const e of this.ongoingQueries.values())if(this.isValidParent(e)&&t.isSubqueryOfQuery(e.query))return e}processQuery(e,t,r,n,i,s){return i&&this.socketManager.notifyWebSocketIsNeeded(),(0,o.defer)((()=>{const a=this.createOngoingQueryGraph(e,t,r,n,i,!0);s&&(a.forceFetchFromServer=!0),this.sendQueryToServerOrUseParentQuery(a),a.allObservables=new o.ReplaySubject(1);const u=a.allObservables.pipe((0,o.switchMap)((e=>(0,o.combineLatest)(e).pipe(j((e=>this.joinResults(e,n,a)))))),ur((()=>this.allOngoingQueriesGotInitialResult(a))),(0,o.startWith)(void 0),(0,o.pairwise)(),ur((([e,t])=>!Ie(e,t))),j((([,e])=>e)),i?(0,o.tap)():(0,o.take)(1),(0,o.finalize)((()=>{a.dataSubject.complete(),a.done=!0,this.completeAllSupportedQueries(a).then(),a.allObservables?.complete()}))),c=this.collectAllObservables(a);return a.allObservables.next(c),u})).pipe((0,o.share)())}hasOngoingQueryForDocId(e){const t=this.localDocumentToClientRequestIds.get(e);return!!t&&!!t.size}removeClientRequestIdMapping(e){const t=this.clientRequestIdToLocalDocuments.get(e);if(!t)return;this.clientRequestIdToLocalDocuments.delete(e);const r=[];for(const n of t){const t=(0,ie.truthy)(this.localDocumentToClientRequestIds.get(n));t.delete(e),t.size||(this.localDocumentToClientRequestIds.delete(n),r.push(n))}r.length&&this.onOrphanDocuments.next(r)}registerQueryFinalizer(e){const t=e.clientRequestId,r=At(this.clientIdService.getClientId(),t);e.dataSubject.pipe((0,o.finalize)((async()=>{if(e.unsubscribeBlockerCount.value>0&&await(0,o.firstValueFrom)((0,o.race)(this.destructManager.observeIsDestructing(),e.unsubscribeBlockerCount.pipe(ur((e=>0===e))))),this.queryMappingManager.removeQuery(r).then(),this.ongoingQueries.delete(t),e.subscribe&&!e.isEmptyForJoin&&e.activated){const r={clientRequestId:t};this.rpcManager.post("query/unsubscribe",r).catch((t=>{this.destructManager.isDestructing||console.error("Got error while unsubscribing from query",e.query,t)}))}this.removeClientRequestIdMapping(t),this.ongoingQueries.delete(t)})),ur(Boolean)).subscribe({error:()=>{}})}createOngoingQueryGraph(e,t,r,n,i,s,a={}){if(a[t])return a[t];const u=this.clientIdService.generateClientRequestId(),c=[],l={clientRequestId:u,activated:s,alias:t,query:e,subscribe:i,dataSubject:new o.BehaviorSubject(null),supportedQueries:c,supportingOngoingQuery:void 0,joinCondition:void 0,gotInitialResponse:!1,isEmptyForJoin:!1,canExpandForJoin:!0,unsubscribeBlockerCount:new o.BehaviorSubject(0),queryRegistered:new o.BehaviorSubject(!1),done:!1,isInFlight:!1,forceFetchFromServer:!1,limitUnderflowState:i?lr.UNKNOWN:lr.DISABLED};this.registerQueryFinalizer(l),this.ongoingQueries.set(u,l),a[t]=l;for(const[e,o]of Object.entries(n)){const s=o.leftAlias;if(s!==t&&e!==t)continue;const u=s===t?e:s;if(s===t){const e=this.createOngoingQueryGraph(r[u],u,r,n,i,!1,a);e.joinCondition=o,c.push(e)}else l.supportingOngoingQuery=this.createOngoingQueryGraph(r[u],u,r,n,i,!1,a)}return l}collectAllObservables(e,t=[]){if(e.isEmptyForJoin)return t;const r=e.alias;t.push(e.dataSubject.pipe(ur(Boolean),j((e=>({docs:e,alias:r})))));for(const r of e.supportedQueries)this.collectAllObservables(r,t);return t}joinResults(e,t,r){const n=e.reduce(((e,t)=>(e[t.alias]?e[t.alias].push(...t.docs):e[t.alias]=[...t.docs],e)),{});let i=n[r.alias].map((e=>({[r.alias]:e})));const o=this.getOngoingQueriesBfs(r),s=new Set;for(let e=1;e<o.length;e++){const r=o[e].alias;s.has(r)||(s.add(r),i=this.join(i,r,n[r],t[r]))}return i}join(e,t,r,n){if(!e.length)return e;const i=Object.keys(e[0]);if(!n||!i.includes(n.leftAlias))throw new Error("No join condition found for alias "+t);const o=new Map;return(r||[]).forEach((e=>{const t=this.transformKey(e[n.right]);o.has(t)||o.set(t,[]),(0,ie.truthy)(o.get(t)).push(e)})),e.flatMap((e=>{const r=o.get(this.transformKey(e[n.leftAlias]?.[n.left]))||[];return r.length?r.map((r=>({...e,[t]:r}))):n.isInner?[]:[{...e,[t]:void 0}]}))}getOngoingQueriesBfs(e){const t=[],r=[e];for(;r.length;){const e=(0,ie.truthy)(r.shift());e.isEmptyForJoin||(t.push(e),r.push(...e.supportedQueries))}return t}updateOngoingQueryWithNewDataFromSupportingQuery(e,t){const r=(0,ie.truthy)(t.joinCondition),n=t.query;if(t.activated){if(!t.canExpandForJoin)return!1;const i=(0,ie.truthy)(t.supportingOngoingQuery?.supportedQueries).filter((e=>e.alias===t.alias)),s=new Set(e.map((e=>e[r.left]??null)));for(const e of i)e.query.conditions.filter(st).filter((e=>e.fieldName===r.right)).forEach((e=>{s.delete(e.value)}));if(0===s.size)return!1;const a=Ee(n);a.conditions=a.conditions.filter((e=>!st(e)||e.fieldName!==r.right)),[...s].forEach((e=>{a.conditions.push({fieldName:r.right,operator:"==",value:e})}));const u={...t,query:a,activated:!0,gotInitialResponse:!1,dataSubject:new o.BehaviorSubject(null),clientRequestId:this.clientIdService.generateClientRequestId(),isEmptyForJoin:!1};return this.registerQueryFinalizer(u),this.ongoingQueries.set(u.clientRequestId,u),(0,ie.truthy)(t.supportingOngoingQuery).supportedQueries.push(u),this.sendQueryToServerOrUseParentQuery(u),!0}{if(t.activated=!0,n.conditions.filter(st).filter((e=>e.fieldName===r.right&&"=="===e.operator)).map((e=>e.value)).length)return this.sendQueryToServerOrUseParentQuery(t),t.canExpandForJoin=!1,!0;const i=e.map((e=>e[r.left]??null)).map((e=>({fieldName:r.right,operator:"==",value:e})));return i.length?(n.conditions.push(...i),this.sendQueryToServerOrUseParentQuery(t)):t.isEmptyForJoin=!0,!0}}allOngoingQueriesGotInitialResult(e){return!!e.isEmptyForJoin||!!e.gotInitialResponse&&(!e.supportedQueries.length||e.supportedQueries.every((e=>this.allOngoingQueriesGotInitialResult(e))))}async completeAllSupportedQueries(e){const t=[...e.supportedQueries||[]];for(;t.length;){const e=(0,ie.truthy)(t.shift());t.push(...e.supportedQueries||[]),await(0,o.firstValueFrom)(e.unsubscribeBlockerCount.pipe(ur((e=>0===e)))),e.dataSubject.complete()}}transformKey(e){return e instanceof Date?`DATE AS string KEY: ${e.toISOString()}`:e}preDestruct(){this.unsubscribe()}unsubscribe(){const e=[...this.ongoingQueries.values()];for(const t of e)t.dataSubject.complete(),t.allObservables?.complete()}hasSubscription(e){return!!this.ongoingQueries.get(e)?.subscribe}sendQueryToServerOrUseParentQuery(e,t=!1){if(this.destructManager.isDestructing)return;const r=e.query,n=e.clientRequestId,i=At(this.clientIdService.getClientId(),n);this.queryMappingManager.addQuery(r,i),this.ongoingQueries.set(n,e);const o=t?void 0:this.findValidParentOfOngoingQuery(e);o?this.useParentOngoingQuery(e,o).then():this.sendQueryToServer(e)}async useParentOngoingQuery(e,t){const r={clientRequestId:e.clientRequestId,query:e.query,parentClientRequestId:t.clientRequestId},n=new sr(e.query);t.unsubscribeBlockerCount.next(t.unsubscribeBlockerCount.value+1);try{await(0,o.firstValueFrom)(t.queryRegistered.pipe(ur(Boolean)))}catch(t){return this.destructManager.isDestructing?(e.dataSubject.complete(),e.queryRegistered.complete()):(e.dataSubject.error(t),e.queryRegistered.error(t)),void(e.done=!0)}if(this.destructManager.isDestructing)return;if(e.done)return;this.rpcManager.post("query/register",r).then((()=>{e.isInFlight=!1,e.queryRegistered.next(!0)})).catch((r=>{e.isInFlight=!1,this.destructManager.isDestructing?e.dataSubject.complete():(console.error("Query error",e.query,t.query,r),e.dataSubject.error(r)),e.done=!0})).finally((()=>{t.unsubscribeBlockerCount.next(t.unsubscribeBlockerCount.value-1)}));const i=(0,o.race)(e.queryRegistered.pipe(ur(Boolean),(0,o.delay)(2e3),(0,o.take)(1)),this.destructManager.observeIsDestructing().pipe((0,o.take)(1)));t.dataSubject.pipe((0,o.takeWhile)((()=>!e.done)),(0,o.takeUntil)(i),ur(Boolean),(0,o.tap)((()=>{e.gotInitialResponse||this.setGotInitialResult(e.clientRequestId)})),j((e=>e.filter((e=>n.documentMatchesQuery(e)))))).subscribe({next:t=>{for(const r of t)this.setClientRequestIdsForLocalDoc(ft(r.__docId__,e.query.collectionName,e.query.integrationId),r);this.notifyAllSubscriptions([e.clientRequestId])},error:t=>{this.destructManager.isDestructing?e.dataSubject.complete():e.dataSubject.error(t)}})}sendQueryToServer(e){const t=e.query.limit,r=t>0&&e.subscribe?t+yr:t,n={query:{...e.query,limit:r},clientRequestId:e.clientRequestId,subscribe:e.subscribe};e.isInFlight=!0,this.querySender.sendQuery(n).then((t=>{e.isInFlight=!1,e.queryRegistered.next(!0),this.queryResultsSubject.next(t)})).catch((t=>{e.isInFlight=!1,this.destructManager.isDestructing?(e.dataSubject.complete(),e.queryRegistered.complete()):(Ne.debug("Query error",e.query,t),e.dataSubject.error(t),e.queryRegistered.error("query failed")),e.done=!0}))}refreshOngoingQueries(){for(const e of this.ongoingQueries.values())this.sendQueryToServerOrUseParentQuery(e,!0)}migrateDocIds(e){const t=Object.keys(e);for(const r of this.clientRequestIdToLocalDocuments.values())t.forEach((t=>{r.has(t)&&(r.delete(t),r.add(e[t]))}));t.forEach((t=>{Oe(this.localDocumentToClientRequestIds,t,e[t])}))}}function gr(e,t){for(const r of e.fields){const e=ge(t,r.fieldName)??null;if(Mt(r.value,e,r.operator))return!0;if(Mt(r.value,e,"!="))return!1}return!1}class mr{constructor(){this.stateService=new dr.TrieStore({}),this.querySubscriptionIdToQuery={}}addQuery(e,t){this.stateService.runInBatch((()=>{let r=0;const n=new Set;for(const i of e.conditions){if(st(i)&&["=="].includes(i.operator)){const e=Ce(i.fieldName);n.has(e)||(r++,n.add(e))}else r++;const o=this.getConditionStatePath(e,i),s=[...this.stateService.get(o)||[]];fr(s,t),this.stateService.set(o,s)}if(!e.conditions.length){const r=["queryMapping",e.collectionName,e.integrationId,"mapping","unconditional"],n=[...this.stateService.get(r)||[]];fr(n,t),this.stateService.set(r,n)}this.stateService.set([...this.getQueryMetadataStatePath(e,t),"condCount"],r)})),this.querySubscriptionIdToQuery[t]=e}async removeQuery(e){const t=this.querySubscriptionIdToQuery[e];if(t)return this.stateService.runInBatch((()=>{for(const r of t.conditions){const n=this.getConditionStatePath(t,r),i=[...this.stateService.get(n)||[]];pr(i,e),i.length?this.stateService.set(n,i):this.stateService.delete(n)}if(!t.conditions.length){const r=["queryMapping",t.collectionName,t.integrationId,"mapping","unconditional"],n=[...this.stateService.get(r)||[]];pr(n,e),this.stateService.set(r,n)}this.stateService.delete(this.getQueryMetadataStatePath(t,e))})),t}getMapping(e,t){return this.stateService.get(["queryMapping",e,t,"mapping"])}getQueryMetadataStatePath(e,t){return["queryMapping",e.collectionName,e.integrationId,"mapping","queriesMetadata",`${t}`]}getConditionStatePath(e,t){return["queryMapping",e.collectionName,e.integrationId,"mapping","conditional",(r=t,Pe(r))];var r}}class _r{constructor(){this.locks={}}async lock(...e){if(this.canGetLock(...e))return void this.lockSync(...e);const t=Object.entries(this.locks).filter((([t])=>e.includes(t))).map((([,e])=>e));await(0,o.lastValueFrom)((0,o.combineLatest)(t).pipe((0,o.filter)((e=>!e.includes(!0))),(0,o.take)(1))),await this.lock(...e)}release(...e){for(const t of e){const e=(0,ie.truthy)(this.locks[t]);e.next(!1),e.complete(),delete this.locks[t]}}canGetLock(...e){return!e.some((e=>this.locks[e]?.value))}lockSync(...e){(0,ie.assertTruthy)(this.canGetLock(...e),"Cannot acquire lock sync");for(const t of e)this.locks[t]=new o.BehaviorSubject(!0)}}class Sr{constructor(e,t,r){this.rpcManager=e,this.socketManager=t,this.queueManagers=new Map,this.socketManager.observeNotifications().subscribe((e=>{const t=this.getOrUndefined(e.integrationId,e.topicName);t&&t.onMessages(e.payload)})),r.onPreDestruct((()=>{for(const e of this.queueManagers.values())for(const t of e.values())t.destruct()}))}get(e,t){let r=this.queueManagers.get(e);r||(r=new Map,this.queueManagers.set(e,r));let n=r.get(t);return n||(n=new wr(e,t,this.rpcManager,this.socketManager),r.set(t,n)),n}getOrUndefined(e,t){return this.queueManagers.get(e)?.get(t)}}const Or="subscriptionMutex";class wr{constructor(e,t,r,n){this.integrationId=e,this.topicName=t,this.rpcManager=r,this.socketManager=n,this.messagesSubject=new o.Subject,this.subscriberCount=0,this.lockManager=new _r}async produce(e){await this.lockManager.lock(Or);try{await this.rpcManager.post("queue/produceMessages",{integrationId:this.integrationId,topicName:this.topicName,messages:e})}finally{this.lockManager.release(Or)}}consume(){return this.socketManager.notifyWebSocketIsNeeded(),(0,o.defer)((()=>(this.subscriberCount++,1===this.subscriberCount&&this.performSubscribe(),this.messagesSubject.asObservable().pipe((0,o.finalize)((()=>{this.subscriberCount--,0===this.subscriberCount&&this.performUnsubscribe()}))))))}async performSubscribe(){await this.lockManager.lock(Or);try{await this.rpcManager.post("queue/subscribe",{integrationId:this.integrationId,topicName:this.topicName})}catch(e){this.messagesSubject.error(e),this.messagesSubject.complete(),this.subscriberCount=0,this.messagesSubject=new o.Subject}finally{this.lockManager.release(Or)}}async performUnsubscribe(){await this.lockManager.lock(Or);try{await this.rpcManager.post("queue/unsubscribe",{integrationId:this.integrationId,topicName:this.topicName})}finally{this.lockManager.release(Or)}}onMessages(e){for(const t of e)this.messagesSubject.next(t)}destruct(){this.messagesSubject.complete()}}class Ir{constructor(e,t){this.capacity=e,this.seconds=t,this.tokens=e,this.refillRatePerMs=e/(1e3*t),this.lastRefillTimestamp=Date.now()}async consume(){this.attemptConsume()||await(0,o.firstValueFrom)((0,o.interval)(10).pipe((0,o.filter)((()=>this.attemptConsume())),(0,o.first)()))}attemptConsume(){return this.refill(),this.tokens>=1&&(this.tokens-=1,!0)}refill(){const e=Date.now(),t=(e-this.lastRefillTimestamp)*this.refillRatePerMs;this.tokens=Math.min(this.tokens+t,this.capacity),this.lastRefillTimestamp=e}}const Mr=["aiData","api","application","application-kotlin","auth","backend-function","connector","extraction","integration","internal-storage","internalCodeExecutor","mutation","named-query","native-query","observability","openapi","query","queue","quota","scheduler","secret","storage","webhooks","ws","personalStorage"];function Er(e,t,r){const n=new URL("https://squid.cloud");n.host=`${t}.${e}.${n.host}`;const i=r.replace(/^\//g,"").split("/")[0]||"";(function(e){return/^local/.test(e)})(e)&&(n.protocol="http",n.port=Mr.includes(i)?"8001":"8000",function(e){return/android$/.test(e)}(e)?n.host="10.0.2.2":function(e){return/ios$/.test(e)}(e)&&(n.host="localhost"));const o=n.toString();r=r.startsWith("/")?r.slice(1):r;const s=o.replace(/\/$/g,"");return r.length?`${s}/${r}`:s}const Ar="1.0.338";class Tr extends Error{constructor(e,t,r,n,i,o){super(o||`RPC error ${e} ${t} calling ${r}`),this.statusCode=e,this.statusText=t,this.url=r,this.headers=n,this.body=i}}async function Fr(e){const t=await Cr({url:e.url,headers:e.headers,method:"POST",message:e.message,files:e.files,filesFieldName:e.filesFieldName,extractErrorMessage:e.extractErrorMessage});return t.body=xr(t.body),t}async function jr(e){const t=await Cr({...e,method:"GET",files:[],filesFieldName:""});return t.body=xr(t.body),t}async function Pr(e){const t=await Cr({...e,method:"PUT"});return t.body=xr(t.body),t}async function Dr(e){const t=await Cr({...e,method:"PATCH"});return t.body=xr(t.body),t}async function kr(e){const t=await Cr({...e,method:"DELETE",files:[],filesFieldName:""});return t.body=xr(t.body),t}async function Cr({headers:e,files:t,filesFieldName:r,message:n,url:i,extractErrorMessage:o,method:s}){const a=new Headers(e);a.append("x-squid-client-version",Ar);const u={method:s,headers:a,body:void 0};if("GET"!==s&&"DELETE"!==s)if(t&&t.length){const e=new FormData;for(const n of t)e.append(r||"files",n,n.name);e.append("body",De(n)),u.body=e}else void 0!==n&&(a.append("Content-Type","application/json"),u.body=De(n));else"DELETE"===s&&void 0!==n&&(a.append("Content-Type","application/json"),u.body=De(n));try{const e=await fetch(i,u),t={};if(e.headers.forEach(((e,r)=>{t[r]=e})),!e.ok){const r=await e.text(),n=xr(r);if(!o)throw new Tr(e.status,e.statusText,i,t,n,r);let s;try{s="string"==typeof n?n:n?.message||r}catch{}throw s||(s=e.statusText),new Tr(e.status,e.statusText,i,t,n,s)}const r=await e.text();return Ne.debug(`received response from url ${i}: ${JSON.stringify(r)}`),{body:r,headers:t,status:e.status,statusText:e.statusText}}catch(e){throw Ne.debug(`Unable to perform fetch request to url: ${i}`,e),e}}function xr(e){if(e){try{return ke(e)}catch{}return e}}class Rr{constructor(e,t,r,n,i,s){this.region=e,this.appId=t,this.authManager=i,this.clientIdService=s,this.staticHeaders={},this.onGoingRpcCounter=new o.BehaviorSubject(0);for(const[e,t]of Object.entries(n))this.setStaticHeader(e,t);this.clientIdService.observeClientId().subscribe((e=>{e?this.setStaticHeader("x-squid-clientid",e):this.deleteStaticHeader("x-squid-clientid")})),r.onDestruct((async()=>{await this.awaitAllSettled()}));const a=this.authManager.getApiKey()?5:1;this.rateLimiters={default:new Ir(60*a,5),ai:new Ir(20*a,5),secret:new Ir(20*a,5)}}async getAuthHeaders(){const e=this.authManager.getApiKey();if(e)return{Authorization:`ApiKey ${e}`};const{token:t,integrationId:r}=await this.authManager.getAuthData();if(!t)return{};let n=`Bearer ${t}`;return r&&(n+=`; IntegrationId ${r}`),{Authorization:n}}async awaitAllSettled(){await(0,o.firstValueFrom)(this.onGoingRpcCounter.pipe((0,o.filter)((e=>0===e))))}setStaticHeader(e,t){this.staticHeaders[e]=t}deleteStaticHeader(e){delete this.staticHeaders[e]}getStaticHeaders(){return this.staticHeaders}async post(e,t,r=[],n="files"){return(await this.rawPost(e,t,r,n)).body}async rawPost(e,t,r=[],n="files",i=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const o=await this.getAuthHeaders(),s={...this.staticHeaders,...o};Ne.debug(`sending POST request: path: ${e} message: ${JSON.stringify(t)}`);const a=e.startsWith("http://")||e.startsWith("https://")?e:Er(this.region,this.appId,e);return await Fr({url:a,headers:s,message:t,files:r,filesFieldName:n,extractErrorMessage:i})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}async get(e,t,r=!0){return(await this.rawGet(e,t,r)).body}async rawGet(e,t,r=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const n=await this.getAuthHeaders(),i={...this.staticHeaders,...n};let o=e.startsWith("http://")||e.startsWith("https://")?e:Er(this.region,this.appId,e);if(t&&Object.keys(t).length>0){const e=new URLSearchParams;Object.entries(t).forEach((([t,r])=>{e.append(t,String(r))})),o+=`?${e.toString()}`}return Ne.debug(`sending GET request: path: ${e}, queryParams: ${JSON.stringify(t)}`),await jr({url:o,headers:i,extractErrorMessage:r})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}async put(e,t,r=[],n="files"){return(await this.rawPut(e,t,r,n)).body}async rawPut(e,t,r=[],n="files",i=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const o=await this.getAuthHeaders(),s={...this.staticHeaders,...o};Ne.debug(`sending PUT request: path: ${e} message: ${JSON.stringify(t)}`);const a=e.startsWith("http://")||e.startsWith("https://")?e:Er(this.region,this.appId,e);return await Pr({url:a,headers:s,message:t,files:r,filesFieldName:n,extractErrorMessage:i})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}async patch(e,t,r=[],n="files"){return(await this.rawPatch(e,t,r,n)).body}async rawPatch(e,t,r=[],n="files",i=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const o=await this.getAuthHeaders(),s={...this.staticHeaders,...o};Ne.debug(`sending PATCH request: path: ${e} message: ${JSON.stringify(t)}`);const a=e.startsWith("http://")||e.startsWith("https://")?e:Er(this.region,this.appId,e);return await Dr({url:a,headers:s,message:t,files:r,filesFieldName:n,extractErrorMessage:i})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}async delete(e,t,r=!0){return(await this.rawDelete(e,t,r)).body}async rawDelete(e,t,r=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const n=await this.getAuthHeaders(),i={...this.staticHeaders,...n};Ne.debug(`sending DELETE request: path: ${e}, body: ${JSON.stringify(t)}`);const o=e.startsWith("http://")||e.startsWith("https://")?e:Er(this.region,this.appId,e);return await kr({url:o,headers:i,message:t,extractErrorMessage:r})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}getRateLimiterBucket(e){return e.startsWith("ai/chatbot")?(0,ie.truthy)(this.rateLimiters.ai,"MISSING_RATE_LIMITER_AI"):e.startsWith("secret/")?(0,ie.truthy)(this.rateLimiters.secret,"MISSING_RATE_LIMITER_SECRETS"):(0,ie.truthy)(this.rateLimiters.default,"MISSING_RATE_LIMITER_DEFAULT")}}const Nr={groupByTags:[],orderByTags:[],pointIntervalAlignment:"align-by-start-time",tagFilter:{},tagDomains:{},noDataBehavior:"return-no-result-groups",fillValue:null,pointIntervalSeconds:0};class qr{constructor(e){this.rpcManager=e,this.pendingPromises=[],this.isReporting=!1}reportMetric(e){const t=e.tags||{},r=Object.keys(t).filter((e=>!Lr.test(e)||e.length>=Br));(0,ie.assertTruthy)(0===r.length,(()=>`Tag name is not allowed: ${r.join(",")}`)),this.isReporting=!0;const n={...e,tags:t,timestamp:void 0===e.timestamp?Date.now():e.timestamp},i=this.rpcManager.post("/observability/metrics",{metrics:[n]}).finally((()=>{this.pendingPromises=this.pendingPromises.filter((e=>e!==i)),this.isReporting=this.pendingPromises.length>0}));this.pendingPromises.push(i)}async flush(){this.isReporting&&await Promise.all(this.pendingPromises)}async queryMetrics(e){const t={...Nr,...e,fn:Array.isArray(e.fn)?e.fn:[e.fn]};t.pointIntervalSeconds||(t.pointIntervalSeconds=t.periodEndSeconds-t.periodStartSeconds);const r=await this.rpcManager.post("/observability/metrics/query",t);return function(e,t){const{pointIntervalSeconds:r,noDataBehavior:n}=e,i=void 0===e.fillValue?null:e.fillValue,o=function({periodStartSeconds:e,periodEndSeconds:t,pointIntervalSeconds:r,pointIntervalAlignment:n}){if("align-by-start-time"===n)return e;const i=t-e;let o=t-Math.floor(i/r)*r;return o>e&&(o-=r),o}(e),s=function({periodStartSeconds:e,periodEndSeconds:t,pointIntervalSeconds:r,pointIntervalAlignment:n}){if("align-by-end-time"===n)return t-r;const i=t-e;let o=e+Math.floor(i/r)*r;return o>=t&&(o-=r),o}(e),a=e.tagDomains||{},u=Object.entries(a);if(0===t.length)if(u.length>0){const r=[];for(let t=0;t<e.groupByTags.length;t++){const n=e.groupByTags[t],i=a[n]?.[0]||"";r.push(i)}t.push({tagValues:r,points:[]})}else"return-result-group-with-default-values"===n&&t.push({tagValues:e.groupByTags.map((()=>"")),points:[]});for(const[r,n]of Object.entries(a)){const i=e.groupByTags.indexOf(r);if(!(i<0))for(let e=0;e<t.length;e++){const r=t[e],o=new Set(n);for(let e=0;e<t.length;e++){const n=t[e];r.tagValues.every(((e,t)=>t===i||e===n.tagValues[t]))&&o.delete(n.tagValues[i])}if(0!==o.size)for(const e of o){const n={tagValues:[...r.tagValues],points:[]};n.tagValues[i]=e,t.push(n)}}}for(const n of t){if(0!==n.points.length){const e=n.points[0][0],t=n.points[n.points.length-1][0];(0,ie.assertTruthy)(e>=o,(()=>`Invalid first point time: ${e}`)),(0,ie.assertTruthy)(t<=s,(()=>`Invalid last point time: ${t}`))}const t=[];let a=0;const u=e=>"count"===e?0:i,c=Array.isArray(e.fn)?e.fn.map(u):[i];for(let e=o;e<=s;e+=r){const r=n.points[a];r?r[0]===e?(t.push(r),a++):((0,ie.assertTruthy)(r[0]>e,(()=>`Result point has invalid time: ${r[0]}`)),t.push([e,...c])):t.push([e,...c])}n.points=t}}(t,r.resultGroups),r}}const Lr=/^[a-zA-Z0-9_-]+$/,Br=1e3;class Ur{constructor(e){this.rpcManager=e}async get(e){const t={key:e};return await this.rpcManager.post("secret/get",t)||void 0}getAll(){return this.rpcManager.post("secret/getAll",{})}async upsert(e,t){return this.upsertMany([{key:e,value:t}]).then((e=>e[0]))}async upsertMany(e){if(0===e.length)return[];const t={entries:e};return this.rpcManager.post("secret/upsert",t)}delete(e,t=!1){const r={keys:[e],force:t};return this.rpcManager.post("secret/delete",r)}async deleteMany(e,t=!1){if(0===e.length)return;const r={keys:e,force:t};return this.rpcManager.post("secret/delete",r)}get apiKeys(){return new Qr(this.rpcManager)}}class Qr{constructor(e){this.rpcManager=e}get(e){const t={key:e};return this.rpcManager.post("secret/api-key/get",t)}getAll(){return this.rpcManager.post("secret/api-key/getAll",{})}upsert(e){const t={key:e};return this.rpcManager.post("secret/api-key/upsert",t)}delete(e){const t={key:e};return this.rpcManager.post("secret/api-key/delete",t)}}class $r{constructor(e){this.rpcManager=e}async list(){return(await this.rpcManager.post("/scheduler/listSchedulers",{})).schedulers}async enable(e){await this.update(this.createUpdateSchedulerOptions(e,!0))}async disable(e){await this.update(this.createUpdateSchedulerOptions(e,!1))}async update(e){const t={schedulers:e};await this.rpcManager.post("scheduler/updateSchedulers",t)}createUpdateSchedulerOptions(e,t){return Array.isArray(e)?e.map((e=>({schedulerId:e,enabled:t}))):[{schedulerId:e,enabled:t}]}}function Vr(e,t=""){return e.includes("sandbox")?Er("us-east-1.aws.sandbox","console",t):Er("local"===e?"local":"us-east-1.aws","console",t)}class Yr{constructor(e,t,r){this.rpcManager=e,this.iacBaseUrl=Vr(t,`openapi/iac/applications/${r}/integrations`)}async list(e){const t=await this.rpcManager.get(this.iacBaseUrl);return e?t.filter((t=>t.type===e)):t}async get(e){return await this.rpcManager.get(`${this.iacBaseUrl}/${e}`)}async delete(e){await this.rpcManager.delete(`${this.iacBaseUrl}/${e}`)}async deleteMany(e){await Promise.all(e.map((e=>this.delete(e))))}async upsertIntegration(e){await this.rpcManager.put(`${this.iacBaseUrl}/${e.id}`,e)}}const Wr=e=>e();function Hr(){}const zr="undefined"!=typeof process&&process.versions?.node?r(5086):Re().WebSocket;class Gr{constructor(e,t,r,n=Wr,i,s){this.clientIdService=e,this.region=t,this.appId=r,this.messageNotificationWrapper=n,this.destructManager=i,this.authManager=s,this.webSocketObserver=new o.Subject,this.allMessagesObserver=new o.Subject,this.connectionReady=new o.BehaviorSubject(!1),this.seenMessageIds=new Set,this.destructSubject=new o.Subject,this.connectedAtLeastOnce=!1,this.webSocketNeededSubject=new o.BehaviorSubject(!1),this.clientTooOldThreshold=3e4,this.destructManager.onDestruct((()=>this.destruct())),this.setupMessageAcknowledgments(),this.webSocketNeededSubject.pipe((0,o.filter)(Boolean),(0,o.take)(1)).subscribe((()=>{this.connect(),this.lastTick=new Date,this.tickInterval=setInterval((()=>this.keepAlive()),5e3)})),this.observeConnectionReady().pipe((0,o.skip)(1),(0,o.filter)((e=>!e)),(0,o.switchMap)((()=>(0,o.race)((0,o.timer)(this.clientTooOldThreshold),this.connectionReady.pipe((0,o.filter)(Boolean)),this.destructManager.observeIsDestructing())))).subscribe((()=>{this.connectionReady.value?Ne.debug(this.clientIdService.getClientId(),"Client reconnected before becoming too old. Ignoring..."):this.destructManager.isDestructing||(Ne.debug(this.clientIdService.getClientId(),"Client disconnected for a long period - refreshing"),this.refreshClient())})),this.observeConnectionReady().pipe((0,o.filter)(Boolean)).subscribe((()=>{this.clientIdService.isClientTooOld()&&this.clientIdService.notifyClientNotTooOld()})),this.observeNotifications().pipe((0,o.filter)((e=>"clientInfo"===e.type))).subscribe((e=>{console.log("Client info message received",e)}))}refreshClient(){this.destructManager.isDestructing?Ne.debug(this.clientIdService.getClientId(),"Client too old but is destructed. Ignoring..."):this.clientIdService.isClientTooOld()?Ne.debug(this.clientIdService.getClientId(),"Client is already marked as too old. Ignoring..."):(Ne.debug(this.clientIdService.getClientId(),"Notifying client too old"),this.clientIdService.notifyClientTooOld(),Ne.debug(this.clientIdService.getClientId(),"Client too old. Reconnecting..."),this.connect())}getClientInfo(){this.sendMessage({type:"getClientInfo"})}keepAlive(){this.lastTick&&(Math.abs(Date.now()-this.lastTick.getTime())>this.clientTooOldThreshold&&(Ne.debug(this.clientIdService.getClientId(),"Tick: Client not responding for a long time. Refreshing..."),this.refreshClient()),this.lastTick=new Date)}observeNotifications(){return this.webSocketObserver.asObservable()}observeConnectionReady(){return this.connectionReady.asObservable().pipe((0,o.distinctUntilChanged)())}notifyWebSocketIsNeeded(){this.webSocketNeededSubject.next(!0)}sendMessage(e){this.sendMessageAsync(e).then()}async sendMessageAsync(e){this.webSocketNeededSubject.next(!0),await(0,o.firstValueFrom)(this.connectionReady.pipe((0,o.filter)(Boolean)));const t=await this.authManager.getToken();if(this.connectionReady.value)try{(0,ie.assertTruthy)(this.socket,"Socket is undefined in sendMessageAsync");const r=De({message:e,authToken:t});Ne.debug(this.clientIdService.getClientId(),"Sending message to socket: ",r),this.socket.send(r)}catch(t){this.socket?.connected?console.error("Websocket message is ignored due to a non-recoverable error",t):(this.connectionReady.next(!1),await this.sendMessageAsync(e))}else await this.sendMessageAsync(e)}sendKillMessage(){this.socket?.connected&&this.socket.send(De({message:{type:"kill"}}))}closeCurrentSocketSilently(){if(this.socket)try{this.socket.close()}catch(e){}}connect(){this.closeCurrentSocketSilently(),this.connectionReady.value&&this.connectionReady.next(!1);const e=Er(this.region,this.appId,"ws/general").replace("https","wss").replace("http","ws"),t=this.clientIdService.getClientId();Ne.debug(this.clientIdService.getClientId(),"Connecting to socket at:",e);const r=`${e}?clientId=${t}`;this.socket=function(e,t={}){let r,n=0,i=1;const o={connected:!1,closeCalled:!1,open(){r=new(zr?.WebSocket??zr)(e,t.protocols||[]),r.onmessage=t.onmessage?e=>{e.data&&t.onmessage?t.onmessage(e):console.log("No data received from websockets, please contact support@getsquid.ai with this message.")}:Hr,r.onopen=function(e){o.connected=!0,(t.onopen||Hr)(e),n=0},r.onclose=function(e){if(o.connected=!1,4999!==e.code&&4001!==e.code)return Ne.debug("WebSocket closed. Reconnecting. Close code: ",e.code),(t.onclose||Hr)(e),void o.reconnect(e);(t.onclose||Hr)(e)},r.onerror=function(e){o.connected=!1,e&&"ECONNREFUSED"===e.code?o.reconnect(e):o.closeCalled||(t.onerror||Hr)(e)}},reconnect(e){const r=void 0!==t.maxAttempts?t.maxAttempts:1/0;i&&n++<r?i=setTimeout((function(){(t.onreconnect||Hr)(e),Ne.debug("WebSocket trying to reconnect..."),o.open()}),t.timeoutMillis||1e3):(t.onmaximum||Hr)(e)},json(e){r.send(JSON.stringify(e))},send(e){r.send(e)},close(e=4999,t){o.closeCalled=!0;try{o.connected=!1,clearTimeout(i),i=void 0,r.close(e,t)}catch(e){}}};return o.open(),o}(r,{timeoutMillis:1e4,onmessage:e=>this.onMessage(e.data),onopen:()=>{Ne.debug(this.clientIdService.getClientId(),`Connection to socket established. Endpoint: ${e}`)},onreconnect:()=>{Ne.debug(t,"WebSocket reconnect event triggered"),this.clientIdService.getClientId()===t?this.connectionReady.value&&this.connectionReady.next(!1):Ne.debug(t,`WebSocket reconnect event triggered - ignored because the client id changed. Old: ${this.clientIdService.getClientId()}`)},onclose:()=>{Ne.debug(t,"WebSocket onclose event triggered"),this.clientIdService.getClientId()===t?this.connectionReady.value&&this.connectionReady.next(!1):Ne.debug(t,`WebSocket onclose event triggered - ignored because the client id changed. new: ${this.clientIdService.getClientId()}`)},onerror:e=>console.error("WebSocket error:",e)})}disconnectForTest(){this.connectionReady.next(!1),this.socket?.close(4998)}onConnectionReady(){this.connectionReady.next(!0),this.connectedAtLeastOnce?this.sendMessage({type:"catchup"}):this.connectedAtLeastOnce=!0}onMessage(e){if("connectionReady"===e)return Ne.debug(this.clientIdService.getClientId(),"Got socket message: connectionReady"),void this.onConnectionReady();const t=ke(e);for(const e of t)this.allMessagesObserver.next(e),this.seenMessageIds.has(e.messageId)||(this.seenMessageIds.add(e.messageId),Ne.debug(this.clientIdService.getClientId(),new Date,"Got socket message",JSON.stringify(e,null,2)),this.messageNotificationWrapper((()=>{this.webSocketObserver.next(e)})))}setupMessageAcknowledgments(){const e=new o.Subject;this.allMessagesObserver.subscribe((t=>{t?.messageId&&e.next(t.messageId)}));const t=[];e.pipe((0,o.tap)((e=>t.push(e))),(0,o.debounceTime)(100)).subscribe((async()=>{const e=[...t.splice(0)];this.sendMessage({type:"acknowledge",payload:e})}))}async destruct(){this.sendKillMessage(),await(0,o.firstValueFrom)((0,o.timer)(0)),this.connectionReady.next(!1),await(0,o.firstValueFrom)((0,o.timer)(0)),clearInterval(this.tickInterval),this.closeCurrentSocketSilently(),this.webSocketObserver.complete(),this.allMessagesObserver.complete(),this.destructSubject.next()}}function Jr(e){(0,ie.assertString)(e,"Invalid application ID");const[t,r,n,i]=e.split("-");return(0,ie.assertTruthy)(!i,`Invalid application ID: ${e}`),{appId:t,environmentId:r??"prod",squidDeveloperId:n}}function Kr(e,t){return`${Jr(e).appId}${t&&"prod"!==t?`-${t}`:""}`}function Zr(e,t,r){return`${Kr(e,t)}${r?`-${r}`:""}`}class Xr{constructor(e="built_in_storage",t){this.integrationId=e,this.rpcManager=t}async uploadFile(e,t,r){const n={integrationId:this.integrationId,dirPathInBucket:e,expirationInSeconds:r};await this.rpcManager.post("storage/uploadFile",n,[t])}async getFileMetadata(e){const t={integrationId:this.integrationId,filePathInBucket:e};return await this.rpcManager.post("storage/getFileMetadata",t)}async getDownloadUrl(e,t){const r={integrationId:this.integrationId,filePathInBucket:e,urlExpirationInSeconds:t};return await this.rpcManager.post("storage/getDownloadUrl",r)}async listDirectoryContents(e){const t={integrationId:this.integrationId,dirPathInBucket:e};return await this.rpcManager.post("storage/listDirectoryContents",t)}async deleteFile(e){await this.deleteFiles([e])}async deleteFiles(e){const t={integrationId:this.integrationId,filePathsInBucket:e};await this.rpcManager.post("storage/deleteFiles",t)}}class en{constructor(e){this.rpcManager=e}async extractDataFromDocumentFile(e,t){return t||(t={}),await this.rpcManager.post("documentExtraction/extractDataFromDocumentFile",t,[e])}}class tn{constructor(e,t){this.integrationId=e,this.rpcManager=t}async saveAuthCode(e,t){const r={authCode:e,personalStorageConfig:{identifier:t,integrationId:this.integrationId}};return await this.rpcManager.post("personalStorage/saveAuthCode",r)}async getAccessToken(e){const t={personalStorageConfig:{identifier:e,integrationId:this.integrationId}};return await this.rpcManager.post("personalStorage/getAccessToken",t)}async extractDataFromDocument(e,t){const r={documentId:e,personalStorageConfig:{identifier:t,integrationId:this.integrationId}};return await this.rpcManager.post("personalStorage/extractDataFromDocument",r)}async indexDocumentOrFolder(e,t,r,n){const i={documentOrFolderId:e,metadata:n,personalStorageConfig:{identifier:t,integrationId:this.integrationId},agentId:r};await this.rpcManager.post("personalStorage/indexDocumentOrFolder",i)}async listIndexedDocuments(e,t,r){const n={personalStorageConfig:{identifier:e,integrationId:this.integrationId},agentId:t,type:r};return(await this.rpcManager.post("personalStorage/listIndexedDocuments",n)).documents}async unindexDocument(e,t,r){const n={documentId:e,personalStorageConfig:{identifier:t,integrationId:this.integrationId},agentId:r};await this.rpcManager.post("personalStorage/unindexDocument",n)}}class rn{constructor(e,t,r){this.rpcManager=e,this.region=t,this.appId=r,this.integrationClient=new Yr(this.rpcManager,this.region,this.appId),this.secretClient=new Ur(this.rpcManager)}integrations(){return this.integrationClient}secrets(){return this.secretClient}}class nn{constructor(e){this.rpcManager=e}async createMatchMaker(e){const t=await this.rpcManager.post("matchMaking/createMatchMaker",{matchMaker:e});return new on(t,this.rpcManager)}async getMatchMaker(e){const t=(await this.rpcManager.post("matchMaking/getMatchMaker",{matchMakerId:e})).matchMaker;if(t)return new on(t,this.rpcManager)}async listMatchMakers(){return await this.rpcManager.post("matchMaking/listMatchMakers",{})}}class on{constructor(e,t){this.matchMaker=e,this.rpcManager=t,this.id=e.id}async insertEntity(e){await this.rpcManager.post("matchMaking/insertEntity",{matchMakerId:this.id,entity:e})}async insertManyEntities(e){await this.rpcManager.post("matchMaking/insertEntities",{matchMakerId:this.id,entities:e})}async delete(){await this.rpcManager.post("matchMaking/deleteMatchMaker",{matchMakerId:this.id})}async deleteEntity(e){await this.rpcManager.post("matchMaking/deleteEntity",{entityId:e,matchMakerId:this.id})}async findMatches(e,t={}){return(await this.rpcManager.post("matchMaking/findMatches",{matchMakerId:this.id,entityId:e,options:t})).matches}async findMatchesForEntity(e,t={}){return(await this.rpcManager.post("matchMaking/findMatchesForEntity",{matchMakerId:this.id,entity:e,options:t})).matches}async listEntities(e,t={}){return await this.rpcManager.post("matchMaking/listEntities",{categoryId:e,options:t,matchMakerId:this.id})}async getEntity(e){return(await this.rpcManager.post("matchMaking/getEntity",{matchMakerId:this.id,entityId:e})).entity}getMatchMakerDetails(){return this.matchMaker}}class sn{constructor(e,t){this.socketManager=e,this.rpcManager=t,this.aiAssistantClient=new i(this.rpcManager)}agent(e=C){return this.aiAgentClient||(this.aiAgentClient=new de(this.rpcManager,this.socketManager)),this.aiAgentClient.agent(e)}async listAgents(){return this.aiAgentClient||(this.aiAgentClient=new de(this.rpcManager,this.socketManager)),this.aiAgentClient.listAgents()}assistant(){return this.aiAssistantClient}image(){return new he(this.rpcManager)}audio(){return new fe(this.rpcManager)}matchMaking(){return new nn(this.rpcManager)}executeAiQuery(e,t,r){const n={integrationId:e,prompt:t,options:r};return this.rpcManager.post("aiData/executeAiQuery",n)}executeAiQueryMulti(e,t,r){const n={integrationIds:e,prompt:t,options:r};return this.rpcManager.post("aiData/executeAiQueryMulti",n)}executeAiApiCall(e,t,r,n){const i={integrationId:e,prompt:t,allowedEndpoints:r,provideExplanation:n};return this.rpcManager.post("aiData/executeAiApiCall",i)}}class an{static{this.squidInstancesMap={}}constructor(e){this.options=e,this.destructManager=new Ut,(0,ie.assertTruthy)(e.appId,"APP_ID_MUST_BE_PROVIDED");for(const e of Object.getOwnPropertyNames(Object.getPrototypeOf(this))){const t=this[e];"function"!=typeof t||"constructor"===e||e.startsWith("_")||(this[e]=t.bind(this))}const t="prod"!==e.environmentId&&e.squidDeveloperId,r=Zr(e.appId,e.environmentId,t?e.squidDeveloperId:void 0);this.clientIdService=new qe(this.destructManager),Ne.debug(this.clientIdService.getClientId(),"New Squid instance created"),this.authManager=new be(e.apiKey,e.authProvider),this.socketManager=new Gr(this.clientIdService,e.region,r,e.messageNotificationWrapper,this.destructManager,this.authManager),this.rpcManager=new Rr(e.region,r,this.destructManager,{},this.authManager,this.clientIdService),this.aiClient=new sn(this.socketManager,this.rpcManager),this.apiClient=new ye(this.rpcManager),this.documentStore=new Wt,this.lockManager=new _r,this.distributedLockManager=new Qt(this.socketManager,this.destructManager),this.documentIdentityService=new Vt(this.documentStore,this.destructManager),this.documentReferenceFactory=new Yt(this.documentIdentityService),this.querySender=new cr(this.rpcManager,this.destructManager),this.observabilityClient=new qr(this.rpcManager),this.schedulerClient=new $r(this.rpcManager),this._appId=r,this.querySubscriptionManager=new vr(this.rpcManager,this.clientIdService,this.documentStore,this.destructManager,this.documentIdentityService,this.querySender,this.socketManager),this.localQueryManager=new ar(this.documentStore,this.documentReferenceFactory,this.querySubscriptionManager);const n=new Ht(this.rpcManager,this.lockManager,this.querySender);this.queryBuilderFactory=new bt(this.querySubscriptionManager,this.localQueryManager,this.documentReferenceFactory,this.documentIdentityService),this.dataManager=new Lt(this.documentStore,n,this.socketManager,this.querySubscriptionManager,this.queryBuilderFactory,this.lockManager,this.destructManager,this.documentIdentityService,this.querySender),this.collectionReferenceFactory=new jt(this.documentReferenceFactory,this.queryBuilderFactory,this.querySubscriptionManager,this.dataManager),this.documentReferenceFactory.setDataManager(this.dataManager),this.backendFunctionManager=new xe(this.rpcManager),this.nativeQueryManager=new zt(this.rpcManager),this._connectionDetails=new Pt(this.clientIdService,this.socketManager),this.queueManagerFactory=new Sr(this.rpcManager,this.socketManager,this.destructManager),this.adminClient=new rn(this.rpcManager,this.options.region,function(e){const t=Jr(e);return Kr(t.appId,t.environmentId)}(r))}static getInstance(e){const t=Pe(e);let r=an.squidInstancesMap[t];return r||(r=new an(e),an.squidInstancesMap[t]=r,r)}static getInstances(){return Object.values(an.squidInstancesMap)}setAuthProvider(e){this.authManager.setAuthProvider(e)}collection(e,t=Ke){return this._validateNotDestructed(),this.collectionReferenceFactory.get(e,t)}runInTransaction(e){return this._validateNotDestructed(),this.dataManager.runInTransaction(e)}executeFunction(e,...t){return this._validateNotDestructed(),(0,o.firstValueFrom)(this.backendFunctionManager.executeFunctionAndSubscribe(e,...t))}executeNativeRelationalQuery(e,t,r={}){const n={type:"relational",query:t,params:r,integrationId:e};return this.nativeQueryManager.executeNativeQuery(n)}executeNativeMongoQuery(e,t,r){const n={type:"mongo",collectionName:t,aggregationPipeline:r,integrationId:e};return this.nativeQueryManager.executeNativeQuery(n)}ai(){return this._validateNotDestructed(),this.aiClient}api(){return this._validateNotDestructed(),this.apiClient}admin(){return this._validateNotDestructed(),this.adminClient}storage(e="built_in_storage"){return this._validateNotDestructed(),new Xr(e,this.rpcManager)}personalStorage(e){return this._validateNotDestructed(),new tn(e,this.rpcManager)}extraction(){return this._validateNotDestructed(),new en(this.rpcManager)}get observability(){return this.observabilityClient}get schedulers(){return this.schedulerClient}get appId(){return this._appId}acquireLock(e){return this._validateNotDestructed(),this.distributedLockManager.lock(e)}async withLock(e,t){const r=await this.acquireLock(e);try{return await t(r)}finally{r.release()}}queue(e,t=Ze){return this._validateNotDestructed(),this.queueManagerFactory.get(t,e)}async destruct(){return this.destructManager.destruct().finally((()=>{const e=Object.entries(an.squidInstancesMap).find((([,e])=>e===this));e&&delete an.squidInstancesMap[e[0]]}))}connectionDetails(){return this._validateNotDestructed(),this._connectionDetails}async _unsubscribe(){this.querySubscriptionManager.unsubscribe(),await this.rpcManager.awaitAllSettled()}_validateNotDestructed(){(0,ie.assertTruthy)(!this.destructManager.isDestructing,"The client was already destructed.")}internal(){const{rpcManager:e}=this;return{getApplicationUrl:(e,t,r)=>Er(e,t,r),getStaticHeaders:()=>e.getStaticHeaders(),getAuthHeaders:()=>e.getAuthHeaders(),appIdWithEnvironmentIdAndDevId:(e,t,r)=>Zr(e,t,r)}}}var un=exports;for(var cn in n)un[cn]=n[cn];n.__esModule&&Object.defineProperty(un,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{"use strict";var e={11:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.selectUniquePaths=t.selectUniquePathPrefixes=t.sortPaths=t.isPathPrefix=t.extractPaths=t.deepCloneOnPath=t.deleteInPath=t.setInPath=t.apply=void 0;const n=r(5036);function i(e,t,r){if(void 0===r)return o(e,t);if(0===t.length)return(0,n.assertTruthy)("object"==typeof r&&null!==r&&!Array.isArray(r),(()=>`Root state must be a record. Trying to set '${r}', type: ${typeof r}`)),r;function i(e){const t=Number(e);return!isNaN(t)&&t>=0&&t!==1/0}let a=e;for(let e=0;e<t.length-1&&void 0!==a;e++){const r=t[e];(0,n.assertTruthy)(!Array.isArray(a)||i(r),(()=>`Invalid array index. Path: '${t.slice(0,e+1)}', index: '${r}'`)),a=a[r],(0,n.assertTruthy)(void 0===a||"object"==typeof a&&null!==a,(()=>`Cannot set a property to a non-record parent. Path: '${t.slice(0,e+1)}', type: '${null===a?"<null>":typeof a}'`))}const u=t[t.length-1];return(0,n.assertTruthy)(!Array.isArray(a)||i(u),(()=>`Invalid array index Path: '${t}`)),(null==a?void 0:a[u])===r?e:s(e,t,r)}function o(e,t){(0,n.assertTruthy)(0!==t.length,"Can't delete an empty path");let r=e;for(let i=0;i<t.length-1;i++){const o=t[i];if(r=r[o],void 0===r)return e;(0,n.assertTruthy)("object"==typeof r&&null!==r,(()=>`Cannot delete a property from a non-record parent. Path: '${t.slice(0,i+1)}', type: ${null===r?"<null>":typeof r}`))}const i=t[t.length-1];return void 0===r[i]?e:s(e,t,void 0)}function s(e,t,r){function i(e,r){(0,n.assertTruthy)(!Array.isArray(e),(()=>`Can't delete element of array. Path: '${t}'`)),delete e[r]}const o=Object.assign({},e);let s=o;for(let e=0;e<t.length-1;e++){const o=t[e],a=s[o];(0,n.assertTruthy)(void 0===a||"object"==typeof a&&null!==a,(()=>`Internal error: sub-path has an invalid type and can't be patched: '${t.slice(0,e+1)}', type: '${null===a?null:typeof a}'`));const u=void 0===a?void 0===r?void 0:{}:Array.isArray(a)?[...a]:Object.assign({},a);if(void 0===u)return i(s,o),s;s[o]=u,s=u}const a=t[t.length-1];return void 0===r?i(s,a):s[a]=r,o}function a(e,t){if(e.length<t.length)return!1;for(let r=0;r<t.length;r++)if(e[r]!==t[r])return!1;return!0}function u(e){const t=[...e];return t.sort(((e,t)=>{for(let r=0;r<e.length;r++){if(r===t.length)return 1;const n=e[r].localeCompare(t[r]);if(0!==n)return n}return e.length-t.length})),t}function c(e){const t=u(e),r=t;for(let e=0;e<t.length-1;e++){const n=t[e];for(let i=e+1;i<t.length;i++){const o=t[i];n.length===o.length&&a(n,o)&&(r[i]=void 0,e++)}}return r.filter((e=>void 0!==e))}t.apply=function e(t,r){switch(r.type){case"set":return i(t,r.path,r.value);case"delete":return o(t,r.path);case"batch":return r.actions.reduce(((t,r)=>e(t,r)),t)}},t.setInPath=i,t.deleteInPath=o,t.deepCloneOnPath=s,t.extractPaths=function e(t,r){const n=[];if("set"===t.type||"delete"===t.type)n.push(t.path);else if("batch"===t.type)for(const r of t.actions)n.push(...e(r,"as-is"));return"unique-and-sorted"===r?c(n):n},t.isPathPrefix=a,t.sortPaths=u,t.selectUniquePathPrefixes=function(e){if(1===e.length)return[...e];if(e.some((e=>0===e.length)))return[[]];const t=u(e),r=t;for(let e=0;e<r.length-1;e++){const n=t[e];for(let i=e+1;i<t.length;i++)a(t[i],n)&&(r[i]=void 0,e++)}return r.filter((e=>void 0!==e))},t.selectUniquePaths=c},20:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),i=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.AnonymousSubject=t.Subject=void 0;var o=r(2023),s=r(7491),a=r(8083),u=r(7394),c=r(9916),l=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return n(t,e),t.prototype.lift=function(e){var t=new d(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new a.ObjectUnsubscribedError},t.prototype.next=function(e){var t=this;c.errorContext((function(){var r,n;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=i(t.currentObservers),s=o.next();!s.done;s=o.next())s.value.next(e)}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}}}))},t.prototype.error=function(e){var t=this;c.errorContext((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var r=t.observers;r.length;)r.shift().error(e)}}))},t.prototype.complete=function(){var e=this;c.errorContext((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,r=this,n=r.hasError,i=r.isStopped,o=r.observers;return n||i?s.EMPTY_SUBSCRIPTION:(this.currentObservers=null,o.push(e),new s.Subscription((function(){t.currentObservers=null,u.arrRemove(o,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t.thrownError,i=t.isStopped;r?e.error(n):i&&e.complete()},t.prototype.asObservable=function(){var e=new o.Observable;return e.source=this,e},t.create=function(e,t){return new d(e,t)},t}(o.Observable);t.Subject=l;var d=function(e){function t(t,r){var n=e.call(this)||this;return n.destination=t,n.source=r,n}return n(t,e),t.prototype.next=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)},t.prototype.error=function(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:s.EMPTY_SUBSCRIPTION},t}(l);t.AnonymousSubject=d},118:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferToggle=void 0;var i=r(7491),o=r(5416),s=r(2296),a=r(1266),u=r(6129),c=r(7394);t.bufferToggle=function(e,t){return o.operate((function(r,o){var l=[];s.innerFrom(e).subscribe(a.createOperatorSubscriber(o,(function(e){var r=[];l.push(r);var n=new i.Subscription;n.add(s.innerFrom(t(e)).subscribe(a.createOperatorSubscriber(o,(function(){c.arrRemove(l,r),o.next(r),n.unsubscribe()}),u.noop)))}),u.noop)),r.subscribe(a.createOperatorSubscriber(o,(function(e){var t,r;try{for(var i=n(l),o=i.next();!o.done;o=i.next())o.value.push(e)}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}}),(function(){for(;l.length>0;)o.next(l.shift());o.complete()})))}))}},160:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.argsOrArgArray=void 0;var r=Array.isArray;t.argsOrArgArray=function(e){return 1===e.length&&r(e[0])?e[0]:e}},177:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.raceWith=void 0;var o=r(4143),s=r(5416),a=r(9391);t.raceWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length?s.operate((function(t,r){o.raceInit(i([t],n(e)))(r)})):a.identity}},183:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.distinctUntilKeyChanged=void 0;var n=r(9939);t.distinctUntilKeyChanged=function(e,t){return n.distinctUntilChanged((function(r,n){return t?t(r[e],n[e]):r[e]===n[e]}))}},234:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromisePoolExecutor=void 0;const n=r(5642),i=r(1172),o=r(7837),s=r(6858);t.PromisePoolExecutor=class{constructor(){this.meta={tasks:[],items:[],errors:[],results:[],stopped:!1,concurrency:10,shouldResultsCorrespond:!1,processedItems:[],taskTimeout:0},this.handler=e=>e,this.errorHandler=void 0,this.onTaskStartedHandlers=[],this.onTaskFinishedHandlers=[]}useConcurrency(e){if(!this.isValidConcurrency(e))throw i.ValidationError.createFrom(`"concurrency" must be a number, 1 or up. Received "${e}" (${typeof e})`);return this.meta.concurrency=e,this}isValidConcurrency(e){return"number"==typeof e&&e>=1}withTaskTimeout(e){return this.meta.taskTimeout=e,this}concurrency(){return this.meta.concurrency}useCorrespondingResults(e){return this.meta.shouldResultsCorrespond=e,this}shouldUseCorrespondingResults(){return this.meta.shouldResultsCorrespond}taskTimeout(){return this.meta.taskTimeout}for(e){return this.meta.items=e,this}items(){return this.meta.items}itemsCount(){const e=this.items();return Array.isArray(e)?e.length:NaN}tasks(){return this.meta.tasks}activeTaskCount(){return this.activeTasksCount()}activeTasksCount(){return this.tasks().length}processedItems(){return this.meta.processedItems}processedCount(){return this.processedItems().length}processedPercentage(){return this.processedCount()/this.itemsCount()*100}results(){return this.meta.results}errors(){return this.meta.errors}withHandler(e){return this.handler=e,this}hasErrorHandler(){return!!this.errorHandler}handleError(e){return this.errorHandler=e,this}onTaskStarted(e){return this.onTaskStartedHandlers=e,this}onTaskFinished(e){return this.onTaskFinishedHandlers=e,this}hasReachedConcurrencyLimit(){return this.activeTasksCount()>=this.concurrency()}stop(){throw this.markAsStopped(),new s.StopThePromisePoolError}markAsStopped(){return this.meta.stopped=!0,this}isStopped(){return this.meta.stopped}async start(){return await this.validateInputs().prepareResultsArray().process()}validateInputs(){if("function"!=typeof this.handler)throw i.ValidationError.createFrom("The first parameter for the .process(fn) method must be a function");const e=this.taskTimeout();if(!(null==e||"number"==typeof e&&e>=0))throw i.ValidationError.createFrom(`"timeout" must be undefined or a number. A number must be 0 or up. Received "${String(e)}" (${typeof e})`);if(!this.areItemsValid())throw i.ValidationError.createFrom(`"items" must be an array, an iterable or an async iterable. Received "${typeof this.items()}"`);if(this.errorHandler&&"function"!=typeof this.errorHandler)throw i.ValidationError.createFrom(`The error handler must be a function. Received "${typeof this.errorHandler}"`);return this.onTaskStartedHandlers.forEach((e=>{if(e&&"function"!=typeof e)throw i.ValidationError.createFrom(`The onTaskStarted handler must be a function. Received "${typeof e}"`)})),this.onTaskFinishedHandlers.forEach((e=>{if(e&&"function"!=typeof e)throw i.ValidationError.createFrom(`The error handler must be a function. Received "${typeof e}"`)})),this}areItemsValid(){const e=this.items();return!!Array.isArray(e)||"function"==typeof e[Symbol.iterator]||"function"==typeof e[Symbol.asyncIterator]}prepareResultsArray(){const e=this.items();return Array.isArray(e)&&this.shouldUseCorrespondingResults()?(this.meta.results=Array(e.length).fill(n.PromisePool.notRun),this):this}async process(){let e=0;for await(const t of this.items()){if(this.isStopped())break;this.shouldUseCorrespondingResults()&&(this.results()[e]=n.PromisePool.notRun),this.startProcessing(t,e),e+=1,await this.waitForProcessingSlot()}return await this.drained()}async waitForProcessingSlot(){for(;this.hasReachedConcurrencyLimit();)await this.waitForActiveTaskToFinish()}async waitForActiveTaskToFinish(){await Promise.race(this.tasks())}startProcessing(e,t){const r=this.createTaskFor(e,t).then((e=>{this.save(e,t).removeActive(r)})).catch((async n=>{await this.handleErrorFor(n,e,t),this.removeActive(r)})).finally((()=>{this.processedItems().push(e),this.runOnTaskFinishedHandlers(e)}));this.tasks().push(r),this.runOnTaskStartedHandlers(e)}async createTaskFor(e,t){if(void 0===this.taskTimeout())return this.handler(e,t,this);const[r,n]=this.createTaskTimeout(e);return Promise.race([this.handler(e,t,this),r()]).finally(n)}createTaskTimeout(e){let t;return[async()=>new Promise(((r,n)=>{t=setTimeout((()=>{n(new o.PromisePoolError(`Task in promise pool timed out after ${this.taskTimeout()}ms`,e))}),this.taskTimeout())})),()=>clearTimeout(t)]}save(e,t){return this.shouldUseCorrespondingResults()?this.results()[t]=e:this.results().push(e),this}removeActive(e){return this.tasks().splice(this.tasks().indexOf(e),1),this}async handleErrorFor(e,t,r){if(this.shouldUseCorrespondingResults()&&(this.results()[r]=n.PromisePool.failed),!this.isStoppingThePoolError(e)){if(this.isValidationError(e))throw this.markAsStopped(),e;this.hasErrorHandler()?await this.runErrorHandlerFor(e,t):this.saveErrorFor(e,t)}}isStoppingThePoolError(e){return e instanceof s.StopThePromisePoolError}isValidationError(e){return e instanceof i.ValidationError}async runErrorHandlerFor(e,t){try{await(this.errorHandler?.(e,t,this))}catch(e){this.rethrowIfNotStoppingThePool(e)}}runOnTaskStartedHandlers(e){this.onTaskStartedHandlers.forEach((t=>{t(e,this)}))}runOnTaskFinishedHandlers(e){this.onTaskFinishedHandlers.forEach((t=>{t(e,this)}))}rethrowIfNotStoppingThePool(e){if(!this.isStoppingThePoolError(e))throw e}saveErrorFor(e,t){this.errors().push(o.PromisePoolError.createFrom(e,t))}async drained(){return await this.drainActiveTasks(),{errors:this.errors(),results:this.results()}}async drainActiveTasks(){await Promise.all(this.tasks())}}},264:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retryWhen=void 0;var n=r(2296),i=r(20),o=r(5416),s=r(1266);t.retryWhen=function(e){return o.operate((function(t,r){var o,a,u=!1,c=function(){o=t.subscribe(s.createOperatorSubscriber(r,void 0,void 0,(function(t){a||(a=new i.Subject,n.innerFrom(e(a)).subscribe(s.createOperatorSubscriber(r,(function(){return o?c():u=!0})))),a&&a.next(t)}))),u&&(o.unsubscribe(),o=null,u=!1,c())};c()}))}},297:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.publish=void 0;var n=r(20),i=r(9924),o=r(2216);t.publish=function(e){return e?function(t){return o.connect(e)(t)}:function(e){return i.multicast(new n.Subject)(e)}}},452:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isPromise=void 0;var n=r(4717);t.isPromise=function(e){return n.isFunction(null==e?void 0:e.then)}},469:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Scheduler=void 0;var n=r(4575),i=function(){function e(t,r){void 0===r&&(r=e.now),this.schedulerActionCtor=t,this.now=r}return e.prototype.schedule=function(e,t,r){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(r,t)},e.now=n.dateTimestampProvider.now,e}();t.Scheduler=i},573:e=>{e.exports=require("rxjs")},587:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.joinAllInternals=void 0;var n=r(9391),i=r(8240),o=r(2393),s=r(1282),a=r(2984);t.joinAllInternals=function(e,t){return o.pipe(a.toArray(),s.mergeMap((function(t){return e(t)})),t?i.mapOneOrManyArgs(t):n.identity)}},665:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.UnsubscriptionError=void 0;var n=r(6871);t.UnsubscriptionError=n.createErrorClass((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}))},787:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.takeLast=void 0;var i=r(7209),o=r(5416),s=r(1266);t.takeLast=function(e){return e<=0?function(){return i.EMPTY}:o.operate((function(t,r){var i=[];t.subscribe(s.createOperatorSubscriber(r,(function(t){i.push(t),e<i.length&&i.shift()}),(function(){var e,t;try{for(var o=n(i),s=o.next();!s.done;s=o.next()){var a=s.value;r.next(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}r.complete()}),void 0,(function(){i=null})))}))}},795:(e,t)=>{function r(e,t,r){return{kind:e,value:t,error:r}}Object.defineProperty(t,"__esModule",{value:!0}),t.createNotification=t.nextNotification=t.errorNotification=t.COMPLETE_NOTIFICATION=void 0,t.COMPLETE_NOTIFICATION=r("C",void 0,void 0),t.errorNotification=function(e){return r("E",void 0,e)},t.nextNotification=function(e){return r("N",e,void 0)},t.createNotification=r},861:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatAll=void 0;var n=r(1867);t.concatAll=function(){return n.mergeAll(1)}},884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.single=void 0;var n=r(7676),i=r(8168),o=r(2318),s=r(5416),a=r(1266);t.single=function(e){return s.operate((function(t,r){var s,u=!1,c=!1,l=0;t.subscribe(a.createOperatorSubscriber(r,(function(n){c=!0,e&&!e(n,l++,t)||(u&&r.error(new i.SequenceError("Too many matching values")),u=!0,s=n)}),(function(){u?(r.next(s),r.complete()):r.error(c?new o.NotFoundError("No matching values"):new n.EmptyError)})))}))}},973:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.zipWith=void 0;var o=r(2681);t.zipWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.zip.apply(void 0,i([],n(e)))}},994:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatestInit=t.combineLatest=void 0;var n=r(2023),i=r(3787),o=r(5294),s=r(9391),a=r(8240),u=r(1824),c=r(4950),l=r(1266),d=r(5031);function h(e,t,r){return void 0===r&&(r=s.identity),function(n){f(t,(function(){for(var i=e.length,s=new Array(i),a=i,u=i,c=function(i){f(t,(function(){var c=o.from(e[i],t),d=!1;c.subscribe(l.createOperatorSubscriber(n,(function(e){s[i]=e,d||(d=!0,u--),u||n.next(r(s.slice()))}),(function(){--a||n.complete()})))}),n)},d=0;d<i;d++)c(d)}),n)}}function f(e,t,r){e?d.executeSchedule(r,e,t):t()}t.combineLatest=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=u.popScheduler(e),l=u.popResultSelector(e),d=i.argsArgArrayOrObject(e),f=d.args,p=d.keys;if(0===f.length)return o.from([],r);var y=new n.Observable(h(f,r,p?function(e){return c.createObject(p,e)}:s.identity));return l?y.pipe(a.mapOneOrManyArgs(l)):y},t.combineLatestInit=h},1012:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatMap=void 0;var n=r(1282),i=r(4717);t.concatMap=function(e,t){return i.isFunction(t)?n.mergeMap(e,t,1):n.mergeMap(e,1)}},1017:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncScheduler=void 0;var i=r(469),o=function(e){function t(t,r){void 0===r&&(r=i.Scheduler.now);var n=e.call(this,t,r)||this;return n.actions=[],n._active=!1,n}return n(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var r;this._active=!0;do{if(r=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,r){for(;e=t.shift();)e.unsubscribe();throw r}}},t}(i.Scheduler);t.AsyncScheduler=o},1080:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncAction=void 0;var i=r(7638),o=r(2320),s=r(7394),a=function(e){function t(t,r){var n=e.call(this,t,r)||this;return n.scheduler=t,n.work=r,n.pending=!1,n}return n(t,e),t.prototype.schedule=function(e,t){var r;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var n=this.id,i=this.scheduler;return null!=n&&(this.id=this.recycleAsyncId(i,n,t)),this.pending=!0,this.delay=t,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(i,this.id,t),this},t.prototype.requestAsyncId=function(e,t,r){return void 0===r&&(r=0),o.intervalProvider.setInterval(e.flush.bind(e,this),r)},t.prototype.recycleAsyncId=function(e,t,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return t;null!=t&&o.intervalProvider.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(e,t);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var r,n=!1;try{this.work(e)}catch(e){n=!0,r=e||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),r},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,r=this.scheduler,n=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,s.arrRemove(n,this),null!=t&&(this.id=this.recycleAsyncId(r,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(i.Action);t.AsyncAction=a},1157:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concatMapTo=void 0;var n=r(1012),i=r(4717);t.concatMapTo=function(e,t){return i.isFunction(t)?n.concatMap((function(){return e}),t):n.concatMap((function(){return e}))}},1172:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ValidationError=void 0;class r extends Error{constructor(e){super(e),Error.captureStackTrace&&"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static createFrom(e){return new this(e)}}t.ValidationError=r},1195:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.elementAt=void 0;var n=r(9148),i=r(2914),o=r(5956),s=r(7507),a=r(6803);t.elementAt=function(e,t){if(e<0)throw new n.ArgumentOutOfRangeError;var r=arguments.length>=2;return function(u){return u.pipe(i.filter((function(t,r){return r===e})),a.take(1),r?s.defaultIfEmpty(t):o.throwIfEmpty((function(){return new n.ArgumentOutOfRangeError})))}}},1222:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.BehaviorSubject=void 0;var i=function(e){function t(t){var r=e.call(this)||this;return r._value=t,r}return n(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(t){var r=e.prototype._subscribe.call(this,t);return!r.closed&&t.next(this._value),r},t.prototype.getValue=function(){var e=this,t=e.hasError,r=e.thrownError,n=e._value;if(t)throw r;return this._throwIfClosed(),n},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(r(20).Subject);t.BehaviorSubject=i},1266:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.OperatorSubscriber=t.createOperatorSubscriber=void 0;var i=r(4512);t.createOperatorSubscriber=function(e,t,r,n,i){return new o(e,t,r,n,i)};var o=function(e){function t(t,r,n,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return n(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(i.Subscriber);t.OperatorSubscriber=o},1276:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.not=void 0,t.not=function(e,t){return function(r,n){return!e.call(t,r,n)}}},1282:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeMap=void 0;var n=r(4828),i=r(2296),o=r(5416),s=r(3754),a=r(4717);t.mergeMap=function e(t,r,u){return void 0===u&&(u=1/0),a.isFunction(r)?e((function(e,o){return n.map((function(t,n){return r(e,t,o,n)}))(i.innerFrom(t(e,o)))}),u):("number"==typeof r&&(u=r),o.operate((function(e,r){return s.mergeInternals(e,r,t,u)})))}},1306:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.min=void 0;var n=r(3818),i=r(4717);t.min=function(e){return n.reduce(i.isFunction(e)?function(t,r){return e(t,r)<0?t:r}:function(e,t){return e<t?e:t})}},1333:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.assertDate=t.assertEmail=t.assertHexString=t.assertUuid=t.assertBoolean=t.assertNumber=t.assertString=void 0,t.formatError=s,t.assertNonNullable=function(e,t){(0,n.assertTruthy)((0,i.isNonNullable)(e),(()=>s(t,"Value is "+(void 0===e?"undefined":"null"),e)))};const n=r(6373),i=r(4665),o=r(6663);function s(e,t,r){const i=(0,n.getAssertionErrorFromProvider)(e);if("object"==typeof i)throw i;return`${i?`${i}: `:""}${t} ${(0,o.formatValue)(r)}`}t.assertString=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isString)(e),(()=>s(t,"Not a string",e)))},t.assertNumber=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isNumber)(e),(()=>s(t,"Not a number",e)))},t.assertBoolean=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isBoolean)(e),(()=>s(t,"Not a boolean",e)))},t.assertUuid=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isUuid)(e),(()=>s(t,"Invalid uuid",e)))},t.assertHexString=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isHexString)(e),(()=>s(t,"Invalid hex string",e)))},t.assertEmail=(e,t=void 0)=>{(0,n.assertTruthy)((0,i.isEmail)(e),(()=>s(t,"Invalid email",e)))},t.assertDate=(e,t=void 0)=>{(0,n.assertTruthy)(e instanceof Date,(()=>s(t,"Invalid Date",e)))}},1357:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mapTo=void 0;var n=r(4828);t.mapTo=function(e){return n.map((function(){return e}))}},1424:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.combineAll=void 0;var n=r(2945);t.combineAll=n.combineLatestAll},1432:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.first=void 0;var n=r(7676),i=r(2914),o=r(6803),s=r(7507),a=r(5956),u=r(9391);t.first=function(e,t){var r=arguments.length>=2;return function(c){return c.pipe(e?i.filter((function(t,r){return e(t,r,c)})):u.identity,o.take(1),r?s.defaultIfEmpty(t):a.throwIfEmpty((function(){return new n.EmptyError})))}}},1507:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.ConnectableObservable=void 0;var i=r(2023),o=r(7491),s=r(5884),a=r(1266),u=r(5416),c=function(e){function t(t,r){var n=e.call(this)||this;return n.source=t,n.subjectFactory=r,n._subject=null,n._refCount=0,n._connection=null,u.hasLift(t)&&(n.lift=t.lift),n}return n(t,e),t.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},t.prototype.getSubject=function(){var e=this._subject;return e&&!e.isStopped||(this._subject=this.subjectFactory()),this._subject},t.prototype._teardown=function(){this._refCount=0;var e=this._connection;this._subject=this._connection=null,null==e||e.unsubscribe()},t.prototype.connect=function(){var e=this,t=this._connection;if(!t){t=this._connection=new o.Subscription;var r=this.getSubject();t.add(this.source.subscribe(a.createOperatorSubscriber(r,void 0,(function(){e._teardown(),r.complete()}),(function(t){e._teardown(),r.error(t)}),(function(){return e._teardown()})))),t.closed&&(this._connection=null,t=o.Subscription.EMPTY)}return t},t.prototype.refCount=function(){return s.refCount()(this)},t}(i.Observable);t.ConnectableObservable=c},1550:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.merge=void 0;var o=r(5416),s=r(160),a=r(1867),u=r(1824),c=r(5294);t.merge=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=u.popScheduler(e),l=u.popNumber(e,1/0);return e=s.argsOrArgArray(e),o.operate((function(t,o){a.mergeAll(l)(c.from(i([t],n(e)),r)).subscribe(o)}))}},1689:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.switchScan=void 0;var n=r(6300),i=r(5416);t.switchScan=function(e,t){return i.operate((function(r,i){var o=t;return n.switchMap((function(t,r){return e(o,t,r)}),(function(e,t){return o=t,t}))(r).subscribe(i),function(){o=null}}))}},1738:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.shareReplay=void 0;var n=r(5129),i=r(3329);t.shareReplay=function(e,t,r){var o,s,a,u,c=!1;return e&&"object"==typeof e?(o=e.bufferSize,u=void 0===o?1/0:o,s=e.windowTime,t=void 0===s?1/0:s,c=void 0!==(a=e.refCount)&&a,r=e.scheduler):u=null!=e?e:1/0,i.share({connector:function(){return new n.ReplaySubject(u,t,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:c})}},1763:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.zip=void 0;var o=r(2023),s=r(2296),a=r(160),u=r(7209),c=r(1266),l=r(1824);t.zip=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l.popResultSelector(e),d=a.argsOrArgArray(e);return d.length?new o.Observable((function(e){var t=d.map((function(){return[]})),o=d.map((function(){return!1}));e.add((function(){t=o=null}));for(var a=function(a){s.innerFrom(d[a]).subscribe(c.createOperatorSubscriber(e,(function(s){if(t[a].push(s),t.every((function(e){return e.length}))){var u=t.map((function(e){return e.shift()}));e.next(r?r.apply(void 0,i([],n(u))):u),t.some((function(e,t){return!e.length&&o[t]}))&&e.complete()}}),(function(){o[a]=!0,!t[a].length&&e.complete()})))},u=0;!e.closed&&u<d.length;u++)a(u);return function(){t=o=null}})):u.EMPTY}},1801:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isInteropObservable=void 0;var n=r(2131),i=r(4717);t.isInteropObservable=function(e){return i.isFunction(e[n.observable])}},1812:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.concat=void 0;var o=r(5416),s=r(861),a=r(1824),u=r(5294);t.concat=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=a.popScheduler(e);return o.operate((function(t,o){s.concatAll()(u.from(i([t],n(e)),r)).subscribe(o)}))}},1824:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.popNumber=t.popScheduler=t.popResultSelector=void 0;var n=r(4717),i=r(4568);function o(e){return e[e.length-1]}t.popResultSelector=function(e){return n.isFunction(o(e))?e.pop():void 0},t.popScheduler=function(e){return i.isScheduler(o(e))?e.pop():void 0},t.popNumber=function(e,t){return"number"==typeof o(e)?e.pop():t}},1867:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAll=void 0;var n=r(1282),i=r(9391);t.mergeAll=function(e){return void 0===e&&(e=1/0),n.mergeMap(i.identity,e)}},1909:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.every=void 0;var n=r(5416),i=r(1266);t.every=function(e,t){return n.operate((function(r,n){var o=0;r.subscribe(i.createOperatorSubscriber(n,(function(i){e.call(t,i,o++,r)||(n.next(!1),n.complete())}),(function(){n.next(!0),n.complete()})))}))}},1933:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.switchMapTo=void 0;var n=r(6300),i=r(4717);t.switchMapTo=function(e,t){return i.isFunction(t)?n.switchMap((function(){return e}),t):n.switchMap((function(){return e}))}},1997:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.onErrorResumeNext=t.onErrorResumeNextWith=void 0;var o=r(160),s=r(6467);function a(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=o.argsOrArgArray(e);return function(e){return s.onErrorResumeNext.apply(void 0,i([e],n(r)))}}t.onErrorResumeNextWith=a,t.onErrorResumeNext=a},2e3:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatest=void 0;var o=r(994),s=r(5416),a=r(160),u=r(8240),c=r(2393),l=r(1824);t.combineLatest=function e(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var d=l.popResultSelector(t);return d?c.pipe(e.apply(void 0,i([],n(t))),u.mapOneOrManyArgs(d)):s.operate((function(e,r){o.combineLatestInit(i([e],n(a.argsOrArgArray(t))))(r)}))}},2001:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timeoutWith=void 0;var n=r(4386),i=r(6349),o=r(7517);t.timeoutWith=function(e,t,r){var s,a,u;if(r=null!=r?r:n.async,i.isValidDate(e)?s=e:"number"==typeof e&&(a=e),!t)throw new TypeError("No observable provided to switch to");if(u=function(){return t},null==s&&null==a)throw new TypeError("No timeout provided.");return o.timeout({first:s,each:a,scheduler:r,with:u})}},2023:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Observable=void 0;var n=r(4512),i=r(7491),o=r(2131),s=r(2393),a=r(7820),u=r(4717),c=r(9916),l=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(e,t,r){var o,s=this,a=(o=e)&&o instanceof n.Subscriber||function(e){return e&&u.isFunction(e.next)&&u.isFunction(e.error)&&u.isFunction(e.complete)}(o)&&i.isSubscription(o)?e:new n.SafeSubscriber(e,t,r);return c.errorContext((function(){var e=s,t=e.operator,r=e.source;a.add(t?t.call(a,r):r?s._subscribe(a):s._trySubscribe(a))})),a},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var r=this;return new(t=d(t))((function(t,i){var o=new n.SafeSubscriber({next:function(t){try{e(t)}catch(e){i(e),o.unsubscribe()}},error:i,complete:t});r.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[o.observable]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.pipeFromArray(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=d(e))((function(e,r){var n;t.subscribe((function(e){return n=e}),(function(e){return r(e)}),(function(){return e(n)}))}))},e.create=function(t){return new e(t)},e}();function d(e){var t;return null!==(t=null!=e?e:a.config.Promise)&&void 0!==t?t:Promise}t.Observable=l},2070:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.concat=void 0;var n=r(861),i=r(1824),o=r(5294);t.concat=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.concatAll()(o.from(e,i.popScheduler(e)))}},2131:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.observable=void 0,t.observable="function"==typeof Symbol&&Symbol.observable||"@@observable"},2216:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.connect=void 0;var n=r(20),i=r(2296),o=r(5416),s=r(3123),a={connector:function(){return new n.Subject}};t.connect=function(e,t){void 0===t&&(t=a);var r=t.connector;return o.operate((function(t,n){var o=r();i.innerFrom(e(s.fromSubscribable(o))).subscribe(n),n.add(t.subscribe(o))}))}},2296:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function s(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},o=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e="function"==typeof s?s(e):e[Symbol.iterator](),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,i){!function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)}(n,i,(t=e[r](t)).done,t.value)}))}}},s=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.fromReadableStreamLike=t.fromAsyncIterable=t.fromIterable=t.fromPromise=t.fromArrayLike=t.fromInteropObservable=t.innerFrom=void 0;var a=r(5547),u=r(452),c=r(2023),l=r(1801),d=r(9451),h=r(3533),f=r(6847),p=r(3026),y=r(4717),b=r(4696),v=r(2131);function g(e){return new c.Observable((function(t){var r=e[v.observable]();if(y.isFunction(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")}))}function m(e){return new c.Observable((function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()}))}function _(e){return new c.Observable((function(t){e.then((function(e){t.closed||(t.next(e),t.complete())}),(function(e){return t.error(e)})).then(null,b.reportUnhandledError)}))}function S(e){return new c.Observable((function(t){var r,n;try{for(var i=s(e),o=i.next();!o.done;o=i.next()){var a=o.value;if(t.next(a),t.closed)return}}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}t.complete()}))}function O(e){return new c.Observable((function(t){(function(e,t){var r,s,a,u;return n(this,void 0,void 0,(function(){var n,c;return i(this,(function(i){switch(i.label){case 0:i.trys.push([0,5,6,11]),r=o(e),i.label=1;case 1:return[4,r.next()];case 2:if((s=i.sent()).done)return[3,4];if(n=s.value,t.next(n),t.closed)return[2];i.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=i.sent(),a={error:c},[3,11];case 6:return i.trys.push([6,,9,10]),s&&!s.done&&(u=r.return)?[4,u.call(r)]:[3,8];case 7:i.sent(),i.label=8;case 8:return[3,10];case 9:if(a)throw a.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function w(e){return O(p.readableStreamLikeToAsyncGenerator(e))}t.innerFrom=function(e){if(e instanceof c.Observable)return e;if(null!=e){if(l.isInteropObservable(e))return g(e);if(a.isArrayLike(e))return m(e);if(u.isPromise(e))return _(e);if(d.isAsyncIterable(e))return O(e);if(f.isIterable(e))return S(e);if(p.isReadableStreamLike(e))return w(e)}throw h.createInvalidObservableTypeError(e)},t.fromInteropObservable=g,t.fromArrayLike=m,t.fromPromise=_,t.fromIterable=S,t.fromAsyncIterable=O,t.fromReadableStreamLike=w},2318:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NotFoundError=void 0;var n=r(6871);t.NotFoundError=n.createErrorClass((function(e){return function(t){e(this),this.name="NotFoundError",this.message=t}}))},2320:function(e,t){var r=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},n=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.intervalProvider=void 0,t.intervalProvider={setInterval:function(e,i){for(var o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];var a=t.intervalProvider.delegate;return(null==a?void 0:a.setInterval)?a.setInterval.apply(a,n([e,i],r(o))):setInterval.apply(void 0,n([e,i],r(o)))},clearInterval:function(e){var r=t.intervalProvider.delegate;return((null==r?void 0:r.clearInterval)||clearInterval)(e)},delegate:void 0}},2366:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.schedulePromise=void 0;var n=r(2296),i=r(2803),o=r(4027);t.schedulePromise=function(e,t){return n.innerFrom(e).pipe(o.subscribeOn(t),i.observeOn(t))}},2393:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pipeFromArray=t.pipe=void 0;var n=r(9391);function i(e){return 0===e.length?n.identity:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}t.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i(e)},t.pipeFromArray=i},2409:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.delay=void 0;var n=r(4386),i=r(5137),o=r(5461);t.delay=function(e,t){void 0===t&&(t=n.asyncScheduler);var r=o.timer(e,t);return i.delayWhen((function(){return r}))}},2426:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},2457:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scan=void 0;var n=r(5416),i=r(7071);t.scan=function(e,t){return n.operate(i.scanInternals(e,t,arguments.length>=2,!0))}},2507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ignoreElements=void 0;var n=r(5416),i=r(1266),o=r(6129);t.ignoreElements=function(){return n.operate((function(e,t){e.subscribe(i.createOperatorSubscriber(t,o.noop))}))}},2681:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.zip=void 0;var o=r(1763),s=r(5416);t.zip=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.operate((function(t,r){o.zip.apply(void 0,i([t],n(e))).subscribe(r)}))}},2747:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debounce=void 0;var n=r(5416),i=r(6129),o=r(1266),s=r(2296);t.debounce=function(e){return n.operate((function(t,r){var n=!1,a=null,u=null,c=function(){if(null==u||u.unsubscribe(),u=null,n){n=!1;var e=a;a=null,r.next(e)}};t.subscribe(o.createOperatorSubscriber(r,(function(t){null==u||u.unsubscribe(),n=!0,a=t,u=o.createOperatorSubscriber(r,c,i.noop),s.innerFrom(e(t)).subscribe(u)}),(function(){c(),r.complete()}),void 0,(function(){a=u=null})))}))}},2778:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.startWith=void 0;var n=r(2070),i=r(1824),o=r(5416);t.startWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=i.popScheduler(e);return o.operate((function(t,i){(r?n.concat(e,t,r):n.concat(e,t)).subscribe(i)}))}},2803:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.observeOn=void 0;var n=r(5031),i=r(5416),o=r(1266);t.observeOn=function(e,t){return void 0===t&&(t=0),i.operate((function(r,i){r.subscribe(o.createOperatorSubscriber(i,(function(r){return n.executeSchedule(i,e,(function(){return i.next(r)}),t)}),(function(){return n.executeSchedule(i,e,(function(){return i.complete()}),t)}),(function(r){return n.executeSchedule(i,e,(function(){return i.error(r)}),t)})))}))}},2819:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createFind=t.find=void 0;var n=r(5416),i=r(1266);function o(e,t,r){var n="index"===r;return function(r,o){var s=0;r.subscribe(i.createOperatorSubscriber(o,(function(i){var a=s++;e.call(t,i,a,r)&&(o.next(n?a:i),o.complete())}),(function(){o.next(n?-1:void 0),o.complete()})))}}t.find=function(e,t){return n.operate(o(e,t,"value"))},t.createFind=o},2914:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.filter=void 0;var n=r(5416),i=r(1266);t.filter=function(e,t){return n.operate((function(r,n){var o=0;r.subscribe(i.createOperatorSubscriber(n,(function(r){return e.call(t,r,o++)&&n.next(r)})))}))}},2945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatestAll=void 0;var n=r(994),i=r(587);t.combineLatestAll=function(e){return i.joinAllInternals(n.combineLatest,e)}},2947:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.skipUntil=void 0;var n=r(5416),i=r(1266),o=r(2296),s=r(6129);t.skipUntil=function(e){return n.operate((function(t,r){var n=!1,a=i.createOperatorSubscriber(r,(function(){null==a||a.unsubscribe(),n=!0}),s.noop);o.innerFrom(e).subscribe(a),t.subscribe(i.createOperatorSubscriber(r,(function(e){return n&&r.next(e)})))}))}},2984:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toArray=void 0;var n=r(3818),i=r(5416),o=function(e,t){return e.push(t),e};t.toArray=function(){return i.operate((function(e,t){n.reduce(o,[])(e).subscribe(t)}))}},3016:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.windowWhen=void 0;var n=r(20),i=r(5416),o=r(1266),s=r(2296);t.windowWhen=function(e){return i.operate((function(t,r){var i,a,u=function(e){i.error(e),r.error(e)},c=function(){var t;null==a||a.unsubscribe(),null==i||i.complete(),i=new n.Subject,r.next(i.asObservable());try{t=s.innerFrom(e())}catch(e){return void u(e)}t.subscribe(a=o.createOperatorSubscriber(r,c,c,u))};c(),t.subscribe(o.createOperatorSubscriber(r,(function(e){return i.next(e)}),(function(){i.complete(),r.complete()}),u,(function(){null==a||a.unsubscribe(),i=null})))}))}},3026:function(e,t,r){var n=this&&this.__generator||function(e,t){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},i=this&&this.__await||function(e){return this instanceof i?(this.v=e,this):new i(e)},o=this&&this.__asyncGenerator||function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),s=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(e){o[e]&&(n[e]=function(t){return new Promise((function(r,n){s.push([e,t,r,n])>1||u(e,t)}))})}function u(e,t){try{(r=o[e](t)).value instanceof i?Promise.resolve(r.value.v).then(c,l):d(s[0][2],r)}catch(e){d(s[0][3],e)}var r}function c(e){u("next",e)}function l(e){u("throw",e)}function d(e,t){e(t),s.shift(),s.length&&u(s[0][0],s[0][1])}};Object.defineProperty(t,"__esModule",{value:!0}),t.isReadableStreamLike=t.readableStreamLikeToAsyncGenerator=void 0;var s=r(4717);t.readableStreamLikeToAsyncGenerator=function(e){return o(this,arguments,(function(){var t,r,o;return n(this,(function(n){switch(n.label){case 0:t=e.getReader(),n.label=1;case 1:n.trys.push([1,,9,10]),n.label=2;case 2:return[4,i(t.read())];case 3:return r=n.sent(),o=r.value,r.done?[4,i(void 0)]:[3,5];case 4:return[2,n.sent()];case 5:return[4,i(o)];case 6:return[4,n.sent()];case 7:return n.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))},t.isReadableStreamLike=function(e){return s.isFunction(null==e?void 0:e.getReader)}},3123:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.fromSubscribable=void 0;var n=r(2023);t.fromSubscribable=function(e){return new n.Observable((function(t){return e.subscribe(t)}))}},3329:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.share=void 0;var o=r(2296),s=r(20),a=r(4512),u=r(5416);function c(e,t){for(var r=[],s=2;s<arguments.length;s++)r[s-2]=arguments[s];if(!0!==t){if(!1!==t){var u=new a.SafeSubscriber({next:function(){u.unsubscribe(),e()}});return o.innerFrom(t.apply(void 0,i([],n(r)))).subscribe(u)}}else e()}t.share=function(e){void 0===e&&(e={});var t=e.connector,r=void 0===t?function(){return new s.Subject}:t,n=e.resetOnError,i=void 0===n||n,l=e.resetOnComplete,d=void 0===l||l,h=e.resetOnRefCountZero,f=void 0===h||h;return function(e){var t,n,s,l=0,h=!1,p=!1,y=function(){null==n||n.unsubscribe(),n=void 0},b=function(){y(),t=s=void 0,h=p=!1},v=function(){var e=t;b(),null==e||e.unsubscribe()};return u.operate((function(e,u){l++,p||h||y();var g=s=null!=s?s:r();u.add((function(){0!=--l||p||h||(n=c(v,f))})),g.subscribe(u),!t&&l>0&&(t=new a.SafeSubscriber({next:function(e){return g.next(e)},error:function(e){p=!0,y(),n=c(b,i,e),g.error(e)},complete:function(){h=!0,y(),n=c(b,d),g.complete()}}),o.innerFrom(e).subscribe(t))}))(e)}}},3367:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.findIndex=void 0;var n=r(5416),i=r(2819);t.findIndex=function(e,t){return n.operate(i.createFind(e,t,"index"))}},3391:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pluck=void 0;var n=r(4828);t.pluck=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length;if(0===r)throw new Error("list of properties cannot be empty.");return n.map((function(t){for(var n=t,i=0;i<r;i++){var o=null==n?void 0:n[e[i]];if(void 0===o)return;n=o}return n}))}},3484:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.last=void 0;var n=r(7676),i=r(2914),o=r(787),s=r(5956),a=r(7507),u=r(9391);t.last=function(e,t){var r=arguments.length>=2;return function(c){return c.pipe(e?i.filter((function(t,r){return e(t,r,c)})):u.identity,o.takeLast(1),r?a.defaultIfEmpty(t):s.throwIfEmpty((function(){return new n.EmptyError})))}}},3533:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createInvalidObservableTypeError=void 0,t.createInvalidObservableTypeError=function(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}},3585:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleIterable=void 0;var n=r(2023),i=r(3967),o=r(4717),s=r(5031);t.scheduleIterable=function(e,t){return new n.Observable((function(r){var n;return s.executeSchedule(r,t,(function(){n=e[i.iterator](),s.executeSchedule(r,t,(function(){var e,t,i;try{t=(e=n.next()).value,i=e.done}catch(e){return void r.error(e)}i?r.complete():r.next(t)}),0,!0)})),function(){return o.isFunction(null==n?void 0:n.return)&&n.return()}}))}},3692:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.concatWith=void 0;var o=r(1812);t.concatWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.concat.apply(void 0,i([],n(e)))}},3704:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getMessageFromError=function(e,t){return e instanceof Error?e.message:null!=t?t:`${e}`}},3723:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.endWith=void 0;var o=r(2070),s=r(8743);t.endWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(t){return o.concat(t,s.of.apply(void 0,i([],n(e))))}}},3741:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleAsyncIterable=void 0;var n=r(2023),i=r(5031);t.scheduleAsyncIterable=function(e,t){if(!e)throw new Error("Iterable cannot be null");return new n.Observable((function(r){i.executeSchedule(r,t,(function(){var n=e[Symbol.asyncIterator]();i.executeSchedule(r,t,(function(){n.next().then((function(e){e.done?r.complete():r.next(e.value)}))}),0,!0)}))}))}},3754:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeInternals=void 0;var n=r(2296),i=r(5031),o=r(1266);t.mergeInternals=function(e,t,r,s,a,u,c,l){var d=[],h=0,f=0,p=!1,y=function(){!p||d.length||h||t.complete()},b=function(e){return h<s?v(e):d.push(e)},v=function(e){u&&t.next(e),h++;var l=!1;n.innerFrom(r(e,f++)).subscribe(o.createOperatorSubscriber(t,(function(e){null==a||a(e),u?b(e):t.next(e)}),(function(){l=!0}),void 0,(function(){if(l)try{h--;for(var e=function(){var e=d.shift();c?i.executeSchedule(t,c,(function(){return v(e)})):v(e)};d.length&&h<s;)e();y()}catch(e){t.error(e)}})))};return e.subscribe(o.createOperatorSubscriber(t,b,(function(){p=!0,y()}))),function(){null==l||l()}}},3787:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.argsArgArrayOrObject=void 0;var r=Array.isArray,n=Object.getPrototypeOf,i=Object.prototype,o=Object.keys;t.argsArgArrayOrObject=function(e){if(1===e.length){var t=e[0];if(r(t))return{args:t,keys:null};if((a=t)&&"object"==typeof a&&n(a)===i){var s=o(t);return{args:s.map((function(e){return t[e]})),keys:s}}}var a;return{args:e,keys:null}}},3818:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reduce=void 0;var n=r(7071),i=r(5416);t.reduce=function(e,t){return i.operate(n.scanInternals(e,t,arguments.length>=2,!1,!0))}},3870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.debounceTime=void 0;var n=r(4386),i=r(5416),o=r(1266);t.debounceTime=function(e,t){return void 0===t&&(t=n.asyncScheduler),i.operate((function(r,n){var i=null,s=null,a=null,u=function(){if(i){i.unsubscribe(),i=null;var e=s;s=null,n.next(e)}};function c(){var r=a+e,o=t.now();if(o<r)return i=this.schedule(void 0,r-o),void n.add(i);u()}r.subscribe(o.createOperatorSubscriber(n,(function(r){s=r,a=t.now(),i||(i=t.schedule(c,e),n.add(i))}),(function(){u(),n.complete()}),void 0,(function(){s=i=null})))}))}},3928:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.combineLatestWith=void 0;var o=r(2e3);t.combineLatestWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.combineLatest.apply(void 0,i([],n(e)))}},3967:(e,t)=>{function r(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}Object.defineProperty(t,"__esModule",{value:!0}),t.iterator=t.getSymbolIterator=void 0,t.getSymbolIterator=r,t.iterator=r()},4027:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.subscribeOn=void 0;var n=r(5416);t.subscribeOn=function(e,t){return void 0===t&&(t=0),n.operate((function(r,n){n.add(e.schedule((function(){return r.subscribe(n)}),t))}))}},4077:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(6373),t),i(r(8596),t),i(r(1333),t),i(r(4665),t),i(r(6663),t),i(r(8630),t),i(r(3704),t)},4116:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.auditTime=void 0;var n=r(4386),i=r(6993),o=r(5461);t.auditTime=function(e,t){return void 0===t&&(t=n.asyncScheduler),i.audit((function(){return o.timer(e,t)}))}},4123:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(7243),t)},4126:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dematerialize=void 0;var n=r(6145),i=r(5416),o=r(1266);t.dematerialize=function(){return i.operate((function(e,t){e.subscribe(o.createOperatorSubscriber(t,(function(e){return n.observeNotification(e,t)})))}))}},4143:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.raceInit=t.race=void 0;var n=r(2023),i=r(2296),o=r(160),s=r(1266);function a(e){return function(t){for(var r=[],n=function(n){r.push(i.innerFrom(e[n]).subscribe(s.createOperatorSubscriber(t,(function(e){if(r){for(var i=0;i<r.length;i++)i!==n&&r[i].unsubscribe();r=null}t.next(e)}))))},o=0;r&&!t.closed&&o<e.length;o++)n(o)}}t.race=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return 1===(e=o.argsOrArgArray(e)).length?i.innerFrom(e[0]):new n.Observable(a(e))},t.raceInit=a},4386:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.async=t.asyncScheduler=void 0;var n=r(1080),i=r(1017);t.asyncScheduler=new i.AsyncScheduler(n.AsyncAction),t.async=t.asyncScheduler},4388:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.max=void 0;var n=r(3818),i=r(4717);t.max=function(e){return n.reduce(i.isFunction(e)?function(t,r){return e(t,r)>0?t:r}:function(e,t){return e>t?e:t})}},4411:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.skip=void 0;var n=r(2914);t.skip=function(e){return n.filter((function(t,r){return e<=r}))}},4463:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduled=void 0;var n=r(4502),i=r(2366),o=r(8762),s=r(3585),a=r(3741),u=r(1801),c=r(452),l=r(5547),d=r(6847),h=r(9451),f=r(3533),p=r(3026),y=r(9136);t.scheduled=function(e,t){if(null!=e){if(u.isInteropObservable(e))return n.scheduleObservable(e,t);if(l.isArrayLike(e))return o.scheduleArray(e,t);if(c.isPromise(e))return i.schedulePromise(e,t);if(h.isAsyncIterable(e))return a.scheduleAsyncIterable(e,t);if(d.isIterable(e))return s.scheduleIterable(e,t);if(p.isReadableStreamLike(e))return y.scheduleReadableStreamLike(e,t)}throw f.createInvalidObservableTypeError(e)}},4492:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.pairwise=void 0;var n=r(5416),i=r(1266);t.pairwise=function(){return n.operate((function(e,t){var r,n=!1;e.subscribe(i.createOperatorSubscriber(t,(function(e){var i=r;r=e,n&&t.next([i,e]),n=!0})))}))}},4502:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleObservable=void 0;var n=r(2296),i=r(2803),o=r(4027);t.scheduleObservable=function(e,t){return n.innerFrom(e).pipe(o.subscribeOn(t),i.observeOn(t))}},4512:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.EMPTY_OBSERVER=t.SafeSubscriber=t.Subscriber=void 0;var i=r(4717),o=r(7491),s=r(7820),a=r(4696),u=r(6129),c=r(795),l=r(6476),d=r(9916),h=function(e){function r(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,o.isSubscription(r)&&r.add(n)):n.destination=t.EMPTY_OBSERVER,n}return n(r,e),r.create=function(e,t,r){return new b(e,t,r)},r.prototype.next=function(e){this.isStopped?g(c.nextNotification(e),this):this._next(e)},r.prototype.error=function(e){this.isStopped?g(c.errorNotification(e),this):(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped?g(c.COMPLETE_NOTIFICATION,this):(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(o.Subscription);t.Subscriber=h;var f=Function.prototype.bind;function p(e,t){return f.call(e,t)}var y=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){v(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){v(e)}else v(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){v(e)}},e}(),b=function(e){function t(t,r,n){var o,a,u=e.call(this)||this;return i.isFunction(t)||!t?o={next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:u&&s.config.useDeprecatedNextContext?((a=Object.create(t)).unsubscribe=function(){return u.unsubscribe()},o={next:t.next&&p(t.next,a),error:t.error&&p(t.error,a),complete:t.complete&&p(t.complete,a)}):o=t,u.destination=new y(o),u}return n(t,e),t}(h);function v(e){s.config.useDeprecatedSynchronousErrorHandling?d.captureError(e):a.reportUnhandledError(e)}function g(e,t){var r=s.config.onStoppedNotification;r&&l.timeoutProvider.setTimeout((function(){return r(e,t)}))}t.SafeSubscriber=b,t.EMPTY_OBSERVER={closed:!0,next:u.noop,error:function(e){throw e},complete:u.noop}},4568:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isScheduler=void 0;var n=r(4717);t.isScheduler=function(e){return e&&n.isFunction(e.schedule)}},4575:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.dateTimestampProvider=void 0,t.dateTimestampProvider={now:function(){return(t.dateTimestampProvider.delegate||Date).now()},delegate:void 0}},4665:(e,t)=>{function r(e){return"string"==typeof e}function n(e,t,r){if(e===t)return!0;if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n]))return!1;return!0}Object.defineProperty(t,"__esModule",{value:!0}),t.isBoolean=function(e){return"boolean"==typeof e},t.isString=r,t.isNumber=function(e){return"number"==typeof e},t.isDate=function(e){return e instanceof Date},t.checkArrayHasUniqueElements=function(e,t){if(e.length<=1)return!0;const r=new Set;for(const n of e){const e=t(n);if(r.has(e))return!1;r.add(e)}return!0},t.checkArraysHaveEqualElements=function(e,t){return n(e,t,((e,t)=>e===t))},t.checkArraysHasEqualElementsByComparator=n,t.isEmail=function(e,t={allowInternationalDomains:!1}){if(!r(e)||0===e.length||e.length>254)return!1;if(!(t.allowInternationalDomains?o:i).test(e))return!1;const n=e.split("@");return!(n[0].length>64)&&!n[1].split(".").some((e=>e.length>63))},t.isUuid=function(e){return r(e)&&s.test(e)},t.isHexString=function(e){return r(e)&&a.test(e)},t.isNonNullable=function(e){return null!=e};const i=/^[-!#$%&'*+/\d=?A-Z^_a-z{|}~](\.?[-!#$%&'*+/\d=?A-Z^_a-z`{|}~])*@[a-zA-Z0-9](-*\.?[a-zA-Z\d])*\.[a-zA-Z](-?[a-zA-Z\d])+$/,o=/^(?!\.)((?!.*\.{2})[a-zA-Z0-9\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF.!#$%&'*+-/=?^_`{|}~\-\d]+)@(?!\.)([a-zA-Z0-9\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF\-.\d]+)((\.([a-zA-Z\u0080-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF\u1000-\u109F\u10A0-\u10FF\u1100-\u11FF\u1200-\u137F\u1380-\u139F\u13A0-\u13FF\u1400-\u167F\u1680-\u169F\u16A0-\u16FF\u1700-\u171F\u1720-\u173F\u1740-\u175F\u1760-\u177F\u1780-\u17FF\u1800-\u18AF\u1900-\u194F\u1950-\u197F\u1980-\u19DF\u19E0-\u19FF\u1A00-\u1A1F\u1B00-\u1B7F\u1D00-\u1D7F\u1D80-\u1DBF\u1DC0-\u1DFF\u1E00-\u1EFF\u1F00-\u1FFF\u20D0-\u20FF\u2100-\u214F\u2C00-\u2C5F\u2C60-\u2C7F\u2C80-\u2CFF\u2D00-\u2D2F\u2D30-\u2D7F\u2D80-\u2DDF\u2F00-\u2FDF\u2FF0-\u2FFF\u3040-\u309F\u30A0-\u30FF\u3100-\u312F\u3130-\u318F\u3190-\u319F\u31C0-\u31EF\u31F0-\u31FF\u3200-\u32FF\u3300-\u33FF\u3400-\u4DBF\u4DC0-\u4DFF\u4E00-\u9FFF\uA000-\uA48F\uA490-\uA4CF\uA700-\uA71F\uA800-\uA82F\uA840-\uA87F\uAC00-\uD7AF\uF900-\uFAFF]){2,63})+)$/i,s=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,a=/^[0-9a-fA-F]*$/},4696:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.reportUnhandledError=void 0;var n=r(7820),i=r(6476);t.reportUnhandledError=function(e){i.timeoutProvider.setTimeout((function(){var t=n.config.onUnhandledError;if(!t)throw e;t(e)}))}},4717:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isFunction=void 0,t.isFunction=function(e){return"function"==typeof e}},4740:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.retry=void 0;var n=r(5416),i=r(1266),o=r(9391),s=r(5461),a=r(2296);t.retry=function(e){var t;void 0===e&&(e=1/0);var r=(t=e&&"object"==typeof e?e:{count:e}).count,u=void 0===r?1/0:r,c=t.delay,l=t.resetOnSuccess,d=void 0!==l&&l;return u<=0?o.identity:n.operate((function(e,t){var r,n=0,o=function(){var l=!1;r=e.subscribe(i.createOperatorSubscriber(t,(function(e){d&&(n=0),t.next(e)}),void 0,(function(e){if(n++<u){var d=function(){r?(r.unsubscribe(),r=null,o()):l=!0};if(null!=c){var h="number"==typeof c?s.timer(c):a.innerFrom(c(e,n)),f=i.createOperatorSubscriber(t,(function(){f.unsubscribe(),d()}),(function(){t.complete()}));h.subscribe(f)}else d()}else t.error(e)}))),l&&(r.unsubscribe(),r=null,o())};o()}))}},4811:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.takeUntil=void 0;var n=r(5416),i=r(1266),o=r(2296),s=r(6129);t.takeUntil=function(e){return n.operate((function(t,r){o.innerFrom(e).subscribe(i.createOperatorSubscriber(r,(function(){return r.complete()}),s.noop)),!r.closed&&t.subscribe(r)}))}},4828:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.map=void 0;var n=r(5416),i=r(1266);t.map=function(e,t){return n.operate((function(r,n){var o=0;r.subscribe(i.createOperatorSubscriber(n,(function(r){n.next(e.call(t,r,o++))})))}))}},4880:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.windowToggle=void 0;var i=r(20),o=r(7491),s=r(5416),a=r(2296),u=r(1266),c=r(6129),l=r(7394);t.windowToggle=function(e,t){return s.operate((function(r,s){var d=[],h=function(e){for(;0<d.length;)d.shift().error(e);s.error(e)};a.innerFrom(e).subscribe(u.createOperatorSubscriber(s,(function(e){var r=new i.Subject;d.push(r);var n,f=new o.Subscription;try{n=a.innerFrom(t(e))}catch(e){return void h(e)}s.next(r.asObservable()),f.add(n.subscribe(u.createOperatorSubscriber(s,(function(){l.arrRemove(d,r),r.complete(),f.unsubscribe()}),c.noop,h)))}),c.noop)),r.subscribe(u.createOperatorSubscriber(s,(function(e){var t,r,i=d.slice();try{for(var o=n(i),s=o.next();!s.done;s=o.next())s.value.next(e)}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(t)throw t.error}}}),(function(){for(;0<d.length;)d.shift().complete();s.complete()}),h,(function(){for(;0<d.length;)d.shift().unsubscribe()})))}))}},4908:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(7129),t)},4950:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createObject=void 0,t.createObject=function(e,t){return e.reduce((function(e,r,n){return e[r]=t[n],e}),{})}},4956:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.groupBy=void 0;var n=r(2023),i=r(2296),o=r(20),s=r(5416),a=r(1266);t.groupBy=function(e,t,r,u){return s.operate((function(s,c){var l;t&&"function"!=typeof t?(r=t.duration,l=t.element,u=t.connector):l=t;var d=new Map,h=function(e){d.forEach(e),e(c)},f=function(e){return h((function(t){return t.error(e)}))},p=0,y=!1,b=new a.OperatorSubscriber(c,(function(t){try{var s=e(t),h=d.get(s);if(!h){d.set(s,h=u?u():new o.Subject);var v=(m=s,_=h,(S=new n.Observable((function(e){p++;var t=_.subscribe(e);return function(){t.unsubscribe(),0==--p&&y&&b.unsubscribe()}}))).key=m,S);if(c.next(v),r){var g=a.createOperatorSubscriber(h,(function(){h.complete(),null==g||g.unsubscribe()}),void 0,void 0,(function(){return d.delete(s)}));b.add(i.innerFrom(r(v)).subscribe(g))}}h.next(l?l(t):t)}catch(e){f(e)}var m,_,S}),(function(){return h((function(e){return e.complete()}))}),f,(function(){return d.clear()}),(function(){return y=!0,0===p}));s.subscribe(b)}))}},5031:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.executeSchedule=void 0,t.executeSchedule=function(e,t,r,n,i){void 0===n&&(n=0),void 0===i&&(i=!1);var o=t.schedule((function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()}),n);if(e.add(o),!i)return o}},5036:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(4077),t)},5086:e=>{e.exports=require("ws")},5109:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sequenceEqual=void 0;var n=r(5416),i=r(1266),o=r(2296);t.sequenceEqual=function(e,t){return void 0===t&&(t=function(e,t){return e===t}),n.operate((function(r,n){var s={buffer:[],complete:!1},a={buffer:[],complete:!1},u=function(e){n.next(e),n.complete()},c=function(e,r){var o=i.createOperatorSubscriber(n,(function(n){var i=r.buffer,o=r.complete;0===i.length?o?u(!1):e.buffer.push(n):!t(n,i.shift())&&u(!1)}),(function(){e.complete=!0;var t=r.complete,n=r.buffer;t&&u(0===n.length),null==o||o.unsubscribe()}));return o};r.subscribe(c(s,a)),o.innerFrom(e).subscribe(c(a,s))}))}},5129:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.ReplaySubject=void 0;var i=r(20),o=r(4575),s=function(e){function t(t,r,n){void 0===t&&(t=1/0),void 0===r&&(r=1/0),void 0===n&&(n=o.dateTimestampProvider);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=r,i._timestampProvider=n,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=r===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,r),i}return n(t,e),t.prototype.next=function(t){var r=this,n=r.isStopped,i=r._buffer,o=r._infiniteTimeWindow,s=r._timestampProvider,a=r._windowTime;n||(i.push(t),!o&&i.push(s.now()+a)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),r=this._infiniteTimeWindow,n=this._buffer.slice(),i=0;i<n.length&&!e.closed;i+=r?1:2)e.next(n[i]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,r=e._timestampProvider,n=e._buffer,i=e._infiniteTimeWindow,o=(i?1:2)*t;if(t<1/0&&o<n.length&&n.splice(0,n.length-o),!i){for(var s=r.now(),a=0,u=1;u<n.length&&n[u]<=s;u+=2)a=u;a&&n.splice(0,a+1)}},t}(i.Subject);t.ReplaySubject=s},5137:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.delayWhen=void 0;var n=r(2070),i=r(6803),o=r(2507),s=r(1357),a=r(1282),u=r(2296);t.delayWhen=function e(t,r){return r?function(s){return n.concat(r.pipe(i.take(1),o.ignoreElements()),s.pipe(e(t)))}:a.mergeMap((function(e,r){return u.innerFrom(t(e,r)).pipe(i.take(1),s.mapTo(e))}))}},5150:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0});const o=r(5642);t.default=o.PromisePool,i(r(9273),t),i(r(5642),t),i(r(7837),t),i(r(2426),t),i(r(6858),t),i(r(1172),t)},5208:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.distinct=void 0;var n=r(5416),i=r(1266),o=r(6129),s=r(2296);t.distinct=function(e,t){return n.operate((function(r,n){var a=new Set;r.subscribe(i.createOperatorSubscriber(n,(function(t){var r=e?e(t):t;a.has(r)||(a.add(r),n.next(t))}))),t&&s.innerFrom(t).subscribe(i.createOperatorSubscriber(n,(function(){return a.clear()}),o.noop))}))}},5219:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferTime=void 0;var i=r(7491),o=r(5416),s=r(1266),a=r(7394),u=r(4386),c=r(1824),l=r(5031);t.bufferTime=function(e){for(var t,r,d=[],h=1;h<arguments.length;h++)d[h-1]=arguments[h];var f=null!==(t=c.popScheduler(d))&&void 0!==t?t:u.asyncScheduler,p=null!==(r=d[0])&&void 0!==r?r:null,y=d[1]||1/0;return o.operate((function(t,r){var o=[],u=!1,c=function(e){var t=e.buffer;e.subs.unsubscribe(),a.arrRemove(o,e),r.next(t),u&&d()},d=function(){if(o){var t=new i.Subscription;r.add(t);var n={buffer:[],subs:t};o.push(n),l.executeSchedule(t,f,(function(){return c(n)}),e)}};null!==p&&p>=0?l.executeSchedule(r,f,d,p,!0):u=!0,d();var h=s.createOperatorSubscriber(r,(function(e){var t,r,i=o.slice();try{for(var s=n(i),a=s.next();!a.done;a=s.next()){var u=a.value,l=u.buffer;l.push(e),y<=l.length&&c(u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}}),(function(){for(;null==o?void 0:o.length;)r.next(o.shift().buffer);null==h||h.unsubscribe(),r.complete(),r.unsubscribe()}),void 0,(function(){return o=null}));t.subscribe(h)}))}},5294:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.from=void 0;var n=r(4463),i=r(2296);t.from=function(e,t){return t?n.scheduled(e,t):i.innerFrom(e)}},5352:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.partition=void 0;var n=r(1276),i=r(2914);t.partition=function(e,t){return function(r){return[i.filter(e,t)(r),i.filter(n.not(e,t))(r)]}}},5366:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.AsyncSubject=void 0;var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._value=null,t._hasValue=!1,t._isComplete=!1,t}return n(t,e),t.prototype._checkFinalizedStatuses=function(e){var t=this,r=t.hasError,n=t._hasValue,i=t._value,o=t.thrownError,s=t.isStopped,a=t._isComplete;r?e.error(o):(s||a)&&(n&&e.next(i),e.complete())},t.prototype.next=function(e){this.isStopped||(this._value=e,this._hasValue=!0)},t.prototype.complete=function(){var t=this,r=t._hasValue,n=t._value;t._isComplete||(this._isComplete=!0,r&&e.prototype.next.call(this,n),e.prototype.complete.call(this))},t}(r(20).Subject);t.AsyncSubject=i},5411:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sampleTime=void 0;var n=r(4386),i=r(6870),o=r(8767);t.sampleTime=function(e,t){return void 0===t&&(t=n.asyncScheduler),i.sample(o.interval(e,t))}},5416:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.operate=t.hasLift=void 0;var n=r(4717);function i(e){return n.isFunction(null==e?void 0:e.lift)}t.hasLift=i,t.operate=function(e){return function(t){if(i(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}},5461:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timer=void 0;var n=r(2023),i=r(4386),o=r(4568),s=r(6349);t.timer=function(e,t,r){void 0===e&&(e=0),void 0===r&&(r=i.async);var a=-1;return null!=t&&(o.isScheduler(t)?r=t:a=t),new n.Observable((function(t){var n=s.isValidDate(e)?+e-r.now():e;n<0&&(n=0);var i=0;return r.schedule((function(){t.closed||(t.next(i++),0<=a?this.schedule(void 0,a):t.complete())}),n)}))}},5492:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.window=void 0;var n=r(20),i=r(5416),o=r(1266),s=r(6129),a=r(2296);t.window=function(e){return i.operate((function(t,r){var i=new n.Subject;r.next(i.asObservable());var u=function(e){i.error(e),r.error(e)};return t.subscribe(o.createOperatorSubscriber(r,(function(e){return null==i?void 0:i.next(e)}),(function(){i.complete(),r.complete()}),u)),a.innerFrom(e).subscribe(o.createOperatorSubscriber(r,(function(){i.complete(),r.next(i=new n.Subject)}),s.noop,u)),function(){null==i||i.unsubscribe(),i=null}}))}},5547:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isArrayLike=void 0,t.isArrayLike=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e}},5567:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.repeatWhen=void 0;var n=r(2296),i=r(20),o=r(5416),s=r(1266);t.repeatWhen=function(e){return o.operate((function(t,r){var o,a,u=!1,c=!1,l=!1,d=function(){return l&&c&&(r.complete(),!0)},h=function(){l=!1,o=t.subscribe(s.createOperatorSubscriber(r,void 0,(function(){l=!0,!d()&&(a||(a=new i.Subject,n.innerFrom(e(a)).subscribe(s.createOperatorSubscriber(r,(function(){o?h():u=!0}),(function(){c=!0,d()})))),a).next()}))),u&&(o.unsubscribe(),o=null,u=!1,h())};h()}))}},5606:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.zipAll=void 0;var n=r(1763),i=r(587);t.zipAll=function(e){return i.joinAllInternals(n.zip,e)}},5642:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromisePool=void 0;const n=r(234);class i{constructor(e){this.timeout=void 0,this.concurrency=10,this.items=e??[],this.errorHandler=void 0,this.onTaskStartedHandlers=[],this.onTaskFinishedHandlers=[],this.shouldResultsCorrespond=!1}withConcurrency(e){return this.concurrency=e,this}static withConcurrency(e){return(new this).withConcurrency(e)}withTaskTimeout(e){return this.timeout=e,this}static withTaskTimeout(e){return(new this).withTaskTimeout(e)}for(e){const t=new i(e).withConcurrency(this.concurrency);return"function"==typeof this.errorHandler&&t.handleError(this.errorHandler),"number"==typeof this.timeout?t.withTaskTimeout(this.timeout):t}static for(e){return(new this).for(e)}handleError(e){return this.errorHandler=e,this}onTaskStarted(e){return this.onTaskStartedHandlers.push(e),this}onTaskFinished(e){return this.onTaskFinishedHandlers.push(e),this}useCorrespondingResults(){return this.shouldResultsCorrespond=!0,this}async process(e){return(new n.PromisePoolExecutor).useConcurrency(this.concurrency).useCorrespondingResults(this.shouldResultsCorrespond).withTaskTimeout(this.timeout).withHandler(e).handleError(this.errorHandler).onTaskStarted(this.onTaskStartedHandlers).onTaskFinished(this.onTaskFinishedHandlers).for(this.items).start()}}t.PromisePool=i,i.notRun=Symbol("notRun"),i.failed=Symbol("failed")},5834:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.mergeWith=void 0;var o=r(1550);t.mergeWith=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o.merge.apply(void 0,i([],n(e)))}},5884:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.refCount=void 0;var n=r(5416),i=r(1266);t.refCount=function(){return n.operate((function(e,t){var r=null;e._refCount++;var n=i.createOperatorSubscriber(t,void 0,void 0,void 0,(function(){if(!e||e._refCount<=0||0<--e._refCount)r=null;else{var n=e._connection,i=r;r=null,!n||i&&n!==i||n.unsubscribe(),t.unsubscribe()}}));e.subscribe(n),n.closed||(r=e.connect())}))}},5945:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.throttleTime=void 0;var n=r(4386),i=r(6516),o=r(5461);t.throttleTime=function(e,t,r){void 0===t&&(t=n.asyncScheduler);var s=o.timer(e,t);return i.throttle((function(){return s}),r)}},5956:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.throwIfEmpty=void 0;var n=r(7676),i=r(5416),o=r(1266);function s(){return new n.EmptyError}t.throwIfEmpty=function(e){return void 0===e&&(e=s),i.operate((function(t,r){var n=!1;t.subscribe(o.createOperatorSubscriber(r,(function(e){n=!0,r.next(e)}),(function(){return n?r.complete():r.error(e())})))}))}},6022:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeAll=t.merge=t.max=t.materialize=t.mapTo=t.map=t.last=t.isEmpty=t.ignoreElements=t.groupBy=t.first=t.findIndex=t.find=t.finalize=t.filter=t.expand=t.exhaustMap=t.exhaustAll=t.exhaust=t.every=t.endWith=t.elementAt=t.distinctUntilKeyChanged=t.distinctUntilChanged=t.distinct=t.dematerialize=t.delayWhen=t.delay=t.defaultIfEmpty=t.debounceTime=t.debounce=t.count=t.connect=t.concatWith=t.concatMapTo=t.concatMap=t.concatAll=t.concat=t.combineLatestWith=t.combineLatest=t.combineLatestAll=t.combineAll=t.catchError=t.bufferWhen=t.bufferToggle=t.bufferTime=t.bufferCount=t.buffer=t.auditTime=t.audit=void 0,t.timeInterval=t.throwIfEmpty=t.throttleTime=t.throttle=t.tap=t.takeWhile=t.takeUntil=t.takeLast=t.take=t.switchScan=t.switchMapTo=t.switchMap=t.switchAll=t.subscribeOn=t.startWith=t.skipWhile=t.skipUntil=t.skipLast=t.skip=t.single=t.shareReplay=t.share=t.sequenceEqual=t.scan=t.sampleTime=t.sample=t.refCount=t.retryWhen=t.retry=t.repeatWhen=t.repeat=t.reduce=t.raceWith=t.race=t.publishReplay=t.publishLast=t.publishBehavior=t.publish=t.pluck=t.partition=t.pairwise=t.onErrorResumeNext=t.observeOn=t.multicast=t.min=t.mergeWith=t.mergeScan=t.mergeMapTo=t.mergeMap=t.flatMap=void 0,t.zipWith=t.zipAll=t.zip=t.withLatestFrom=t.windowWhen=t.windowToggle=t.windowTime=t.windowCount=t.window=t.toArray=t.timestamp=t.timeoutWith=t.timeout=void 0;var n=r(6993);Object.defineProperty(t,"audit",{enumerable:!0,get:function(){return n.audit}});var i=r(4116);Object.defineProperty(t,"auditTime",{enumerable:!0,get:function(){return i.auditTime}});var o=r(7190);Object.defineProperty(t,"buffer",{enumerable:!0,get:function(){return o.buffer}});var s=r(6835);Object.defineProperty(t,"bufferCount",{enumerable:!0,get:function(){return s.bufferCount}});var a=r(5219);Object.defineProperty(t,"bufferTime",{enumerable:!0,get:function(){return a.bufferTime}});var u=r(118);Object.defineProperty(t,"bufferToggle",{enumerable:!0,get:function(){return u.bufferToggle}});var c=r(7514);Object.defineProperty(t,"bufferWhen",{enumerable:!0,get:function(){return c.bufferWhen}});var l=r(8251);Object.defineProperty(t,"catchError",{enumerable:!0,get:function(){return l.catchError}});var d=r(1424);Object.defineProperty(t,"combineAll",{enumerable:!0,get:function(){return d.combineAll}});var h=r(2945);Object.defineProperty(t,"combineLatestAll",{enumerable:!0,get:function(){return h.combineLatestAll}});var f=r(2e3);Object.defineProperty(t,"combineLatest",{enumerable:!0,get:function(){return f.combineLatest}});var p=r(3928);Object.defineProperty(t,"combineLatestWith",{enumerable:!0,get:function(){return p.combineLatestWith}});var y=r(1812);Object.defineProperty(t,"concat",{enumerable:!0,get:function(){return y.concat}});var b=r(861);Object.defineProperty(t,"concatAll",{enumerable:!0,get:function(){return b.concatAll}});var v=r(1012);Object.defineProperty(t,"concatMap",{enumerable:!0,get:function(){return v.concatMap}});var g=r(1157);Object.defineProperty(t,"concatMapTo",{enumerable:!0,get:function(){return g.concatMapTo}});var m=r(3692);Object.defineProperty(t,"concatWith",{enumerable:!0,get:function(){return m.concatWith}});var _=r(2216);Object.defineProperty(t,"connect",{enumerable:!0,get:function(){return _.connect}});var S=r(8041);Object.defineProperty(t,"count",{enumerable:!0,get:function(){return S.count}});var O=r(2747);Object.defineProperty(t,"debounce",{enumerable:!0,get:function(){return O.debounce}});var w=r(3870);Object.defineProperty(t,"debounceTime",{enumerable:!0,get:function(){return w.debounceTime}});var I=r(7507);Object.defineProperty(t,"defaultIfEmpty",{enumerable:!0,get:function(){return I.defaultIfEmpty}});var M=r(2409);Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return M.delay}});var E=r(5137);Object.defineProperty(t,"delayWhen",{enumerable:!0,get:function(){return E.delayWhen}});var F=r(4126);Object.defineProperty(t,"dematerialize",{enumerable:!0,get:function(){return F.dematerialize}});var T=r(5208);Object.defineProperty(t,"distinct",{enumerable:!0,get:function(){return T.distinct}});var A=r(9939);Object.defineProperty(t,"distinctUntilChanged",{enumerable:!0,get:function(){return A.distinctUntilChanged}});var j=r(183);Object.defineProperty(t,"distinctUntilKeyChanged",{enumerable:!0,get:function(){return j.distinctUntilKeyChanged}});var P=r(1195);Object.defineProperty(t,"elementAt",{enumerable:!0,get:function(){return P.elementAt}});var k=r(3723);Object.defineProperty(t,"endWith",{enumerable:!0,get:function(){return k.endWith}});var C=r(1909);Object.defineProperty(t,"every",{enumerable:!0,get:function(){return C.every}});var x=r(9228);Object.defineProperty(t,"exhaust",{enumerable:!0,get:function(){return x.exhaust}});var D=r(9765);Object.defineProperty(t,"exhaustAll",{enumerable:!0,get:function(){return D.exhaustAll}});var N=r(8748);Object.defineProperty(t,"exhaustMap",{enumerable:!0,get:function(){return N.exhaustMap}});var R=r(8324);Object.defineProperty(t,"expand",{enumerable:!0,get:function(){return R.expand}});var q=r(2914);Object.defineProperty(t,"filter",{enumerable:!0,get:function(){return q.filter}});var L=r(9822);Object.defineProperty(t,"finalize",{enumerable:!0,get:function(){return L.finalize}});var B=r(2819);Object.defineProperty(t,"find",{enumerable:!0,get:function(){return B.find}});var U=r(3367);Object.defineProperty(t,"findIndex",{enumerable:!0,get:function(){return U.findIndex}});var Q=r(1432);Object.defineProperty(t,"first",{enumerable:!0,get:function(){return Q.first}});var $=r(4956);Object.defineProperty(t,"groupBy",{enumerable:!0,get:function(){return $.groupBy}});var W=r(2507);Object.defineProperty(t,"ignoreElements",{enumerable:!0,get:function(){return W.ignoreElements}});var V=r(6095);Object.defineProperty(t,"isEmpty",{enumerable:!0,get:function(){return V.isEmpty}});var z=r(3484);Object.defineProperty(t,"last",{enumerable:!0,get:function(){return z.last}});var G=r(4828);Object.defineProperty(t,"map",{enumerable:!0,get:function(){return G.map}});var H=r(1357);Object.defineProperty(t,"mapTo",{enumerable:!0,get:function(){return H.mapTo}});var Y=r(7967);Object.defineProperty(t,"materialize",{enumerable:!0,get:function(){return Y.materialize}});var J=r(4388);Object.defineProperty(t,"max",{enumerable:!0,get:function(){return J.max}});var K=r(1550);Object.defineProperty(t,"merge",{enumerable:!0,get:function(){return K.merge}});var Z=r(1867);Object.defineProperty(t,"mergeAll",{enumerable:!0,get:function(){return Z.mergeAll}});var X=r(6977);Object.defineProperty(t,"flatMap",{enumerable:!0,get:function(){return X.flatMap}});var ee=r(1282);Object.defineProperty(t,"mergeMap",{enumerable:!0,get:function(){return ee.mergeMap}});var te=r(6295);Object.defineProperty(t,"mergeMapTo",{enumerable:!0,get:function(){return te.mergeMapTo}});var re=r(9527);Object.defineProperty(t,"mergeScan",{enumerable:!0,get:function(){return re.mergeScan}});var ne=r(5834);Object.defineProperty(t,"mergeWith",{enumerable:!0,get:function(){return ne.mergeWith}});var ie=r(1306);Object.defineProperty(t,"min",{enumerable:!0,get:function(){return ie.min}});var oe=r(9924);Object.defineProperty(t,"multicast",{enumerable:!0,get:function(){return oe.multicast}});var se=r(2803);Object.defineProperty(t,"observeOn",{enumerable:!0,get:function(){return se.observeOn}});var ae=r(1997);Object.defineProperty(t,"onErrorResumeNext",{enumerable:!0,get:function(){return ae.onErrorResumeNext}});var ue=r(4492);Object.defineProperty(t,"pairwise",{enumerable:!0,get:function(){return ue.pairwise}});var ce=r(5352);Object.defineProperty(t,"partition",{enumerable:!0,get:function(){return ce.partition}});var le=r(3391);Object.defineProperty(t,"pluck",{enumerable:!0,get:function(){return le.pluck}});var de=r(297);Object.defineProperty(t,"publish",{enumerable:!0,get:function(){return de.publish}});var he=r(6383);Object.defineProperty(t,"publishBehavior",{enumerable:!0,get:function(){return he.publishBehavior}});var fe=r(8229);Object.defineProperty(t,"publishLast",{enumerable:!0,get:function(){return fe.publishLast}});var pe=r(8226);Object.defineProperty(t,"publishReplay",{enumerable:!0,get:function(){return pe.publishReplay}});var ye=r(8973);Object.defineProperty(t,"race",{enumerable:!0,get:function(){return ye.race}});var be=r(177);Object.defineProperty(t,"raceWith",{enumerable:!0,get:function(){return be.raceWith}});var ve=r(3818);Object.defineProperty(t,"reduce",{enumerable:!0,get:function(){return ve.reduce}});var ge=r(7775);Object.defineProperty(t,"repeat",{enumerable:!0,get:function(){return ge.repeat}});var me=r(5567);Object.defineProperty(t,"repeatWhen",{enumerable:!0,get:function(){return me.repeatWhen}});var _e=r(4740);Object.defineProperty(t,"retry",{enumerable:!0,get:function(){return _e.retry}});var Se=r(264);Object.defineProperty(t,"retryWhen",{enumerable:!0,get:function(){return Se.retryWhen}});var Oe=r(5884);Object.defineProperty(t,"refCount",{enumerable:!0,get:function(){return Oe.refCount}});var we=r(6870);Object.defineProperty(t,"sample",{enumerable:!0,get:function(){return we.sample}});var Ie=r(5411);Object.defineProperty(t,"sampleTime",{enumerable:!0,get:function(){return Ie.sampleTime}});var Me=r(2457);Object.defineProperty(t,"scan",{enumerable:!0,get:function(){return Me.scan}});var Ee=r(5109);Object.defineProperty(t,"sequenceEqual",{enumerable:!0,get:function(){return Ee.sequenceEqual}});var Fe=r(3329);Object.defineProperty(t,"share",{enumerable:!0,get:function(){return Fe.share}});var Te=r(1738);Object.defineProperty(t,"shareReplay",{enumerable:!0,get:function(){return Te.shareReplay}});var Ae=r(884);Object.defineProperty(t,"single",{enumerable:!0,get:function(){return Ae.single}});var je=r(4411);Object.defineProperty(t,"skip",{enumerable:!0,get:function(){return je.skip}});var Pe=r(9355);Object.defineProperty(t,"skipLast",{enumerable:!0,get:function(){return Pe.skipLast}});var ke=r(2947);Object.defineProperty(t,"skipUntil",{enumerable:!0,get:function(){return ke.skipUntil}});var Ce=r(9842);Object.defineProperty(t,"skipWhile",{enumerable:!0,get:function(){return Ce.skipWhile}});var xe=r(2778);Object.defineProperty(t,"startWith",{enumerable:!0,get:function(){return xe.startWith}});var De=r(4027);Object.defineProperty(t,"subscribeOn",{enumerable:!0,get:function(){return De.subscribeOn}});var Ne=r(9061);Object.defineProperty(t,"switchAll",{enumerable:!0,get:function(){return Ne.switchAll}});var Re=r(6300);Object.defineProperty(t,"switchMap",{enumerable:!0,get:function(){return Re.switchMap}});var qe=r(1933);Object.defineProperty(t,"switchMapTo",{enumerable:!0,get:function(){return qe.switchMapTo}});var Le=r(1689);Object.defineProperty(t,"switchScan",{enumerable:!0,get:function(){return Le.switchScan}});var Be=r(6803);Object.defineProperty(t,"take",{enumerable:!0,get:function(){return Be.take}});var Ue=r(787);Object.defineProperty(t,"takeLast",{enumerable:!0,get:function(){return Ue.takeLast}});var Qe=r(4811);Object.defineProperty(t,"takeUntil",{enumerable:!0,get:function(){return Qe.takeUntil}});var $e=r(7770);Object.defineProperty(t,"takeWhile",{enumerable:!0,get:function(){return $e.takeWhile}});var We=r(9967);Object.defineProperty(t,"tap",{enumerable:!0,get:function(){return We.tap}});var Ve=r(6516);Object.defineProperty(t,"throttle",{enumerable:!0,get:function(){return Ve.throttle}});var ze=r(5945);Object.defineProperty(t,"throttleTime",{enumerable:!0,get:function(){return ze.throttleTime}});var Ge=r(5956);Object.defineProperty(t,"throwIfEmpty",{enumerable:!0,get:function(){return Ge.throwIfEmpty}});var He=r(9712);Object.defineProperty(t,"timeInterval",{enumerable:!0,get:function(){return He.timeInterval}});var Ye=r(7517);Object.defineProperty(t,"timeout",{enumerable:!0,get:function(){return Ye.timeout}});var Je=r(2001);Object.defineProperty(t,"timeoutWith",{enumerable:!0,get:function(){return Je.timeoutWith}});var Ke=r(8158);Object.defineProperty(t,"timestamp",{enumerable:!0,get:function(){return Ke.timestamp}});var Ze=r(2984);Object.defineProperty(t,"toArray",{enumerable:!0,get:function(){return Ze.toArray}});var Xe=r(5492);Object.defineProperty(t,"window",{enumerable:!0,get:function(){return Xe.window}});var et=r(6817);Object.defineProperty(t,"windowCount",{enumerable:!0,get:function(){return et.windowCount}});var tt=r(6841);Object.defineProperty(t,"windowTime",{enumerable:!0,get:function(){return tt.windowTime}});var rt=r(4880);Object.defineProperty(t,"windowToggle",{enumerable:!0,get:function(){return rt.windowToggle}});var nt=r(3016);Object.defineProperty(t,"windowWhen",{enumerable:!0,get:function(){return nt.windowWhen}});var it=r(9163);Object.defineProperty(t,"withLatestFrom",{enumerable:!0,get:function(){return it.withLatestFrom}});var ot=r(2681);Object.defineProperty(t,"zip",{enumerable:!0,get:function(){return ot.zip}});var st=r(5606);Object.defineProperty(t,"zipAll",{enumerable:!0,get:function(){return st.zipAll}});var at=r(973);Object.defineProperty(t,"zipWith",{enumerable:!0,get:function(){return at.zipWith}})},6095:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isEmpty=void 0;var n=r(5416),i=r(1266);t.isEmpty=function(){return n.operate((function(e,t){e.subscribe(i.createOperatorSubscriber(t,(function(){t.next(!1),t.complete()}),(function(){t.next(!0),t.complete()})))}))}},6129:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.noop=void 0,t.noop=function(){}},6145:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.observeNotification=t.Notification=t.NotificationKind=void 0;var n,i=r(7209),o=r(8743),s=r(6612),a=r(4717);(n=t.NotificationKind||(t.NotificationKind={})).NEXT="N",n.ERROR="E",n.COMPLETE="C";var u=function(){function e(e,t,r){this.kind=e,this.value=t,this.error=r,this.hasValue="N"===e}return e.prototype.observe=function(e){return c(this,e)},e.prototype.do=function(e,t,r){var n=this,i=n.kind,o=n.value,s=n.error;return"N"===i?null==e?void 0:e(o):"E"===i?null==t?void 0:t(s):null==r?void 0:r()},e.prototype.accept=function(e,t,r){var n;return a.isFunction(null===(n=e)||void 0===n?void 0:n.next)?this.observe(e):this.do(e,t,r)},e.prototype.toObservable=function(){var e=this,t=e.kind,r=e.value,n=e.error,a="N"===t?o.of(r):"E"===t?s.throwError((function(){return n})):"C"===t?i.EMPTY:0;if(!a)throw new TypeError("Unexpected notification kind "+t);return a},e.createNext=function(t){return new e("N",t)},e.createError=function(t){return new e("E",void 0,t)},e.createComplete=function(){return e.completeNotification},e.completeNotification=new e("C"),e}();function c(e,t){var r,n,i,o=e,s=o.kind,a=o.value,u=o.error;if("string"!=typeof s)throw new TypeError('Invalid notification, missing "kind"');"N"===s?null===(r=t.next)||void 0===r||r.call(t,a):"E"===s?null===(n=t.error)||void 0===n||n.call(t,u):null===(i=t.complete)||void 0===i||i.call(t)}t.Notification=u,t.observeNotification=c},6295:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeMapTo=void 0;var n=r(1282),i=r(4717);t.mergeMapTo=function(e,t,r){return void 0===r&&(r=1/0),i.isFunction(t)?n.mergeMap((function(){return e}),t,r):("number"==typeof t&&(r=t),n.mergeMap((function(){return e}),r))}},6300:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.switchMap=void 0;var n=r(2296),i=r(5416),o=r(1266);t.switchMap=function(e,t){return i.operate((function(r,i){var s=null,a=0,u=!1,c=function(){return u&&!s&&i.complete()};r.subscribe(o.createOperatorSubscriber(i,(function(r){null==s||s.unsubscribe();var u=0,l=a++;n.innerFrom(e(r,l)).subscribe(s=o.createOperatorSubscriber(i,(function(e){return i.next(t?t(r,e,l,u++):e)}),(function(){s=null,c()})))}),(function(){u=!0,c()})))}))}},6349:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isValidDate=void 0,t.isValidDate=function(e){return e instanceof Date&&!isNaN(e)}},6373:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setDefaultAssertionErrorFactory=function(e){s=e||o},t.assertTruthy=a,t.truthy=function(e,t,...r){return a(e,t,...r),e},t.fail=u,t.getAssertionErrorFromProvider=c,t.getErrorMessage=l,t.assertObject=d,t.assertArray=function(e,t,r={},i=void 0){var o,s;const u=f(i);a(Array.isArray(e),(()=>`${u()}value is not an array: ${e}`));const c=null!==(o=r.minLength)&&void 0!==o?o:0,l=null!==(s=r.maxLength)&&void 0!==s?s:1/0;a(e.length>=c,(()=>`${u()}array length < minLength. Array length: ${e.length}, minLength: ${c}`)),a(e.length<=l,(()=>`${u()}array length > maxLength. Array length: ${e.length}, maxLength: ${l}`)),r.uniqueByIdentity&&a((0,n.checkArrayHasUniqueElements)(e,r.uniqueByIdentity),(()=>`${u()}array contains non-unique elements`));let d=0;const h=()=>`${u("no-space-separator")}[${d}]`;for(;d<e.length;d++)p(e[d],t,h)},t.assertRecord=function(e,t,r={},n=void 0){const o=f(n);a("object"==typeof e,(()=>`${o()}value is not an object: ${(0,i.formatValue)(e)}`)),a(null!==e,(()=>`${o()}value is null`)),a(!Array.isArray(e),(()=>`${o()}the value is not a record, but is an array`));for(const[n,s]of Object.entries(e)){const e=()=>`${o("no-space-separator")}['${n}']`;r.keyAssertion&&p(n,r.keyAssertion,(()=>`${e()}, key assertion failed:`)),p(s,t,e);const{keyField:u}=r;if(u){a("object"==typeof s&&null!==s,(()=>`${e()} is not an object: ${(0,i.formatValue)(s)}`));const t=s[u];a(t===n,(()=>`${e()} key value does not match object field '${u}' value: ${(0,i.formatValue)(t)}`))}}r.$o&&r.$o(e,n)},t.callValueAssertion=h;const n=r(4665),i=r(6663),o=e=>new Error(e);let s=o;function a(e,t,...r){e||u(t,...r)}function u(e,...t){const r=c(e);if("object"==typeof r)throw r;throw s(r||"Assertion error",...t)}function c(e){return void 0===e?"":"string"==typeof e?e:e()}function l(e){const t=c(e);return"string"==typeof t?t:t.message||"<no error message>"}function d(e,t,r=void 0,n={}){const i=()=>l(r),o=e=>{const t=i();return 0===t.length?e:`${t} ${e}`};a("object"==typeof e,(()=>o("is not an object: "+typeof e))),a(void 0!==e,(()=>o("is not defined"))),a(null!==e,(()=>o("is null"))),a(!Array.isArray(e),(()=>o("is an array.")));const s=Object.entries(t);if(n.failOnUnknownFields){const t=n.allowedUnknownFieldNames||[];for(const r in e)a(t.includes(r)||s.some((([e])=>r===e)),o(`property can't be checked: ${r}`))}let u;for(const[t,r]of s){a("function"==typeof r||"object"==typeof r&&null!==r,(()=>`${i()}.${t} assertion is not an object or a function: ${typeof r}`));const n=e[t],o=()=>`${i()}.${t}`;if("object"==typeof r)a(!Array.isArray(n),(()=>`${i()}.${o()} use arrayAssertion() to create a ValueAssertion for an array`)),d(n,r,o);else if(a("function"==typeof r,(()=>`${i()}.${o()} assertion is not a function`)),"$o"===t)u=r;else{const e=r(n,o);a(void 0===e,`Assertion function must assert (void) but it returns a value: ${e}. Wrap with $u()?`)}}u&&u(e,r)}function h(e,t,r){t(e,r)}function f(e){return(t="with-space-separator")=>{const r=l(e);return r?`${r}${"with-space-separator"===t?" ":""}`:""}}function p(e,t,r){"object"==typeof t?(a(!Array.isArray(e),(()=>`${r}: use arrayAssertion() to create a ValueAssertion for an array`)),d(e,t,r)):h(e,t,r)}},6383:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.publishBehavior=void 0;var n=r(1222),i=r(1507);t.publishBehavior=function(e){return function(t){var r=new n.BehaviorSubject(e);return new i.ConnectableObservable(t,(function(){return r}))}}},6467:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.onErrorResumeNext=void 0;var n=r(2023),i=r(160),o=r(1266),s=r(6129),a=r(2296);t.onErrorResumeNext=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=i.argsOrArgArray(e);return new n.Observable((function(e){var t=0,n=function(){if(t<r.length){var i=void 0;try{i=a.innerFrom(r[t++])}catch(e){return void n()}var u=new o.OperatorSubscriber(e,void 0,s.noop,s.noop);i.subscribe(u),u.add(n)}else e.complete()};n()}))}},6476:function(e,t){var r=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},n=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.timeoutProvider=void 0,t.timeoutProvider={setTimeout:function(e,i){for(var o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];var a=t.timeoutProvider.delegate;return(null==a?void 0:a.setTimeout)?a.setTimeout.apply(a,n([e,i],r(o))):setTimeout.apply(void 0,n([e,i],r(o)))},clearTimeout:function(e){var r=t.timeoutProvider.delegate;return((null==r?void 0:r.clearTimeout)||clearTimeout)(e)},delegate:void 0}},6516:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.throttle=void 0;var n=r(5416),i=r(1266),o=r(2296);t.throttle=function(e,t){return n.operate((function(r,n){var s=null!=t?t:{},a=s.leading,u=void 0===a||a,c=s.trailing,l=void 0!==c&&c,d=!1,h=null,f=null,p=!1,y=function(){null==f||f.unsubscribe(),f=null,l&&(g(),p&&n.complete())},b=function(){f=null,p&&n.complete()},v=function(t){return f=o.innerFrom(e(t)).subscribe(i.createOperatorSubscriber(n,y,b))},g=function(){if(d){d=!1;var e=h;h=null,n.next(e),!p&&v(e)}};r.subscribe(i.createOperatorSubscriber(n,(function(e){d=!0,h=e,(!f||f.closed)&&(u?g():v(e))}),(function(){p=!0,(!(l&&d&&f)||f.closed)&&n.complete()})))}))}},6612:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.throwError=void 0;var n=r(2023),i=r(4717);t.throwError=function(e,t){var r=i.isFunction(e)?e:function(){return e},o=function(e){return e.error(r())};return new n.Observable(t?function(e){return t.schedule(o,0,e)}:o)}},6663:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.formatValue=function(e){return void 0===e?"<undefined>":"symbol"==typeof e?e.toString():null===e?"<null>":`<${typeof e}:${e}>`}},6803:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.take=void 0;var n=r(7209),i=r(5416),o=r(1266);t.take=function(e){return e<=0?function(){return n.EMPTY}:i.operate((function(t,r){var n=0;t.subscribe(o.createOperatorSubscriber(r,(function(t){++n<=e&&(r.next(t),e<=n&&r.complete())})))}))}},6817:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.windowCount=void 0;var i=r(20),o=r(5416),s=r(1266);t.windowCount=function(e,t){void 0===t&&(t=0);var r=t>0?t:e;return o.operate((function(t,o){var a=[new i.Subject],u=0;o.next(a[0].asObservable()),t.subscribe(s.createOperatorSubscriber(o,(function(t){var s,c;try{for(var l=n(a),d=l.next();!d.done;d=l.next())d.value.next(t)}catch(e){s={error:e}}finally{try{d&&!d.done&&(c=l.return)&&c.call(l)}finally{if(s)throw s.error}}var h=u-e+1;if(h>=0&&h%r==0&&a.shift().complete(),++u%r==0){var f=new i.Subject;a.push(f),o.next(f.asObservable())}}),(function(){for(;a.length>0;)a.shift().complete();o.complete()}),(function(e){for(;a.length>0;)a.shift().error(e);o.error(e)}),(function(){a=null})))}))}},6835:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(t,"__esModule",{value:!0}),t.bufferCount=void 0;var i=r(5416),o=r(1266),s=r(7394);t.bufferCount=function(e,t){return void 0===t&&(t=null),t=null!=t?t:e,i.operate((function(r,i){var a=[],u=0;r.subscribe(o.createOperatorSubscriber(i,(function(r){var o,c,l,d,h=null;u++%t==0&&a.push([]);try{for(var f=n(a),p=f.next();!p.done;p=f.next())(v=p.value).push(r),e<=v.length&&(h=null!=h?h:[]).push(v)}catch(e){o={error:e}}finally{try{p&&!p.done&&(c=f.return)&&c.call(f)}finally{if(o)throw o.error}}if(h)try{for(var y=n(h),b=y.next();!b.done;b=y.next()){var v=b.value;s.arrRemove(a,v),i.next(v)}}catch(e){l={error:e}}finally{try{b&&!b.done&&(d=y.return)&&d.call(y)}finally{if(l)throw l.error}}}),(function(){var e,t;try{for(var r=n(a),o=r.next();!o.done;o=r.next()){var s=o.value;i.next(s)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=r.return)&&t.call(r)}finally{if(e)throw e.error}}i.complete()}),void 0,(function(){a=null})))}))}},6841:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.windowTime=void 0;var n=r(20),i=r(4386),o=r(7491),s=r(5416),a=r(1266),u=r(7394),c=r(1824),l=r(5031);t.windowTime=function(e){for(var t,r,d=[],h=1;h<arguments.length;h++)d[h-1]=arguments[h];var f=null!==(t=c.popScheduler(d))&&void 0!==t?t:i.asyncScheduler,p=null!==(r=d[0])&&void 0!==r?r:null,y=d[1]||1/0;return s.operate((function(t,r){var i=[],s=!1,c=function(e){var t=e.window,r=e.subs;t.complete(),r.unsubscribe(),u.arrRemove(i,e),s&&d()},d=function(){if(i){var t=new o.Subscription;r.add(t);var s=new n.Subject,a={window:s,subs:t,seen:0};i.push(a),r.next(s.asObservable()),l.executeSchedule(t,f,(function(){return c(a)}),e)}};null!==p&&p>=0?l.executeSchedule(r,f,d,p,!0):s=!0,d();var h=function(e){return i.slice().forEach(e)},b=function(e){h((function(t){var r=t.window;return e(r)})),e(r),r.unsubscribe()};return t.subscribe(a.createOperatorSubscriber(r,(function(e){h((function(t){t.window.next(e),y<=++t.seen&&c(t)}))}),(function(){return b((function(e){return e.complete()}))}),(function(e){return b((function(t){return t.error(e)}))}))),function(){i=null}}))}},6847:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isIterable=void 0;var n=r(3967),i=r(4717);t.isIterable=function(e){return i.isFunction(null==e?void 0:e[n.iterator])}},6858:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StopThePromisePoolError=void 0;class r extends Error{}t.StopThePromisePoolError=r},6870:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.sample=void 0;var n=r(2296),i=r(5416),o=r(6129),s=r(1266);t.sample=function(e){return i.operate((function(t,r){var i=!1,a=null;t.subscribe(s.createOperatorSubscriber(r,(function(e){i=!0,a=e}))),n.innerFrom(e).subscribe(s.createOperatorSubscriber(r,(function(){if(i){i=!1;var e=a;a=null,r.next(e)}}),o.noop))}))}},6871:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createErrorClass=void 0,t.createErrorClass=function(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}},6977:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.flatMap=void 0;var n=r(1282);t.flatMap=n.mergeMap},6993:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.audit=void 0;var n=r(5416),i=r(2296),o=r(1266);t.audit=function(e){return n.operate((function(t,r){var n=!1,s=null,a=null,u=!1,c=function(){if(null==a||a.unsubscribe(),a=null,n){n=!1;var e=s;s=null,r.next(e)}u&&r.complete()},l=function(){a=null,u&&r.complete()};t.subscribe(o.createOperatorSubscriber(r,(function(t){n=!0,s=t,a||i.innerFrom(e(t)).subscribe(a=o.createOperatorSubscriber(r,c,l))}),(function(){u=!0,(!n||!a||a.closed)&&r.complete()})))}))}},7071:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scanInternals=void 0;var n=r(1266);t.scanInternals=function(e,t,r,i,o){return function(s,a){var u=r,c=t,l=0;s.subscribe(n.createOperatorSubscriber(a,(function(t){var r=l++;c=u?e(c,t,r):(u=!0,t),i&&a.next(c)}),o&&function(){u&&a.next(c),a.complete()}))}}},7129:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Trie=void 0;class r{constructor(){this.root={children:new Map,childrenWithValue:0}}get(e){var t;return null===(t=this.getNode(e))||void 0===t?void 0:t.value}getOrSet(e,t){const r=this._buildPath(e);if(void 0!==r.value)return r.value;const n=t(e);return this._setNodeValue(r,n,void 0===n),n}set(e,t){const r=void 0===t?this._findNode(e):this._buildPath(e);r&&this._setNodeValue(r,t,!0)}delete(e){const t=this._findNode(e);if(void 0===t)return;if(void 0===t.parent){if(t!==this.root)throw new Error("Only root node can have no parent.");return this.root.value=void 0,this.root.children.clear(),void(this.root.childrenWithValue=0)}const r=(void 0===t.value?0:1)+t.childrenWithValue;r>0&&this._updateChildrenWithValue(t,-r),t.parent.children.delete(e[e.length-1]),this._runGc(t.parent)}clear(){this.delete([])}count(e=[],t="node-and-children"){const r=this.getNode(e);return void 0===r?0:r.childrenWithValue+("node-and-children"===t&&void 0!==r.value?1:0)}get isEmpty(){return 0===this.count()}fillPath(e,t){const n=[];let i=this.root,o=t(i.value,n);if(o!==r.StopFillToken){this._setNodeValue(i,o,!1);for(let s=0;s<e.length;s++){const a=e[s];n.push(a);let u=i.children.get(a);if(o=t(null==u?void 0:u.value,n),o===r.StopFillToken)break;u||(u={children:new Map,parent:i,childrenWithValue:0},i.children.set(a,u)),this._setNodeValue(u,o,!1),i=u}this._runGc(i)}}visitDfs(e,t,r=[]){const n=this.getNode(r);void 0!==n&&this._visitDfs(e,n,t,[...r])}_visitDfs(e,t,r,n){if("pre-order"===e&&!1===r(t.value,n))return!1;for(const[i,o]of t.children){if(n.push(i),!this._visitDfs(e,o,r,n))return!1;n.pop()}return"in-order"!==e||!1!==r(t.value,n)}getNode(e){return this._getNode(e)}_getNode(e){let t=this.root;for(const r of e)if(t=t.children.get(r),!t)return;return t}_findNode(e){let t=this.root;for(let r=0;r<e.length&&t;r++)t=t.children.get(e[r]);return t}_buildPath(e){let t=this.root;for(let r=0;r<e.length;r++){const n=e[r];let i=t.children.get(n);i||(i={children:new Map,parent:t,childrenWithValue:0},t.children.set(n,i)),t=i}return t}_setNodeValue(e,t,r){if(e.value!==t){const r=void 0===t?-1:void 0===e.value?1:0;e.value=t,this._updateChildrenWithValue(e,r)}r&&this._runGc(e)}_updateChildrenWithValue(e,t){if(0!==t)for(let r=e.parent;r;r=r.parent)if(r.childrenWithValue+=t,r.childrenWithValue<0)throw new Error("Internal error: negative counter value!")}_runGc(e){void 0===e.value&&(0===e.childrenWithValue&&e.children.clear(),e.parent&&this._runGc(e.parent))}}t.Trie=r,r.StopFillToken=Symbol("Trie.StopFillToken")},7190:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buffer=void 0;var n=r(5416),i=r(6129),o=r(1266),s=r(2296);t.buffer=function(e){return n.operate((function(t,r){var n=[];return t.subscribe(o.createOperatorSubscriber(r,(function(e){return n.push(e)}),(function(){r.next(n),r.complete()}))),s.innerFrom(e).subscribe(o.createOperatorSubscriber(r,(function(){var e=n;n=[],r.next(e)}),i.noop)),function(){n=null}}))}},7209:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.empty=t.EMPTY=void 0;var n=r(2023);t.EMPTY=new n.Observable((function(e){return e.complete()})),t.empty=function(e){return e?function(e){return new n.Observable((function(t){return e.schedule((function(){return t.complete()}))}))}(e):t.EMPTY}},7243:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TrieStore=void 0;const n=r(11),i=r(573),o=r(6022),s=r(4908);class a extends i.Subject{constructor(){super(...arguments),this.isAllDetailsMode=!1}}t.TrieStore=class{constructor(e){this.observersTrie=new s.Trie,this.batchDepth=0,this.appliedBatchActions=[],this.stubForUnusedPaths=[],this.rootState=e,this.rootStateBeforeBatchStart=this.rootState}get state(){return this.rootState}get state$(){return this.observe([])}get(e){return this._get(this.rootState,e)}observe(e,t=[]){return this._observeChanges(e,t,"new-value-only").pipe((0,o.map)((e=>e.value)))}observeChanges(e,t=[]){return this._observeChanges(e,t,"all-details")}set(e,t,r){(null==r?void 0:r(this.get(e),t,e))||this._apply({type:"set",path:e,value:t})}delete(e){this._apply({type:"delete",path:e})}reset(e){this.observersTrie.visitDfs("pre-order",(e=>null==e?void 0:e.complete())),this.observersTrie.delete([]),this.rootState=e}runInBatch(e){this.batchDepth++;try{e()}finally{if(this.batchDepth--,0===this.batchDepth&&this.appliedBatchActions.length>0){const e={type:"batch",actions:this.appliedBatchActions};this.appliedBatchActions=[],this._notify(e)}}}_apply(e){0===this.batchDepth&&(this.rootStateBeforeBatchStart=this.rootState),this.rootState=(0,n.apply)(this.rootState,e),this.rootState===this.rootStateBeforeBatchStart||this.observersTrie.isEmpty||(this.batchDepth>0?this.appliedBatchActions.push(e):this._notify(e))}_notify(e){const t=(0,n.extractPaths)(e,"unique-and-sorted"),r=this.selectChildPathsWithObservers(t),i=(0,n.selectUniquePaths)([...t,...r]),o=new s.Trie;for(const e of i)o.fillPath(e,(()=>!0));o.visitDfs("pre-order",((t,r)=>{const n=this.observersTrie.get(r);if(n){const t=this.get(r),i=n.isAllDetailsMode?this._get(this.rootStateBeforeBatchStart,r):void 0;n.next({action:e,value:t,oldValue:i})}}))}_observeChanges(e,t=[],r){const u=0===t.length?void 0:new s.Trie;for(const e of t)null==u||u.set(e,!0);return new i.Observable((t=>{const i=this.observersTrie.getOrSet(e,(()=>new a));i.isAllDetailsMode=i.isAllDetailsMode||"all-details"===r;const s={oldValue:void 0,value:this.get(e),paths:[[]]};t.next(s);const c=i.pipe((0,o.filter)((({action:e})=>void 0===u||(0,n.extractPaths)(e,"as-is").some((e=>!u.get(e))))),(0,o.map)((({action:t,value:r,oldValue:o})=>{let s=this.stubForUnusedPaths;if(i.isAllDetailsMode){const r=(0,n.extractPaths)(t,"as-is"),i=e.length>0?r.filter((t=>(0,n.isPathPrefix)(t,e))).map((t=>t.slice(e.length))):r;s=(0,n.selectUniquePathPrefixes)(i)}return{value:r,oldValue:o,paths:s}}))).subscribe(t);return()=>{c.unsubscribe(),i.observed||this.observersTrie.delete(e)}}))}_get(e,t){let r=e;for(let e=0;e<t.length&&void 0!==r;e++){const n=t[e];r=null==r?void 0:r[n]}return r}selectChildPathsWithObservers(e){const t=[];for(const r of e)this.observersTrie.count(r,"children-only")>0&&this.observersTrie.visitDfs("pre-order",((e,r)=>{e&&t.push([...r])}),r);return t}}},7394:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.arrRemove=void 0,t.arrRemove=function(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}},7491:function(e,t,r){var n=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},i=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},o=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.isSubscription=t.EMPTY_SUBSCRIPTION=t.Subscription=void 0;var s=r(4717),a=r(665),u=r(7394),c=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,u,c;if(!this.closed){this.closed=!0;var d=this._parentage;if(d)if(this._parentage=null,Array.isArray(d))try{for(var h=n(d),f=h.next();!f.done;f=h.next())f.value.remove(this)}catch(t){e={error:t}}finally{try{f&&!f.done&&(t=h.return)&&t.call(h)}finally{if(e)throw e.error}}else d.remove(this);var p=this.initialTeardown;if(s.isFunction(p))try{p()}catch(e){c=e instanceof a.UnsubscriptionError?e.errors:[e]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var b=n(y),v=b.next();!v.done;v=b.next()){var g=v.value;try{l(g)}catch(e){c=null!=c?c:[],e instanceof a.UnsubscriptionError?c=o(o([],i(c)),i(e.errors)):c.push(e)}}}catch(e){r={error:e}}finally{try{v&&!v.done&&(u=b.return)&&u.call(b)}finally{if(r)throw r.error}}}if(c)throw new a.UnsubscriptionError(c)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)l(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&u.arrRemove(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&u.arrRemove(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function l(e){s.isFunction(e)?e():e.unsubscribe()}t.Subscription=c,t.EMPTY_SUBSCRIPTION=c.EMPTY,t.isSubscription=function(e){return e instanceof c||e&&"closed"in e&&s.isFunction(e.remove)&&s.isFunction(e.add)&&s.isFunction(e.unsubscribe)}},7507:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.defaultIfEmpty=void 0;var n=r(5416),i=r(1266);t.defaultIfEmpty=function(e){return n.operate((function(t,r){var n=!1;t.subscribe(i.createOperatorSubscriber(r,(function(e){n=!0,r.next(e)}),(function(){n||r.next(e),r.complete()})))}))}},7514:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.bufferWhen=void 0;var n=r(5416),i=r(6129),o=r(1266),s=r(2296);t.bufferWhen=function(e){return n.operate((function(t,r){var n=null,a=null,u=function(){null==a||a.unsubscribe();var t=n;n=[],t&&r.next(t),s.innerFrom(e()).subscribe(a=o.createOperatorSubscriber(r,u,i.noop))};u(),t.subscribe(o.createOperatorSubscriber(r,(function(e){return null==n?void 0:n.push(e)}),(function(){n&&r.next(n),r.complete()}),void 0,(function(){return n=a=null})))}))}},7517:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timeout=t.TimeoutError=void 0;var n=r(4386),i=r(6349),o=r(5416),s=r(2296),a=r(6871),u=r(1266),c=r(5031);function l(e){throw new t.TimeoutError(e)}t.TimeoutError=a.createErrorClass((function(e){return function(t){void 0===t&&(t=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=t}})),t.timeout=function(e,t){var r=i.isValidDate(e)?{first:e}:"number"==typeof e?{each:e}:e,a=r.first,d=r.each,h=r.with,f=void 0===h?l:h,p=r.scheduler,y=void 0===p?null!=t?t:n.asyncScheduler:p,b=r.meta,v=void 0===b?null:b;if(null==a&&null==d)throw new TypeError("No timeout provided.");return o.operate((function(e,t){var r,n,i=null,o=0,l=function(e){n=c.executeSchedule(t,y,(function(){try{r.unsubscribe(),s.innerFrom(f({meta:v,lastValue:i,seen:o})).subscribe(t)}catch(e){t.error(e)}}),e)};r=e.subscribe(u.createOperatorSubscriber(t,(function(e){null==n||n.unsubscribe(),o++,t.next(i=e),d>0&&l(d)}),void 0,void 0,(function(){(null==n?void 0:n.closed)||null==n||n.unsubscribe(),i=null}))),!o&&l(null!=a?"number"==typeof a?a:+a-y.now():d)}))}},7638:function(e,t,r){var n=this&&this.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)};return function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}();Object.defineProperty(t,"__esModule",{value:!0}),t.Action=void 0;var i=function(e){function t(t,r){return e.call(this)||this}return n(t,e),t.prototype.schedule=function(e,t){return void 0===t&&(t=0),this},t}(r(7491).Subscription);t.Action=i},7676:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.EmptyError=void 0;var n=r(6871);t.EmptyError=n.createErrorClass((function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}}))},7770:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.takeWhile=void 0;var n=r(5416),i=r(1266);t.takeWhile=function(e,t){return void 0===t&&(t=!1),n.operate((function(r,n){var o=0;r.subscribe(i.createOperatorSubscriber(n,(function(r){var i=e(r,o++);(i||t)&&n.next(r),!i&&n.complete()})))}))}},7775:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.repeat=void 0;var n=r(7209),i=r(5416),o=r(1266),s=r(2296),a=r(5461);t.repeat=function(e){var t,r,u=1/0;return null!=e&&("object"==typeof e?(t=e.count,u=void 0===t?1/0:t,r=e.delay):u=e),u<=0?function(){return n.EMPTY}:i.operate((function(e,t){var n,i=0,c=function(){if(null==n||n.unsubscribe(),n=null,null!=r){var e="number"==typeof r?a.timer(r):s.innerFrom(r(i)),u=o.createOperatorSubscriber(t,(function(){u.unsubscribe(),l()}));e.subscribe(u)}else l()},l=function(){var r=!1;n=e.subscribe(o.createOperatorSubscriber(t,void 0,(function(){++i<u?n?c():r=!0:t.complete()}))),r&&c()};l()}))}},7820:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.config=void 0,t.config={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1}},7837:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PromisePoolError=void 0;class r extends Error{constructor(e,t){super(),this.raw=e,this.item=t,this.name=this.constructor.name,this.message=this.messageFrom(e),Error.captureStackTrace&&"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}static createFrom(e,t){return new this(e,t)}messageFrom(e){return e instanceof Error||"object"==typeof e?e.message:"string"==typeof e||"number"==typeof e?e.toString():""}}t.PromisePoolError=r},7967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.materialize=void 0;var n=r(6145),i=r(5416),o=r(1266);t.materialize=function(){return i.operate((function(e,t){e.subscribe(o.createOperatorSubscriber(t,(function(e){t.next(n.Notification.createNext(e))}),(function(){t.next(n.Notification.createComplete()),t.complete()}),(function(e){t.next(n.Notification.createError(e)),t.complete()})))}))}},8041:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.count=void 0;var n=r(3818);t.count=function(e){return n.reduce((function(t,r,n){return!e||e(r,n)?t+1:t}),0)}},8083:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ObjectUnsubscribedError=void 0;var n=r(6871);t.ObjectUnsubscribedError=n.createErrorClass((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}))},8158:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.timestamp=void 0;var n=r(4575),i=r(4828);t.timestamp=function(e){return void 0===e&&(e=n.dateTimestampProvider),i.map((function(t){return{value:t,timestamp:e.now()}}))}},8168:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SequenceError=void 0;var n=r(6871);t.SequenceError=n.createErrorClass((function(e){return function(t){e(this),this.name="SequenceError",this.message=t}}))},8226:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.publishReplay=void 0;var n=r(5129),i=r(9924),o=r(4717);t.publishReplay=function(e,t,r,s){r&&!o.isFunction(r)&&(s=r);var a=o.isFunction(r)?r:void 0;return function(r){return i.multicast(new n.ReplaySubject(e,t,s),a)(r)}}},8229:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.publishLast=void 0;var n=r(5366),i=r(1507);t.publishLast=function(){return function(e){var t=new n.AsyncSubject;return new i.ConnectableObservable(e,(function(){return t}))}}},8240:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.mapOneOrManyArgs=void 0;var o=r(4828),s=Array.isArray;t.mapOneOrManyArgs=function(e){return o.map((function(t){return function(e,t){return s(t)?e.apply(void 0,i([],n(t))):e(t)}(e,t)}))}},8251:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.catchError=void 0;var n=r(2296),i=r(1266),o=r(5416);t.catchError=function e(t){return o.operate((function(r,o){var s,a=null,u=!1;a=r.subscribe(i.createOperatorSubscriber(o,void 0,void 0,(function(i){s=n.innerFrom(t(i,e(t)(r))),a?(a.unsubscribe(),a=null,s.subscribe(o)):u=!0}))),u&&(a.unsubscribe(),a=null,s.subscribe(o))}))}},8324:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.expand=void 0;var n=r(5416),i=r(3754);t.expand=function(e,t,r){return void 0===t&&(t=1/0),t=(t||0)<1?1/0:t,n.operate((function(n,o){return i.mergeInternals(n,o,e,t,void 0,!0,r)}))}},8596:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.stringAssertion=void 0,t.objectAssertion=function(e,t=void 0){return r=>(0,n.assertObject)(r,e,t)},t.arrayAssertion=function(e,t={}){const{minLength:r,maxLength:i}=t;return(0,n.assertTruthy)((null!=r?r:0)<=(null!=i?i:1/0),`minLength must be < maxLength! minLength ${r}, maxLength: ${i}`),(0,n.assertTruthy)((null!=r?r:0)>=0,`minLength must be a positive number: ${r}`),(0,n.assertTruthy)((null!=i?i:0)>=0,`maxLength must be a positive number: ${i}`),(r,i=void 0)=>{(0,n.assertArray)(r,e,t,i)}},t.recordAssertion=function(e,t={}){return(r,i=void 0)=>{(0,n.assertRecord)(r,e,t,i)}},t.$a=o,t.$u=function(e,t){return o(e,t)},t.valueOr=s,t.undefinedOr=function(e){return s(void 0,e)},t.nullOr=function(e){return s(null,e)};const n=r(6373),i=r(1333);function o(e,t){return(0,n.assertTruthy)("function"==typeof e,`"check" is not a function: ${e}`),(r,i=void 0)=>(0,n.assertTruthy)(e(r),(()=>{let e=(0,n.getErrorMessage)(i)||"Check is failed";return e.endsWith(":")||(e+=":"),`${e} ${(0,n.getErrorMessage)(t)||("object"==typeof r?"[object]":`'${r}'`)}`}))}function s(e,t){return(r,i=void 0)=>{r!==e&&("object"==typeof t?(0,n.assertObject)(r,t,i):(0,n.callValueAssertion)(r,t,i))}}t.stringAssertion=e=>(t,r=void 0)=>{var o,s;(0,i.assertString)(t,r),(0,n.assertTruthy)(t.length>=(null!==(o=e.minLength)&&void 0!==o?o:0),`${(0,n.getErrorMessage)(r)} length is too small: ${t.length} < ${e.minLength}`),(0,n.assertTruthy)(t.length<=(null!==(s=e.maxLength)&&void 0!==s?s:1/0),`${(0,n.getErrorMessage)(r)} length is too large ${t.length} > ${e.maxLength}`)}},8630:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tryCatch=i,t.validateObject=function(e,t,r=void 0,o={}){return i((()=>(0,n.assertObject)(e,t,r,o)))},t.validateArray=function(e,t,r={},o=void 0){return i((()=>(0,n.assertArray)(e,t,r,o)))},t.validateRecord=function(e,t,r={},o=void 0){return i((()=>(0,n.assertRecord)(e,t,r,o)))};const n=r(6373);function i(e){try{e()}catch(e){return e instanceof Error&&e.message||`${e}`}}},8743:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.of=void 0;var n=r(1824),i=r(5294);t.of=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=n.popScheduler(e);return i.from(e,r)}},8748:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.exhaustMap=void 0;var n=r(4828),i=r(2296),o=r(5416),s=r(1266);t.exhaustMap=function e(t,r){return r?function(o){return o.pipe(e((function(e,o){return i.innerFrom(t(e,o)).pipe(n.map((function(t,n){return r(e,t,o,n)})))})))}:o.operate((function(e,r){var n=0,o=null,a=!1;e.subscribe(s.createOperatorSubscriber(r,(function(e){o||(o=s.createOperatorSubscriber(r,void 0,(function(){o=null,a&&r.complete()})),i.innerFrom(t(e,n++)).subscribe(o))}),(function(){a=!0,!o&&r.complete()})))}))}},8762:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleArray=void 0;var n=r(2023);t.scheduleArray=function(e,t){return new n.Observable((function(r){var n=0;return t.schedule((function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())}))}))}},8767:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.interval=void 0;var n=r(4386),i=r(5461);t.interval=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=n.asyncScheduler),e<0&&(e=0),i.timer(e,e,t)}},8973:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.race=void 0;var o=r(160),s=r(177);t.race=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return s.raceWith.apply(void 0,i([],n(o.argsOrArgArray(e))))}},9061:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.switchAll=void 0;var n=r(6300),i=r(9391);t.switchAll=function(){return n.switchMap(i.identity)}},9136:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.scheduleReadableStreamLike=void 0;var n=r(3741),i=r(3026);t.scheduleReadableStreamLike=function(e,t){return n.scheduleAsyncIterable(i.readableStreamLikeToAsyncGenerator(e),t)}},9148:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ArgumentOutOfRangeError=void 0;var n=r(6871);t.ArgumentOutOfRangeError=n.createErrorClass((function(e){return function(){e(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range"}}))},9163:function(e,t,r){var n=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s},i=this&&this.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(t,"__esModule",{value:!0}),t.withLatestFrom=void 0;var o=r(5416),s=r(1266),a=r(2296),u=r(9391),c=r(6129),l=r(1824);t.withLatestFrom=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=l.popResultSelector(e);return o.operate((function(t,o){for(var l=e.length,d=new Array(l),h=e.map((function(){return!1})),f=!1,p=function(t){a.innerFrom(e[t]).subscribe(s.createOperatorSubscriber(o,(function(e){d[t]=e,f||h[t]||(h[t]=!0,(f=h.every(u.identity))&&(h=null))}),c.noop))},y=0;y<l;y++)p(y);t.subscribe(s.createOperatorSubscriber(o,(function(e){if(f){var t=i([e],n(d));o.next(r?r.apply(void 0,i([],n(t))):t)}})))}))}},9228:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.exhaust=void 0;var n=r(9765);t.exhaust=n.exhaustAll},9273:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},9355:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.skipLast=void 0;var n=r(9391),i=r(5416),o=r(1266);t.skipLast=function(e){return e<=0?n.identity:i.operate((function(t,r){var n=new Array(e),i=0;return t.subscribe(o.createOperatorSubscriber(r,(function(t){var o=i++;if(o<e)n[o]=t;else{var s=o%e,a=n[s];n[s]=t,r.next(a)}}))),function(){n=null}}))}},9391:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.identity=void 0,t.identity=function(e){return e}},9451:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isAsyncIterable=void 0;var n=r(4717);t.isAsyncIterable=function(e){return Symbol.asyncIterator&&n.isFunction(null==e?void 0:e[Symbol.asyncIterator])}},9527:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.mergeScan=void 0;var n=r(5416),i=r(3754);t.mergeScan=function(e,t,r){return void 0===r&&(r=1/0),n.operate((function(n,o){var s=t;return i.mergeInternals(n,o,(function(t,r){return e(s,t,r)}),r,(function(e){s=e}),!1,void 0,(function(){return s=null}))}))}},9712:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TimeInterval=t.timeInterval=void 0;var n=r(4386),i=r(5416),o=r(1266);t.timeInterval=function(e){return void 0===e&&(e=n.asyncScheduler),i.operate((function(t,r){var n=e.now();t.subscribe(o.createOperatorSubscriber(r,(function(t){var i=e.now(),o=i-n;n=i,r.next(new s(t,o))})))}))};var s=function(e,t){this.value=e,this.interval=t};t.TimeInterval=s},9765:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.exhaustAll=void 0;var n=r(8748),i=r(9391);t.exhaustAll=function(){return n.exhaustMap(i.identity)}},9822:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.finalize=void 0;var n=r(5416);t.finalize=function(e){return n.operate((function(t,r){try{t.subscribe(r)}finally{r.add(e)}}))}},9842:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.skipWhile=void 0;var n=r(5416),i=r(1266);t.skipWhile=function(e){return n.operate((function(t,r){var n=!1,o=0;t.subscribe(i.createOperatorSubscriber(r,(function(t){return(n||(n=!e(t,o++)))&&r.next(t)})))}))}},9916:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.captureError=t.errorContext=void 0;var n=r(7820),i=null;t.errorContext=function(e){if(n.config.useDeprecatedSynchronousErrorHandling){var t=!i;if(t&&(i={errorThrown:!1,error:null}),e(),t){var r=i,o=r.errorThrown,s=r.error;if(i=null,o)throw s}}else e()},t.captureError=function(e){n.config.useDeprecatedSynchronousErrorHandling&&i&&(i.errorThrown=!0,i.error=e)}},9924:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.multicast=void 0;var n=r(1507),i=r(4717),o=r(2216);t.multicast=function(e,t){var r=i.isFunction(e)?e:function(){return e};return i.isFunction(t)?o.connect(t,{connector:r}):function(e){return new n.ConnectableObservable(e,r)}}},9939:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.distinctUntilChanged=void 0;var n=r(9391),i=r(5416),o=r(1266);function s(e,t){return e===t}t.distinctUntilChanged=function(e,t){return void 0===t&&(t=n.identity),e=null!=e?e:s,i.operate((function(r,n){var i,s=!0;r.subscribe(o.createOperatorSubscriber(n,(function(r){var o=t(r);!s&&e(i,o)||(s=!1,i=o,n.next(r))})))}))}},9967:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tap=void 0;var n=r(4717),i=r(5416),o=r(1266),s=r(9391);t.tap=function(e,t,r){var a=n.isFunction(e)||t||r?{next:e,error:t,complete:r}:e;return a?i.operate((function(e,t){var r;null===(r=a.subscribe)||void 0===r||r.call(a);var n=!0;e.subscribe(o.createOperatorSubscriber(t,(function(e){var r;null===(r=a.next)||void 0===r||r.call(a,e),t.next(e)}),(function(){var e;n=!1,null===(e=a.complete)||void 0===e||e.call(a),t.complete()}),(function(e){var r;n=!1,null===(r=a.error)||void 0===r||r.call(a,e),t.error(e)}),(function(){var e,t;n&&(null===(e=a.unsubscribe)||void 0===e||e.call(a)),null===(t=a.finalize)||void 0===t||t.call(a)})))})):s.identity}}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{AI_AGENTS_INTEGRATION_ID:()=>Ue,AI_AUDIO_CREATE_SPEECH_MODEL_NAMES:()=>Re,AI_AUDIO_TRANSCRIPTION_MODEL_NAMES:()=>Ne,AI_CHAT_MODEL_NAMES:()=>Ee,AI_EMBEDDINGS_MODEL_NAMES:()=>Te,AI_IMAGE_MODEL_NAMES:()=>De,ALL_OPERATORS:()=>nt,ANTHROPIC_CHAT_MODEL_NAMES:()=>Me,API_INJECTION_FIELD_TYPES:()=>Ke,ARRAY_OPERATORS:()=>rt,AUTH_INTEGRATION_TYPES:()=>We,AdminClient:()=>Kr,AiAgentClient:()=>V,AiAgentReference:()=>$,AiAssistantClient:()=>i,AiAudioClient:()=>G,AiClient:()=>en,AiImageClient:()=>z,AiMatchMakingClient:()=>Zr,ApiClient:()=>Y,ApiKeysSecretClient:()=>Rr,AuthManager:()=>J,BUILT_IN_AGENT_ID:()=>C,BUILT_IN_DB_INTEGRATION_ID:()=>He,BUILT_IN_QUEUE_INTEGRATION_ID:()=>Ye,BUILT_IN_STORAGE_INTEGRATION_ID:()=>Je,BackendFunctionManager:()=>ye,BaseQueryBuilder:()=>bt,CLIENT_CONNECTION_STATES:()=>ot,CLIENT_ID_GENERATOR_KEY:()=>me,CLIENT_REQUEST_ID_GENERATOR_KEY:()=>_e,Changes:()=>mt,ClientIdService:()=>ge,CollectionReference:()=>It,CollectionReferenceFactory:()=>Et,ConnectionDetails:()=>Ft,DATA_INTEGRATION_TYPES:()=>$e,DEFAULT_SHORT_ID_LENGTH:()=>N,DataManager:()=>Dt,DereferencedJoin:()=>St,DestructManager:()=>Rt,DistributedLockImpl:()=>Lt,DistributedLockManager:()=>qt,DocumentReference:()=>ct,DocumentReferenceFactory:()=>Ut,DocumentStore:()=>Qt,EMPTY_CHAT_ID:()=>P,ENVIRONMENT_IDS:()=>k,ExtractionClient:()=>Yr,FETCH_BEYOND_LIMIT:()=>dr,FLUX_MODEL_NAMES:()=>xe,GEMINI_CHAT_MODEL_NAMES:()=>Ie,GRAPHQL_INTEGRATION_TYPES:()=>Ve,GroupedJoin:()=>wt,HTTP_INTEGRATION_TYPES:()=>ze,HttpStatus:()=>Be,INTEGRATION_SCHEMA_TYPES:()=>Ge,INTEGRATION_TYPES:()=>Qe,IntegrationClient:()=>Br,JoinQueryBuilder:()=>_t,LimitUnderflowState:()=>sr,LocalQueryManager:()=>nr,METRIC_DOMAIN:()=>et,METRIC_FUNCTIONS:()=>Xe,METRIC_INTERVAL_ALIGNMENT:()=>tt,MatchMaker:()=>Xr,MutationSender:()=>$t,NOOP_FN:()=>Ur,NativeQueryManager:()=>Wt,OPENAI_AUDIO_CREATE_SPEECH_MODEL_NAMES:()=>Pe,OPENAI_AUDIO_MODEL_NAMES:()=>ke,OPENAI_AUDIO_TRANSCRIPTION_MODEL_NAMES:()=>je,OPENAI_CHAT_MODEL_NAMES:()=>we,OPENAI_EMBEDDINGS_MODEL_NAMES:()=>Fe,OPENAI_IMAGE_MODEL_NAMES:()=>Ae,OPENAI_O1_CHAT_MODEL_NAMES:()=>Se,OPENAI_REASONING_CHAT_MODEL_NAMES:()=>Oe,OPEN_AI_CREATE_SPEECH_FORMATS:()=>qe,ObservabilityClient:()=>Cr,Pagination:()=>lt,PersonalStorageClient:()=>Jr,QueryBuilder:()=>gt,QueryBuilderFactory:()=>yt,QuerySender:()=>or,QuerySubscriptionManager:()=>hr,QueueManagerFactory:()=>br,QueueManagerImpl:()=>gr,RateLimiter:()=>mr,RpcError:()=>wr,RpcManager:()=>Pr,SQUID_METRIC_NAMES:()=>Ze,SQUID_REGIONS:()=>it,STABLE_DIFFUSION_MODEL_NAMES:()=>Ce,SchedulerClient:()=>qr,SecretClient:()=>Nr,SocketManager:()=>Wr,Squid:()=>tn,StorageClient:()=>Hr,base64ToFile:()=>Q,deserializeQuery:()=>zt,generateId:()=>D,generateShortId:()=>q,getConsoleBaseUrl:()=>Lr,isPlaceholderParam:()=>Le,rawSquidHttpDelete:()=>Tr,rawSquidHttpGet:()=>Mr,rawSquidHttpPatch:()=>Fr,rawSquidHttpPost:()=>Ir,rawSquidHttpPut:()=>Er,tryDeserializing:()=>jr,visitQueryResults:()=>Vt});class i{constructor(e){this.rpcManager=e}async createAssistant(e,t,r,n){const i={name:e,instructions:t,functions:r,toolTypes:n};return(await this.rpcManager.post("ai/assistant/createAssistant",i)).assistantId}async deleteAssistant(e){const t={assistantId:e};await this.rpcManager.post("ai/assistant/deleteAssistant",t)}async createThread(e){const t={assistantId:e};return(await this.rpcManager.post("ai/assistant/createThread",t)).threadId}async deleteThread(e){const t={threadId:e};await this.rpcManager.post("ai/assistant/deleteThread",t)}async queryAssistant(e,t,r,n,i){const o={assistantId:e,threadId:t,prompt:r,fileIds:n,options:i};return(await this.rpcManager.post("ai/assistant/queryAssistant",o)).answer}async addFileToAssistant(e,t){const r={assistantId:e};return(await this.rpcManager.post("ai/assistant/addFileToAssistant",r,[t],"file")).fileId}async removeFileFromAssistant(e,t){const r={assistantId:e,fileId:t};await this.rpcManager.post("ai/assistant/removeFileFromAssistant",r)}async addFileToThread(e,t){const r={threadId:e};return(await this.rpcManager.post("ai/assistant/addFileToThread",r,[t],"file")).fileId}}var o=r(573);function s(e){return"function"==typeof e}function a(e){return function(t){if(function(e){return s(null==e?void 0:e.lift)}(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}var u=function(e,t){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},u(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function d(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function h(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var f,p=((f=function(e){var t;t=this,Error.call(t),t.stack=(new Error).stack,this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e}).prototype=Object.create(Error.prototype),f.prototype.constructor=f,f);function y(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var b=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,r,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=l(o),u=a.next();!u.done;u=a.next())u.value.remove(this)}catch(t){e={error:t}}finally{try{u&&!u.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else o.remove(this);var c=this.initialTeardown;if(s(c))try{c()}catch(e){i=e instanceof p?e.errors:[e]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var y=l(f),b=y.next();!b.done;b=y.next()){var g=b.value;try{v(g)}catch(e){i=null!=i?i:[],e instanceof p?i=h(h([],d(i)),d(e.errors)):i.push(e)}}}catch(e){r={error:e}}finally{try{b&&!b.done&&(n=y.return)&&n.call(y)}finally{if(r)throw r.error}}}if(i)throw new p(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)v(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&y(t,e)},e.prototype.remove=function(t){var r=this._finalizers;r&&y(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}();function v(e){s(e)?e():e.unsubscribe()}b.EMPTY;var g={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=g.delegate;return(null==i?void 0:i.setTimeout)?i.setTimeout.apply(i,h([e,t],d(r))):setTimeout.apply(void 0,h([e,t],d(r)))},clearTimeout:function(e){var t=g.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function m(){}var _=S("C",void 0,void 0);function S(e,t,r){return{kind:e,value:t,error:r}}var O=function(e){function t(t){var r,n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,((r=t)instanceof b||r&&"closed"in r&&s(r.remove)&&s(r.add)&&s(r.unsubscribe))&&t.add(n)):n.destination=F,n}return c(t,e),t.create=function(e,t,r){return new I(e,t,r)},t.prototype.next=function(e){this.isStopped?E(function(e){return S("N",e,void 0)}(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?E(S("E",void 0,e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?E(_,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(b);Function.prototype.bind;var w=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){M(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){M(e)}else M(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){M(e)}},e}(),I=function(e){function t(t,r,n){var i,o=e.call(this)||this;return i=s(t)||!t?{next:null!=t?t:void 0,error:null!=r?r:void 0,complete:null!=n?n:void 0}:t,o.destination=new w(i),o}return c(t,e),t}(O);function M(e){!function(e){g.setTimeout((function(){throw e}))}(e)}function E(e,t){var r=null;r&&g.setTimeout((function(){return r(e,t)}))}var F={closed:!0,next:m,error:function(e){throw e},complete:m};function T(e,t,r,n,i){return new A(e,t,r,n,i)}var A=function(e){function t(t,r,n,i,o,s){var a=e.call(this,t)||this;return a.onFinalize=o,a.shouldUnsubscribe=s,a._next=r?function(e){try{r(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=n?function(){try{n()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return c(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;e.prototype.unsubscribe.call(this),!r&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(O);function j(e,t){return a((function(r,n){var i=0;r.subscribe(T(n,(function(r){n.next(e.call(t,r,i++))})))}))}const P="__squid_empty_chat_id",k=["dev","prod"],C="built_in_agent";var x=r(5036);function D(){let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const r=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)}))}const N=18,R="abcdefghijklmnopqrstuvwxyz0123456789";function q(e=N,t=""){(0,x.assertTruthy)(t.length<e,"ID prefix is too long");let r="";for(let t=0;t<e;t++)r+=R.charAt(Math.floor(Math.random()*R.length));return t.length>0&&(r=t+r.substring(t.length)),r}const L=["groupId","appId","integrationId","profileId","index","text","filePathInBucket"];function B(e){for(const t in e){const r=e[t];if("string"!=typeof r&&"number"!=typeof r&&"boolean"!=typeof r&&void 0!==r)throw new Error(`Invalid metadata value for key ${t} - cannot be of type ${typeof r}`);if(L.includes(t))throw new Error(`Invalid metadata key ${t} - cannot be an internal key. Internal keys: ${L.join(", ")}`);if(!/^[a-zA-Z0-9_]+$/.test(t))throw new Error(`Invalid metadata key ${t} - can only contain letters, numbers, and underscores`)}}function U(e){if(function(e){return"$and"in e}(e))for(const t of e.$and)U(t);else if(function(e){return"$or"in e}(e))for(const t of e.$or)U(t);else for(const t in e){if(!/^[a-zA-Z0-9_]+$/.test(t))throw new Error(`Invalid metadata filter key ${t} - can only contain letters, numbers, and underscores`);if(L.includes(t))throw new Error(`Invalid metadata filter key ${t} - cannot be an internal key. Internal keys: ${L.join(", ")}`);const r=e[t];if("object"!=typeof r&&"string"!=typeof r&&"number"!=typeof r&&"boolean"!=typeof r)throw new Error(`Invalid metadata filter value for key ${t} - cannot be of type ${typeof r}`)}}function Q(e,t,r){const n=atob(e),i=new Uint8Array(n.length);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);const o=r||"application/octet-stream",s=new Blob([i],{type:o});return new File([s],t,{type:o})}class ${constructor(e,t,r,n,i){this.agentId=e,this.ongoingChatSequences=t,this.statusUpdates=r,this.rpcManager=n,this.socketManager=i}async get(){const e=await this.rpcManager.post("ai/agent/getAgent",{agentId:this.agentId});return e?.agent}async upsert(e){await this.rpcManager.post("ai/agent/upsertAgent",{...e,id:this.agentId})}async delete(){await this.rpcManager.post("ai/agent/deleteAgent",{agentId:this.agentId})}async updateInstructions(e){const t=await this.get();(0,x.assertTruthy)(t,"Agent not found"),await this.upsert({...t,options:{...t.options,instructions:e}})}async updateModel(e){const t=await this.get();(0,x.assertTruthy)(t,"Agent not found"),await this.upsert({...t,options:{...t.options,model:e}})}async updateConnectedAgents(e){const t=await this.get();(0,x.assertTruthy)(t,"Agent not found"),await this.upsert({...t,options:{...t.options,connectedAgents:e}})}async getContext(e){return await this.rpcManager.post("ai/agent/getContext",{agentId:this.agentId,contextId:e})}async listContexts(){return(await this.rpcManager.post("ai/agent/listContexts",{agentId:this.agentId})).contexts||[]}async deleteContext(e){await this.deleteContexts([e])}async deleteContexts(e){await this.rpcManager.post("ai/agent/deleteContexts",{agentId:this.agentId,contextIds:e})}async upsertContext(e,t){await this.upsertContexts([e],t?[t]:void 0)}async upsertContexts(e,t){for(const t of e)t.metadata&&B(t.metadata);await this.rpcManager.post("ai/agent/upsertContexts",{agentId:this.agentId,contextRequests:e},t)}async provideFeedback(e){await this.rpcManager.post("ai/agent/provideFeedback",{agentId:this.agentId,feedback:e})}async resetFeedback(){await this.rpcManager.post("ai/agent/resetFeedback",{agentId:this.agentId})}async updateGuardrails(e){const t=await this.get();(0,x.assertTruthy)(t,"Agent not found"),await this.upsert({...t,options:{...t.options,guardrails:{...t.options?.guardrails,...e}}})}async upsertCustomGuardrails(e){await this.rpcManager.post("ai/agent/upsertCustomGuardrails",{agentId:this.agentId,customGuardrail:e})}async deleteCustomGuardrail(){await this.rpcManager.post("ai/agent/deleteCustomGuardrails",{agentId:this.agentId})}chat(e,t){return this.chatInternal(e,t).responseStream}async transcribeAndChat(e,t){const r=this.chatInternal(e,t),n=await(0,x.truthy)(r.serverResponse,"TRANSCRIPTION_RESPONSE_NOT_FOUND");return{responseStream:r.responseStream,transcribedPrompt:n.transcribedPrompt}}async search(e){(0,x.assertTruthy)(this.agentId!==C,"Cannot search the built-in agent");const t={options:e,agentId:this.agentId};return(await this.rpcManager.post("ai/chatbot/search",t)).chunks}async ask(e,t){return(await this.askInternal(e,!1,t)).responseString}observeStatusUpdates(e){const{chatId:t}=e||{};return this.createStatusSubject(t),t?this.statusUpdates[this.agentId][t].asObservable():(0,o.merge)(...Object.values(this.statusUpdates[this.agentId]))}async transcribeAndAsk(e,t){return await this.askInternal(e,!1,t)}async transcribeAndAskWithVoiceResponse(e,t){const r=await this.askInternal(e,!0,t),n=r.voiceResponse;return{responseString:r.responseString,transcribedPrompt:r.transcribedPrompt,voiceResponseFile:Q(n.base64File,`voice.${n.extension}`,n.mimeType)}}async askWithVoiceResponse(e,t){const r=await this.askInternal(e,!0,t),n=r.voiceResponse;return{responseString:r.responseString,voiceResponseFile:Q(n.base64File,`voice.${n.extension}`,n.mimeType)}}async askInternal(e,t,r){r?.contextMetadataFilter&&U(r.contextMetadataFilter),r={...W,...r||{}};const n="string"==typeof e;let i="ai/chatbot/";i+=n||t?!n&&t?"transcribeAndAskWithVoiceResponse":n&&t?"askWithVoiceResponse":"ask":"transcribeAndAsk";const o={agentId:this.agentId,prompt:n?e:void 0,options:r},s=n?void 0:[e];return await this.rpcManager.post(i,o,s,"file")}createStatusSubject(e){this.statusUpdates[this.agentId]||(this.statusUpdates[this.agentId]={});const t=e||P;this.statusUpdates[this.agentId][t]||(this.statusUpdates[this.agentId][t]=new o.Subject)}chatInternal(e,t){this.socketManager.notifyWebSocketIsNeeded(),t?.contextMetadataFilter&&U(t.contextMetadataFilter);const r=D(),n=void 0===(t={...W,...t||{}}).smoothTyping||t.smoothTyping;let i="";const s=new o.Subject,a=new o.Subject;this.ongoingChatSequences[r]=a;let u=-1;a.pipe((0,o.tap)((({tokenIndex:e})=>{void 0!==e&&e<u&&console.warn("Received token index out of order",e,u),void 0!==e&&(u=e)})),(0,o.concatMap)((({value:e,complete:t})=>t?(0,o.of)({value:e,complete:t}):(0,o.of)(e).pipe(n?(0,o.delay)(0):(0,o.tap)(),j((e=>({value:e,complete:!1})))))),(0,o.takeWhile)((({complete:e})=>!e),!0)).subscribe({next:({value:e})=>{i+=e,s.next(i)},error:e=>{console.error(e)},complete:()=>{s.complete()}});const c="string"==typeof e,l={agentId:this.agentId,prompt:c?e:void 0,options:t,clientRequestId:r},d={responseStream:s.pipe((0,o.finalize)((()=>{delete this.ongoingChatSequences[r]})),(0,o.share)())};return c?this.rpcManager.post("ai/chatbot/chat",l).catch((e=>{s.error(e),s.complete()})):d.serverResponse=this.rpcManager.post("ai/chatbot/transcribeAndChat",l,[e],"file").catch((e=>{throw s.error(e),s.complete(),e})),d}}const W={smoothTyping:!0,responseFormat:"text"};class V{constructor(e,t){this.rpcManager=e,this.socketManager=t,this.ongoingChatSequences={},this.statusUpdates={},this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"aiChatbot"===e.type)),j((e=>e))).subscribe((e=>{this.handleChatResponse(e).then()})),this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"aiStatus"===e.type)),j((e=>e))).subscribe((e=>{this.handleStatusMessage(e).then()}))}agent(e){return new $(e,this.ongoingChatSequences,this.statusUpdates,this.rpcManager,this.socketManager)}async listAgents(){return(await this.rpcManager.post("ai/agent/listAgents",{})).agents}async handleChatResponse(e){const t=this.ongoingChatSequences[e.clientRequestId];if(!t)return;const{token:r,complete:n,tokenIndex:i}=e.payload;if(n&&!r.length)t.next({value:"",complete:!0,tokenIndex:void 0});else if(r.match(/\[.*?]\((.*?)\)/g))t.next({value:r,complete:n,tokenIndex:void 0===i?void 0:i});else for(let e=0;e<r.length;e++)t.next({value:r[e],complete:n&&e===r.length-1,tokenIndex:void 0===i?void 0:i})}async handleStatusMessage(e){const{agentId:t,chatId:r,payload:n}=e,{title:i,tags:o}=n,s=this.getStatusSubject(t,r);s?.next({agentId:t,chatId:r,title:i,tags:o})}getStatusSubject(e,t){if(!this.statusUpdates[e])return;const r=t||P;return this.statusUpdates[e][r]}}class z{constructor(e){this.rpcManager=e}async generate(e,t){const r={prompt:e,options:t};return await this.rpcManager.post("ai/image/generate",r)}async removeBackground(e){return await this.rpcManager.post("ai/image/removeBackground",{},[e])}}class G{constructor(e){this.rpcManager=e}async transcribe(e,t={modelName:"whisper-1"}){return this.rpcManager.post("ai/audio/transcribe",t,[e])}async createSpeech(e,t){const r={input:e,options:t},n=await this.rpcManager.post("ai/audio/createSpeech",r);return Q(n.base64File,`audio.${n.extension}`,n.mimeType)}}const H={headers:{},queryParams:{},pathParams:{}};class Y{constructor(e){this.rpcManager=e}async get(e,t,r){return this.request(e,t,void 0,r,"get")}async post(e,t,r,n){return this.request(e,t,r,n,"post")}async delete(e,t,r,n){return this.request(e,t,r,n,"delete")}async patch(e,t,r,n){return this.request(e,t,r,n,"patch")}async put(e,t,r,n){return this.request(e,t,r,n,"put")}async request(e,t,r,n,i){const o={integrationId:e,endpointId:t,body:r,options:{...H,...this.convertOptionsToStrings(n||{})},overrideMethod:i};return await this.rpcManager.rawPost("api/callApi",o,void 0,void 0,!1)}convertOptionsToStrings(e){return{headers:this.convertToStrings(e.headers),queryParams:this.convertToStrings(e.queryParams),pathParams:this.convertToStrings(e.pathParams)}}convertToStrings(e){if(!e)return{};const t=Object.entries(e).filter((([,e])=>void 0!==e)).map((([e,t])=>[e,String(t)]));return Object.fromEntries(t)}}class J{constructor(e,t){this.apiKey=e,this.authProvider=t}setAuthProvider(e){this.authProvider=e}async getAuthData(){return{token:await this.getTokenFromAuthProvider(),integrationId:this.authProvider?.integrationId}}async getTokenFromAuthProvider(){const e=this.authProvider?.getToken();return"object"==typeof e?await e:e}getApiKey(){return this.apiKey}async getToken(){if(this.apiKey)return{type:"ApiKey",token:this.apiKey};const e=await this.getTokenFromAuthProvider();return e?{type:"Bearer",token:e,integrationId:this.authProvider?.integrationId}:void 0}}const K=/[.\[\]]/;function Z(e,t){if(!e)return;const r=t.split(K);let n,i=e;for(;i&&r.length;){const e=r.shift();if(e){if("object"!=typeof i||!(e in i))return;n=i[e],i=n}}return n}function X(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function ee(e,t,r,n="."){const i=t.split(n);let o=e;for(;i.length;){const e=(0,x.truthy)(i.shift());if(i.length){const t=o[e],r=X(t)?ae(t)??{}:{};o[e]=r,o=r}else o[e]=r}}function te(e,t,r="."){const n=t.split(r);let i=e;for(;n.length;){const e=(0,x.truthy)(n.shift());if(n.length){const t=X(i[e])?ae(i[e])??{}:{};i[e]=t,i=t}else delete i[e]}}function re(e,t,r){if(e.has(t)){const n=e.get(t);e.delete(t),e.set(r,n)}}function ne(e){return null==e}function ie(e,t){if(e===t)return!0;if(null===e||null===t)return!1;const r=typeof e;if(r!==typeof t)return!1;if("object"!==r)return e===t;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(const r of n)if(!i.includes(r)||!ie(e[r],t[r]))return!1;return!0}function oe(e,t){const r=new Array(e.length);for(let n=0;n<e.length;n++)r[n]=se(e[n],t);return r}function se(e,t){const r=t?t(e):void 0;if(void 0!==r)return r;if("object"!=typeof e||null===e)return e;if(e instanceof Date)return new Date(e);if(Array.isArray(e))return oe(e,t);if(e instanceof Map)return new Map(oe(Array.from(e),t));if(e instanceof Set)return new Set(oe(Array.from(e),t));if(ArrayBuffer.isView(e))return(n=e)instanceof Buffer?Buffer.from(n):new n.constructor(n.buffer.slice(),n.byteOffset,n.length);var n;const i={};for(const r in e)Object.hasOwnProperty.call(e,r)&&(i[r]=se(e[r],t));return i}function ae(e){return"object"!=typeof e||null===e?e:e instanceof Date?new Date(e):Array.isArray(e)?[...e]:e instanceof Map?new Map(Array.from(e)):e instanceof Set?new Set(Array.from(e)):{...e}}function ue(e,t){if(e===t||ne(e)&&ne(t))return 0;if(ne(e))return-1;if(ne(t))return 1;const r=typeof e,n=typeof t;return r!==n?r<n?-1:1:"number"==typeof e?((0,x.assertTruthy)("number"==typeof t),isNaN(e)&&isNaN(t)?0:isNaN(e)?-1:isNaN(t)?1:e<t?-1:1):"boolean"==typeof e?((0,x.assertTruthy)("boolean"==typeof t),e<t?-1:1):"bigint"==typeof e?((0,x.assertTruthy)("bigint"==typeof t),e<t?-1:1):"string"==typeof e?((0,x.assertTruthy)("string"==typeof t),e<t?-1:1):e instanceof Date&&t instanceof Date?Math.sign(e.getTime()-t.getTime()):0}function ce(e,t){return e.reduce(((e,r)=>{const n=t(r);return e[n]?e[n].push(r):e[n]=[r],e}),{})}function le(e){if(Array.isArray(e))return e.map((e=>le(e)));if("object"!=typeof e||null===e||e instanceof Date)return e;const t=Object.keys(e),r={};return t.sort().forEach((t=>{r[t]=le(e[t])})),r}function de(e){return he(le(e))}function he(e){if(void 0===e)return null;const t=se(e,(e=>function(e){return"[object Date]"===Object.prototype.toString.call(e)}(e)?{$date:e.toISOString()}:void 0));return JSON.stringify(t)}function fe(e){return se(JSON.parse(e),(e=>{if(null===e||"object"!=typeof e)return;const t=e,r=t.$date;return r&&1===Object.keys(t).length?new Date(r):void 0}))}function pe(e){if(void 0===e)throw new Error("INVALID_ENCODE_VALUE");const t=he(e);if("undefined"!=typeof Buffer)return Buffer.from(t,"utf8").toString("base64");{const e=(new TextEncoder).encode(t);let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return btoa(r)}}class ye{constructor(e){this.rpcManager=e}executeFunctionAndSubscribe(e,...t){const r=[],n=[];let i=0;t.forEach((e=>{if("undefined"!=typeof File)if(e instanceof File){r.push(e);const t={type:"file",__squid_placeholder__:!0,fileIndex:i++};n.push(t)}else if(this.isArrayOfFiles(e)){const t={type:"fileArray",__squid_placeholder__:!0,fileIndexes:e.map(((t,n)=>(r.push(e[n]),i++)))};n.push(t)}else n.push(e);else n.push(e)}));const s={functionName:e,paramsArrayStr:he(n)},a=`backend-function/execute?${encodeURIComponent(e)}`;return(0,o.race)((0,o.from)(this.rpcManager.post(a,s,r.length>0?r:[])).pipe(j((e=>{if(!e.success)throw new Error(e.payload);return fe(e.payload)}))))}isArrayOfFiles(e){return"undefined"!=typeof File&&Array.isArray(e)&&e.every((e=>e instanceof File))}}function be(){if("undefined"!=typeof window)return window;if(void 0!==r.g)return r.g;if("undefined"!=typeof self)return self;throw new Error("Unable to locate global object")}!function(e=!0){be().SQUID_LOG_DEBUG_ENABLED=e}(function(){let e="";return"undefined"!=typeof window&&window.location?e=new URLSearchParams(window.location.search).get("SQUID_DEBUG")||"":"undefined"!=typeof process&&process.env&&(e=process.env.SQUID_DEBUG||""),"1"===e||"true"===e}());class ve{static debug(...e){(function(){const e=be();return!0===e?.SQUID_LOG_DEBUG_ENABLED})()&&console.debug(`${function(){if(function(){const e=be();return!0===e?.SQUID_LOG_TIMESTAMPS_DISABLED}()){const e=new Date;return`[${e.toLocaleTimeString()}.${e.getMilliseconds()}] squid`}return"squid"}()} DEBUG`,...e)}}class ge{constructor(e){this.destructManager=e,this.clientTooOldSubject=new o.BehaviorSubject(!1),this.isTenant=!0===be().squidTenant,this.clientIdSubject=new o.BehaviorSubject(this.generateClientId()),this.destructManager.onDestruct((()=>{this.clientTooOldSubject.complete(),this.clientIdSubject.complete()}))}observeClientId(){return this.clientIdSubject}observeClientTooOld(){return this.clientTooOldSubject.pipe((0,o.filter)((e=>e)),(0,o.map)((()=>{})))}notifyClientTooOld(){this.clientTooOldSubject.next(!0),this.clientIdSubject.next(this.generateClientId())}notifyClientNotTooOld(){this.clientTooOldSubject.next(!1)}observeClientReadyToBeRegenerated(){return this.clientTooOldSubject.pipe((0,o.skip)(1),(0,o.filter)((e=>!e)),(0,o.map)((()=>{})))}getClientId(){return this.clientIdSubject.value}isClientTooOld(){return this.clientTooOldSubject.value}generateClientId(){const e=be()[me];if(e)return e();let t=`${this.isTenant?"tenant-":""}${D()}`;return"object"==typeof navigator&&!0===navigator.userAgent?.toLowerCase()?.includes("playwright")&&(t=`e2e${t.substring(3)}`),t}generateClientRequestId(){const e=be()[_e];return e?e():D()}}const me="SQUID_CLIENT_ID_GENERATOR",_e="SQUID_CLIENT_REQUEST_ID_GENERATOR",Se=["o1","o1-mini"],Oe=[...Se,"o3-mini"],we=["gpt-4o","gpt-4o-mini",...Oe],Ie=["gemini-1.5-pro","gemini-2.0-flash"],Me=["claude-3-5-haiku-latest","claude-3-5-sonnet-latest"],Ee=[...we,...Me,...Ie],Fe=["text-embedding-3-small","text-embedding-3-large","text-embedding-ada-002"],Te=[...Fe],Ae=["dall-e-3"],je=["whisper-1"],Pe=["tts-1","tts-1-hd"],ke=[...je,...Pe],Ce=["stable-diffusion-core"],xe=["flux-pro-1.1"],De=[...Ae,...Ce,...xe],Ne=[...je],Re=[...Pe],qe=["mp3","opus","aac","flac","wav","pcm"];function Le(e){return!!e&&"object"==typeof e&&"__squid_placeholder__"in e}const Be={CONTINUE:100,SWITCHING_PROTOCOLS:101,PROCESSING:102,EARLY_HINTS:103,OK:200,CREATED:201,ACCEPTED:202,NON_AUTHORITATIVE_INFORMATION:203,NO_CONTENT:204,RESET_CONTENT:205,PARTIAL_CONTENT:206,MULTI_STATUS:207,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,MOVED_TEMPORARILY:302,SEE_OTHER:303,NOT_MODIFIED:304,USE_PROXY:305,TEMPORARY_REDIRECT:307,PERMANENT_REDIRECT:308,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,REQUEST_TOO_LONG:413,REQUEST_URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,REQUESTED_RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,IM_A_TEAPOT:418,INSUFFICIENT_SPACE_ON_RESOURCE:419,METHOD_FAILURE:420,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,INSUFFICIENT_STORAGE:507,NETWORK_AUTHENTICATION_REQUIRED:511},Ue="ai_agents",Qe=["active_directory","ai_agents","ai_chatbot","algolia","alloydb","api","auth0","azure_cosmosdb","azure_postgresql","azure_sql","bigquery","built_in_db","built_in_gcs","built_in_queue","built_in_s3","cassandra","clickhouse","cloudsql","cockroach","cognito","confluence","confluent","datadog","db2","descope","documentdb","dynamodb","elastic_enterprise_search","elastic_observability","elastic_search","firebase_auth","firestore","gcs","google_docs","google_drive","graphql","hubspot","jira","jwt_hmac","jwt_rsa","kafka","linear","mariadb","monday","mongo","mssql","mysql","newrelic","okta","onedrive","oracledb","pinecone","postgres","redis","s3","salesforce_crm","sap_hana","sentry","servicenow","snowflake","spanner","xata","zendesk","mail","slack"],$e=["bigquery","built_in_db","clickhouse","cockroach","mongo","mssql","mysql","oracledb","postgres","sap_hana","snowflake"],We=["auth0","jwt_rsa","jwt_hmac","cognito","okta","descope","firebase_auth"],Ve=["graphql","linear"],ze=["api","confluence"],Ge=["data","api","graphql"],He="built_in_db",Ye="built_in_queue",Je="built_in_storage",Ke=["secret","regular"],Ze=["squid_functionExecution_count","squid_functionExecution_time"],Xe=["sum","max","min","average","median","p95","p99","count"],et=["user","squid"],tt=["align-by-start-time","align-by-end-time"],rt=["in","not in","array_includes_some","array_includes_all","array_not_includes"],nt=[...rt,"==","!=",">=","<=",">","<","like","not like","like_cs","not like_cs"],it=["us-east-1.aws","ap-south-1.aws","us-central1.gcp"],ot=["CONNECTED","DISCONNECTED","REMOVED"],st="__squidId";function at(e){return fe(e)}function ut(...e){const[t,r,n]=e,i="object"==typeof t?t:{docId:t,collectionName:r,integrationId:n};return i.integrationId||(i.integrationId=void 0),de(i)}class ct{constructor(e,t,r){this._squidDocId=e,this.dataManager=t,this.queryBuilderFactory=r,this.refId=D()}get squidDocId(){return this._squidDocId}get data(){return se(this.dataRef)}get dataRef(){return(0,x.truthy)(this.dataManager.getProperties(this.squidDocId),(()=>{const{collectionName:e,integrationId:t,docId:r}=at(this.squidDocId);return`No data found for document reference: ${JSON.stringify({docId:r,collectionName:e,integrationId:t},null,2)}`}))}get hasData(){return!!this.dataManager.getProperties(this.squidDocId)}async snapshot(){if(this.hasSquidPlaceholderId())throw new Error("Cannot invoke snapshot of a document that was created locally without storing it on the server.");if(this.isTracked()&&this.hasData)return this.data;const e=await this.queryBuilderFactory.getForDocument(this.squidDocId).dereference().snapshot();return(0,x.truthy)(e.length<=1,"Got more than one doc for the same id:"+this.squidDocId),e.length?e[0]:void 0}snapshots(){return this.queryBuilderFactory.getForDocument(this.squidDocId).dereference().snapshots().pipe((0,o.map)((e=>((0,x.truthy)(e.length<=1,"Got more than one doc for the same id:"+this.squidDocId),e.length?e[0]:void 0))))}peek(){return this.isTracked()&&this.hasData?this.data:void 0}isDirty(){return this.dataManager.isDirty(this.squidDocId)}isTracked(){return this.dataManager.isTracked(this.squidDocId)}async update(e,t){const r={};Object.entries(e).forEach((([e,t])=>{const n=void 0!==t?{type:"update",value:t}:{type:"removeProperty"};r[e]=[n]}));const n={type:"update",squidDocIdObj:at(this.squidDocId),properties:r};return this.dataManager.applyOutgoingMutation(n,t)}async setInPath(e,t,r){return this.update({[e]:se(t)},r)}async deleteInPath(e,t){return this.update({[e]:void 0},t)}incrementInPath(e,t,r){const n={type:"applyNumericFn",fn:"increment",value:t},i={type:"update",squidDocIdObj:at(this.squidDocId),properties:{[e]:[n]}};return this.dataManager.applyOutgoingMutation(i,r)}decrementInPath(e,t,r){return this.incrementInPath(e,-t,r)}async insert(e,t){const r=at(this.squidDocId),n=r.integrationId;let i=fe(r.docId);if(i[st]&&(i={}),n===He&&i.__id)try{const e=fe(i.__id);i={...i,...e}}catch{}const o={type:"insert",squidDocIdObj:r,properties:{...e,__docId__:r.docId,...i}};return this.dataManager.applyOutgoingMutation(o,t)}async delete(e){const t={type:"delete",squidDocIdObj:at(this.squidDocId)};return this.dataManager.applyOutgoingMutation(t,e)}migrateDocIds(e){const t=e[this.squidDocId];t&&(this._squidDocId=t)}hasSquidPlaceholderId(){const e=fe(this._squidDocId);if("object"==typeof e&&e.docId){const t=fe(e.docId);if("object"==typeof t&&Object.keys(t).includes(st))return!0}return!1}}Error;class lt{constructor(e,t={}){this.internalStateObserver=new o.BehaviorSubject(null),this.firstElement=null,this.isDestroyed=new o.BehaviorSubject(!1),this.snapshotSubject=new o.Subject,this.onFirstPage=!0,this.navigatingToLastPage=!1,this.lastElement=null,(0,x.assertTruthy)(e.getSortOrders().length>0,"Unable to paginate results. Please specify a sort order."),this.snapshotSubject.pipe((0,o.switchAll)()).subscribe((e=>this.dataReceived(e))),this.templateSnapshotEmitter=e.clone(),this.paginateOptions={pageSize:100,subscribe:!0,...t},this.goToFirstPage()}goToFirstPage(){this.onFirstPage=!0;const e=this.templateSnapshotEmitter.clone().limit(3*this.paginateOptions.pageSize).snapshots(this.paginateOptions.subscribe);this.snapshotSubject.next(e)}compareObjects(e,t){if(e===t||ne(e)&&ne(t))return 0;if(ne(e))return-1;if(ne(t))return 1;const r=this.templateSnapshotEmitter.getSortOrders();for(const{fieldName:n,asc:i}of r){const r=ue(Z(e,n),Z(t,n));if(0!==r)return i?r:-r}return 0}async dataReceived(e){const t=e.map((e=>this.templateSnapshotEmitter.extractData(e)));if(0===e.length)return void(this.onFirstPage?this.internalStateObserver.next({numBefore:0,numAfter:0,data:e,extractedData:t}):this.goToFirstPage());if(null===this.firstElement)if(null!==this.lastElement){const r=t.filter((e=>1===this.compareObjects(e,this.lastElement))).length;this.firstElement=t[e.length-r-this.paginateOptions.pageSize],this.lastElement=null}else this.navigatingToLastPage&&(this.firstElement=t[e.length-this.paginateOptions.pageSize],this.navigatingToLastPage=!1);const r=t.filter((e=>-1===this.compareObjects(e,this.firstElement))).length,n=Math.max(0,e.length-r-this.paginateOptions.pageSize);r!==e.length?this.internalStateObserver.next({numBefore:r,numAfter:n,data:e,extractedData:t}):this.prevInternal({numBefore:r,numAfter:n,data:e,extractedData:t})}doNewQuery(e,t){if(this.onFirstPage=!1,t){const t=this.templateSnapshotEmitter.clone().limit(3*this.paginateOptions.pageSize).flipSortOrder();e&&t.addCompositeCondition(this.templateSnapshotEmitter.getSortOrders().map((t=>({fieldName:t.fieldName,operator:t.asc?"<=":">=",value:Z(e,t.fieldName)||null})))),this.snapshotSubject.next(t.snapshots(this.paginateOptions.subscribe).pipe((0,o.map)((e=>e.reverse()))))}else{const t=this.templateSnapshotEmitter.clone().limit(3*this.paginateOptions.pageSize);e&&t.addCompositeCondition(this.templateSnapshotEmitter.getSortOrders().map((t=>({fieldName:t.fieldName,operator:t.asc?">=":"<=",value:Z(e,t.fieldName)||null})))),this.snapshotSubject.next(t.snapshots(this.paginateOptions.subscribe))}}async waitForInternalState(){const e=this.internalStateObserver.value;return null!==e?e:await(0,o.firstValueFrom)((0,o.race)(this.isDestroyed.pipe((0,o.filter)(Boolean),(0,o.map)((()=>({data:[],extractedData:[],numBefore:0,numAfter:0})))),this.internalStateObserver.pipe((0,o.filter)((e=>null!==e)),(0,o.take)(1))))}internalStateToState(e){const{data:t,numBefore:r,numAfter:n,extractedData:i}=e;return{data:t.filter(((e,t)=>-1!==this.compareObjects(i[t],this.firstElement))).slice(0,this.paginateOptions.pageSize),hasNext:n>0,hasPrev:r>0}}unsubscribe(){this.isDestroyed.next(!0),this.isDestroyed.complete(),this.internalStateObserver.complete(),this.snapshotSubject.complete()}prevInternal(e){const{numBefore:t,numAfter:r,extractedData:n}=e;this.firstElement=null,this.lastElement=n[t-1],this.internalStateObserver.next(null),this.doNewQuery(n[n.length-r-1],!0)}async prev(){return this.prevInternal(await this.waitForInternalState()),await this.waitForData()}async next(){const{numBefore:e,extractedData:t}=await this.waitForInternalState();return e+this.paginateOptions.pageSize<t.length&&(this.firstElement=t[e+this.paginateOptions.pageSize]),this.internalStateObserver.next(null),this.doNewQuery(t[e],!1),await this.waitForData()}async waitForData(){return this.internalStateToState(await this.waitForInternalState())}observeState(){return this.internalStateObserver.pipe((0,o.filter)((e=>null!==e)),(0,o.map)((e=>this.internalStateToState(e))))}async first(){return await this.waitForInternalState(),this.internalStateObserver.next(null),this.firstElement=null,this.lastElement=null,this.goToFirstPage(),await this.waitForData()}async refreshPage(){const{extractedData:e}=await this.waitForInternalState();return this.internalStateObserver.next(null),this.onFirstPage?this.goToFirstPage():this.doNewQuery(e[0],!1),await this.waitForData()}async last(){await this.waitForInternalState(),this.internalStateObserver.next(null),this.firstElement=null,this.lastElement=null,this.navigatingToLastPage=!0;const e=this.templateSnapshotEmitter.clone().limit(3*this.paginateOptions.pageSize).flipSortOrder().snapshots(this.paginateOptions.subscribe).pipe((0,o.map)((e=>e.reverse())));return this.snapshotSubject.next(e),await this.waitForData()}}function dt(e,t,r){if(e=e instanceof Date?e.getTime():e??null,t=t instanceof Date?t.getTime():t??null,"=="===r)return ie(e,t);if("!="===r)return!ie(e,t);switch(r){case"<":return!ne(e)&&(!!ne(t)||t<e);case"<=":return!!ne(t)||!ne(e)&&t<=e;case">":return!ne(t)&&(!!ne(e)||t>e);case">=":return!!ne(e)||!ne(t)&&t>=e;case"like":return"string"==typeof t&&"string"==typeof e&&ht(t,e,!1);case"not like":return!("string"==typeof t&&"string"==typeof e&&ht(t,e,!1));case"like_cs":return"string"==typeof t&&"string"==typeof e&&ht(t,e,!0);case"not like_cs":return!("string"==typeof t&&"string"==typeof e&&ht(t,e,!0));case"array_includes_some":{const r=t;return Array.isArray(t)&&Array.isArray(e)&&e.some((e=>(0,x.truthy)(r,"VALUE_CANNOT_BE_NULL").some((t=>ie(t,e)))))}case"array_includes_all":{const r=t;return Array.isArray(e)&&Array.isArray(t)&&e.every((e=>(0,x.truthy)(r,"VALUE_CANNOT_BE_NULL").some((t=>ie(t,e)))))}case"array_not_includes":{const r=t;return Array.isArray(t)&&Array.isArray(e)&&e.every((e=>!(0,x.truthy)(r,"VALUE_CANNOT_BE_NULL").some((t=>ie(t,e)))))}default:throw new Error(`Unsupported operator comparison: ${r}`)}}function ht(e,t,r){r||(e=e.toLowerCase(),t=t.toLowerCase());const n=function(e){let t="";for(let r=0;r<e.length;++r)"\\"===e[r]?r+1<e.length&&["%","_"].includes(e[r+1])?(t+=e[r+1],r++):r+1<e.length&&"\\"===e[r+1]?(t+="\\\\",r++):t+="\\":"%"===e[r]?t+="[\\s\\S]*":"_"===e[r]?t+="[\\s\\S]":("/-\\^$*+?.()[]{}|".includes(e[r])&&(t+="\\"),t+=e[r]);return t}(t);return new RegExp(`^${n}$`).test(e)}function ft(e,t){return`${e}_${t}`}function pt(e){return"fieldName"in e}class yt{constructor(e,t,r,n){this.querySubscriptionManager=e,this.localQueryManager=t,this.documentReferenceFactory=r,this.documentIdentityService=n}getForDocument(e){const{collectionName:t,integrationId:r,docId:n}=at(e),i=fe(n),o=this.get(t,r);for(const[e,t]of Object.entries(i))o.where(e,"==",t);return o}get(e,t){return new gt(e,t,this.querySubscriptionManager,this.localQueryManager,this.documentReferenceFactory,this,this.documentIdentityService)}}class bt{constructor(){this.containsEmptyInCondition=!1}eq(e,t){return this.where(e,"==",t)}neq(e,t){return this.where(e,"!=",t)}in(e,t){return this.where(e,"in",t)}nin(e,t){return this.where(e,"not in",t)}gt(e,t){return this.where(e,">",t)}gte(e,t){return this.where(e,">=",t)}lt(e,t){return this.where(e,"<",t)}lte(e,t){return this.where(e,"<=",t)}like(e,t,r){return this.throwIfInvalidLikePattern(t),this.where(e,r?"like_cs":"like",t)}notLike(e,t,r){return this.throwIfInvalidLikePattern(t),this.where(e,r?"not like_cs":"not like",t)}arrayIncludesSome(e,t){return this.where(e,"array_includes_some",t)}arrayIncludesAll(e,t){return this.where(e,"array_includes_all",t)}arrayNotIncludes(e,t){return this.where(e,"array_not_includes",t)}throwIfInvalidLikePattern(e){if(/\\(?![%_\\])/.test(e))throw new Error("Invalid pattern. Cannot have any \\ which are not followed by _, % or \\")}}class vt{constructor(e){this.queryBuilder=e}peek(){return this.queryBuilder.peek().map((e=>e.data))}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1).pipe((0,o.defaultIfEmpty)([])))}snapshots(e){return this.queryBuilder.snapshots(e).pipe(j((e=>e.map((e=>e.data)))))}getSortOrders(){return this.queryBuilder.getSortOrders()}clone(){return new vt(this.queryBuilder.clone())}addCompositeCondition(e){return this.queryBuilder.addCompositeCondition(e),this}limit(e){return this.queryBuilder.limit(e),this}getLimit(){return this.queryBuilder.getLimit()}flipSortOrder(){return this.queryBuilder.flipSortOrder(),this}extractData(e){return e}serialize(){return{...this.queryBuilder.serialize(),dereference:!0}}paginate(e){return new lt(this,e)}}class gt extends bt{constructor(e,t,r,n,i,o,s){super(),this.collectionName=e,this.integrationId=t,this.querySubscriptionManager=r,this.localQueryManager=n,this.documentReferenceFactory=i,this.queryBuilderFactory=o,this.documentIdentityService=s,this.forceFetchFromServer=!1,this.query={integrationId:t,collectionName:e,conditions:[],limit:-1,sortOrder:[]}}where(e,t,r){if((0,x.assertTruthy)(nt.includes(t),`Invalid operator: ${t}`),(0,x.assertTruthy)(void 0!==r,"Condition value cannot be undefined"),"in"===t||"not in"===t){const n=Array.isArray(r)?[...r]:[r];"in"===t&&0===n.length&&(this.containsEmptyInCondition=!0);for(const r of n)this.query.conditions.push({fieldName:e,operator:"in"===t?"==":"!=",value:r});return this}return this.query.conditions.push({fieldName:e,operator:t,value:r}),this}limit(e){return function(e){(0,x.assertNumber)(e,"Limit needs to be a number"),-1!==e&&((0,x.assertTruthy)(e>0,"query limit has to be greater than 0"),(0,x.assertTruthy)(Math.floor(e)===e,"query limit has to be an integer"),(0,x.assertTruthy)(e<=2e4,"Limit can be maximum 20000"))}(e),this.query.limit=e,this}getLimit(){return this.query.limit}limitBy(e,...t){const r=this.query.sortOrder.map((e=>e.fieldName));return(0,x.assertTruthy)(ie(t.sort(),r.slice(0,t.length).sort()),"All fields in limitBy must be appear in the first fields in the sortBy list."),this.query.limitBy={limit:e,fields:t,reverseSort:!1},this}sortBy(e,t=!0){const r={asc:t,fieldName:e};return function(e){if(!(e instanceof Object))throw new Error("Field sort has to be an object");const t=e;var r,n,i,o;(0,x.assertTruthy)((r=t,n=["fieldName","asc"],!Array.isArray(r)&&[...Object.keys(r)].every((e=>n.includes(e)))),"Field sort should only contain a fieldName and asc"),(0,x.assertTruthy)((i=t.asc,o="boolean",Array.isArray(i)?i.every((e=>typeof e===o)):typeof i===o),"Asc needs to be boolean")}(r),(0,x.assertTruthy)(!this.query.sortOrder.some((t=>t.fieldName===e)),`${e} already in the sort list.`),this.query.sortOrder.push(r),this}build(){const e=this.mergeConditions();return{...this.query,conditions:e}}mergeConditions(){const e=[],t=ce(this.query.conditions.filter(pt)||[],(e=>e.fieldName));for(const r of Object.values(t)){const t=ce(r,(e=>e.operator));for(const[r,n]of Object.entries(t)){if("=="===r||"!="===r){e.push(...n);continue}const t=[...n];t.sort(((e,t)=>ue(e.value,t.value))),">"===r||">="===r?e.push(t[t.length-1]):e.push(t[0])}}return[...this.query.conditions.filter((e=>!pt(e))),...e]}getSortOrder(){return this.query.sortOrder}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1).pipe((0,o.defaultIfEmpty)([])))}setForceFetchFromServer(){return this.forceFetchFromServer=!0,this}peek(){return this.localQueryManager.peek(this.build())}snapshots(e=!0){if(this.containsEmptyInCondition)return new o.BehaviorSubject([]);const t=this.build();return this.querySubscriptionManager.processQuery(t,this.collectionName,{},{},e,this.forceFetchFromServer).pipe(j((e=>e.map((e=>{(0,x.assertTruthy)(1===Object.keys(e).length);const t=e[this.collectionName],r=ut((0,x.truthy)(t).__docId__,this.collectionName,this.integrationId);return this.documentReferenceFactory.create(r,this.queryBuilderFactory)})))))}changes(){let e,t=new Set;return this.snapshots().pipe((0,o.combineLatestWith)(this.documentIdentityService.observeChanges().pipe((0,o.switchMap)((t=>(Object.entries(t).forEach((([t,r])=>{!function(e,t,r){const n=e[t];void 0!==n&&(e[r]=n,delete e[t])}(e||{},t,r)})),o.NEVER))),(0,o.startWith)({}))),j((([r])=>{let n=[];const i=[],o=[];if(e){for(const o of r){const r=o.squidDocId,s=o.dataRef;if(t.has(s))delete e[r],t.delete(s);else if(e[r]){i.push(o);const n=e[r];delete e[r],t.delete(n)}else n.push(o)}for(const e of t)o.push(e)}else n=r;e={},t=new Set;for(const n of r){const r=n.dataRef;e[n.squidDocId]=r,t.add(r)}return new mt(n,i,o)})))}get hash(){return pe(this.build())}dereference(){return new vt(this)}getSortOrders(){return this.query.sortOrder}clone(){const e=new gt(this.collectionName,this.integrationId,this.querySubscriptionManager,this.localQueryManager,this.documentReferenceFactory,this.queryBuilderFactory,this.documentIdentityService);return e.query=se(this.query),e.containsEmptyInCondition=this.containsEmptyInCondition,e}addCompositeCondition(e){return e.length?(this.query.conditions.push({fields:e}),this):this}flipSortOrder(){return this.query.sortOrder=this.query.sortOrder.map((e=>({...e,asc:!e.asc}))),this.query.limitBy&&(this.query.limitBy.reverseSort=!this.query.limitBy.reverseSort),this}serialize(){return{type:"simple",dereference:!1,query:this.build()}}extractData(e){return e.dataRef}paginate(e){return new lt(this,e)}}class mt{constructor(e,t,r){this.inserts=e,this.updates=t,this.deletes=r}}class _t extends bt{constructor(e,t,r,n,i,o,s,a,u,c,l){super(),this.collectionName=e,this.integrationId=t,this.querySubscriptionManager=r,this.documentReferenceFactory=n,this.queryBuilderFactory=i,this.rootAlias=o,this.latestAlias=s,this.leftToRight=a,this.joins=u,this.joinConditions=c,this.queryBuilder=l}where(e,t,r){return this.queryBuilder.where(e,t,r),this}limit(e){return this.queryBuilder.limit(e),this}getLimit(){return this.queryBuilder.getLimit()}sortBy(e,t=!0){return this.queryBuilder.sortBy(e,t),this}join(e,t,r,n){const i=n?.leftAlias??this.latestAlias,o={...r,leftAlias:i,isInner:n?.isInner??!1},s={...this.leftToRight,[t]:[]};return s[i].push(t),new _t(this.collectionName,this.integrationId,this.querySubscriptionManager,this.documentReferenceFactory,this.queryBuilderFactory,this.rootAlias,t,s,{...this.joins,[t]:e.build()},{...this.joinConditions,[t]:o},this.queryBuilder)}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e=!0){return this.queryBuilder.containsEmptyInCondition?new o.BehaviorSubject([]):this.querySubscriptionManager.processQuery(this.build(),this.rootAlias,se(this.joins),se(this.joinConditions),e,!1).pipe(j((e=>e.map((e=>{const t={};for(const[r,n]of Object.entries(e)){const e=r===this.rootAlias?this.collectionName:this.joins[r].collectionName,i=r===this.rootAlias?this.integrationId:this.joins[r].integrationId,o=n?ut(n.__docId__,e,i):void 0;t[r]=o?this.documentReferenceFactory.create(o,this.queryBuilderFactory):void 0}return t})))))}peek(){throw new Error("peek is not currently supported for join queries")}grouped(){return new wt(this)}dereference(){return new St(this)}build(){return this.queryBuilder.build()}getSortOrders(){return this.queryBuilder.getSortOrders()}clone(){return new _t(this.collectionName,this.integrationId,this.querySubscriptionManager,this.documentReferenceFactory,this.queryBuilderFactory,this.rootAlias,this.latestAlias,se(this.leftToRight),se(this.joins),se(this.joinConditions),this.queryBuilder.clone())}addCompositeCondition(e){return this.queryBuilder.addCompositeCondition(e),this}flipSortOrder(){return this.queryBuilder.flipSortOrder(),this}extractData(e){return e[this.rootAlias].dataRef}serialize(){return{type:"join",grouped:!1,dereference:!1,root:{alias:this.rootAlias,query:this.build()},leftToRight:this.leftToRight,joins:this.joins,joinConditions:this.joinConditions}}paginate(e){if(this.hasIsInner())throw Error("Cannot paginate on joins when isInner is enabled.");return new lt(this,e)}hasIsInner(){return!!Object.values(this.joinConditions).find((e=>e.isInner))}}class St{constructor(e){this.joinQueryBuilder=e}grouped(){return this.joinQueryBuilder.grouped().dereference()}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e){return this.joinQueryBuilder.snapshots(e).pipe(j((e=>e.map((e=>function(e){const t={},r=Object.keys(e);for(const i of r){const r=e[i];t[i]=(n=r,n?.data)}var n;return t}(e))))))}peek(){throw new Error("peek is not currently supported for join queries")}getSortOrders(){return this.joinQueryBuilder.getSortOrders()}clone(){return new St(this.joinQueryBuilder.clone())}addCompositeCondition(e){return this.joinQueryBuilder.addCompositeCondition(e),this}flipSortOrder(){return this.joinQueryBuilder.flipSortOrder(),this}limit(e){return this.joinQueryBuilder.limit(e),this}extractData(e){return e[this.joinQueryBuilder.rootAlias]}paginate(e){if(this.joinQueryBuilder.hasIsInner())throw Error("Cannot paginate on joins when isInner is enabled.");return new lt(this,e)}serialize(){return{...this.joinQueryBuilder.serialize(),dereference:!0}}getLimit(){return this.joinQueryBuilder.getLimit()}}class Ot{constructor(e){this.groupedJoin=e}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e){return this.groupedJoin.snapshots(e).pipe(j((e=>e.map((e=>this.dereference(e,this.groupedJoin.joinQueryBuilder.rootAlias))))))}peek(){throw new Error("peek is not currently supported for join queries")}dereference(e,t){const r=this.groupedJoin.joinQueryBuilder.leftToRight[t];if(r.length){const n={[t]:e[t].data};for(const t of r)n[t]=e[t].map((e=>this.dereference(e,t)));return n}return e.data}getSortOrders(){return this.groupedJoin.getSortOrders()}clone(){return new Ot(this.groupedJoin.clone())}addCompositeCondition(e){return this.groupedJoin.addCompositeCondition(e),this}flipSortOrder(){return this.groupedJoin.flipSortOrder(),this}limit(e){return this.groupedJoin.limit(e),this}getLimit(){return this.groupedJoin.getLimit()}extractData(e){return e[this.groupedJoin.joinQueryBuilder.rootAlias]}serialize(){return{...this.groupedJoin.joinQueryBuilder.serialize(),dereference:!0,grouped:!0}}paginate(e){if(this.groupedJoin.joinQueryBuilder.hasIsInner())throw Error("Cannot paginate on joins when isInner is enabled.");return new lt(this,e)}}class wt{constructor(e){this.joinQueryBuilder=e}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e){return this.joinQueryBuilder.snapshots(e).pipe(j((e=>this.groupData(e,this.joinQueryBuilder.rootAlias))))}peek(){throw new Error("peek is not currently supported for join queries")}dereference(){return new Ot(this)}groupData(e,t){const r=ce(e,(e=>e[t]?.squidDocId));return Object.values(r).filter((e=>void 0!==e[0][t])).map((e=>{const r=this.joinQueryBuilder.leftToRight[t],n=e[0][t];if(0===r.length)return n;const i={[t]:n};for(const t of r)i[t]=this.groupData(e,t);return i}))}getSortOrders(){return this.joinQueryBuilder.getSortOrders()}clone(){return new wt(this.joinQueryBuilder.clone())}addCompositeCondition(e){return this.joinQueryBuilder.addCompositeCondition(e),this}flipSortOrder(){return this.joinQueryBuilder.flipSortOrder(),this}limit(e){return this.joinQueryBuilder.limit(e),this}getLimit(){return this.joinQueryBuilder.getLimit()}extractData(e){return Object.keys(this.joinQueryBuilder.leftToRight).length>1?e[this.joinQueryBuilder.rootAlias].dataRef:e.dataRef}serialize(){return{...this.joinQueryBuilder.serialize(),grouped:!0}}paginate(e){if(this.joinQueryBuilder.hasIsInner())throw Error("Cannot paginate on joins when isInner is enabled.");return new lt(this,e)}}class It{constructor(e,t,r,n,i,o){this.collectionName=e,this.integrationId=t,this.documentReferenceFactory=r,this.queryBuilderFactory=n,this.querySubscriptionManager=i,this.dataManager=o,this.refId=D()}doc(e){if(e&&"string"!=typeof e&&"object"!=typeof e&&!Array.isArray(e))throw new Error("Invalid doc id. Can be only object or string.");if(this.integrationId!==He)if(e){if("object"!=typeof e)throw new Error("Invalid doc id. String doc ids are only supported for the built_in_db integration. For all other integrations, the doc id must be an object.")}else e={[st]:D()};else e=e&&"string"!=typeof e?{__id:de(e)}:{__id:e||D()};const t=ut(de(e),this.collectionName,this.integrationId);return this.documentReferenceFactory.create(t,this.queryBuilderFactory)}async insertMany(e,t){0!==e.length&&await this.dataManager.runInTransaction((async t=>{for(const r of e)await this.doc(r.id).insert(r.data,t)}),t)}async deleteMany(e,t){0!==e.length&&await this.dataManager.runInTransaction((async t=>{for(const r of e)r instanceof ct?await r.delete(t):await this.doc(r).delete(t)}),t)}query(){return this.queryBuilderFactory.get(this.collectionName,this.integrationId)}joinQuery(e){return new _t(this.collectionName,this.integrationId,this.querySubscriptionManager,this.documentReferenceFactory,this.queryBuilderFactory,e,e,{[e]:[]},{},{},this.query())}or(...e){return new Mt(...e)}}class Mt{constructor(...e){if(0===e.length)throw new Error("At least one query builder must be provided");this.snapshotEmitters=e.map((e=>e.clone()));const t=Math.max(...this.snapshotEmitters.map((e=>{const t=e.getLimit();return-1===t?1e3:t})));this.snapshotEmitters.forEach((e=>e.limit(t)));const r=this.snapshotEmitters[0].getSortOrders();for(const e of this.snapshotEmitters){const t=e.getSortOrders();if(t.length!==r.length)throw new Error("All the queries must have the same sort order");for(let e=0;e<r.length;e++)if(t[e].fieldName!==r[e].fieldName||t[e].asc!==r[e].asc)throw new Error("All the queries must have the same sort order")}}snapshot(){return(0,o.firstValueFrom)(this.snapshots(!1))}snapshots(e=!0){const t=this.snapshotEmitters.map((t=>t.snapshots(e)));return this.or(this.snapshotEmitters[0].getSortOrders(),...t)}peek(){throw new Error("peek is not currently supported for merged queries")}or(e,...t){return(0,o.combineLatest)([...t]).pipe((0,o.map)((t=>{const r=new Set,n=t.flat(),i=[];for(const e of n)r.has(this.extractData(e))||(r.add(this.extractData(e)),i.push(e));return i.sort(((t,r)=>{for(const{fieldName:n,asc:i}of e){const e=Z(this.extractData(t),n),o=Z(this.extractData(r),n);if(!dt(e,o,"=="))return dt(o,e,"<")?i?-1:1:i?1:-1}return 0})).slice(0,this.getLimit())})))}clone(){return new Mt(...this.snapshotEmitters.map((e=>e.clone())))}getSortOrders(){return this.snapshotEmitters[0].getSortOrders()}addCompositeCondition(e){for(const t of this.snapshotEmitters)t.addCompositeCondition(e);return this}limit(e){return this.snapshotEmitters.forEach((t=>t.limit(e))),this}getLimit(){return this.snapshotEmitters[0].getLimit()}flipSortOrder(){return this.snapshotEmitters.forEach((e=>e.flipSortOrder())),this}serialize(){return{type:"merged",queries:this.snapshotEmitters.map((e=>e.serialize()))}}extractData(e){return this.snapshotEmitters[0].extractData(e)}paginate(e){return new lt(this,e)}}class Et{constructor(e,t,r,n){this.documentReferenceFactory=e,this.queryBuilderFactory=t,this.querySubscriptionManager=r,this.dataManager=n,this.collections=new Map}get(e,t){let r=this.collections.get(t);r||(r=new Map,this.collections.set(t,r));let n=r.get(e);return n||(n=new It(e,t,this.documentReferenceFactory,this.queryBuilderFactory,this.querySubscriptionManager,this.dataManager),r.set(e,n)),n}}class Ft{constructor(e,t){this.clientIdService=e,this.socketManager=t,this.isConnected=!1,this.socketManager.observeConnectionReady().subscribe((e=>{this.isConnected=e}))}get connected(){return this.isConnected}get clientId(){return this.clientIdService.getClientId()}observeConnected(){return this.socketManager.observeConnectionReady()}}var Tt=r(5150);function At(e,t){switch(t.type){case"applyNumericFn":return function(e,t){if("increment"===t.fn)return null==e?t.value:e+t.value;throw new Error("Unknown numeric function: "+JSON.stringify(t))}(e,t);case"applyStringFn":return function(e,t){switch(t.fn){case"trim":return"string"!=typeof e?e:e.trim();case"extendString":return null==e?t.value:e+t.value;default:throw new Error("Unknown string function: "+JSON.stringify(t))}}(e,t);case"update":return"object"==typeof t.value?se(t.value):t.value;case"removeProperty":return;default:throw new Error("Unknown property mutation type: "+JSON.stringify(t))}}function jt(e){return Object.entries(e.properties).sort((([e],[t])=>e.split(".").length-t.split(".").length))}function Pt(e,t){if("insert"===t.type)return t;if("delete"===t.type)return t;if("delete"===e.type)return e;if((0,x.assertTruthy)("update"===t.type,"Invalid mutation type"),"update"===e.type)return function(e,t){const r=se(e);t=se(t);for(const[e]of jt(r)){const n=e.split(".").length;Object.entries(t.properties).some((([t])=>e.startsWith(t+".")&&n>t.split(".").length))&&delete r.properties[e]}for(const[e,n]of jt(t))r.properties[e]=kt([...r.properties[e]||[],...n]);return r}(e,t);const r=se(e);for(const[e,n]of jt(t)){const t=n;for(const n of t){const t=At(Z(r.properties,e),n);void 0===t?te(r.properties,e):ee(r.properties,e,t)}}return r}function kt(e){let t=0;for(;t+1<e.length;){const i=(r=e[t],"removeProperty"===(n=e[t+1]).type||"update"===n.type?n:"applyNumericFn"===n.type?((0,x.assertTruthy)("increment"===n.fn,"Unrecognized applyNumericFn"),"applyNumericFn"===r.type?((0,x.assertTruthy)("increment"===r.fn,"Unrecognized applyNumericFn"),{type:"applyNumericFn",fn:"increment",value:r.value+n.value}):"update"===r.type?{type:"update",value:r.value+n.value}:n):"extendString"===n.fn?"update"===r.type?{type:"update",value:r.value+n.value}:"applyStringFn"===r.type?"trim"===r.fn?null:{type:"applyStringFn",fn:"extendString",value:r.value+n.value}:n:null);i?e.splice(t,2,i):++t}var r,n;return e}function Ct(e){const t={};for(const r of e){const e=`${r.squidDocIdObj.integrationId}/${r.squidDocIdObj.collectionName}/${r.squidDocIdObj.docId}`;t[e]||(t[e]=[]),t[e].push(r)}const r=[];for(const e in t){const n=t[e].reduce(((e,t)=>(0,x.truthy)(Pt(e,t),"Merge result cannot be null")));r.push(n)}return r}const xt="dataManager_runInTransaction";class Dt{constructor(e,t,r,n,i,s,a,u,c){this.documentStore=e,this.mutationSender=t,this.socketManager=r,this.querySubscriptionManager=n,this.queryBuilderFactory=i,this.lockManager=s,this.destructManager=a,this.documentIdentityService=u,this.querySender=c,this.docIdToLocalTimestamp=new Map,this.batchClientRequestIds=new Set,this.docIdToServerTimestamp=new Map,this.pendingIncomingUpdates=new Map,this.pendingOutgoingMutations=new Map,this.pendingOutgoingMutationsChanged=new o.Subject,this.outgoingMutationsEmpty=new o.BehaviorSubject(!0),this.knownDirtyDocs=new Set,this.failedDocsToResync=[],this.refreshDocIdToTimestamp=new Map,this.handleIncomingMessagesForTests=!0,this.destructManager.onDestruct((()=>{this.destruct()})),this.documentIdentityService.observeChanges().subscribe(this.migrateDocIds.bind(this)),this.handleNotifications(),this.startDeleteExpiredTimestampsJob(),this.handleOrphanDocs(),this.outgoingMutationsEmpty.subscribe((e=>{this.querySender.safeToSendQueriesToServer.next(e)}))}getProperties(e){return this.documentStore.getDocumentOrUndefined(e)}isDirty(e){if(this.knownDirtyDocs.has(e))return!0;if(this.pendingOutgoingMutations.get(e)?.length)return!0;const t=this.docIdToServerTimestamp.get(e),r=t&&!t.expireTimestamp?t.timestamp:void 0,n=this.docIdToLocalTimestamp.get(e);return!((!n||r)&&!this.isForgotten(e)&&!this.isLocalOnly(e)&&n===r)}async runInTransaction(e,t){if(t)return(0,x.assertTruthy)(t===this.currentTransactionId,(()=>`Invalid transaction ID: ${t}`)),e(t).then((e=>Promise.resolve(e)));this.lockManager.canGetLock(xt)?this.lockManager.lockSync(xt):await this.lockManager.lock(xt);let r=Nt;const n=()=>r!==Nt;return new Promise((async(t,i)=>{try{let o;this.currentTransactionId=D();try{o=await e(this.currentTransactionId)}catch(e){r=e}finally{this.finishTransaction(n()?void 0:{resolve:()=>t(o),reject:i})}}catch(e){r=n()?r:e}finally{try{this.lockManager.release(xt)}catch(e){r=n()?r:e}}n()&&i(r)}))}async applyOutgoingMutation(e,t){const r=ut(e.squidDocIdObj);this.knownDirtyDocs.add(r),t||this.lockManager.canGetLock(xt)||(await this.lockManager.lock(xt),this.lockManager.release(xt)),this.knownDirtyDocs.delete(r);const n=this.pendingOutgoingMutations.get(r)?.slice(-1)[0];if(n&&!n.sentToServer)n.mutation=(0,x.truthy)(Ct([n.mutation,this.removeInternalProperties(e)])[0],"Failed to reduce mutations"),this.outgoingMutationsEmpty.next(!1);else{const t={mutation:this.removeInternalProperties(e),sentToServer:!1},n=this.pendingOutgoingMutations.get(r)||[];n.push(t),this.pendingOutgoingMutations.set(r,n),this.outgoingMutationsEmpty.next(!1),this.pendingOutgoingMutationsChanged.next()}return this.runInTransaction((async()=>{const t=this.documentStore.getDocumentOrUndefined(r),n="delete"===e.type?void 0:"update"===e.type?function(e,t){if(!e)return;const r={...e},n=jt(t);for(const[e,t]of n){const n=t;for(const t of n){const n=At(Z(r,e),t);void 0===n?te(r,e):ee(r,e,n)}}return r}(t,e):{...e.properties};this.updateDocumentFromSnapshot(r,n)&&("insert"===e.type&&this.docIdToLocalTimestamp.set(r,(new Date).getTime()),this.querySubscriptionManager.setClientRequestIdsForLocalDoc(r,n).forEach((e=>this.batchClientRequestIds.add(e))))}),t)}async runInTransactionSync(e,t){if(t)return(0,x.assertTruthy)(t===this.currentTransactionId,(()=>`Invalid transaction ID: ${t}`)),void e(t);await this.lockManager.lock(xt);try{this.currentTransactionId=D();try{return e(this.currentTransactionId)}catch(e){console.error("error while executing callback function in transaction",e)}finally{this.finishTransaction()}}catch(e){console.error("error while executing transaction",e)}finally{this.lockManager.release(xt)}}removeInternalProperties(e){if("delete"===e.type)return e;const t={...e,properties:{...e.properties}};return delete t.properties.__docId__,delete t.properties.__ts__,t}handleNotifications(){this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"mutations"===e.type)),j((e=>e))).subscribe((e=>{this.outgoingMutationsEmpty.pipe((0,o.filter)(Boolean),(0,o.take)(1)).subscribe((()=>{this.handleIncomingMutations(e.payload)}))})),this.querySubscriptionManager.observeQueryResults().subscribe((e=>{this.outgoingMutationsEmpty.pipe((0,o.filter)(Boolean),(0,o.take)(1)).subscribe((()=>{this.handleIncomingQuerySnapshots(e)}))}))}handleIncomingMutations(e){if(!this.handleIncomingMessagesForTests)return;const t=e.reduce(((e,t)=>this.querySubscriptionManager.hasOngoingQuery(t.clientRequestId)?(e[t.squidDocId]={properties:t.doc,timestamp:t.mutationTimestamp},e):e),{});this.applyIncomingUpdates(t)}handleIncomingQuerySnapshots(e){if(!this.handleIncomingMessagesForTests)return;if(!this.querySubscriptionManager.hasOngoingQuery(e.clientRequestId))return;const t=this.querySubscriptionManager.getQuery(e.clientRequestId),r={};for(const n of e.docs){const e=ut(n.__docId__,t.collectionName,t.integrationId);r[e]={properties:n,timestamp:n.__ts__}}this.runInTransactionSync((t=>{this.querySubscriptionManager.setGotInitialResult(e.clientRequestId),this.batchClientRequestIds.add(e.clientRequestId),this.applyIncomingUpdates(r,t)&&this.querySubscriptionManager.hasSubscription(e.clientRequestId)&&this.batchClientRequestIds.delete(e.clientRequestId)})).then()}applyIncomingUpdates(e,t){let r=!1;const n=new Set,i=new Set;for(const[t,o]of Object.entries(e)){const e=this.pendingIncomingUpdates.get(t),s=this.docIdToServerTimestamp.get(t);e&&e.timestamp>o.timestamp?r=!0:s&&s.timestamp>o.timestamp?i.add(t):(this.pendingIncomingUpdates.set(t,o),n.add(t))}return this.runInTransactionSync((()=>{for(const e of n)this.maybeApplyIncomingUpdate(e);for(const e of i)this.refreshQueryMapping(e)}),t).then(),r}maybeApplyIncomingUpdate(e){const t=this.pendingIncomingUpdates.get(e);if(!t)return;const r=this.pendingOutgoingMutations.get(e);r&&r.length||(this.updateDocumentFromSnapshot(e,t.properties),this.acknowledgeDocument(e,t.timestamp,!t.properties),this.docIdToLocalTimestamp.set(e,t.timestamp),this.pendingIncomingUpdates.delete(e),this.refreshQueryMapping(e))}refreshQueryMapping(e){const t=this.documentStore.getDocumentOrUndefined(e);this.querySubscriptionManager.setClientRequestIdsForLocalDoc(e,t).forEach((e=>{this.batchClientRequestIds.add(e)})),t&&(this.querySubscriptionManager.findQueriesForDocument(t,e).length||this.forgetDocument(e,!1))}destruct(){this.stopDeleteExpiredTimestampsJob()}stopDeleteExpiredTimestampsJob(){void 0!==this.deleteExpiredTimestampsInterval&&(clearInterval(this.deleteExpiredTimestampsInterval),this.deleteExpiredTimestampsInterval=void 0)}startDeleteExpiredTimestampsJob(){this.deleteExpiredTimestampsInterval=setInterval((()=>{const e=[...this.docIdToServerTimestamp.entries()].filter((([e,t])=>!(!t.expireTimestamp||t.expireTimestamp>Date.now()||this.isTracked(e))));for(const[t]of e)this.docIdToServerTimestamp.delete(t),this.forgetDocument(t,!0)}),1e4)}isTracked(e){if(this.pendingIncomingUpdates.get(e))return!0;const t=this.pendingOutgoingMutations.get(e);return!(!t||!t.length)||this.querySubscriptionManager.hasOngoingQueryForDocId(e)}isForgotten(e){return this.documentStore.hasData(e)&&!this.isTracked(e)}isLocalOnly(e){return!this.hasBeenAcknowledged(e)&&this.documentStore.hasData(e)}hasBeenAcknowledged(e){return this.docIdToServerTimestamp.has(e)}updateDocumentFromSnapshot(e,t){const r=this.documentStore.getDocumentOrUndefined(e);return!(!r&&!t||r===t)&&((!r||!t||de({...t,__ts__:void 0})!==de(r))&&(this.documentStore.saveDocument(e,t),!0))}finishTransaction(e){this.currentTransactionId=void 0;const t=[...this.batchClientRequestIds.values()];this.batchClientRequestIds.clear(),this.querySubscriptionManager.notifyAllSubscriptions(t),this.sendAllUnsentOutgoingMutations(e).then()}async sendAllUnsentOutgoingMutations(e){const t=this.groupOutgoingMutationsByIntegrationId();try{await Tt.PromisePool.for(t).withConcurrency(t.length||1).handleError((e=>{throw e})).process((async([e,t])=>{await this.sendMutationsForIntegration([...t],e)})),this.pendingOutgoingMutations.size||this.outgoingMutationsEmpty.next(!0),await this.refreshUpdatedDocuments(),this.hasPendingSentMutations()?(await(0,o.firstValueFrom)(this.pendingOutgoingMutationsChanged.pipe((0,o.filter)((()=>!this.hasPendingSentMutations())))),e?.resolve()):e?.resolve()}catch(t){this.pendingOutgoingMutations.size||(this.outgoingMutationsEmpty.next(!0),await this.resyncFailedUpdates()),e?.reject(t)}}async sendMutationsForIntegration(e,t){try{const{timestamp:r,idResolutionMap:n={},refreshList:i=[]}=await this.mutationSender.sendMutations(e.map((e=>e.mutation)),t);this.documentIdentityService.migrate(n),i.forEach((e=>{this.refreshDocIdToTimestamp.set(n[e]||e,r)}));for(const t of e){let e=this.removeOutgoingMutation(t);n[e]&&(e=n[e]),this.acknowledgeDocument(e,r),this.isTracked(e)||(this.setExpiration(e,!0),this.forgetDocument(e,!1))}}catch(t){for(const t of e){const e=this.removeOutgoingMutation(t);this.forgetDocument(e,!1),(this.hasBeenAcknowledged(e)||"insert"===t.mutation.type)&&this.failedDocsToResync.push(e)}throw t}}removeOutgoingMutation(e){const t=ut(e.mutation.squidDocIdObj),r=(0,x.truthy)(this.pendingOutgoingMutations.get(t));return r.splice(r.indexOf(e),1),r.length||this.pendingOutgoingMutations.delete(t),this.pendingOutgoingMutationsChanged.next(),t}async resyncFailedUpdates(){const e=[...this.failedDocsToResync];this.failedDocsToResync.splice(0);for(const t of e){const{docId:e}=at(t);this.setExpiration(t,!0);try{const r=e.includes(st)?[]:await this.queryBuilderFactory.getForDocument(t).setForceFetchFromServer().snapshot();if((0,x.truthy)(r.length<=1,"Got more than one doc for the same id:"+t),!r.length){this.forgetDocument(t,!1);const e=this.querySubscriptionManager.setClientRequestIdsForLocalDoc(t,void 0);this.querySubscriptionManager.notifyAllSubscriptions(e)}}catch(e){this.querySubscriptionManager.errorOutAllQueries(t,e)}}}async refreshUpdatedDocuments(){const e=[];for(const[t,r]of this.refreshDocIdToTimestamp.entries()){const n=this.docIdToServerTimestamp.get(t)?.timestamp;n&&n>r||e.push(t)}this.refreshDocIdToTimestamp.clear(),await Promise.allSettled(e.map((e=>this.queryBuilderFactory.getForDocument(e).snapshot())))}groupOutgoingMutationsByIntegrationId(){const e={};for(const[,t]of[...this.pendingOutgoingMutations.entries()]){const r=t[t.length-1];if(r&&!r.sentToServer){const t=r.mutation.squidDocIdObj.integrationId;(e[t]||=[]).push(r),r.sentToServer=!0}}return Object.entries(e)}handleOrphanDocs(){this.querySubscriptionManager.onOrphanDocuments.subscribe((e=>{for(const t of e)this.isTracked(t)||this.forgetDocument(t,!1)}))}acknowledgeDocument(e,t,r=!1){this.docIdToServerTimestamp.set(e,{timestamp:t}),this.setExpiration(e,r)}setExpiration(e,t){const r=this.docIdToServerTimestamp.get(e);r&&(r.expireTimestamp=t?Date.now()+2e4:void 0)}forgetDocument(e,t){this.docIdToLocalTimestamp.delete(e),t&&this.documentStore.saveDocument(e,void 0),this.setExpiration(e,!0)}migrateDocIds(e){this.pendingOutgoingMutations.forEach((t=>{t.forEach((t=>{const r=ut(t.mutation.squidDocIdObj),n=e[r];n&&(t.mutation.squidDocIdObj=at(n))}))})),Object.entries(e).forEach((([e,t])=>{re(this.pendingOutgoingMutations,e,t),re(this.docIdToLocalTimestamp,e,t),re(this.docIdToServerTimestamp,e,t)}))}hasPendingSentMutations(){for(const e of this.pendingOutgoingMutations.values())for(const t of e)if(t.sentToServer)return!0;return!1}}const Nt=Symbol("undefined");class Rt{constructor(){this.preDestructors=[],this.destructors=[],this.isDestructedSubject=new o.BehaviorSubject(!1)}get isDestructing(){return this.isDestructedSubject.value}observeIsDestructing(){return this.isDestructedSubject.asObservable().pipe((0,o.filter)(Boolean),j((()=>{})))}onPreDestruct(e){this.preDestructors.push(e)}onDestruct(e){this.destructors.push(e)}async destruct(){this.reportDestructed();const e=this.preDestructors.concat(this.destructors);let t=e.shift();for(;t;){try{await t()}catch(e){console.error("Error while destructing Squid",e)}t=e.shift()}}reportDestructed(){this.isDestructing||this.isDestructedSubject.next(!0)}}class qt{constructor(e,t){this.socketManager=e,this.destructManager=t,this.ongoingLocks={},this.acquireLockMessagesFromServer=this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"lockAcquired"===e.type))),this.releaseLockMessagesFromServer=this.socketManager.observeNotifications().pipe((0,o.filter)((e=>"lockReleased"===e.type))),this.lockWaitForConnectionThreshold=2e3,t.onPreDestruct((()=>{this.releaseAllLocks()})),this.socketManager.observeConnectionReady().subscribe((e=>{e||this.releaseAllLocks()})),this.releaseLockMessagesFromServer.subscribe((e=>{const t=this.ongoingLocks[e.payload.clientRequestId];void 0!==t&&t.release()}))}async lock(e,t=1e3){if(this.socketManager.notifyWebSocketIsNeeded(),!await(0,o.firstValueFrom)((0,o.race)((0,o.timer)(this.lockWaitForConnectionThreshold).pipe(j((()=>!1))),this.socketManager.observeConnectionReady().pipe((0,o.filter)(Boolean)),this.destructManager.observeIsDestructing())))return Promise.reject("CLIENT_NOT_CONNECTED");const r=D(),n={type:"acquireLock",payload:{mutex:e,timeoutMillis:t,clientRequestId:r}};this.socketManager.sendMessage(n);const i=await(0,o.firstValueFrom)((0,o.race)((0,o.timer)(t+4e3).pipe((0,o.take)(1),j((()=>({payload:{error:"TIMEOUT_GETTING_LOCK",lockId:void 0}})))),this.acquireLockMessagesFromServer.pipe((0,o.filter)((e=>e.payload.clientRequestId===r)))));if(this.destructManager.isDestructing)throw new Error("Destructing");if(!i.payload.lockId)throw new Error(`Failed to acquire lock: ${i.payload.error}`);const s=i.payload.lockId,a=new Lt(s,r,this.ongoingLocks,this.socketManager);return this.ongoingLocks[s]=a,a}releaseAllLocks(){for(const[e,t]of Object.entries(this.ongoingLocks))t.release(),delete this.ongoingLocks[e]}}class Lt{constructor(e,t,r,n){this.lockId=e,this.clientRequestId=t,this.ongoingLocks=r,this.socketManager=n,this.released=!1,this.onReleaseSubject=new o.Subject}release(){if(this.released)return;this.released=!0,delete this.ongoingLocks[this.lockId];const e={type:"releaseLock",payload:{lockId:this.lockId,clientRequestId:this.clientRequestId}};this.socketManager.sendMessage(e),this.onReleaseSubject.next()}observeRelease(){return this.onReleaseSubject.asObservable()}isReleased(){return this.released}}class Bt{constructor(e,t){this.documentStore=e,this.destructManager=t,this.changeNotifier=new o.BehaviorSubject({}),this.destructManager.onDestruct((()=>{this.changeNotifier.complete()}))}migrate(e){Object.entries(e).forEach((([e,t])=>{this.documentStore.migrateDocId(e,t)})),this.changeNotifier.next(e)}observeChanges(){return this.changeNotifier.asObservable()}}class Ut{constructor(e){this.documentIdentityService=e,this.documents=new Map,this.documentsForCollection=new Map,this.documentIdentityService.observeChanges().subscribe(this.migrateDocIds.bind(this))}create(e,t){let r=this.documents.get(e);if(r)return r;r=new ct(e,(0,x.truthy)(this.dataManager,"dataManager not found"),t);const{integrationId:n,collectionName:i}=at(e);this.documents.set(e,r);const o=this.getCollectionKey(n,i),s=this.documentsForCollection.get(o)||[];return this.documentsForCollection.set(o,s.concat(r)),r}setDataManager(e){this.dataManager=e}getDocumentsForCollection(e,t){const r=this.getCollectionKey(e,t);return(this.documentsForCollection.get(r)||[]).filter((e=>e.hasData))}migrateDocIds(e){for(const[,t]of this.documents)t.migrateDocIds(e);Object.entries(e).forEach((([e,t])=>{const r=at(e),n=at(t);re(this.documents,r.docId,n.docId)}))}getCollectionKey(e,t){return`${e}_${t}`}}class Qt{constructor(){this.squidDocIdToDoc=new Map}saveDocument(e,t){const r=this.squidDocIdToDoc.get(e);if(void 0===r&&!t)return;if(void 0!==r){if(t){const r=se(t),n=this.removeInternalProperties(r);return this.squidDocIdToDoc.set(e,n),n}return void this.squidDocIdToDoc.delete(e)}const n=this.removeInternalProperties(t);return this.squidDocIdToDoc.set(e,n),t}hasData(e){return void 0!==this.squidDocIdToDoc.get(e)}getDocument(e){return(0,x.truthy)(this.getDocumentOrUndefined(e))}getDocumentOrUndefined(e){return this.squidDocIdToDoc.get(e)}compareSquidDocs(e,t,r){for(const{fieldName:n,asc:i}of r){const r=ue(Z(e,n),Z(t,n));if(0!==r)return i?r:-r}return 0}group(e,t){return Object.values(ce(e,(e=>de(t.map((t=>Z(e,t)))))))}sortAndLimitDocs(e,t){if(0===e.size)return[];const r=[...e].map((e=>this.squidDocIdToDoc.get(e))).filter(x.isNonNullable),{sortOrder:n,limitBy:i}=t,o=r.sort(((e,t)=>this.compareSquidDocs(e,t,n))),s=t.limit<0?2e3:t.limit;if(!i)return o.slice(0,s);const{limit:a,fields:u,reverseSort:c}=i,l=this.group(o,u);let d;return d=c?l.map((e=>e.slice(-a))):l.map((e=>e.slice(0,a))),d.flat().slice(0,s)}removeInternalProperties(e){if(!e)return;const t={...e};return delete t.__ts__,t}migrateDocId(e,t){const r=this.getDocumentOrUndefined(e);if(!r)return;re(this.squidDocIdToDoc,e,t);const n=at(t),i=fe(n.docId);this.saveDocument(t,{...r,...i,__docId__:n.docId})}}class $t{constructor(e,t,r){this.rpcManager=e,this.lockManager=t,this.querySender=r}async sendMutations(e,t){const r=Ct(e),n=r.map((e=>`sendMutation_${ut(e.squidDocIdObj)}`));await this.lockManager.lock(...n),await this.querySender.waitForAllQueriesToFinish();try{const e={mutations:r,integrationId:t};return await this.rpcManager.post("mutation/mutate",e)}catch(e){throw ve.debug("Error while sending mutations",{error:e,mutations:JSON.stringify(r,null,2)}),e}finally{this.lockManager.release(...n)}}}class Wt{constructor(e){this.rpcManager=e}async executeNativeQuery(e){return this.rpcManager.post("native-query/execute",e)}}async function Vt(e,t,r=500){const n=Date.now(),i=e.paginate({pageSize:r,subscribe:!1});let o=0,s=await i.waitForData();for(;;){for(const e of s.data)o++,await t(e.data);if(!s.hasNext)break;s=await i.next()}return{count:o,time:Date.now()-n}}function zt(e,t){switch(t.type){case"simple":return function(e,t){const{query:r,dereference:n}=t,{collectionName:i,integrationId:o}=r;let s=e.collection(i,o).query();return s=Gt(s,r),n?s.dereference():s}(e,t);case"join":return function(e,t){const{root:r,joins:n,joinConditions:i,dereference:o,grouped:s}=t,{collectionName:a,integrationId:u}=r.query;let c=e.collection(a,u).joinQuery(r.alias);return c=Gt(c,r.query),Object.entries(n).map((([t,r])=>{const{collectionName:n,integrationId:o}=r,{left:s,right:a,leftAlias:u}=i[t];let l=e.collection(n,o).query();l=Gt(l,r),c=c.join(l,t,{left:s,right:a},{leftAlias:u})})),o&&s?c.grouped().dereference():o?c.dereference():s?c.grouped():c}(e,t);case"merged":return function(e,t){const{queries:r}=t,{collectionName:n,integrationId:i}=Ht(r[0]),o=r.map((t=>zt(e,t)));return e.collection(n,i).or(...o)}(e,t)}}function Gt(e,t){const{conditions:r,limit:n,sortOrder:i}=t;for(const t of r){if(!("operator"in t))throw new Error("Composite conditions are not support in query serialization.");const{fieldName:r,operator:n,value:i}=t;e.where(r,n,i)}e.limit(n);for(const{fieldName:t,asc:r}of i)e.sortBy(t,r);return e}function Ht(e){switch(e.type){case"simple":{const{collectionName:t,integrationId:r}=e.query;return{collectionName:t,integrationId:r}}case"join":{const{collectionName:t,integrationId:r}=e.root.query;return{collectionName:t,integrationId:r}}case"merged":return Ht(e.queries[0])}}const Yt={"in:in":(e,t)=>e.every((e=>t.includes(e))),"in:not in":(e,t)=>e.every((e=>!t.includes(e))),"not in:not in":(e,t)=>t.every((t=>e.includes(t))),">:not in":(e,t)=>t.every((t=>e>=t)),">=:not in":(e,t)=>t.every((t=>e>t)),"<:not in":(e,t)=>t.every((t=>e<=t)),"<=:not in":(e,t)=>t.every((t=>e<t)),">:>":(e,t)=>e>=t,">=:>":(e,t)=>e>t,"in:>":(e,t)=>e.every((e=>e>t)),">:>=":(e,t)=>e>=t,">=:>=":(e,t)=>e>=t,"in:>=":(e,t)=>e.every((e=>e>=t)),"<:<":(e,t)=>e<=t,"<=:<":(e,t)=>e<t,"in:<":(e,t)=>e.every((e=>e<t)),"<:<=":(e,t)=>e<=t,"<=:<=":(e,t)=>e<=t,"in:<=":(e,t)=>e.every((e=>e<=t)),"like:like":(e,t)=>Jt(e.toLowerCase(),t.toLowerCase()),"like_cs:like":(e,t)=>Jt(e.toLowerCase(),t.toLowerCase()),"like:like_cs":(e,t)=>Jt(e,t)&&Zt(t),"like_cs:like_cs":(e,t)=>Jt(e,t),"like:not like":(e,t)=>!Kt(e.toLowerCase(),t.toLowerCase()),"like_cs:not like":(e,t)=>!Kt(e.toLowerCase(),t.toLowerCase()),"like:not like_cs":(e,t)=>!Kt(e.toLowerCase(),t.toLowerCase()),"like_cs:not like_cs":(e,t)=>!Kt(e,t),"not like:like":(e,t)=>er(e,t),"not like_cs:like":(e,t)=>er(e,t),"not like:like_cs":(e,t)=>er(e,t),"not like_cs:like_cs":(e,t)=>er(e,t),"not like:not like":(e,t)=>Jt(t.toLowerCase(),e.toLowerCase()),"not like_cs:not like":(e,t)=>Jt(t,e)&&Zt(e),"not like:not like_cs":(e,t)=>Jt(t.toLowerCase(),e.toLowerCase()),"not like_cs:not like_cs":(e,t)=>Jt(t,e),"in:like":(e,t)=>e.every((e=>dt(t,e,"like"))),"in:like_cs":(e,t)=>e.every((e=>dt(t,e,"like_cs"))),"in:not like":(e,t)=>e.every((e=>dt(t,e,"not like"))),"in:not like_cs":(e,t)=>e.every((e=>dt(t,e,"not like_cs"))),"like:in":(e,t)=>!e.includes("%")&&!e.includes("_")&&!!t.find((t=>t.toLowerCase()===e.toLowerCase())),"like_cs:in":(e,t)=>!e.includes("%")&&!e.includes("_")&&t.includes(e),"not like:in":(e,t)=>e.length>0&&Xt(e)||tr(e)&&t.includes(""),"not like_cs:in":(e,t)=>e.length>0&&Xt(e)||tr(e)&&t.includes(""),"not in:like":(e,t)=>t.length>0&&Xt(t)||tr(t)&&e.includes(""),"not in:like_cs":(e,t)=>t.length>0&&Xt(t)||tr(t)&&e.includes(""),"not in:not like":(e,t)=>!t.includes("%")&&!t.includes("_")&&!!e.find((e=>e.toLowerCase()===t.toLowerCase())),"not in:not like_cs":(e,t)=>!t.includes("%")&&!t.includes("_")&&e.includes(t),"like:not in":(e,t)=>t.every((t=>dt(e,t,"not like"))),"like_cs:not in":(e,t)=>t.every((t=>dt(e,t,"not like_cs"))),"not like:not in":(e,t)=>t.every((t=>dt(e,t,"like"))),"not like_cs:not in":(e,t)=>t.every((t=>dt(e,t,"like_cs"))),"array_includes_some:array_includes_some":(e,t)=>e.every((e=>t.includes(e))),"array_includes_all:array_includes_all":(e,t)=>e.every((e=>t.includes(e))),"array_not_includes:array_not_includes":(e,t)=>t.every((t=>e.includes(t))),"array_includes_some:array_not_includes":(e,t)=>e.every((e=>!t.includes(e))),"array_not_includes:array_includes_some":(e,t)=>t.every((t=>!e.includes(t))),"array_includes_all:array_includes_some":(e,t)=>e.every((e=>t.includes(e))),"array_includes_some:array_includes_all":(e,t)=>e.every((e=>t.includes(e))),"array_not_includes:array_includes_all":(e,t)=>t.every((t=>!e.includes(t))),"array_includes_all:array_not_includes":(e,t)=>e.every((e=>!t.includes(e)))};function Jt(e,t,r=0,n=0){if(n>=t.length)return r>=e.length;if(r>=e.length)return Xt(t.substring(n));const i=e[r],o=t[n];return"%"===i&&"%"===o?Jt(e,t,r+1,n+1)||Jt(e,t,r+1,n):"%"!==i&&("%"===o?Jt(e,t,r,n+1)||Jt(e,t,r+1,n):(i===o||"_"===o)&&Jt(e,t,r+1,n+1))}function Kt(e,t,r=0,n=0){if(r>=e.length&&n>=t.length)return!0;if(r>=e.length)return Xt(t.substring(n));if(n>=t.length)return Xt(e.substring(r));const i=r<e.length?e[r]:"",o=n<t.length?t[n]:"";return"%"===i&&"%"===o?Kt(e,t,r+1,n+1)||Kt(e,t,r,n+1)||Kt(e,t,r+1,n):"%"===i||"%"===o?Kt(e,t,r,n+1)||Kt(e,t,r+1,n):(i===o||"_"===i||"_"===o)&&Kt(e,t,r+1,n+1)}function Zt(e){return!/[a-zA-Z]/.test(e)}function Xt(e){return e.split("").every((e=>"%"===e))}function er(e,t){return e.length>0&&Xt(e)||t.length>0&&Xt(t)||tr(e)&&0===t.length}function tr(e){let t=!1,r=!1;for(const n of e)switch(n){case"%":t=!0;break;case"_":if(r)return!1;r=!0;break;default:return!1}return t&&r}class rr{constructor(e){this.query=e,this.query=e,this.parsedConditions=this.parseConditions(this.query.conditions.filter(pt))}get integrationId(){return this.query.integrationId}get collectionName(){return this.query.collectionName}get limit(){return this.query.limit}sortedBy(e){return!e.find(((e,t)=>!ie(this.query.sortOrder[t],{...e,asc:e.asc??!0})))}sortedByExact(e){return e.length===this.query.sortOrder.length&&this.sortedBy(e)}isSubqueryOf(e,t,r){return this.isSubqueryOfCondition({fieldName:e,operator:t,value:r})}isSubqueryOfCondition(e){return!!this.parsedConditions.filter((t=>t.fieldName===e.fieldName)).find((t=>this.evaluateSubset(t,e)))}isSubqueryOfConditions(e){return this.parseConditions(e).every((e=>this.isSubqueryOfCondition(e)))}isSubqueryOfQuery(e){if(e.collectionName!==this.collectionName||e.integrationId!==this.integrationId)return!1;const t=e.conditions.filter(pt),r=this.isSubqueryOfConditions(t),n=this.sortedBy(e.sortOrder),i=-1===e.limit||this.limit>-1&&this.limit<e.limit;return r&&n&&i}getConditionsFor(...e){return this.parsedConditions.filter((t=>e.includes(t.fieldName)))}getConditionsForField(e){return this.parsedConditions.filter((t=>t.fieldName===e))}documentMatchesQuery(e){for(const t of this.parsedConditions){const r=t.fieldName,n=t.operator,i=Z(e,r);if("in"===n){if(t.value.includes(i))continue;return!1}if("not in"!==n){if(!dt(t.value,i,n))return!1}else if(t.value.includes(i))return!1}return!0}evaluateSubset(e,t){const{operator:r,value:n}=e,{operator:i,value:o}=this.parseConditions([t])[0],s=Yt[`${r}:${i}`];return!!s&&s(n,o)}parseConditions(e){const t=[],r=new Map,n=new Map;return e.forEach((e=>{switch(e.operator){case"==":case"in":r.set(e.fieldName,(r.get(e.fieldName)||[]).concat(e.value));break;case"!=":case"not in":n.set(e.fieldName,(n.get(e.fieldName)||[]).concat(e.value));break;default:t.push(e)}})),r.forEach(((e,r)=>{t.push({fieldName:r,operator:"in",value:e})})),n.forEach(((e,r)=>{t.push({fieldName:r,operator:"not in",value:e})})),t}}class nr{constructor(e,t,r){this.documentStore=e,this.documentReferenceFactory=t,this.querySubscriptionManager=r}peek(e){if(!this.querySubscriptionManager.findValidParentOfQuery(e))return[];const{integrationId:t,collectionName:r}=e,n=new rr(e),i=this.documentReferenceFactory.getDocumentsForCollection(t,r).filter((e=>n.documentMatchesQuery(e.data))),o={};return i.forEach((e=>{o[e.squidDocId]=e})),this.documentStore.sortAndLimitDocs(new Set(Object.keys(o)),e).map((e=>o[ut(e.__docId__,r,t)]))}}function ir(e,t){return a((function(r,n){var i=0;r.subscribe(T(n,(function(r){return e.call(t,r,i++)&&n.next(r)})))}))}class or{constructor(e,t){this.rpcManager=e,this.destructManager=t,this.pendingQueryRequests=[],this.safeToSendQueriesToServer=new o.BehaviorSubject(!0),this.inflightQueriesCount=new o.BehaviorSubject(0),this.destructManager.onPreDestruct((()=>{this.preDestruct()}))}async sendQuery(e){const t=new o.Subject,r=(0,o.firstValueFrom)(t);return this.pendingQueryRequests.push({queryRequest:e,responseSubject:t}),this.pendingQueryBatchTimeout&&(clearTimeout(this.pendingQueryBatchTimeout),this.pendingQueryBatchTimeout=void 0),this.pendingQueryRequests.length>=10?(this.processQueryBatch(),r):(this.pendingQueryBatchTimeout=setTimeout((()=>{this.safeToSendQueriesToServer.pipe(ir(Boolean),(0,o.take)(1)).subscribe((()=>{this.processQueryBatch()}))}),0),r)}async processQueryBatch(){const e=this.pendingQueryRequests.splice(0);if(!e.length)return;const t=Array.from(e.map((({queryRequest:e})=>e)).reduce(((e,t)=>(e.set(t.clientRequestId,t),e)),new Map).values()),r=e.map((({responseSubject:e})=>e));this.inflightQueriesCount.next(this.inflightQueriesCount.value+t.length);try{const r=await this.rpcManager.post("query/batchQueries",t);for(const{queryRequest:t,responseSubject:n}of e){const e=t.clientRequestId,i=r.errors[e],o=r.results[e];i?n.error(i):n.next(o)}}catch(e){r.forEach((t=>t.error(e)))}finally{this.inflightQueriesCount.next(this.inflightQueriesCount.value-t.length)}}async waitForAllQueriesToFinish(){return(0,o.firstValueFrom)(this.inflightQueriesCount.pipe(ir((e=>0===e)))).then((()=>{}))}preDestruct(){this.safeToSendQueriesToServer.next(!1),this.safeToSendQueriesToServer.complete()}}var sr,ar=r(4123);function ur(e,t,r=(e,t)=>e>t?1:e<t?-1:0,n=0,i=e.length-1){if(i<n)return-1;const o=Math.trunc((n+i)/2);return 0===r(t,e[o])?o:r(t,e[o])>0?ur(e,t,r,o+1,i):ur(e,t,r,n,o-1)}function cr(e,t,r=(e,t)=>e>t?1:e<t?-1:0){if(-1!==ur(e,t,r))return;let n;for(n=e.length-1;n>=0&&r(e[n],t)>0;n--)e[n+1]=e[n];e[n+1]=t}function lr(e,t,r=(e,t)=>e>t?1:e<t?-1:0){const n=ur(e,t,r);n>-1&&e.splice(n,1)}!function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.DISABLED=1]="DISABLED",e[e.ENABLED=2]="ENABLED"}(sr||(sr={}));const dr=100;class hr{constructor(e,t,r,n,i,s,a){this.rpcManager=e,this.clientIdService=t,this.documentStore=r,this.destructManager=n,this.documentIdentityService=i,this.querySender=s,this.socketManager=a,this.onOrphanDocuments=new o.Subject,this.ongoingQueries=new Map,this.clientRequestIdToLocalDocuments=new Map,this.localDocumentToClientRequestIds=new Map,this.queryMappingManager=new pr,this.queryResultsSubject=new o.Subject,this.documentIdentityService.observeChanges().subscribe(this.migrateDocIds.bind(this)),this.clientIdService.observeClientReadyToBeRegenerated().subscribe((()=>{this.refreshOngoingQueries()})),this.destructManager.onPreDestruct((()=>{this.preDestruct()}))}dumpSubscriptionInfo(){console.log("Ongoing queries:",this.ongoingQueries),console.log("ClientRequestId to local documents:",this.clientRequestIdToLocalDocuments),console.log("Local documents to clientRequestId:",this.localDocumentToClientRequestIds)}observeQueryResults(){return this.queryResultsSubject.asObservable()}hasOngoingQuery(e){return this.ongoingQueries.has(e)}getQuery(e){return(0,x.truthy)(this.ongoingQueries.get(e),"UNKNOWN_QUERY").query}setGotInitialResult(e){const t=this.ongoingQueries.get(e);t?.gotInitialResponse&&this.removeClientRequestIdMapping(e),t&&(t.gotInitialResponse=!0,t.isInFlight=!1)}findQueriesForDocument(e,t){const{collectionName:r,integrationId:n}=at(t),i=this.queryMappingManager.getMapping(r,n);return i?function(e,t){const r=[...e.unconditional||[]],n=new Map;for(const[r,i]of Object.entries(e.conditional||{})){const e=fe(r);let o;if(pt(e)){const r=Z(t,e.fieldName)??null;o=dt(e.value,r,e.operator)}else o=fr(e,t);if(o)for(const e of i)n.set(e,(n.get(e)||0)+1)}for(const[t,i]of n.entries())i>=e.queriesMetadata[t].condCount&&r.push(t);return r}(i,e):[]}setClientRequestIdsForLocalDoc(e,t){const r=this.localDocumentToClientRequestIds.get(e)||new Set,n=new Set(t?this.findQueriesForDocument(t,e).map((e=>function(e){const t=e.split("_");return{clientId:t[0],clientRequestId:t[1]}}(e).clientRequestId)):[]),i=new Set([...r,...n]);for(const t of[...r]){if(n.has(t))continue;r.delete(t);const i=this.clientRequestIdToLocalDocuments.get(t);i&&(i.delete(e),i.size||this.clientRequestIdToLocalDocuments.delete(t)),r.size||this.localDocumentToClientRequestIds.delete(e)}for(const t of n){let r=this.localDocumentToClientRequestIds.get(e);r||(r=new Set,this.localDocumentToClientRequestIds.set(e,r)),r.add(t);let n=this.clientRequestIdToLocalDocuments.get(t);n||(n=new Set,this.clientRequestIdToLocalDocuments.set(t,n)),n.add(e)}return[...i]}errorOutAllQueries(e,t){const r=this.localDocumentToClientRequestIds.get(e)||new Set;for(const e of r){const r=this.ongoingQueries.get(e);r&&(this.destructManager.isDestructing?r.dataSubject.complete():r.dataSubject.error(t),r.done=!0)}}notifyAllSubscriptions(e){const t=new Set;for(const r of e){const e=this.ongoingQueries.get(r);if(!e)continue;if(!e.gotInitialResponse||!e.activated||e.isInFlight)continue;const n=this.clientRequestIdToLocalDocuments.get(r)||new Set,i=this.documentStore.sortAndLimitDocs(n,e.query),o=e.supportedQueries.map((e=>this.updateOngoingQueryWithNewDataFromSupportingQuery(i,e))).some(Boolean);let s=e;for(;!s.allObservables;)s=(0,x.truthy)(s?.supportingOngoingQuery);if(o&&t.add(s),e.query.limit>0)switch(e.limitUnderflowState){case sr.UNKNOWN:e.limitUnderflowState=n.size===e.query.limit+dr?sr.ENABLED:sr.DISABLED;break;case sr.DISABLED:break;case sr.ENABLED:if(n.size<e.query.limit+20){e.limitUnderflowState=sr.UNKNOWN,this.sendQueryToServerOrUseParentQuery(e);continue}}e.dataSubject.next(i)}for(const e of t){const t=this.collectAllObservables(e);(0,x.truthy)(e.allObservables).next(t)}}isValidParent(e){if(!e.activated||e.isInFlight||e.isEmptyForJoin||e.done||!e.subscribe||!e.gotInitialResponse||!e.dataSubject.value)return!1;const t=-1===e.query.limit?1e3:e.query.limit;return e.dataSubject.value.length<t}findValidParentOfOngoingQuery(e){if(e.forceFetchFromServer)return;const t=new rr(e.query);for(const r of this.ongoingQueries.values()){if(e===r)return;if(this.isValidParent(r)&&t.isSubqueryOfQuery(r.query))return r}}findValidParentOfQuery(e){const t=new rr(e);for(const e of this.ongoingQueries.values())if(this.isValidParent(e)&&t.isSubqueryOfQuery(e.query))return e}processQuery(e,t,r,n,i,s){return i&&this.socketManager.notifyWebSocketIsNeeded(),(0,o.defer)((()=>{const a=this.createOngoingQueryGraph(e,t,r,n,i,!0);s&&(a.forceFetchFromServer=!0),this.sendQueryToServerOrUseParentQuery(a),a.allObservables=new o.ReplaySubject(1);const u=a.allObservables.pipe((0,o.switchMap)((e=>(0,o.combineLatest)(e).pipe(j((e=>this.joinResults(e,n,a)))))),ir((()=>this.allOngoingQueriesGotInitialResult(a))),(0,o.startWith)(void 0),(0,o.pairwise)(),ir((([e,t])=>!ie(e,t))),j((([,e])=>e)),i?(0,o.tap)():(0,o.take)(1),(0,o.finalize)((()=>{a.dataSubject.complete(),a.done=!0,this.completeAllSupportedQueries(a).then(),a.allObservables?.complete()}))),c=this.collectAllObservables(a);return a.allObservables.next(c),u})).pipe((0,o.share)())}hasOngoingQueryForDocId(e){const t=this.localDocumentToClientRequestIds.get(e);return!!t&&!!t.size}removeClientRequestIdMapping(e){const t=this.clientRequestIdToLocalDocuments.get(e);if(!t)return;this.clientRequestIdToLocalDocuments.delete(e);const r=[];for(const n of t){const t=(0,x.truthy)(this.localDocumentToClientRequestIds.get(n));t.delete(e),t.size||(this.localDocumentToClientRequestIds.delete(n),r.push(n))}r.length&&this.onOrphanDocuments.next(r)}registerQueryFinalizer(e){const t=e.clientRequestId,r=ft(this.clientIdService.getClientId(),t);e.dataSubject.pipe((0,o.finalize)((async()=>{if(e.unsubscribeBlockerCount.value>0&&await(0,o.firstValueFrom)((0,o.race)(this.destructManager.observeIsDestructing(),e.unsubscribeBlockerCount.pipe(ir((e=>0===e))))),this.queryMappingManager.removeQuery(r).then(),this.ongoingQueries.delete(t),e.subscribe&&!e.isEmptyForJoin&&e.activated){const r={clientRequestId:t};this.rpcManager.post("query/unsubscribe",r).catch((t=>{this.destructManager.isDestructing||console.error("Got error while unsubscribing from query",e.query,t)}))}this.removeClientRequestIdMapping(t),this.ongoingQueries.delete(t)})),ir(Boolean)).subscribe({error:()=>{}})}createOngoingQueryGraph(e,t,r,n,i,s,a={}){if(a[t])return a[t];const u=this.clientIdService.generateClientRequestId(),c=[],l={clientRequestId:u,activated:s,alias:t,query:e,subscribe:i,dataSubject:new o.BehaviorSubject(null),supportedQueries:c,supportingOngoingQuery:void 0,joinCondition:void 0,gotInitialResponse:!1,isEmptyForJoin:!1,canExpandForJoin:!0,unsubscribeBlockerCount:new o.BehaviorSubject(0),queryRegistered:new o.BehaviorSubject(!1),done:!1,isInFlight:!1,forceFetchFromServer:!1,limitUnderflowState:i?sr.UNKNOWN:sr.DISABLED};this.registerQueryFinalizer(l),this.ongoingQueries.set(u,l),a[t]=l;for(const[e,o]of Object.entries(n)){const s=o.leftAlias;if(s!==t&&e!==t)continue;const u=s===t?e:s;if(s===t){const e=this.createOngoingQueryGraph(r[u],u,r,n,i,!1,a);e.joinCondition=o,c.push(e)}else l.supportingOngoingQuery=this.createOngoingQueryGraph(r[u],u,r,n,i,!1,a)}return l}collectAllObservables(e,t=[]){if(e.isEmptyForJoin)return t;const r=e.alias;t.push(e.dataSubject.pipe(ir(Boolean),j((e=>({docs:e,alias:r})))));for(const r of e.supportedQueries)this.collectAllObservables(r,t);return t}joinResults(e,t,r){const n=e.reduce(((e,t)=>(e[t.alias]?e[t.alias].push(...t.docs):e[t.alias]=[...t.docs],e)),{});let i=n[r.alias].map((e=>({[r.alias]:e})));const o=this.getOngoingQueriesBfs(r),s=new Set;for(let e=1;e<o.length;e++){const r=o[e].alias;s.has(r)||(s.add(r),i=this.join(i,r,n[r],t[r]))}return i}join(e,t,r,n){if(!e.length)return e;const i=Object.keys(e[0]);if(!n||!i.includes(n.leftAlias))throw new Error("No join condition found for alias "+t);const o=new Map;return(r||[]).forEach((e=>{const t=this.transformKey(e[n.right]);o.has(t)||o.set(t,[]),(0,x.truthy)(o.get(t)).push(e)})),e.flatMap((e=>{const r=o.get(this.transformKey(e[n.leftAlias]?.[n.left]))||[];return r.length?r.map((r=>({...e,[t]:r}))):n.isInner?[]:[{...e,[t]:void 0}]}))}getOngoingQueriesBfs(e){const t=[],r=[e];for(;r.length;){const e=(0,x.truthy)(r.shift());e.isEmptyForJoin||(t.push(e),r.push(...e.supportedQueries))}return t}updateOngoingQueryWithNewDataFromSupportingQuery(e,t){const r=(0,x.truthy)(t.joinCondition),n=t.query;if(t.activated){if(!t.canExpandForJoin)return!1;const i=(0,x.truthy)(t.supportingOngoingQuery?.supportedQueries).filter((e=>e.alias===t.alias)),s=new Set(e.map((e=>e[r.left]??null)));for(const e of i)e.query.conditions.filter(pt).filter((e=>e.fieldName===r.right)).forEach((e=>{s.delete(e.value)}));if(0===s.size)return!1;const a=se(n);a.conditions=a.conditions.filter((e=>!pt(e)||e.fieldName!==r.right)),[...s].forEach((e=>{a.conditions.push({fieldName:r.right,operator:"==",value:e})}));const u={...t,query:a,activated:!0,gotInitialResponse:!1,dataSubject:new o.BehaviorSubject(null),clientRequestId:this.clientIdService.generateClientRequestId(),isEmptyForJoin:!1};return this.registerQueryFinalizer(u),this.ongoingQueries.set(u.clientRequestId,u),(0,x.truthy)(t.supportingOngoingQuery).supportedQueries.push(u),this.sendQueryToServerOrUseParentQuery(u),!0}{if(t.activated=!0,n.conditions.filter(pt).filter((e=>e.fieldName===r.right&&"=="===e.operator)).map((e=>e.value)).length)return this.sendQueryToServerOrUseParentQuery(t),t.canExpandForJoin=!1,!0;const i=e.map((e=>e[r.left]??null)).map((e=>({fieldName:r.right,operator:"==",value:e})));return i.length?(n.conditions.push(...i),this.sendQueryToServerOrUseParentQuery(t)):t.isEmptyForJoin=!0,!0}}allOngoingQueriesGotInitialResult(e){return!!e.isEmptyForJoin||!!e.gotInitialResponse&&(!e.supportedQueries.length||e.supportedQueries.every((e=>this.allOngoingQueriesGotInitialResult(e))))}async completeAllSupportedQueries(e){const t=[...e.supportedQueries||[]];for(;t.length;){const e=(0,x.truthy)(t.shift());t.push(...e.supportedQueries||[]),await(0,o.firstValueFrom)(e.unsubscribeBlockerCount.pipe(ir((e=>0===e)))),e.dataSubject.complete()}}transformKey(e){return e instanceof Date?`DATE AS string KEY: ${e.toISOString()}`:e}preDestruct(){this.unsubscribe()}unsubscribe(){const e=[...this.ongoingQueries.values()];for(const t of e)t.dataSubject.complete(),t.allObservables?.complete()}hasSubscription(e){return!!this.ongoingQueries.get(e)?.subscribe}sendQueryToServerOrUseParentQuery(e,t=!1){if(this.destructManager.isDestructing)return;const r=e.query,n=e.clientRequestId,i=ft(this.clientIdService.getClientId(),n);this.queryMappingManager.addQuery(r,i),this.ongoingQueries.set(n,e);const o=t?void 0:this.findValidParentOfOngoingQuery(e);o?this.useParentOngoingQuery(e,o).then():this.sendQueryToServer(e)}async useParentOngoingQuery(e,t){const r={clientRequestId:e.clientRequestId,query:e.query,parentClientRequestId:t.clientRequestId},n=new rr(e.query);t.unsubscribeBlockerCount.next(t.unsubscribeBlockerCount.value+1);try{await(0,o.firstValueFrom)(t.queryRegistered.pipe(ir(Boolean)))}catch(t){return this.destructManager.isDestructing?(e.dataSubject.complete(),e.queryRegistered.complete()):(e.dataSubject.error(t),e.queryRegistered.error(t)),void(e.done=!0)}if(this.destructManager.isDestructing)return;if(e.done)return;this.rpcManager.post("query/register",r).then((()=>{e.isInFlight=!1,e.queryRegistered.next(!0)})).catch((r=>{e.isInFlight=!1,this.destructManager.isDestructing?e.dataSubject.complete():(console.error("Query error",e.query,t.query,r),e.dataSubject.error(r)),e.done=!0})).finally((()=>{t.unsubscribeBlockerCount.next(t.unsubscribeBlockerCount.value-1)}));const i=(0,o.race)(e.queryRegistered.pipe(ir(Boolean),(0,o.delay)(2e3),(0,o.take)(1)),this.destructManager.observeIsDestructing().pipe((0,o.take)(1)));t.dataSubject.pipe((0,o.takeWhile)((()=>!e.done)),(0,o.takeUntil)(i),ir(Boolean),(0,o.tap)((()=>{e.gotInitialResponse||this.setGotInitialResult(e.clientRequestId)})),j((e=>e.filter((e=>n.documentMatchesQuery(e)))))).subscribe({next:t=>{for(const r of t)this.setClientRequestIdsForLocalDoc(ut(r.__docId__,e.query.collectionName,e.query.integrationId),r);this.notifyAllSubscriptions([e.clientRequestId])},error:t=>{this.destructManager.isDestructing?e.dataSubject.complete():e.dataSubject.error(t)}})}sendQueryToServer(e){const t=e.query.limit,r=t>0&&e.subscribe?t+dr:t,n={query:{...e.query,limit:r},clientRequestId:e.clientRequestId,subscribe:e.subscribe};e.isInFlight=!0,this.querySender.sendQuery(n).then((t=>{e.isInFlight=!1,e.queryRegistered.next(!0),this.queryResultsSubject.next(t)})).catch((t=>{e.isInFlight=!1,this.destructManager.isDestructing?(e.dataSubject.complete(),e.queryRegistered.complete()):(ve.debug("Query error",e.query,t),e.dataSubject.error(t),e.queryRegistered.error("query failed")),e.done=!0}))}refreshOngoingQueries(){for(const e of this.ongoingQueries.values())this.sendQueryToServerOrUseParentQuery(e,!0)}migrateDocIds(e){const t=Object.keys(e);for(const r of this.clientRequestIdToLocalDocuments.values())t.forEach((t=>{r.has(t)&&(r.delete(t),r.add(e[t]))}));t.forEach((t=>{re(this.localDocumentToClientRequestIds,t,e[t])}))}}function fr(e,t){for(const r of e.fields){const e=Z(t,r.fieldName)??null;if(dt(r.value,e,r.operator))return!0;if(dt(r.value,e,"!="))return!1}return!1}class pr{constructor(){this.stateService=new ar.TrieStore({}),this.querySubscriptionIdToQuery={}}addQuery(e,t){this.stateService.runInBatch((()=>{let r=0;const n=new Set;for(const i of e.conditions){if(pt(i)&&["=="].includes(i.operator)){const e=pe(i.fieldName);n.has(e)||(r++,n.add(e))}else r++;const o=this.getConditionStatePath(e,i),s=[...this.stateService.get(o)||[]];cr(s,t),this.stateService.set(o,s)}if(!e.conditions.length){const r=["queryMapping",e.collectionName,e.integrationId,"mapping","unconditional"],n=[...this.stateService.get(r)||[]];cr(n,t),this.stateService.set(r,n)}this.stateService.set([...this.getQueryMetadataStatePath(e,t),"condCount"],r)})),this.querySubscriptionIdToQuery[t]=e}async removeQuery(e){const t=this.querySubscriptionIdToQuery[e];if(t)return this.stateService.runInBatch((()=>{for(const r of t.conditions){const n=this.getConditionStatePath(t,r),i=[...this.stateService.get(n)||[]];lr(i,e),i.length?this.stateService.set(n,i):this.stateService.delete(n)}if(!t.conditions.length){const r=["queryMapping",t.collectionName,t.integrationId,"mapping","unconditional"],n=[...this.stateService.get(r)||[]];lr(n,e),this.stateService.set(r,n)}this.stateService.delete(this.getQueryMetadataStatePath(t,e))})),t}getMapping(e,t){return this.stateService.get(["queryMapping",e,t,"mapping"])}getQueryMetadataStatePath(e,t){return["queryMapping",e.collectionName,e.integrationId,"mapping","queriesMetadata",`${t}`]}getConditionStatePath(e,t){return["queryMapping",e.collectionName,e.integrationId,"mapping","conditional",(r=t,de(r))];var r}}class yr{constructor(){this.locks={}}async lock(...e){if(this.canGetLock(...e))return void this.lockSync(...e);const t=Object.entries(this.locks).filter((([t])=>e.includes(t))).map((([,e])=>e));await(0,o.lastValueFrom)((0,o.combineLatest)(t).pipe((0,o.filter)((e=>!e.includes(!0))),(0,o.take)(1))),await this.lock(...e)}release(...e){for(const t of e){const e=(0,x.truthy)(this.locks[t]);e.next(!1),e.complete(),delete this.locks[t]}}canGetLock(...e){return!e.some((e=>this.locks[e]?.value))}lockSync(...e){(0,x.assertTruthy)(this.canGetLock(...e),"Cannot acquire lock sync");for(const t of e)this.locks[t]=new o.BehaviorSubject(!0)}}class br{constructor(e,t,r){this.rpcManager=e,this.socketManager=t,this.queueManagers=new Map,this.socketManager.observeNotifications().subscribe((e=>{const t=this.getOrUndefined(e.integrationId,e.topicName);t&&t.onMessages(e.payload)})),r.onPreDestruct((()=>{for(const e of this.queueManagers.values())for(const t of e.values())t.destruct()}))}get(e,t){let r=this.queueManagers.get(e);r||(r=new Map,this.queueManagers.set(e,r));let n=r.get(t);return n||(n=new gr(e,t,this.rpcManager,this.socketManager),r.set(t,n)),n}getOrUndefined(e,t){return this.queueManagers.get(e)?.get(t)}}const vr="subscriptionMutex";class gr{constructor(e,t,r,n){this.integrationId=e,this.topicName=t,this.rpcManager=r,this.socketManager=n,this.messagesSubject=new o.Subject,this.subscriberCount=0,this.lockManager=new yr}async produce(e){await this.lockManager.lock(vr);try{await this.rpcManager.post("queue/produceMessages",{integrationId:this.integrationId,topicName:this.topicName,messages:e})}finally{this.lockManager.release(vr)}}consume(){return this.socketManager.notifyWebSocketIsNeeded(),(0,o.defer)((()=>(this.subscriberCount++,1===this.subscriberCount&&this.performSubscribe(),this.messagesSubject.asObservable().pipe((0,o.finalize)((()=>{this.subscriberCount--,0===this.subscriberCount&&this.performUnsubscribe()}))))))}async performSubscribe(){await this.lockManager.lock(vr);try{await this.rpcManager.post("queue/subscribe",{integrationId:this.integrationId,topicName:this.topicName})}catch(e){this.messagesSubject.error(e),this.messagesSubject.complete(),this.subscriberCount=0,this.messagesSubject=new o.Subject}finally{this.lockManager.release(vr)}}async performUnsubscribe(){await this.lockManager.lock(vr);try{await this.rpcManager.post("queue/unsubscribe",{integrationId:this.integrationId,topicName:this.topicName})}finally{this.lockManager.release(vr)}}onMessages(e){for(const t of e)this.messagesSubject.next(t)}destruct(){this.messagesSubject.complete()}}class mr{constructor(e,t){this.capacity=e,this.seconds=t,this.tokens=e,this.refillRatePerMs=e/(1e3*t),this.lastRefillTimestamp=Date.now()}async consume(){this.attemptConsume()||await(0,o.firstValueFrom)((0,o.interval)(10).pipe((0,o.filter)((()=>this.attemptConsume())),(0,o.first)()))}attemptConsume(){return this.refill(),this.tokens>=1&&(this.tokens-=1,!0)}refill(){const e=Date.now(),t=(e-this.lastRefillTimestamp)*this.refillRatePerMs;this.tokens=Math.min(this.tokens+t,this.capacity),this.lastRefillTimestamp=e}}const _r=["aiData","api","application","application-kotlin","auth","backend-function","connector","extraction","integration","internal-storage","internalCodeExecutor","mutation","named-query","native-query","observability","openapi","query","queue","quota","scheduler","secret","storage","webhooks","ws","personalStorage"];function Sr(e,t,r){const n=new URL("https://squid.cloud");n.host=`${t}.${e}.${n.host}`;const i=r.replace(/^\//g,"").split("/")[0]||"";(function(e){return/^local/.test(e)})(e)&&(n.protocol="http",n.port=_r.includes(i)?"8001":"8000",function(e){return/android$/.test(e)}(e)?n.host="10.0.2.2":function(e){return/ios$/.test(e)}(e)&&(n.host="localhost"));const o=n.toString();r=r.startsWith("/")?r.slice(1):r;const s=o.replace(/\/$/g,"");return r.length?`${s}/${r}`:s}const Or="1.0.340";class wr extends Error{constructor(e,t,r,n,i,o){super(o||`RPC error ${e} ${t} calling ${r}`),this.statusCode=e,this.statusText=t,this.url=r,this.headers=n,this.body=i}}async function Ir(e){const t=await Ar({url:e.url,headers:e.headers,method:"POST",message:e.message,files:e.files,filesFieldName:e.filesFieldName,extractErrorMessage:e.extractErrorMessage});return t.body=jr(t.body),t}async function Mr(e){const t=await Ar({...e,method:"GET",files:[],filesFieldName:""});return t.body=jr(t.body),t}async function Er(e){const t=await Ar({...e,method:"PUT"});return t.body=jr(t.body),t}async function Fr(e){const t=await Ar({...e,method:"PATCH"});return t.body=jr(t.body),t}async function Tr(e){const t=await Ar({...e,method:"DELETE",files:[],filesFieldName:""});return t.body=jr(t.body),t}async function Ar({headers:e,files:t,filesFieldName:r,message:n,url:i,extractErrorMessage:o,method:s}){const a=new Headers(e);a.append("x-squid-client-version",Or);const u={method:s,headers:a,body:void 0};if("GET"!==s&&"DELETE"!==s)if(t&&t.length){const e=new FormData;for(const n of t)e.append(r||"files",n,n.name);e.append("body",he(n)),u.body=e}else void 0!==n&&(a.append("Content-Type","application/json"),u.body=he(n));else"DELETE"===s&&void 0!==n&&(a.append("Content-Type","application/json"),u.body=he(n));try{const e=await fetch(i,u),t={};if(e.headers.forEach(((e,r)=>{t[r]=e})),!e.ok){const r=await e.text(),n=jr(r);if(!o)throw new wr(e.status,e.statusText,i,t,n,r);let s;try{s="string"==typeof n?n:n?.message||r}catch{}throw s||(s=e.statusText),new wr(e.status,e.statusText,i,t,n,s)}const r=await e.text();return ve.debug(`received response from url ${i}: ${JSON.stringify(r)}`),{body:r,headers:t,status:e.status,statusText:e.statusText}}catch(e){throw ve.debug(`Unable to perform fetch request to url: ${i}`,e),e}}function jr(e){if(e){try{return fe(e)}catch{}return e}}class Pr{constructor(e,t,r,n,i,s){this.region=e,this.appId=t,this.authManager=i,this.clientIdService=s,this.staticHeaders={},this.onGoingRpcCounter=new o.BehaviorSubject(0);for(const[e,t]of Object.entries(n))this.setStaticHeader(e,t);this.clientIdService.observeClientId().subscribe((e=>{e?this.setStaticHeader("x-squid-clientid",e):this.deleteStaticHeader("x-squid-clientid")})),r.onDestruct((async()=>{await this.awaitAllSettled()}));const a=this.authManager.getApiKey()?5:1;this.rateLimiters={default:new mr(60*a,5),ai:new mr(20*a,5),secret:new mr(20*a,5)}}async getAuthHeaders(){const e=this.authManager.getApiKey();if(e)return{Authorization:`ApiKey ${e}`};const{token:t,integrationId:r}=await this.authManager.getAuthData();if(!t)return{};let n=`Bearer ${t}`;return r&&(n+=`; IntegrationId ${r}`),{Authorization:n}}async awaitAllSettled(){await(0,o.firstValueFrom)(this.onGoingRpcCounter.pipe((0,o.filter)((e=>0===e))))}setStaticHeader(e,t){this.staticHeaders[e]=t}deleteStaticHeader(e){delete this.staticHeaders[e]}getStaticHeaders(){return this.staticHeaders}async post(e,t,r=[],n="files"){return(await this.rawPost(e,t,r,n)).body}async rawPost(e,t,r=[],n="files",i=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const o=await this.getAuthHeaders(),s={...this.staticHeaders,...o};ve.debug(`sending POST request: path: ${e} message: ${JSON.stringify(t)}`);const a=e.startsWith("http://")||e.startsWith("https://")?e:Sr(this.region,this.appId,e);return await Ir({url:a,headers:s,message:t,files:r,filesFieldName:n,extractErrorMessage:i})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}async get(e,t,r=!0){return(await this.rawGet(e,t,r)).body}async rawGet(e,t,r=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const n=await this.getAuthHeaders(),i={...this.staticHeaders,...n};let o=e.startsWith("http://")||e.startsWith("https://")?e:Sr(this.region,this.appId,e);if(t&&Object.keys(t).length>0){const e=new URLSearchParams;Object.entries(t).forEach((([t,r])=>{e.append(t,String(r))})),o+=`?${e.toString()}`}return ve.debug(`sending GET request: path: ${e}, queryParams: ${JSON.stringify(t)}`),await Mr({url:o,headers:i,extractErrorMessage:r})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}async put(e,t,r=[],n="files"){return(await this.rawPut(e,t,r,n)).body}async rawPut(e,t,r=[],n="files",i=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const o=await this.getAuthHeaders(),s={...this.staticHeaders,...o};ve.debug(`sending PUT request: path: ${e} message: ${JSON.stringify(t)}`);const a=e.startsWith("http://")||e.startsWith("https://")?e:Sr(this.region,this.appId,e);return await Er({url:a,headers:s,message:t,files:r,filesFieldName:n,extractErrorMessage:i})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}async patch(e,t,r=[],n="files"){return(await this.rawPatch(e,t,r,n)).body}async rawPatch(e,t,r=[],n="files",i=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const o=await this.getAuthHeaders(),s={...this.staticHeaders,...o};ve.debug(`sending PATCH request: path: ${e} message: ${JSON.stringify(t)}`);const a=e.startsWith("http://")||e.startsWith("https://")?e:Sr(this.region,this.appId,e);return await Fr({url:a,headers:s,message:t,files:r,filesFieldName:n,extractErrorMessage:i})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}async delete(e,t,r=!0){return(await this.rawDelete(e,t,r)).body}async rawDelete(e,t,r=!0){this.onGoingRpcCounter.next(this.onGoingRpcCounter.value+1);try{await this.getRateLimiterBucket(e).consume();const n=await this.getAuthHeaders(),i={...this.staticHeaders,...n};ve.debug(`sending DELETE request: path: ${e}, body: ${JSON.stringify(t)}`);const o=e.startsWith("http://")||e.startsWith("https://")?e:Sr(this.region,this.appId,e);return await Tr({url:o,headers:i,message:t,extractErrorMessage:r})}finally{this.onGoingRpcCounter.next(this.onGoingRpcCounter.value-1)}}getRateLimiterBucket(e){return e.startsWith("ai/chatbot")?(0,x.truthy)(this.rateLimiters.ai,"MISSING_RATE_LIMITER_AI"):e.startsWith("secret/")?(0,x.truthy)(this.rateLimiters.secret,"MISSING_RATE_LIMITER_SECRETS"):(0,x.truthy)(this.rateLimiters.default,"MISSING_RATE_LIMITER_DEFAULT")}}const kr={groupByTags:[],orderByTags:[],pointIntervalAlignment:"align-by-start-time",tagFilter:{},tagDomains:{},noDataBehavior:"return-no-result-groups",fillValue:null,pointIntervalSeconds:0};class Cr{constructor(e){this.rpcManager=e,this.pendingPromises=[],this.isReporting=!1}reportMetric(e){const t=e.tags||{},r=Object.keys(t).filter((e=>!xr.test(e)||e.length>=Dr));(0,x.assertTruthy)(0===r.length,(()=>`Tag name is not allowed: ${r.join(",")}`)),this.isReporting=!0;const n={...e,tags:t,timestamp:void 0===e.timestamp?Date.now():e.timestamp},i=this.rpcManager.post("/observability/metrics",{metrics:[n]}).finally((()=>{this.pendingPromises=this.pendingPromises.filter((e=>e!==i)),this.isReporting=this.pendingPromises.length>0}));this.pendingPromises.push(i)}async flush(){this.isReporting&&await Promise.all(this.pendingPromises)}async queryMetrics(e){const t={...kr,...e,fn:Array.isArray(e.fn)?e.fn:[e.fn]};t.pointIntervalSeconds||(t.pointIntervalSeconds=t.periodEndSeconds-t.periodStartSeconds);const r=await this.rpcManager.post("/observability/metrics/query",t);return function(e,t){const{pointIntervalSeconds:r,noDataBehavior:n}=e,i=void 0===e.fillValue?null:e.fillValue,o=function({periodStartSeconds:e,periodEndSeconds:t,pointIntervalSeconds:r,pointIntervalAlignment:n}){if("align-by-start-time"===n)return e;const i=t-e;let o=t-Math.floor(i/r)*r;return o>e&&(o-=r),o}(e),s=function({periodStartSeconds:e,periodEndSeconds:t,pointIntervalSeconds:r,pointIntervalAlignment:n}){if("align-by-end-time"===n)return t-r;const i=t-e;let o=e+Math.floor(i/r)*r;return o>=t&&(o-=r),o}(e),a=e.tagDomains||{},u=Object.entries(a);if(0===t.length)if(u.length>0){const r=[];for(let t=0;t<e.groupByTags.length;t++){const n=e.groupByTags[t],i=a[n]?.[0]||"";r.push(i)}t.push({tagValues:r,points:[]})}else"return-result-group-with-default-values"===n&&t.push({tagValues:e.groupByTags.map((()=>"")),points:[]});for(const[r,n]of Object.entries(a)){const i=e.groupByTags.indexOf(r);if(!(i<0))for(let e=0;e<t.length;e++){const r=t[e],o=new Set(n);for(let e=0;e<t.length;e++){const n=t[e];r.tagValues.every(((e,t)=>t===i||e===n.tagValues[t]))&&o.delete(n.tagValues[i])}if(0!==o.size)for(const e of o){const n={tagValues:[...r.tagValues],points:[]};n.tagValues[i]=e,t.push(n)}}}for(const n of t){if(0!==n.points.length){const e=n.points[0][0],t=n.points[n.points.length-1][0];(0,x.assertTruthy)(e>=o,(()=>`Invalid first point time: ${e}`)),(0,x.assertTruthy)(t<=s,(()=>`Invalid last point time: ${t}`))}const t=[];let a=0;const u=e=>"count"===e?0:i,c=Array.isArray(e.fn)?e.fn.map(u):[i];for(let e=o;e<=s;e+=r){const r=n.points[a];r?r[0]===e?(t.push(r),a++):((0,x.assertTruthy)(r[0]>e,(()=>`Result point has invalid time: ${r[0]}`)),t.push([e,...c])):t.push([e,...c])}n.points=t}}(t,r.resultGroups),r}}const xr=/^[a-zA-Z0-9_-]+$/,Dr=1e3;class Nr{constructor(e){this.rpcManager=e}async get(e){const t={key:e};return await this.rpcManager.post("secret/get",t)||void 0}getAll(){return this.rpcManager.post("secret/getAll",{})}async upsert(e,t){return this.upsertMany([{key:e,value:t}]).then((e=>e[0]))}async upsertMany(e){if(0===e.length)return[];const t={entries:e};return this.rpcManager.post("secret/upsert",t)}delete(e,t=!1){const r={keys:[e],force:t};return this.rpcManager.post("secret/delete",r)}async deleteMany(e,t=!1){if(0===e.length)return;const r={keys:e,force:t};return this.rpcManager.post("secret/delete",r)}get apiKeys(){return new Rr(this.rpcManager)}}class Rr{constructor(e){this.rpcManager=e}get(e){const t={key:e};return this.rpcManager.post("secret/api-key/get",t)}getAll(){return this.rpcManager.post("secret/api-key/getAll",{})}upsert(e){const t={key:e};return this.rpcManager.post("secret/api-key/upsert",t)}delete(e){const t={key:e};return this.rpcManager.post("secret/api-key/delete",t)}}class qr{constructor(e){this.rpcManager=e}async list(){return(await this.rpcManager.post("/scheduler/listSchedulers",{})).schedulers}async enable(e){await this.update(this.createUpdateSchedulerOptions(e,!0))}async disable(e){await this.update(this.createUpdateSchedulerOptions(e,!1))}async update(e){const t={schedulers:e};await this.rpcManager.post("scheduler/updateSchedulers",t)}createUpdateSchedulerOptions(e,t){return Array.isArray(e)?e.map((e=>({schedulerId:e,enabled:t}))):[{schedulerId:e,enabled:t}]}}function Lr(e,t=""){return e.includes("sandbox")?Sr("us-east-1.aws.sandbox","console",t):Sr("local"===e?"local":"us-east-1.aws","console",t)}class Br{constructor(e,t,r){this.rpcManager=e,this.iacBaseUrl=Lr(t,`openapi/iac/applications/${r}/integrations`)}async list(e){const t=await this.rpcManager.get(this.iacBaseUrl);return e?t.filter((t=>t.type===e)):t}async get(e){return await this.rpcManager.get(`${this.iacBaseUrl}/${e}`)}async delete(e){await this.rpcManager.delete(`${this.iacBaseUrl}/${e}`)}async deleteMany(e){await Promise.all(e.map((e=>this.delete(e))))}async upsertIntegration(e){await this.rpcManager.put(`${this.iacBaseUrl}/${e.id}`,e)}}const Ur=e=>e();function Qr(){}const $r="undefined"!=typeof process&&process.versions?.node?r(5086):be().WebSocket;class Wr{constructor(e,t,r,n=Ur,i,s){this.clientIdService=e,this.region=t,this.appId=r,this.messageNotificationWrapper=n,this.destructManager=i,this.authManager=s,this.webSocketObserver=new o.Subject,this.allMessagesObserver=new o.Subject,this.connectionReady=new o.BehaviorSubject(!1),this.seenMessageIds=new Set,this.destructSubject=new o.Subject,this.connectedAtLeastOnce=!1,this.webSocketNeededSubject=new o.BehaviorSubject(!1),this.clientTooOldThreshold=3e4,this.destructManager.onDestruct((()=>this.destruct())),this.setupMessageAcknowledgments(),this.webSocketNeededSubject.pipe((0,o.filter)(Boolean),(0,o.take)(1)).subscribe((()=>{this.connect(),this.lastTick=new Date,this.tickInterval=setInterval((()=>this.keepAlive()),5e3)})),this.observeConnectionReady().pipe((0,o.skip)(1),(0,o.filter)((e=>!e)),(0,o.switchMap)((()=>(0,o.race)((0,o.timer)(this.clientTooOldThreshold),this.connectionReady.pipe((0,o.filter)(Boolean)),this.destructManager.observeIsDestructing())))).subscribe((()=>{this.connectionReady.value?ve.debug(this.clientIdService.getClientId(),"Client reconnected before becoming too old. Ignoring..."):this.destructManager.isDestructing||(ve.debug(this.clientIdService.getClientId(),"Client disconnected for a long period - refreshing"),this.refreshClient())})),this.observeConnectionReady().pipe((0,o.filter)(Boolean)).subscribe((()=>{this.clientIdService.isClientTooOld()&&this.clientIdService.notifyClientNotTooOld()})),this.observeNotifications().pipe((0,o.filter)((e=>"clientInfo"===e.type))).subscribe((e=>{console.log("Client info message received",e)}))}refreshClient(){this.destructManager.isDestructing?ve.debug(this.clientIdService.getClientId(),"Client too old but is destructed. Ignoring..."):this.clientIdService.isClientTooOld()?ve.debug(this.clientIdService.getClientId(),"Client is already marked as too old. Ignoring..."):(ve.debug(this.clientIdService.getClientId(),"Notifying client too old"),this.clientIdService.notifyClientTooOld(),ve.debug(this.clientIdService.getClientId(),"Client too old. Reconnecting..."),this.connect())}getClientInfo(){this.sendMessage({type:"getClientInfo"})}keepAlive(){this.lastTick&&(Math.abs(Date.now()-this.lastTick.getTime())>this.clientTooOldThreshold&&(ve.debug(this.clientIdService.getClientId(),"Tick: Client not responding for a long time. Refreshing..."),this.refreshClient()),this.lastTick=new Date)}observeNotifications(){return this.webSocketObserver.asObservable()}observeConnectionReady(){return this.connectionReady.asObservable().pipe((0,o.distinctUntilChanged)())}notifyWebSocketIsNeeded(){this.webSocketNeededSubject.next(!0)}sendMessage(e){this.sendMessageAsync(e).then()}async sendMessageAsync(e){this.webSocketNeededSubject.next(!0),await(0,o.firstValueFrom)(this.connectionReady.pipe((0,o.filter)(Boolean)));const t=await this.authManager.getToken();if(this.connectionReady.value)try{(0,x.assertTruthy)(this.socket,"Socket is undefined in sendMessageAsync");const r=he({message:e,authToken:t});ve.debug(this.clientIdService.getClientId(),"Sending message to socket: ",r),this.socket.send(r)}catch(t){this.socket?.connected?console.error("Websocket message is ignored due to a non-recoverable error",t):(this.connectionReady.next(!1),await this.sendMessageAsync(e))}else await this.sendMessageAsync(e)}sendKillMessage(){this.socket?.connected&&this.socket.send(he({message:{type:"kill"}}))}closeCurrentSocketSilently(){if(this.socket)try{this.socket.close()}catch(e){}}connect(){this.closeCurrentSocketSilently(),this.connectionReady.value&&this.connectionReady.next(!1);const e=Sr(this.region,this.appId,"ws/general").replace("https","wss").replace("http","ws"),t=this.clientIdService.getClientId();ve.debug(this.clientIdService.getClientId(),"Connecting to socket at:",e);const r=`${e}?clientId=${t}`;this.socket=function(e,t={}){let r,n=0,i=1;const o={connected:!1,closeCalled:!1,open(){r=new($r?.WebSocket??$r)(e,t.protocols||[]),r.onmessage=t.onmessage?e=>{e.data&&t.onmessage?t.onmessage(e):console.log("No data received from websockets, please contact support@getsquid.ai with this message.")}:Qr,r.onopen=function(e){o.connected=!0,(t.onopen||Qr)(e),n=0},r.onclose=function(e){if(o.connected=!1,4999!==e.code&&4001!==e.code)return ve.debug("WebSocket closed. Reconnecting. Close code: ",e.code),(t.onclose||Qr)(e),void o.reconnect(e);(t.onclose||Qr)(e)},r.onerror=function(e){o.connected=!1,e&&"ECONNREFUSED"===e.code?o.reconnect(e):o.closeCalled||(t.onerror||Qr)(e)}},reconnect(e){const r=void 0!==t.maxAttempts?t.maxAttempts:1/0;i&&n++<r?i=setTimeout((function(){(t.onreconnect||Qr)(e),ve.debug("WebSocket trying to reconnect..."),o.open()}),t.timeoutMillis||1e3):(t.onmaximum||Qr)(e)},json(e){r.send(JSON.stringify(e))},send(e){r.send(e)},close(e=4999,t){o.closeCalled=!0;try{o.connected=!1,clearTimeout(i),i=void 0,r.close(e,t)}catch(e){}}};return o.open(),o}(r,{timeoutMillis:1e4,onmessage:e=>this.onMessage(e.data),onopen:()=>{ve.debug(this.clientIdService.getClientId(),`Connection to socket established. Endpoint: ${e}`)},onreconnect:()=>{ve.debug(t,"WebSocket reconnect event triggered"),this.clientIdService.getClientId()===t?this.connectionReady.value&&this.connectionReady.next(!1):ve.debug(t,`WebSocket reconnect event triggered - ignored because the client id changed. Old: ${this.clientIdService.getClientId()}`)},onclose:()=>{ve.debug(t,"WebSocket onclose event triggered"),this.clientIdService.getClientId()===t?this.connectionReady.value&&this.connectionReady.next(!1):ve.debug(t,`WebSocket onclose event triggered - ignored because the client id changed. new: ${this.clientIdService.getClientId()}`)},onerror:e=>console.error("WebSocket error:",e)})}disconnectForTest(){this.connectionReady.next(!1),this.socket?.close(4998)}onConnectionReady(){this.connectionReady.next(!0),this.connectedAtLeastOnce?this.sendMessage({type:"catchup"}):this.connectedAtLeastOnce=!0}onMessage(e){if("connectionReady"===e)return ve.debug(this.clientIdService.getClientId(),"Got socket message: connectionReady"),void this.onConnectionReady();const t=fe(e);for(const e of t)this.allMessagesObserver.next(e),this.seenMessageIds.has(e.messageId)||(this.seenMessageIds.add(e.messageId),ve.debug(this.clientIdService.getClientId(),new Date,"Got socket message",JSON.stringify(e,null,2)),this.messageNotificationWrapper((()=>{this.webSocketObserver.next(e)})))}setupMessageAcknowledgments(){const e=new o.Subject;this.allMessagesObserver.subscribe((t=>{t?.messageId&&e.next(t.messageId)}));const t=[];e.pipe((0,o.tap)((e=>t.push(e))),(0,o.debounceTime)(100)).subscribe((async()=>{const e=[...t.splice(0)];this.sendMessage({type:"acknowledge",payload:e})}))}async destruct(){this.sendKillMessage(),await(0,o.firstValueFrom)((0,o.timer)(0)),this.connectionReady.next(!1),await(0,o.firstValueFrom)((0,o.timer)(0)),clearInterval(this.tickInterval),this.closeCurrentSocketSilently(),this.webSocketObserver.complete(),this.allMessagesObserver.complete(),this.destructSubject.next()}}function Vr(e){(0,x.assertString)(e,"Invalid application ID");const[t,r,n,i]=e.split("-");return(0,x.assertTruthy)(!i,`Invalid application ID: ${e}`),{appId:t,environmentId:r??"prod",squidDeveloperId:n}}function zr(e,t){return`${Vr(e).appId}${t&&"prod"!==t?`-${t}`:""}`}function Gr(e,t,r){return`${zr(e,t)}${r?`-${r}`:""}`}class Hr{constructor(e="built_in_storage",t){this.integrationId=e,this.rpcManager=t}async uploadFile(e,t,r){const n={integrationId:this.integrationId,dirPathInBucket:e,expirationInSeconds:r};await this.rpcManager.post("storage/uploadFile",n,[t])}async getFileMetadata(e){const t={integrationId:this.integrationId,filePathInBucket:e};return await this.rpcManager.post("storage/getFileMetadata",t)}async getDownloadUrl(e,t){const r={integrationId:this.integrationId,filePathInBucket:e,urlExpirationInSeconds:t};return await this.rpcManager.post("storage/getDownloadUrl",r)}async listDirectoryContents(e){const t={integrationId:this.integrationId,dirPathInBucket:e};return await this.rpcManager.post("storage/listDirectoryContents",t)}async deleteFile(e){await this.deleteFiles([e])}async deleteFiles(e){const t={integrationId:this.integrationId,filePathsInBucket:e};await this.rpcManager.post("storage/deleteFiles",t)}}class Yr{constructor(e){this.rpcManager=e}async extractDataFromDocumentFile(e,t){return t||(t={}),await this.rpcManager.post("documentExtraction/extractDataFromDocumentFile",t,[e])}}class Jr{constructor(e,t){this.integrationId=e,this.rpcManager=t}async saveAuthCode(e,t){const r={authCode:e,personalStorageConfig:{identifier:t,integrationId:this.integrationId}};return await this.rpcManager.post("personalStorage/saveAuthCode",r)}async getAccessToken(e){const t={personalStorageConfig:{identifier:e,integrationId:this.integrationId}};return await this.rpcManager.post("personalStorage/getAccessToken",t)}async extractDataFromDocument(e,t){const r={documentId:e,personalStorageConfig:{identifier:t,integrationId:this.integrationId}};return await this.rpcManager.post("personalStorage/extractDataFromDocument",r)}async indexDocumentOrFolder(e,t,r,n){const i={documentOrFolderId:e,metadata:n,personalStorageConfig:{identifier:t,integrationId:this.integrationId},agentId:r};await this.rpcManager.post("personalStorage/indexDocumentOrFolder",i)}async listIndexedDocuments(e,t,r){const n={personalStorageConfig:{identifier:e,integrationId:this.integrationId},agentId:t,type:r};return(await this.rpcManager.post("personalStorage/listIndexedDocuments",n)).documents}async unindexDocument(e,t,r){const n={documentId:e,personalStorageConfig:{identifier:t,integrationId:this.integrationId},agentId:r};await this.rpcManager.post("personalStorage/unindexDocument",n)}}class Kr{constructor(e,t,r){this.rpcManager=e,this.region=t,this.appId=r,this.integrationClient=new Br(this.rpcManager,this.region,this.appId),this.secretClient=new Nr(this.rpcManager)}integrations(){return this.integrationClient}secrets(){return this.secretClient}}class Zr{constructor(e){this.rpcManager=e}async createMatchMaker(e){const t=await this.rpcManager.post("matchMaking/createMatchMaker",{matchMaker:e});return new Xr(t,this.rpcManager)}async getMatchMaker(e){const t=(await this.rpcManager.post("matchMaking/getMatchMaker",{matchMakerId:e})).matchMaker;if(t)return new Xr(t,this.rpcManager)}async listMatchMakers(){return await this.rpcManager.post("matchMaking/listMatchMakers",{})}}class Xr{constructor(e,t){this.matchMaker=e,this.rpcManager=t,this.id=e.id}async insertEntity(e){await this.rpcManager.post("matchMaking/insertEntity",{matchMakerId:this.id,entity:e})}async insertManyEntities(e){await this.rpcManager.post("matchMaking/insertEntities",{matchMakerId:this.id,entities:e})}async delete(){await this.rpcManager.post("matchMaking/deleteMatchMaker",{matchMakerId:this.id})}async deleteEntity(e){await this.rpcManager.post("matchMaking/deleteEntity",{entityId:e,matchMakerId:this.id})}async findMatches(e,t={}){return(await this.rpcManager.post("matchMaking/findMatches",{matchMakerId:this.id,entityId:e,options:t})).matches}async findMatchesForEntity(e,t={}){return(await this.rpcManager.post("matchMaking/findMatchesForEntity",{matchMakerId:this.id,entity:e,options:t})).matches}async listEntities(e,t={}){return await this.rpcManager.post("matchMaking/listEntities",{categoryId:e,options:t,matchMakerId:this.id})}async getEntity(e){return(await this.rpcManager.post("matchMaking/getEntity",{matchMakerId:this.id,entityId:e})).entity}getMatchMakerDetails(){return this.matchMaker}}class en{constructor(e,t){this.socketManager=e,this.rpcManager=t,this.aiAssistantClient=new i(this.rpcManager)}agent(e=C){return this.aiAgentClient||(this.aiAgentClient=new V(this.rpcManager,this.socketManager)),this.aiAgentClient.agent(e)}async listAgents(){return this.aiAgentClient||(this.aiAgentClient=new V(this.rpcManager,this.socketManager)),this.aiAgentClient.listAgents()}assistant(){return this.aiAssistantClient}image(){return new z(this.rpcManager)}audio(){return new G(this.rpcManager)}matchMaking(){return new Zr(this.rpcManager)}executeAiQuery(e,t,r){const n={integrationId:e,prompt:t,options:r};return this.rpcManager.post("aiData/executeAiQuery",n)}executeAiQueryMulti(e,t,r){const n={integrationIds:e,prompt:t,options:r};return this.rpcManager.post("aiData/executeAiQueryMulti",n)}executeAiApiCall(e,t,r,n){const i={integrationId:e,prompt:t,allowedEndpoints:r,provideExplanation:n};return this.rpcManager.post("aiData/executeAiApiCall",i)}}class tn{static{this.squidInstancesMap={}}constructor(e){this.options=e,this.destructManager=new Rt,(0,x.assertTruthy)(e.appId,"APP_ID_MUST_BE_PROVIDED");for(const e of Object.getOwnPropertyNames(Object.getPrototypeOf(this))){const t=this[e];"function"!=typeof t||"constructor"===e||e.startsWith("_")||(this[e]=t.bind(this))}const t="prod"!==e.environmentId&&e.squidDeveloperId,r=Gr(e.appId,e.environmentId,t?e.squidDeveloperId:void 0);this.clientIdService=new ge(this.destructManager),ve.debug(this.clientIdService.getClientId(),"New Squid instance created"),this.authManager=new J(e.apiKey,e.authProvider),this.socketManager=new Wr(this.clientIdService,e.region,r,e.messageNotificationWrapper,this.destructManager,this.authManager),this.rpcManager=new Pr(e.region,r,this.destructManager,{},this.authManager,this.clientIdService),this.aiClient=new en(this.socketManager,this.rpcManager),this.apiClient=new Y(this.rpcManager),this.documentStore=new Qt,this.lockManager=new yr,this.distributedLockManager=new qt(this.socketManager,this.destructManager),this.documentIdentityService=new Bt(this.documentStore,this.destructManager),this.documentReferenceFactory=new Ut(this.documentIdentityService),this.querySender=new or(this.rpcManager,this.destructManager),this.observabilityClient=new Cr(this.rpcManager),this.schedulerClient=new qr(this.rpcManager),this._appId=r,this.querySubscriptionManager=new hr(this.rpcManager,this.clientIdService,this.documentStore,this.destructManager,this.documentIdentityService,this.querySender,this.socketManager),this.localQueryManager=new nr(this.documentStore,this.documentReferenceFactory,this.querySubscriptionManager);const n=new $t(this.rpcManager,this.lockManager,this.querySender);this.queryBuilderFactory=new yt(this.querySubscriptionManager,this.localQueryManager,this.documentReferenceFactory,this.documentIdentityService),this.dataManager=new Dt(this.documentStore,n,this.socketManager,this.querySubscriptionManager,this.queryBuilderFactory,this.lockManager,this.destructManager,this.documentIdentityService,this.querySender),this.collectionReferenceFactory=new Et(this.documentReferenceFactory,this.queryBuilderFactory,this.querySubscriptionManager,this.dataManager),this.documentReferenceFactory.setDataManager(this.dataManager),this.backendFunctionManager=new ye(this.rpcManager),this.nativeQueryManager=new Wt(this.rpcManager),this._connectionDetails=new Ft(this.clientIdService,this.socketManager),this.queueManagerFactory=new br(this.rpcManager,this.socketManager,this.destructManager),this.adminClient=new Kr(this.rpcManager,this.options.region,function(e){const t=Vr(e);return zr(t.appId,t.environmentId)}(r))}static getInstance(e){const t=de(e);let r=tn.squidInstancesMap[t];return r||(r=new tn(e),tn.squidInstancesMap[t]=r,r)}static getInstances(){return Object.values(tn.squidInstancesMap)}setAuthProvider(e){this.authManager.setAuthProvider(e)}collection(e,t=He){return this._validateNotDestructed(),this.collectionReferenceFactory.get(e,t)}runInTransaction(e){return this._validateNotDestructed(),this.dataManager.runInTransaction(e)}executeFunction(e,...t){return this._validateNotDestructed(),(0,o.firstValueFrom)(this.backendFunctionManager.executeFunctionAndSubscribe(e,...t))}executeNativeRelationalQuery(e,t,r={}){const n={type:"relational",query:t,params:r,integrationId:e};return this.nativeQueryManager.executeNativeQuery(n)}executeNativeMongoQuery(e,t,r){const n={type:"mongo",collectionName:t,aggregationPipeline:r,integrationId:e};return this.nativeQueryManager.executeNativeQuery(n)}ai(){return this._validateNotDestructed(),this.aiClient}api(){return this._validateNotDestructed(),this.apiClient}admin(){return this._validateNotDestructed(),this.adminClient}storage(e="built_in_storage"){return this._validateNotDestructed(),new Hr(e,this.rpcManager)}personalStorage(e){return this._validateNotDestructed(),new Jr(e,this.rpcManager)}extraction(){return this._validateNotDestructed(),new Yr(this.rpcManager)}get observability(){return this.observabilityClient}get schedulers(){return this.schedulerClient}get appId(){return this._appId}acquireLock(e){return this._validateNotDestructed(),this.distributedLockManager.lock(e)}async withLock(e,t){const r=await this.acquireLock(e);try{return await t(r)}finally{r.release()}}queue(e,t=Ye){return this._validateNotDestructed(),this.queueManagerFactory.get(t,e)}async destruct(){return this.destructManager.destruct().finally((()=>{const e=Object.entries(tn.squidInstancesMap).find((([,e])=>e===this));e&&delete tn.squidInstancesMap[e[0]]}))}connectionDetails(){return this._validateNotDestructed(),this._connectionDetails}async _unsubscribe(){this.querySubscriptionManager.unsubscribe(),await this.rpcManager.awaitAllSettled()}_validateNotDestructed(){(0,x.assertTruthy)(!this.destructManager.isDestructing,"The client was already destructed.")}internal(){const{rpcManager:e}=this;return{getApplicationUrl:(e,t,r)=>Sr(e,t,r),getStaticHeaders:()=>e.getStaticHeaders(),getAuthHeaders:()=>e.getAuthHeaders(),appIdWithEnvironmentIdAndDevId:(e,t,r)=>Gr(e,t,r)}}}var rn=exports;for(var nn in n)rn[nn]=n[nn];n.__esModule&&Object.defineProperty(rn,"__esModule",{value:!0})})();
|