var rtl_flag = !1
  , dark_flag = !1;
function layout_change_default() {
    let t = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
    layout_change(t);
    var e = document.querySelector('.theme-layout .btn[data-value="default"]');
    e && e.classList.add("active"),
    window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", e => {
        layout_change(t = e.matches ? "dark" : "light")
    }
    )
}
function dark_mode() {
    var e = document.getElementById("dark-mode");
    e && layout_change(e.checked ? "dark" : "light")
}
function font_change(e) {
    var t = {
        Roboto: "https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap",
        Poppins: "https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap",
        Inter: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap"
    }[e] || ""
      , t = (document.querySelector("#main-font-link").setAttribute("href", t),
    document.body.style.fontFamily = `"${e}", sans-serif`,
    document.querySelector(".pct-offcanvas"));
    t && (t = document.querySelector("#layoutfont" + e)) && (t.checked = !0)
}
function layout_caption_change(e) {
    document.body.setAttribute("data-pc-sidebar-caption", "true" === e ? "true" : "false");
    var t = document.querySelector(".theme-nav-caption .btn.active")
      , t = (t && t.classList.remove("active"),
    document.querySelector(`.theme-nav-caption .btn[data-value='${e}']`));
    t && t.classList.add("active")
}
function preset_change(e) {
    var t = document.querySelector("body")
      , a = document.querySelector(".pct-offcanvas");
    t.setAttribute("data-pc-preset", e),
    a && (t = document.querySelector(".preset-color > a.active"),
    a = document.querySelector(`.preset-color > a[data-value='${e}']`),
    t && t.classList.remove("active"),
    a) && a.classList.add("active")
}
function layout_rtl_change(e) {
    var t = document.querySelector("body")
      , a = document.querySelector("html")
      , o = document.querySelector(".theme-direction .btn.active")
      , r = document.querySelector(".theme-direction .btn[data-value='true']")
      , c = document.querySelector(".theme-direction .btn[data-value='false']");
    "true" === e ? (rtl_flag = !0,
    t.setAttribute("data-pc-direction", "rtl"),
    a.setAttribute("dir", "rtl"),
    a.setAttribute("lang", "ar"),
    o && o.classList.remove("active"),
    r && r.classList.add("active")) : (rtl_flag = !1,
    t.setAttribute("data-pc-direction", "ltr"),
    a.removeAttribute("dir"),
    a.removeAttribute("lang"),
    o && o.classList.remove("active"),
    c && c.classList.add("active"))
}
function layout_change(e) {
    var t = "dark" === e
      , e = (document.body.setAttribute("data-pc-theme", e),
    document.querySelector(".theme-layout .btn.active"))
      , e = (e && e.classList.remove("active"),
    document.querySelector(`.theme-layout .btn[data-value='${!t}']`));
    e && e.classList.add("active");
    let a = (dark_flag = t) ? "../assets/images/logo-white.svg" : "../assets/images/logo-dark.svg"
      , o = t ? "assets/images/logo-white.svg" : "assets/images/logo-dark.svg";
    [".pc-sidebar .m-header .logo-lg", ".navbar-brand .logo-lg", ".navbar-brand .brand-logo", ".navbar-brand .landing-logo", ".auth-main .brand-logo", ".footer-top .footer-logo"].forEach(e => {
        var t = document.querySelector(e);
        t && (e = e.includes("landing-logo") ? o : a,
        t.setAttribute("src", e))
    }
    )
}
function change_box_container(e) {
    let t = document.querySelector(".pc-content")
      , a = document.querySelector(".footer-wrapper");
    var o = document.querySelector(".theme-container > a.active");
    t && a && ("true" === e ? (t.classList.add("container"),
    a.classList.add("container"),
    a.classList.remove("container-fluid")) : (t.classList.remove("container"),
    a.classList.remove("container"),
    a.classList.add("container-fluid")),
    o) && (o.classList.remove("active"),
    o = document.querySelector(`.theme-container > a[data-value='${e}']`)) && o.classList.add("active")
}
document.addEventListener("DOMContentLoaded", function() {
    "undefined" != typeof Storage && layout_change(localStorage.getItem("layout"))
}),
document.addEventListener("DOMContentLoaded", function() {
    var e = document.querySelectorAll(".preset-color > a")
      , e = (e.length && e.forEach(e => {
        e.addEventListener("click", function(e) {
            let t = e.target;
            "SPAN" === t.tagName ? t = t.parentNode : "IMG" === t.tagName && (t = t.closest("a")),
            preset_change(t.getAttribute("data-value"))
        })
    }
    ),
    document.querySelector(".pct-body"))
      , e = (e && new SimpleBar(e),
    document.querySelector("#layoutreset"));
    e && e.addEventListener("click", () => location.reload()),
    document.querySelectorAll(".theme-layout .btn").forEach(e => {
        e.addEventListener("click", e => {
            e.stopPropagation();
            let t = e.target;
            for (; "SPAN" === t.tagName; )
                t = t.parentNode;
            e = "true" === t.getAttribute("data-value") ? "light" : "dark";
            localStorage.setItem("layout", e)
        }
        )
    }
    )
});
