/**
* PDA v1.1.2
* (c) 2024 Product Designer App
* @license GPLv3
* Theme
* Free version
* Unminify code for Dev
**/
var pdappCodeMirEditor = null;
const { createApp: createApp } = Vue;
var pdappVueApp = createApp({
    data: () => ({
        loadingPage: !0,
        uploadUrl: pdappUploadUrl,
        pluginUrl: pdappPluginUrl,
        modal: { show: !1 },
        toast: { show: !1, type: "success", text: "" },
        themes: [],
        langs: {},
        version: pdappVersion,
        loading: "",
        listStores: [],
    }),
    created() {
        jQuery("#productdesignerapp-app").show(), this.getThemeSetting();
    },
    computed: {
        breadcrumbs() {
            let t = { title: "", pages: [] };
            return (
                void 0 === this.langs.menu ||
                    ((t.title = this.langs.menu.themes), (t.pages = [{ to: "", title: t.title }])),
                t
            );
        },
        listThemeStores() {
            let t = [],
                e = {};
            for (let t = 0; t < this.themes.length; t++) e[this.themes[t].themeID] = this.themes[t].themeID;
            for (let a = 0; a < this.listStores.length; a++)
                void 0 === e[this.listStores[a].themeID] && t.push(this.listStores[a]);
            return t;
        },
    },
    methods: {
        async getRefreshToken() {
            let t = this,
                e = pdappAdminUrl + "admin-ajax.php?action=pdapp-refresh-token&admin=1";
            try {
                let t = await pdappAPI.tool.getData(e);
                pdappNonce = t.data.token;
            } catch (t) {}
            setTimeout(() => {
                t.getRefreshToken();
            }, 6e4);
        },
        async getThemeSetting() {
            let t = this,
                e =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-load-setting&langs=1&admin=1&pdapp-nonce=" +
                    pdappNonce;
            try {
                let a = await pdappAPI.tool.getData(e);
                (t.langs = a.data.langs), t.showListThemes();
            } catch (t) {}
            setTimeout(() => {
                t.getRefreshToken();
            }, 6e4);
        },
        async showListThemes() {
            let t = this;
            if (((t.loadingPage = !0), 0 == t.themes.length)) {
                let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-themes&admin=1&pdapp-nonce=" + pdappNonce;
                try {
                    let a = await pdappAPI.tool.getData(e);
                    t.themes = a.data;
                } catch (e) {
                    (t.toast = { show: !0, type: "warning", text: e.msg }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                }
            }
            pdappAPI.tool.updateURL("themes"), (t.loadingPage = !1), t.showListStores();
        },
        async showListStores() {
            let t = this;
            t.loadingPage = !0;
            try {
                let e = await pdappAPI.tool.getData(pdappAPIUrl + "/info.php?type=list-theme-releases-wp");
                t.listStores = e.data;
            } catch (e) {
                (t.toast = { show: !0, type: "warning", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.loadingPage = !1;
        },
        showThemeStore() {
            this.modal = { show: !0 };
        },
    },
}).mount("#productdesignerapp-app");