"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.firstValueFrom = void 0;
const Observable_js_1 = require("./Observable.js");
const EmptyError_js_1 = require("./util/EmptyError.js");
function firstValueFrom(source, config) {
    const hasConfig = typeof config === 'object';
    return new Promise((resolve, reject) => {
        const subscriber = new Observable_js_1.Subscriber({
            next: (value) => {
                resolve(value);
                subscriber.unsubscribe();
            },
            error: reject,
            complete: () => {
                if (hasConfig) {
                    resolve(config.defaultValue);
                }
                else {
                    reject(new EmptyError_js_1.EmptyError());
                }
            },
        });
        source.subscribe(subscriber);
    });
}
exports.firstValueFrom = firstValueFrom;//# sourceMappingURL=http://go/sourcemap/sourcemaps/23b9fb205fe595ea2be29da7214e19762d037fc0/node_modules/rxjs/dist/cjs/internal/firstValueFrom.js.map