"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createProxiedDocument = createProxiedDocument;
exports.createProxiedWindow = createProxiedWindow;
function noop() { }
function originalProp(target, prop) {
    if (typeof target[prop] === 'function' && /^[a-z]/.test(prop)) {
        return target[prop].bind && target[prop].bind(target);
    }
    return target[prop];
}
function createProxiedDocument(proxiedHead) {
    return new Proxy(document, {
        get: (target, prop) => {
            switch (prop) {
                case 'write':
                case 'writeln':
                    return noop;
                case 'querySelector':
                    return (selector) => {
                        if (selector === 'head') {
                            return proxiedHead;
                        }
                        return originalProp(target, prop)(selector);
                    };
                default:
                    return originalProp(target, prop);
            }
        },
    });
}
function createProxiedWindow(proxiedDocument, proxiedHead) {
    return new Proxy(window, {
        get: (target, prop) => {
            switch (prop) {
                case 'document':
                    return proxiedDocument || createProxiedDocument(proxiedHead);
                default:
                    return originalProp(target, prop);
            }
        },
    });
}
//# sourceMappingURL=proxies.js.map