{"version":3,"sources":["node_modules/@angular/core/fesm2022/rxjs-interop.mjs"],"sourcesContent":["/**\n * @license Angular v17.2.1\n * (c) 2010-2022 Google LLC. https://angular.io/\n * License: MIT\n */\n\nimport { assertInInjectionContext, inject, DestroyRef, Injector, effect, untracked, assertNotInReactiveContext, signal, ɵRuntimeError, computed } from '@angular/core';\nimport { Observable, ReplaySubject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\n/**\n * Operator which completes the Observable when the calling context (component, directive, service,\n * etc) is destroyed.\n *\n * @param destroyRef optionally, the `DestroyRef` representing the current context. This can be\n * passed explicitly to use `takeUntilDestroyed` outside of an [injection\n * context](guide/dependency-injection-context). Otherwise, the current `DestroyRef` is injected.\n *\n * @developerPreview\n */\nfunction takeUntilDestroyed(destroyRef) {\n if (!destroyRef) {\n assertInInjectionContext(takeUntilDestroyed);\n destroyRef = inject(DestroyRef);\n }\n const destroyed$ = new Observable(observer => {\n const unregisterFn = destroyRef.onDestroy(observer.next.bind(observer));\n return unregisterFn;\n });\n return source => {\n return source.pipe(takeUntil(destroyed$));\n };\n}\n\n/**\n * Exposes the value of an Angular `Signal` as an RxJS `Observable`.\n *\n * The signal's value will be propagated into the `Observable`'s subscribers using an `effect`.\n *\n * `toObservable` must be called in an injection context unless an injector is provided via options.\n *\n * @developerPreview\n */\nfunction toObservable(source, options) {\n !options?.injector && assertInInjectionContext(toObservable);\n const injector = options?.injector ?? inject(Injector);\n const subject = new ReplaySubject(1);\n const watcher = effect(() => {\n let value;\n try {\n value = source();\n } catch (err) {\n untracked(() => subject.error(err));\n return;\n }\n untracked(() => subject.next(value));\n }, {\n injector,\n manualCleanup: true\n });\n injector.get(DestroyRef).onDestroy(() => {\n watcher.destroy();\n subject.complete();\n });\n return subject.asObservable();\n}\n\n/**\n * Get the current value of an `Observable` as a reactive `Signal`.\n *\n * `toSignal` returns a `Signal` which provides synchronous reactive access to values produced\n * by the given `Observable`, by subscribing to that `Observable`. The returned `Signal` will always\n * have the most recent value emitted by the subscription, and will throw an error if the\n * `Observable` errors.\n *\n * With `requireSync` set to `true`, `toSignal` will assert that the `Observable` produces a value\n * immediately upon subscription. No `initialValue` is needed in this case, and the returned signal\n * does not include an `undefined` type.\n *\n * By default, the subscription will be automatically cleaned up when the current [injection\n * context](/guide/dependency-injection-context) is destroyed. For example, when `toObservable` is\n * called during the construction of a component, the subscription will be cleaned up when the\n * component is destroyed. If an injection context is not available, an explicit `Injector` can be\n * passed instead.\n *\n * If the subscription should persist until the `Observable` itself completes, the `manualCleanup`\n * option can be specified instead, which disables the automatic subscription teardown. No injection\n * context is needed in this configuration as well.\n *\n * @developerPreview\n */\nfunction toSignal(source, options) {\n ngDevMode && assertNotInReactiveContext(toSignal, 'Invoking `toSignal` causes new subscriptions every time. ' + 'Consider moving `toSignal` outside of the reactive context and read the signal value where needed.');\n const requiresCleanup = !options?.manualCleanup;\n requiresCleanup && !options?.injector && assertInInjectionContext(toSignal);\n const cleanupRef = requiresCleanup ? options?.injector?.get(DestroyRef) ?? inject(DestroyRef) : null;\n // Note: T is the Observable value type, and U is the initial value type. They don't have to be\n // the same - the returned signal gives values of type `T`.\n let state;\n if (options?.requireSync) {\n // Initially the signal is in a `NoValue` state.\n state = signal({\n kind: 0 /* StateKind.NoValue */\n });\n } else {\n // If an initial value was passed, use it. Otherwise, use `undefined` as the initial value.\n state = signal({\n kind: 1 /* StateKind.Value */,\n value: options?.initialValue\n });\n }\n // Note: This code cannot run inside a reactive context (see assertion above). If we'd support\n // this, we would subscribe to the observable outside of the current reactive context, avoiding\n // that side-effect signal reads/writes are attribute to the current consumer. The current\n // consumer only needs to be notified when the `state` signal changes through the observable\n // subscription. Additional context (related to async pipe):\n // https://github.com/angular/angular/pull/50522.\n const sub = source.subscribe({\n next: value => state.set({\n kind: 1 /* StateKind.Value */,\n value\n }),\n error: error => {\n if (options?.rejectErrors) {\n // Kick the error back to RxJS. It will be caught and rethrown in a macrotask, which causes\n // the error to end up as an uncaught exception.\n throw error;\n }\n state.set({\n kind: 2 /* StateKind.Error */,\n error\n });\n }\n // Completion of the Observable is meaningless to the signal. Signals don't have a concept of\n // \"complete\".\n });\n if (ngDevMode && options?.requireSync && state().kind === 0 /* StateKind.NoValue */) {\n throw new ɵRuntimeError(601 /* ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT */, '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.');\n }\n // Unsubscribe when the current context is destroyed, if requested.\n cleanupRef?.onDestroy(sub.unsubscribe.bind(sub));\n // The actual returned signal is a `computed` of the `State` signal, which maps the various states\n // to either values or errors.\n return computed(() => {\n const current = state();\n switch (current.kind) {\n case 1 /* StateKind.Value */:\n return current.value;\n case 2 /* StateKind.Error */:\n throw current.error;\n case 0 /* StateKind.NoValue */:\n // This shouldn't really happen because the error is thrown on creation.\n // TODO(alxhub): use a RuntimeError when we finalize the error semantics\n throw new ɵRuntimeError(601 /* ɵRuntimeErrorCode.REQUIRE_SYNC_WITHOUT_SYNC_EMIT */, '`toSignal()` called with `requireSync` but `Observable` did not emit synchronously.');\n }\n });\n}\n\n/**\n * Generated bundle index. Do not edit.\n */\n\nexport { takeUntilDestroyed, toObservable, toSignal };\n"],"mappings":"+HAoBA,SAASA,EAAmBC,EAAY,CACjCA,IACHC,EAAyBF,CAAkB,EAC3CC,EAAaE,EAAOC,CAAU,GAEhC,IAAMC,EAAa,IAAIC,EAAWC,GACXN,EAAW,UAAUM,EAAS,KAAK,KAAKA,CAAQ,CAAC,CAEvE,EACD,OAAOC,GACEA,EAAO,KAAKC,EAAUJ,CAAU,CAAC,CAE5C,CAWA,SAASK,EAAaF,EAAQG,EAAS,CACrC,CAACA,GAAS,UAAYT,EAAyBQ,CAAY,EAC3D,IAAME,EAAWD,GAAS,UAAYR,EAAOU,CAAQ,EAC/CC,EAAU,IAAIC,EAAc,CAAC,EAC7BC,EAAUC,EAAO,IAAM,CAC3B,IAAIC,EACJ,GAAI,CACFA,EAAQV,EAAO,CACjB,OAASW,EAAK,CACZC,EAAU,IAAMN,EAAQ,MAAMK,CAAG,CAAC,EAClC,MACF,CACAC,EAAU,IAAMN,EAAQ,KAAKI,CAAK,CAAC,CACrC,EAAG,CACD,SAAAN,EACA,cAAe,EACjB,CAAC,EACD,OAAAA,EAAS,IAAIR,CAAU,EAAE,UAAU,IAAM,CACvCY,EAAQ,QAAQ,EAChBF,EAAQ,SAAS,CACnB,CAAC,EACMA,EAAQ,aAAa,CAC9B,CA0BA,SAASO,EAASb,EAAQG,EAAS,CAEjC,IAAMW,EAAkB,CAACX,GAAS,cAClCW,GAAmB,CAACX,GAAS,UAAYT,EAAyBmB,CAAQ,EAC1E,IAAME,EAAaD,EAAkBX,GAAS,UAAU,IAAIP,CAAU,GAAKD,EAAOC,CAAU,EAAI,KAG5FoB,EACAb,GAAS,YAEXa,EAAQC,EAAO,CACb,KAAM,CACR,CAAC,EAGDD,EAAQC,EAAO,CACb,KAAM,EACN,MAAOd,GAAS,YAClB,CAAC,EAQH,IAAMe,EAAMlB,EAAO,UAAU,CAC3B,KAAMU,GAASM,EAAM,IAAI,CACvB,KAAM,EACN,MAAAN,CACF,CAAC,EACD,MAAOS,GAAS,CACd,GAAIhB,GAAS,aAGX,MAAMgB,EAERH,EAAM,IAAI,CACR,KAAM,EACN,MAAAG,CACF,CAAC,CACH,CAGF,CAAC,EAKD,OAAAJ,GAAY,UAAUG,EAAI,YAAY,KAAKA,CAAG,CAAC,EAGxCE,EAAS,IAAM,CACpB,IAAMC,EAAUL,EAAM,EACtB,OAAQK,EAAQ,KAAM,CACpB,IAAK,GACH,OAAOA,EAAQ,MACjB,IAAK,GACH,MAAMA,EAAQ,MAChB,IAAK,GAGH,MAAM,IAAIC,EAAc,IAA4D,qFAAqF,CAC7K,CACF,CAAC,CACH","names":["takeUntilDestroyed","destroyRef","assertInInjectionContext","inject","DestroyRef","destroyed$","Observable","observer","source","takeUntil","toObservable","options","injector","Injector","subject","ReplaySubject","watcher","effect","value","err","untracked","toSignal","requiresCleanup","cleanupRef","state","signal","sub","error","computed","current","RuntimeError"],"x_google_ignoreList":[0]}