"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toMatchDocument = void 0;
const utilities_1 = require("@apollo/client/utilities");
const toMatchDocument = function (actual, document) {
    const hint = this.utils.matcherHint("toMatchDocument");
    const actualDocument = (0, utilities_1.print)(validateDocument(actual, hint +
        `\n\n${this.utils.RECEIVED_COLOR("received")} document must be a parsed document.`));
    const expectedDocument = (0, utilities_1.print)(validateDocument(document, hint +
        `\n\n${this.utils.EXPECTED_COLOR("expected")} document must be a parsed document.`));
    const pass = actualDocument === expectedDocument;
    return {
        pass,
        message: () => {
            const hint = this.utils.matcherHint("toMatchDocument", undefined, undefined, { isNot: this.isNot });
            if (pass) {
                return (hint +
                    "\n\n" +
                    "Received:\n\n" +
                    this.utils.RECEIVED_COLOR(actualDocument));
            }
            return (hint + "\n\n" + this.utils.diff(expectedDocument, actualDocument));
        },
    };
};
exports.toMatchDocument = toMatchDocument;
function validateDocument(document, message) {
    try {
        (0, utilities_1.checkDocument)(document);
    }
    catch (e) {
        throw new Error(message);
    }
    return document;
}
//# sourceMappingURL=toMatchDocument.cjs.map
