"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var rxjs_1 = require("rxjs");
var operators_1 = require("rxjs/operators");
var jsonRequest_1 = require("../http/jsonRequest");
var requestSite = function (siteId) {
    return jsonRequest_1.jsonRequest("https://api.netlify.com/api/v1/sites/" + siteId, {
        method: 'GET'
    });
};
exports.fetchSite = function (siteId) {
    return requestSite(siteId).pipe(operators_1.catchError(function (error) { return rxjs_1.of(error); }), operators_1.map(function (result) {
        if (result instanceof Error) {
            return { id: siteId, name: siteId, error: result };
        }
        return { id: siteId, name: result.name, data: result };
    }), operators_1.publishReplay(1), operators_1.refCount());
};
//# sourceMappingURL=site.js.map