"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.webDocument = webDocument;
const PositionObserver_1 = require("../../../PositionObserver");
const IntersectionObserver_1 = require("../../../noop/IntersectionObserver");
const MutationObserver_1 = require("../../../noop/MutationObserver");
const ResizeObserver_1 = require("../../../noop/ResizeObserver");
function webDocument(window, root, opt) {
    const { document } = window;
    // @ts-ignore
    const MutationObserver = window.MutationObserver || MutationObserver_1.NoopMutationObserver;
    // @ts-ignore
    const ResizeObserver = window.ResizeObserver || ResizeObserver_1.NoopResizeObserver;
    const IntersectionObserver = 
    // @ts-ignore
    window.IntersectionObserver || IntersectionObserver_1.NoopIntersectionObserver;
    const _document = {
        createElement(tagName) {
            return document.createElement(tagName);
        },
        createElementNS(namespaceURI, qualifiedName) {
            return document.createElementNS(namespaceURI, qualifiedName);
        },
        createTextNode(text) {
            return document.createTextNode(text);
        },
        elementFromPoint(x, y) {
            return root.shadowRoot.elementFromPoint(x, y);
        },
        elementsFromPoint(x, y) {
            return root.shadowRoot.elementsFromPoint(x, y);
        },
        canSelectShadowDom: function () {
            // @ts-ignore
            return !!root.shadowRoot.getSelection;
        },
        getSelection() {
            // @ts-ignore
            if (root.shadowRoot.getSelection) {
                // @ts-ignore
                return root.shadowRoot.getSelection();
            }
            return document.getSelection();
        },
        createRange() {
            return document.createRange();
        },
        exitPictureInPicture() {
            return document.exitPictureInPicture();
        },
        MutationObserver: MutationObserver,
        ResizeObserver: ResizeObserver,
        PositionObserver: PositionObserver_1.PositionObserver_,
        IntersectionObserver: IntersectionObserver,
        pictureInPictureElement: document.pictureInPictureElement,
    };
    return _document;
}
//# sourceMappingURL=document.js.map