import { isWindow } from "./win";
export const setCookie = (name, value, days) => {
    if (!isWindow) {
        return;
    }
    let expires = "";
    if (days) {
        const date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toUTCString();
    }
    document.cookie = `${name}=${encodeURIComponent(value)}${expires}; path=/`;
};
export const getCookie = (name) => {
    if (!isWindow) {
        return null;
    }
    const nameEQ = name + "=";
    const cookies = document.cookie.split(';');
    for (let i = 0; i < cookies.length; i++) {
        let cookie = cookies[i].trim();
        if (cookie.startsWith(nameEQ)) {
            return decodeURIComponent(cookie.substring(nameEQ.length));
        }
    }
    return null;
};
export const isValidSVG = (svgContent) => {
    try {
        const parser = new DOMParser();
        const doc = parser.parseFromString(svgContent, "image/svg+xml");
        const parseError = doc.querySelector("parsererror");
        if (parseError) {
            return false;
        }
        const svgElement = doc.documentElement;
        if (svgElement.tagName.toLowerCase() !== "svg") {
            return false;
        }
        return true;
    }
    catch (error) {
        return false;
    }
};
//# sourceMappingURL=document.js.map
