import { clean, computeRunIfCondition } from "./utils";
let allowlist = [];
export const triggerAxeCore = () => {
    clean();
    const mainElement = document.createElement("abr-index");
    mainElement.allowlist = [...allowlist];
    document.querySelector("body").append(mainElement);
};
export const setupAxeCore = (config) => {
    var _a;
    const triggerHandler = () => {
        triggerAxeCore();
    };
    if (computeRunIfCondition(config)) {
        if (config) {
            allowlist = (_a = config === null || config === void 0 ? void 0 : config.allowlist) !== null && _a !== void 0 ? _a : [];
        }
        document.addEventListener("DOMContentLoaded", () => {
            setTimeout(() => {
                triggerHandler();
                window.addEventListener("popstate", triggerHandler);
                window.addEventListener("beforeunload", () => {
                    window.removeEventListener("popstate", triggerHandler);
                }, false);
            }, 1);
        });
    }
};
