/**
* PDA v1.1.2
* (c) 2024 Product Designer App
* @license GPLv3
* Templates
* Free version
* Unminify code for Dev
**/
const { createApp: createApp } = Vue;
var pdappVueApp = createApp({
    data: () => ({
        settings: {},
        toast: { show: !1, type: "success", text: "" },
        isFullScreen: !1,
        viewPortTemp: null,
        langs: {},
        langDefault: pdappLangDefault,
        listMenus: {},
        activeMenu: "text",
        fontsize: [],
        fontLibrary: {},
        loadedFonts: {},
        addedFonts: [],
        modal: { show: !1 },
        loadingPage: !0,
        folderID: pdappFolderID,
        uploading: !1,
        shapePhoto: [],
        filterPhoto: [],
        showRuler: !0,
        history: { active: -1, values: [] },
        photoStores: {},
        waitCropPhoto: {},
        dropdownMenu: "",
        waitDesign: !1,
        waitTiming: 0,
        pluginUrl: pdappPluginUrl,
        uploadUrl: pdappUploadUrl,
        listTempsData: {},
        listFolders: {},
        listLang: { default: pdappLangDefault, list: {} },
        tempOption: { search: "", searchMobile: !1, folder: "", pages: 1, paged: 1, perpage: 24 },
        tempCheckbox: !1,
        tempCheckboxs: [],
        listAttrTemps: [],
        tempModal: { show: !1 },
        groupItem: { show: !1 },
        artFolders: [],
        artworks: {},
        breadcrs: [],
        loadTextTemp: !1,
        tempFolders: [],
        responsiveLayout: { width: 0, height: 0, screenSize: "desktop", position: "hor" },
        listZoom: [300, 250, 200, 150, 100, 75, 50, 25, 10],
        listTextOptions: [
            "edit",
            "font",
            "color",
            "arc",
            "space",
            "outline",
            "transparent",
            "style",
            "copy",
            "lock",
            "flip",
            "move",
            "size",
            "rotate",
            "delete",
        ],
        listArtworkOptions: ["transparent", "color", "copy", "lock", "flip", "move", "size", "rotate", "delete"],
        listPhotoOptions: [
            "shape",
            "filter",
            "transparent",
            "color",
            "crop",
            "copy",
            "lock",
            "flip",
            "move",
            "size",
            "rotate",
            "delete",
        ],
        listQrcodeOptions: [
            "type",
            "edit",
            "color",
            "level",
            "background",
            "transparent",
            "copy",
            "lock",
            "move",
            "size",
            "rotate",
            "delete",
        ],
        listBarcodeOptions: [
            "edit",
            "type",
            "color",
            "width",
            "height",
            "background",
            "transparent",
            "copy",
            "lock",
            "text",
            "move",
            "size",
            "rotate",
            "delete",
        ],
        listCropRatio: ["area_ratio", "1:1", "1:2", "2:1", "free_ratio"],
        pdappPurchasedCode: pdappPurchasedCode,
        pdappApiToken: "",
        showStore: !1,
        confirmEmail: { code: "", timeLess: 0, error: "", refresh: !0 },
        loadedStore: !1,
        loadingStore: !1,
    }),
    created() {
        jQuery("#productdesignerapp-app").show(),
            this.getTempSetting(),
            jQuery("body").addClass("pdapp-hide-scrollbar-modal"),
            jQuery(document).trigger("after_created_called", { self: self });
    },
    computed: {
        breadcrumbs() {
            let t = { title: "", pages: [] };
            if (void 0 === this.langs.menu) return t;
            if (void 0 !== this.listFolders && void 0 !== this.listLang.list) {
                let e = { id: 0, pid: 0, title: {} };
                for (let t in this.listLang.list) void 0 === e.title[t] && (e.title[t] = this.langs.menu.templates);
                let o = this;
                pdappAPI.folder.getFolderBreads(o.listFolders, e, o.folderID, function (e) {
                    for (let a = 0; a < e.length; a++) {
                        let p = e[a].id == o.folderID ? "" : e[a].id;
                        t.pages.push({ to: p, title: e[a].title });
                    }
                    return (t.title = e[e.length - 1].title), t;
                });
            }
            return t;
        },
        listDatas() {
            let t = { folders: [], temps: [] };
            return (
                void 0 !== this.listFolders &&
                    void 0 !== this.listFolders[this.folderID] &&
                    (t.folders = this.listFolders[this.folderID]),
                void 0 !== this.listTempsData &&
                    void 0 !== this.listTempsData[this.folderID] &&
                    (t.temps = this.listTempsData[this.folderID]),
                t
            );
        },
        listTemps() {
            let t = [];
            for (let e = 0; e < this.listDatas.temps.length; e++)
                "" != this.tempOption.search
                    ? -1 !=
                          this.listDatas.temps[e].title[this.listLang.default]
                              .toLowerCase()
                              .indexOf(this.tempOption.search.toLowerCase()) && t.push(this.listDatas.temps[e])
                    : t.push(this.listDatas.temps[e]);
            this.tempOption.pages = Math.ceil(t.length / this.tempOption.perpage);
            let e = [],
                o = (this.tempOption.paged - 1) * this.tempOption.perpage;
            for (let a = 0; a < t.length; a++) a >= o && a < o + this.tempOption.perpage && e.push(t[a]);
            let a = this;
            return (
                setTimeout(() => {
                    a.checkAllTemp();
                }),
                e
            );
        },
        tempEdits() {
            let t = [];
            for (let e = 0; e < this.listTemps.length; e++)
                t.push({
                    id: this.listTemps[e].id,
                    pid: this.listTemps[e].pid,
                    title: this.listTemps[e].title,
                    price: this.listTemps[e].price,
                });
            return t;
        },
        tempModalPX() {
            let t = {};
            if (this.tempModal.show && "" != this.tempModal.data) {
                let e = JSON.parse(JSON.stringify(this.tempModal.data));
                t = pdappAPI.tool.toTempPX(e);
            }
            return t;
        },
        tempModalViewPort() {
            let t = this,
                e = "margin: unset;";
            if (((t.responsiveLayout = pdappAPI.tool.responsiveLayout()), t.tempModal.show && t.tempModal.data.zoom)) {
                let o = {};
                null != t.viewPortTemp
                    ? ((o = t.viewPortTemp), (t.viewPortTemp = null))
                    : ((o = pdappAPI.tool.getAutoZoom(t.tempModalPX, t.responsiveLayout)),
                      "fit" == t.tempModal.data.zoom && (t.viewPortTemp = o)),
                    (t.tempModal.data.zoom = o.zoom),
                    (t.tempModal.data.ratio = o.ratio);
                let a = t.tempModalPX.ratio;
                e =
                    "width:" +
                    (t.tempModalPX.size.width * a).toFixed(3) +
                    "px;height:" +
                    (t.tempModalPX.size.height * a).toFixed(3) +
                    "px;top:" +
                    o.top.toFixed(3) +
                    "px;left:" +
                    o.left.toFixed(3) +
                    "px;margin: unset;";
            }
            return (
                setTimeout(() => {
                    null != pdappAPI.tool.pdappMoveAbleRef && (t.closeMenuOption(), t.closeGroup());
                }, 1),
                e
            );
        },
        qrcodeTypes() {
            return [
                { key: "text", text: this.langs.options.text_type },
                { key: "url", text: this.langs.options.url_type },
                { key: "phone", text: this.langs.options.phone_type },
                { key: "sms", text: this.langs.options.sms_type },
                { key: "mail", text: this.langs.options.mail_type },
            ];
        },
        barcodeTypes: () => [
            { type: "CODE128", values: ["CODE128", "CODE128A", "CODE128B", "CODE128C", "CODE128C-ean128"] },
            {
                type: "EAN / UPC",
                values: [
                    "EAN13",
                    "EAN13-flat",
                    "EAN13-lastchar",
                    "UPC",
                    "UPC-flat",
                    "EAN8",
                    "EAN8-flat",
                    "EAN5",
                    "EAN2",
                ],
            },
            { type: "CODE39", values: ["CODE39", "CODE39-mod43"] },
            { type: "ITF14", values: ["ITF14"] },
            { type: "MSI", values: ["MSI", "MSI10", "MSI11", "MSI1010", "MSI1110"] },
            { type: "pharmacode", values: ["pharmacode"] },
            { type: "codabar", values: ["codabar"] },
        ],
        listZoom() {
            let t = ["auto"];
            if ("undefined" != this.tempModalPX.zoom) {
                let e = 0,
                    o = this.tempModalPX.maxZoom;
                if (o > 5)
                    for (; e < o; )
                        e < 15 && o <= 100
                            ? (e += 5)
                            : e < 25 && o <= 150
                              ? (e += e < 10 ? 10 : 15)
                              : e < 100
                                ? (e += 25)
                                : 100 < e < 200
                                  ? (e += 50)
                                  : 200 < e < 300
                                    ? (e += 100)
                                    : 300 < e < 1e3
                                      ? (e += 250)
                                      : 1e3 < e < 1e4 && (e += 500),
                            e <= o && t.push(e);
                else (e = o), t.push(e);
            }
            return t;
        },
        menuOptions() {
            let t = this,
                e = {};
            return (
                null != t.activeMenu &&
                    void 0 !== t.listMenus[t.activeMenu] &&
                    void 0 !== t.listMenus[t.activeMenu].options &&
                    (e = t.listMenus[t.activeMenu].options),
                e
            );
        },
        listFonts() {
            let t = this,
                e = { category: [], fonts: [], total: 20 };
            if (void 0 !== t.fontLibrary.fonts) {
                for (let o = 0; o < t.fontLibrary.fonts.length; o++)
                    !1 === e.category.includes(t.fontLibrary.fonts[o].category) &&
                        e.category.push(t.fontLibrary.fonts[o].category),
                        ("" != t.fontLibrary.find &&
                            -1 ==
                                t.fontLibrary.fonts[o].title.toLowerCase().indexOf(t.fontLibrary.find.toLowerCase())) ||
                            ("" != t.fontLibrary.category &&
                                t.fontLibrary.fonts[o].category != t.fontLibrary.category) ||
                            e.fonts.push(t.fontLibrary.fonts[o]);
                if (((e.total = e.fonts.length), void 0 !== t.fontLibrary.page)) {
                    let o = t.fontLibrary.page.paged * t.fontLibrary.page.perpage;
                    if (o < e.fonts.length) {
                        let t = [];
                        for (let a = 0; a < e.fonts.length && !(o <= a); a++) t.push(e.fonts[a]);
                        e.fonts = t;
                    }
                }
            }
            return e;
        },
        qrcodeTypes() {
            let t = this;
            return [
                { key: "text", text: t.langs.options.text_type },
                { key: "url", text: t.langs.options.url_type },
                { key: "phone", text: t.langs.options.phone_type },
                { key: "sms", text: t.langs.options.sms_type },
                { key: "mail", text: t.langs.options.mail_type },
            ];
        },
        barcodeTypes: () => [
            { type: "CODE128", values: ["CODE128", "CODE128A", "CODE128B", "CODE128C", "CODE128C-ean128"] },
            {
                type: "EAN / UPC",
                values: [
                    "EAN13",
                    "EAN13-flat",
                    "EAN13-lastchar",
                    "UPC",
                    "UPC-flat",
                    "EAN8",
                    "EAN8-flat",
                    "EAN5",
                    "EAN2",
                ],
            },
            { type: "CODE39", values: ["CODE39", "CODE39-mod43"] },
            { type: "ITF14", values: ["ITF14"] },
            { type: "MSI", values: ["MSI", "MSI10", "MSI11", "MSI1010", "MSI1110"] },
            { type: "pharmacode", values: ["pharmacode"] },
            { type: "codabar", values: ["codabar"] },
        ],
        listTextTemp() {
            let t = this,
                e = { temps: [], total: 20 };
            if ("text" == t.activeMenu && void 0 !== t.listMenus.text && void 0 !== t.listMenus.text.options.values) {
                let o = t.listMenus.text.options.values;
                if (void 0 !== t.listMenus.text.search && "" != t.listMenus.text.search) {
                    let a = t.listMenus.text.search;
                    for (let t = 0; t < o.length; t++)
                        -1 != o[t].text.toLowerCase().indexOf(a.toLowerCase()) && e.temps.push(o[t]);
                } else e.temps = o;
                if (((e.total = e.temps.length), void 0 !== t.listMenus.text.page)) {
                    let o = t.listMenus.text.page.paged * t.listMenus.text.page.perpage;
                    if (o < e.temps.length) {
                        let t = [];
                        for (let a = 0; a < e.temps.length && !(o <= a); a++) t.push(e.temps[a]);
                        e.temps = t;
                    }
                }
            }
            return e;
        },
        listArtworks() {
            let t = this,
                e = { arts: [], total: 20 };
            if (
                "artwork" == t.activeMenu &&
                void 0 !== t.listMenus.artwork &&
                void 0 !== t.listMenus.artwork.options.values.activeFolder &&
                void 0 !== t.artworks[t.listMenus.artwork.options.values.activeFolder]
            ) {
                let o = t.artworks[t.listMenus.artwork.options.values.activeFolder];
                if (
                    void 0 !== t.listMenus.artwork.options.values.search &&
                    "" != t.listMenus.artwork.options.values.search
                ) {
                    let a = t.listMenus.artwork.options.values.search;
                    for (let p = 0; p < o.length; p++)
                        -1 != t.getTitle(o[p].title).toLowerCase().indexOf(a.toLowerCase()) && e.arts.push(o[p]);
                } else e.arts = o;
                if (((e.total = e.arts.length), void 0 !== t.listMenus.artwork.options.values.page)) {
                    let o =
                        t.listMenus.artwork.options.values.page.paged * t.listMenus.artwork.options.values.page.perpage;
                    if (o < e.arts.length) {
                        let t = [];
                        for (let a = 0; a < e.arts.length && !(o <= a); a++) t.push(e.arts[a]);
                        e.arts = t;
                    }
                }
            }
            return e;
        },
        timeDown() {
            let t = "" + Math.floor(this.confirmEmail.timeLess / 60),
                e = "" + (this.confirmEmail.timeLess - 60 * t);
            return 1 == t.length && (t = "0" + t), 1 == e.length && (e = "0" + e), t + ":" + e;
        },
    },
    watch: {
        menuOptions: {
            handler(t) {
                if (void 0 !== t.childID && void 0 !== t.details[t.childID]) {
                    let e = t.details[t.childID];
                    void 0 !== e.dropdown &&
                        setTimeout(() => {
                            pdappAPI.tool.responsiveDropdown(e, self.responsiveLayout);
                        }, 5);
                }
            },
            deep: !0,
        },
        groupItem: {
            handler(t) {
                if (void 0 !== t.show && t.show && void 0 !== t.active && "" != t.active) {
                    let e = { type: "group", dropdown: t.active };
                    setTimeout(() => {
                        pdappAPI.tool.responsiveDropdown(e, self.responsiveLayout);
                    }, 5);
                }
            },
            deep: !0,
        },
    },
    methods: {
        goToPage(t) {
            (this.tempOption.paged = 1), (this.folderID = t), this.showListTemps();
        },
        startWorker() {
            let t = this;
            if (0 == pdappWorker) return !1;
            pdappWorker.onmessage = function (e) {
                t.actionWorker(e.data);
            };
        },
        actionWorker(t) {
            let e = this;
            if (((e.waitDesign = !1), "getPhoto" == t.action)) {
                if ("blob" == t.type)
                    if (
                        ((e.photoStores[t.id][t.type] = URL.createObjectURL(t.value)),
                        pdappAPI.photo.readPhoto(e.photoStores[t.id], function (o) {
                            e.createPhoto(o, t.id);
                        }),
                        pdappWorker)
                    )
                        pdappWorker.postMessage({ id: t.id, action: "toBase64", type: "base64", value: t.value });
                    else {
                        const o = new FileReader();
                        o.readAsDataURL(t.value),
                            (o.onload = function () {
                                -1 != o.result.indexOf(";base64,") && (e.photoStores[t.id].base64 = o.result);
                            });
                    }
                if ("origBase64" == t.type)
                    if (pdappWorker)
                        pdappWorker.postMessage({ id: t.id, action: "toBase64", type: "origBase64", value: t.value });
                    else {
                        const o = new FileReader();
                        o.readAsDataURL(t.value),
                            (o.onload = function () {
                                -1 != o.result.indexOf(";base64,") &&
                                    ((e.photoStores[t.id].origBase64 = o.result),
                                    void 0 !== e.waitCropPhoto[t.id] &&
                                        e.cropOriginPhoto(
                                            e.waitCropPhoto[t.id].id,
                                            e.waitCropPhoto[t.id].crop,
                                            e.waitCropPhoto[t.id].hisID
                                        ));
                            });
                    }
            }
            if ("getPhotoReplace" == t.action) {
                if ("blob" == t.type)
                    if (
                        ((e.photoStores[t.id][t.type] = URL.createObjectURL(t.value)),
                        pdappAPI.photo.readPhoto(e.photoStores[t.id], function (o) {
                            if (null == pdappAPI.tool.pdappMoveAbleRef.target) return !1;
                            let a = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
                            e.replacePhoto(o, t.id, a);
                        }),
                        pdappWorker)
                    )
                        pdappWorker.postMessage({ id: t.id, action: "toBase64", type: "base64", value: t.value });
                    else {
                        const o = new FileReader();
                        o.readAsDataURL(t.value),
                            (o.onload = function () {
                                -1 != o.result.indexOf(";base64,") && (e.photoStores[t.id].base64 = o.result);
                            });
                    }
                if ("origBase64" == t.type)
                    if (pdappWorker)
                        pdappWorker.postMessage({ id: t.id, action: "toBase64", type: "origBase64", value: t.value });
                    else {
                        const o = new FileReader();
                        o.readAsDataURL(t.value),
                            (o.onload = function () {
                                -1 != o.result.indexOf(";base64,") &&
                                    ((e.photoStores[t.id].origBase64 = o.result),
                                    void 0 !== e.waitCropPhoto[t.id] &&
                                        e.cropOriginPhoto(
                                            e.waitCropPhoto[t.id].id,
                                            e.waitCropPhoto[t.id].crop,
                                            e.waitCropPhoto[t.id].hisID
                                        ));
                            });
                    }
            }
            "toBase64" == t.action &&
                ((e.photoStores[t.id][t.type] = t.value),
                "origBase64" == t.type &&
                    void 0 !== e.waitCropPhoto[t.id] &&
                    e.cropOriginPhoto(
                        e.waitCropPhoto[t.id].id,
                        e.waitCropPhoto[t.id].crop,
                        e.waitCropPhoto[t.id].hisID
                    )),
                "cropOrigImg" == t.action &&
                    void 0 !== e.photoStores[t.id] &&
                    void 0 !== e.photoStores[t.id].crop &&
                    -1 != t.value.indexOf(";base64,") &&
                    ((e.photoStores[t.id].crop.origBase64 = t.value),
                    void 0 !== e.history.values[t.hisID] &&
                        ("createPhoto" == e.history.values[t.hisID].redo.action
                            ? (e.history.values[t.hisID].redo.value = JSON.parse(JSON.stringify(e.photoStores[t.id])))
                            : (e.history.values[t.hisID].redo.value = JSON.parse(
                                  JSON.stringify(e.photoStores[t.id].crop)
                              ))));
        },
        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 getTempSetting() {
            let t = this,
                e =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-load-setting&listLangs=1&langs=1&tempFolder=1&menus=1&settings=1&fontsize=1&admin=1&pdapp-nonce=" +
                    pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.langs = o.data.langs),
                    (t.listLang.list = o.data.listLangs),
                    (t.listFolders = o.data.folders),
                    (t.listMenus = o.data.menus),
                    (t.settings = o.data.settings),
                    jQuery(document).trigger("after_setting_loaded", { self: t }),
                    (t.activeMenu = pdappAPI.tool.getLocalVar("pdappActiveMenuTemp", Object.keys(o.data.menus)[0])),
                    (t.fontsize = o.data.fontsize),
                    t.showListTemps(),
                    t.applyHotKeys(),
                    t.startWorker(),
                    setTimeout(() => {
                        (window.onresize = function () {
                            t.onResizeScreen();
                        }),
                            pdappAPI.tool.setScroll();
                    }, 100);
            } catch (t) {}
            setTimeout(() => {
                t.getRefreshToken();
            }, 6e4);
        },
        applyHotKeys() {
            let t = this;
            pdappAPI.hotkeys.init(function (e, o, a) {
                if (
                    ("move" == e &&
                        ("text" == o
                            ? t.moveText(a)
                            : "artwork" == o || "photo" == o || "qrcode" == o || "barcode" == o
                              ? t.movePhoto(a)
                              : "group" == o && t.moveGroup(a)),
                    "copy" == e &&
                        ("text" == o
                            ? t.copyText()
                            : "artwork" == o
                              ? t.copyArtwork()
                              : "photo" == o
                                ? t.copyPhoto()
                                : "qrcode" == o
                                  ? t.copyQrcode()
                                  : "barcode" == o
                                    ? t.copyBarcode()
                                    : "group" == o && t.copyGroup()),
                    "textStyle" == e && t.formatText(o),
                    "lock" == e &&
                        ("text" == o
                            ? t.lockText()
                            : ("artwork" == o || "photo" == o || "qrcode" == o || "barcode" == o) && t.lockPhoto()),
                    "flip" == e && ("text" == o ? t.flipText() : ("artwork" == o || "photo" == o) && t.flipPhoto()),
                    "del" == e &&
                        ("text" == o
                            ? t.deleteText()
                            : "artwork" == o
                              ? t.deleteArtwork()
                              : "photo" == o
                                ? t.deletePhoto()
                                : "qrcode" == o || "barcode" == o
                                  ? t.deleteQrcode()
                                  : "group" == o && t.deleteGroup()),
                    "selectAll" == e && t.selectAllGroup(),
                    "ruler" == e && t.toggleShowRuler(),
                    "preview" == e && t.previewScreen(),
                    "fullscreen" == e && t.toggleFullScreen(),
                    "reset" == e && t.resetAllDesign(),
                    "save" == e && t.openTempModal(""),
                    "zoom" == e && void 0 !== t.tempModal.data && void 0 !== t.tempModal.data.zoom)
                ) {
                    let e = parseInt(t.tempModal.data.zoom);
                    "up" == o
                        ? ((e += 5), e <= 295 && (t.tempModal.data.zoom = e + 5))
                        : ((e -= 5), e >= 15 && (t.tempModal.data.zoom = e - 5));
                }
                ("undo" != e && "redo" != e) || t.doHistory(e);
            });
        },
        resetAllDesign() {
            pdappAPI.tool.checkDesign() &&
                (this.tempModal.modal = {
                    show: !0,
                    header: !1,
                    size: "md modal-dialog-centered",
                    title: "",
                    type: "confirmReset",
                });
        },
        startReset() {
            pdappAPI.tool.resetDesign(),
                (this.photoStores = {}),
                (this.history = { active: -1, values: [] }),
                (this.menuOptions.childID = null),
                (this.groupItem.show = !1),
                (this.tempModal.modal.show = !1);
        },
        async showListTemps() {
            let t = this;
            if (((t.loadingPage = !0), void 0 === t.listTempsData[t.folderID])) {
                let e =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-temps&folder=" +
                    t.folderID +
                    "&admin=1&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let o = await pdappAPI.tool.getData(e);
                    t.listTempsData[t.folderID] = o.data;
                } catch (e) {
                    (t.toast = { show: !0, type: "warning", text: e.msg }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                }
            }
            let e = 0 != t.folderID ? "templates&folder=" + t.folderID : "templates";
            pdappAPI.tool.updateURL(e), (t.loadingPage = !1);
        },
        childFolders(t) {
            let e = 0;
            return void 0 !== this.listFolders[t] && (e = this.listFolders[t].length), e;
        },
        openFolder(t) {
            let e = this;
            (e.folderID = t.id), (e.tempOption.paged = 1), e.showListTemps(), (this.tempOption.folder = "");
        },
        editFolder(t) {
            t = "" == t ? { id: "", pid: this.folderID, title: {}, thumb: "" } : JSON.parse(JSON.stringify(t));
            for (let e in this.listLang.list) void 0 === t.title[e] && (t.title[e] = "Untitled");
            let e = "" == t.id ? this.langs.temp.create_folder : this.langs.temp.edit_folder;
            (this.modal = {
                show: !0,
                header: !0,
                size: "lg",
                title: e,
                type: "folder",
                data: t,
                saving: !1,
                langCode: this.listLang.default,
            }),
                (this.tempOption.folder = "");
        },
        editTemp(t) {
            let e = this,
                o = {
                    id: "",
                    pid: e.folderID,
                    title: {},
                    price: 0,
                    thumb: "",
                    size: { width: 900, height: 900, unit: "px" },
                    ratio: 1,
                    zoom: 100,
                    file: "",
                };
            "" != t &&
                ((o = JSON.parse(JSON.stringify(t))),
                (o.size = { width: parseFloat(o.size.width), height: parseFloat(o.size.height), unit: o.size.unit }),
                (o.ratio = 1),
                (o.zoom = 100),
                (o.file = ""));
            for (let t in e.listLang.list) void 0 === o.title[t] && (o.title[t] = "Untitled");
            (pdappAPI.tool.ruler.added = !1),
                (e.responsiveLayout = pdappAPI.tool.responsiveLayout()),
                (e.tempModal = {
                    show: !0,
                    type: "add",
                    data: "",
                    saving: !1,
                    modal: { show: !1, type: "", data: "" },
                    langCode: e.listLang.default,
                    unit: ["px", "cm", "in"],
                    loading: !0,
                }),
                setTimeout(() => {
                    (e.tempModal.loading = !1),
                        null == e.activeMenu &&
                            (e.activeMenu = pdappAPI.tool.getLocalVar("pdappActiveMenu", Object.keys(e.listMenus)[0])),
                        e.openMenu(e.activeMenu),
                        setTimeout(() => {
                            (e.tempModal.data = o),
                                setTimeout(() => {
                                    jQuery(".pdapp-viewport .moveable-control-box").length &&
                                        jQuery(".pdapp-viewport .moveable-control-box").remove(),
                                        pdappAPI.tool.enableMoveAble(
                                            function (t) {
                                                let o = jQuery(t);
                                                if (o.hasClass("pdapp-svg-text")) {
                                                    let t = o.find("text").attr("font-size"),
                                                        a = pdappAPI.tool.getTransform(o);
                                                    if ("" != a) {
                                                        let o = a
                                                            .replace("matrix(", "")
                                                            .replace(")", "")
                                                            .replaceAll(" ", "")
                                                            .split(",");
                                                        if (6 == o.length) {
                                                            let a = parseFloat(o[0]);
                                                            1 != a &&
                                                                ((t = Math.round(parseFloat(t) * a)),
                                                                (e.menuOptions.details[e.menuOptions.childID].fontSize =
                                                                    t));
                                                        }
                                                    }
                                                }
                                            },
                                            function (t) {
                                                e.activeLayer(t), pdappAPI.tool.removeControlBox();
                                            },
                                            function (t, o) {
                                                if (o.start != o.end) {
                                                    let a = {};
                                                    (a.undo = {
                                                        action: "updateTransform",
                                                        target: t.attr("id"),
                                                        value: o.start,
                                                    }),
                                                        (a.redo = {
                                                            action: "updateTransform",
                                                            target: t.attr("id"),
                                                            value: o.end,
                                                        }),
                                                        e.setHistory(a),
                                                        t.attr("transform", o.end),
                                                        t.removeAttr("style");
                                                }
                                            }
                                        ),
                                        "" != t && e.loadTemplate(t),
                                        pdappAPI.tool.setScroll();
                                }, 10);
                        }, 1);
                }, 1),
                void 0 === this.fontLibrary.fonts && e.loadListFonts();
        },
        closeModalTemp() {
            pdappAPI.tool.checkDesign()
                ? (this.tempModal.modal = { show: !0, type: "close", size: "md modal-dialog-centered", header: !1 })
                : (this.tempModal.show = !1);
        },
        async loadTemplate(t) {
            let e = this;
            if (void 0 === t.svg) {
                (e.loadingPage = !0),
                    (ajaxUrl =
                        pdappAdminUrl +
                        "admin-ajax.php?action=pdapp-temp&id=" +
                        t.id +
                        "&admin=1&pdapp-nonce=" +
                        pdappNonce);
                try {
                    (res = await pdappAPI.tool.getData(ajaxUrl)), (t.svg = res.data), (e.loadingPage = !1);
                } catch (t) {
                    return (
                        (e.loadingPage = !1),
                        (e.toast = { show: !0, type: "error", text: t.msg }),
                        setTimeout(() => {
                            e.toast.show = !1;
                        }, 5e3),
                        !1
                    );
                }
            }
            let o = new DOMParser().parseFromString(t.svg, "image/svg+xml");
            jQuery(o.documentElement)
                .find("g.pdapp-target")
                .each(function () {
                    let t = "pdapp-target-" + pdappAPI.tool.uID(),
                        e = jQuery(this);
                    if ((e.attr("id", t), e.removeClass("pdapp-active"), e.hasClass("pdapp-arc"))) {
                        let o = e.find("text").attr("font-size"),
                            a = e.find("text").attr("font-family"),
                            p = pdappAPI.tool.getTransform(e);
                        if ("" != p) {
                            let t = p.replace("matrix(", "").replace(")", "").replaceAll(" ", "").split(",");
                            if (6 == t.length) {
                                let e = parseFloat(t[0]);
                                1 != e && (o = Math.round(parseFloat(o) * e));
                            }
                        }
                        let i = e.attr("data-text").replaceAll(" ", "&nbsp;"),
                            l = document.createElement("div");
                        l.setAttribute(
                            "style",
                            "position:absolute;top:0px;left:0px;width:100%;height:100%;font-size:" +
                                o +
                                "px;font-family:" +
                                a +
                                ";"
                        ),
                            l.setAttribute("class", "pdapp-arc-elm " + t),
                            (l.innerHTML = i),
                            jQuery("#pdapp-viewer-area .pdapp-viewport .pdapp-viewport-area")
                                .find(".pdapp-text-arc")[0]
                                .append(l);
                        let s = e.attr("data-radius"),
                            d = new CircleType(l);
                        0 != s && d.radius(s),
                            e.hasClass("pdapp-dir") && d.dir(-1),
                            (pdappAPI.text.arc.pdappCircleType[t] = d);
                    }
                }),
                jQuery("#pdapp-viewer-area .pdapp-viewport .pdapp-viewport-area .pdapp-selecto-area").remove(),
                jQuery("#pdapp-viewer-area .pdapp-viewport .pdapp-viewport-area")[0].appendChild(o.documentElement);
        },
        async loadListFonts() {
            let t = this;
            ajaxUrl = pdappAdminUrl + "admin-ajax.php?action=pdapp-fonts&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let e = await pdappAPI.tool.getData(ajaxUrl);
                t.fontLibrary = e.data;
            } catch (t) {}
        },
        async saveModal() {
            let t = this;
            t.modal.saving = !0;
            for (let e in t.listLang.list)
                void 0 === t.modal.data.title[e] &&
                    (t.modal.data.title[e] =
                        "" != typeof t.modal.data.title[t.modal.langCode]
                            ? t.modal.data.title[t.modal.langCode]
                            : "Untitled");
            let e = void 0 !== t.modal.data.created ? t.modal.data.created : "",
                o = pdappAdminUrl + "admin-ajax.php?action=pdapp-save-temp&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let a = {
                        id: t.modal.data.id,
                        pid: t.modal.data.pid,
                        title: t.modal.data.title,
                        type: "folder",
                        thumb: t.modal.data.thumb,
                        created: e,
                    },
                    p = await pdappAPI.tool.postData(o, a);
                if ("" == t.modal.data.id)
                    void 0 === t.listFolders[t.folderID] && (t.listFolders[t.folderID] = []),
                        t.listFolders[t.folderID].push(p.data);
                else
                    for (let e = 0; e < t.listFolders[t.folderID].length; e++)
                        t.listFolders[t.folderID][e].id == t.modal.data.id && (t.listFolders[t.folderID][e] = p.data);
                (t.toast = { show: !0, type: "success", text: p.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3),
                    (t.modal.show = !1);
            } catch (e) {
                (t.toast = { show: !0, type: "warning", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.modal.saving = !1;
        },
        confirmMoveTemp(t, e) {
            let o = { id: 0, pid: 0, title: {} };
            for (let t in this.listLang.list) void 0 === o.title[t] && (o.title[t] = this.langs.menu.templates);
            let a = "temp" == e ? this.langs.temp.move_temp : this.langs.temp.move_folder;
            this.modal = {
                show: !0,
                header: !0,
                size: "md modal-dialog-scrollable",
                title: a,
                type: "move",
                data: { id: t, tid: this.folderID, confirm: e, breadcrumbs: [] },
                saving: !1,
            };
            let p = this;
            pdappAPI.folder.getFolderBreads(this.listFolders, o, this.folderID, function (t) {
                p.modal.data.breadcrumbs = t;
            }),
                (this.tempOption.folder = "");
        },
        openMove(t) {
            let e = { id: 0, pid: 0, title: {} };
            for (let t in this.listLang.list) void 0 === e.title[t] && (e.title[t] = this.langs.menu.templates);
            let o = this;
            pdappAPI.folder.getFolderBreads(this.listFolders, e, t.id, function (t) {
                o.modal.data.breadcrumbs = t;
            }),
                (o.modal.data.tid = t.id);
        },
        async moveTemp() {
            let t = this;
            t.modal.saving = !0;
            let e = { id: t.modal.data.id, pid: t.folderID, tid: t.modal.data.tid, type: t.modal.data.confirm },
                o = pdappAdminUrl + "admin-ajax.php?action=pdapp-move-temp&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let a = await pdappAPI.tool.postData(o, e);
                if ("temp" == t.modal.data.confirm) {
                    for (let e = 0; e < t.listDatas.temps.length; e++)
                        if (t.listDatas.temps[e].id == t.modal.data.id) {
                            let o = JSON.parse(JSON.stringify(t.listDatas.temps[e]));
                            t.listTempsData[t.folderID].splice(e, 1),
                                (o.pid = t.modal.data.tid),
                                void 0 !== t.listTempsData[t.modal.data.tid] &&
                                    t.listTempsData[t.modal.data.tid].push(o);
                        }
                } else
                    for (let e = 0; e < t.listDatas.folders.length; e++)
                        if (t.listDatas.folders[e].id == t.modal.data.id) {
                            let o = JSON.parse(JSON.stringify(t.listDatas.folders[e]));
                            t.listFolders[t.folderID].splice(e, 1),
                                (o.pid = t.modal.data.tid),
                                void 0 === t.listFolders[t.modal.data.tid] && (t.listFolders[t.modal.data.tid] = []),
                                t.listFolders[t.modal.data.tid].push(o);
                        }
                (t.toast = { show: !0, type: "success", text: a.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3),
                    (t.modal.show = !1);
            } catch (e) {
                (t.toast = { show: !0, type: "warning", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.modal.saving = !1;
        },
        confirmRemove(t, e) {
            (this.modal = {
                show: !0,
                header: !1,
                size: "md modal-dialog-centered",
                title: "",
                type: "message",
                data: {
                    id: t,
                    title: this.langs.msg.confirm_title,
                    text: this.langs.msg.confirm_data,
                    btn: this.langs.delete,
                    type: "warning",
                    confirm: e,
                },
            }),
                (this.tempOption.folder = "");
        },
        confirmEvt(t) {
            ("temp" != t && "folder" != t) || this.removeTemp(this.modal.data.id, t), (this.modal.show = !1);
        },
        async removeTemp(t, e) {
            let o = this,
                a = [];
            if ("" === t) {
                if ("folder" == e) return !1;
                if (0 == o.tempCheckboxs.length) return !1;
                for (let t = 0; t < o.listDatas.temps.length; t++)
                    o.tempCheckboxs.includes(o.listDatas.temps[t].id) &&
                        a.push({ id: o.listDatas.temps[t].id, pid: o.listDatas.temps[t].pid });
            } else a.push({ id: t, pid: o.folderID });
            o.loadingPage = !0;
            let p = pdappAdminUrl + "admin-ajax.php?action=pdapp-remove-temp&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let t = await pdappAPI.tool.postData(p, { data: a, type: e });
                if ("temp" == e) {
                    for (let e = o.listTempsData[o.folderID].length - 1; e >= 0; e--)
                        t.data.includes(parseInt(o.listTempsData[o.folderID][e].id)) &&
                            o.listTempsData[o.folderID].splice(e, 1);
                    (o.tempCheckbox = !1), (o.tempCheckboxs = []);
                } else {
                    let t =
                        pdappAdminUrl +
                        "admin-ajax.php?action=pdapp-load-setting&tempFolder=1&type=folder&admin=1&pdapp-nonce=" +
                        pdappNonce;
                    try {
                        let e = await pdappAPI.tool.getData(t);
                        o.listFolders = e.data;
                    } catch (t) {}
                    t =
                        pdappAdminUrl +
                        "admin-ajax.php?action=pdapp-temps&folder=" +
                        o.folderID +
                        "&admin=1&pdapp-nonce=" +
                        pdappNonce;
                    try {
                        let e = await pdappAPI.tool.getData(t);
                        o.listTempsData[o.folderID] = e.data;
                    } catch (t) {}
                }
                (o.toast = { show: !0, type: "success", text: t.msg }),
                    setTimeout(() => {
                        o.toast.show = !1;
                    }, 5e3);
            } catch (t) {
                (o.toast = { show: !0, type: "warning", text: t.msg }),
                    setTimeout(() => {
                        o.toast.show = !1;
                    }, 5e3);
            }
            o.loadingPage = !1;
        },
        async saveUpdate() {
            let t = this;
            if (0 == t.tempCheckboxs.length) return !1;
            let e = [];
            for (let o = 0; o < t.tempEdits.length; o++)
                t.tempCheckboxs.includes(t.tempEdits[o].id) &&
                    e.push({
                        id: t.tempEdits[o].id,
                        pid: t.tempEdits[o].pid,
                        title: t.tempEdits[o].title,
                        price: t.tempEdits[o].price,
                    });
            t.loadingPage = !0;
            let o = pdappAdminUrl + "admin-ajax.php?action=pdapp-update-temps&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let a = await pdappAPI.tool.postData(o, { data: e });
                for (let o = 0; o < t.listTempsData[t.folderID].length; o++)
                    if (a.data.includes(t.listTempsData[t.folderID][o].id))
                        for (let a = 0; a < e.length; a++)
                            e[a].id == t.listTempsData[t.folderID][o].id &&
                                ((t.listTempsData[t.folderID][o].title = e[a].title),
                                (t.listTempsData[t.folderID][o].price = e[a].price));
                (t.tempCheckbox = !1),
                    (t.tempCheckboxs = []),
                    (t.toast = { show: !0, type: "success", text: a.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            } catch (e) {
                (t.toast = { show: !0, type: "warning", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.loadingPage = !1;
        },
        checkAllTemp() {
            if (((this.tempCheckboxs = []), this.tempCheckbox))
                for (let t = 0; t < this.listTemps.length; t++) this.tempCheckboxs.push(this.listTemps[t].id);
        },
        convertDate: (t) => pdappAPI.tool.toDate(t),
        getTitle(t) {
            let e = "Untitled";
            if (null == t || "" == t) return e;
            if (void 0 !== t[pdappLangDefault] && "" != t[pdappLangDefault]) e = t[pdappLangDefault];
            else for (let o in t) "" != t[o] && (e = t[o]);
            return e;
        },
        showImg(t, e) {
            return void 0 === t || "" == t
                ? "temp" == e || "art" == e
                    ? this.pluginUrl + "assets/images/image.png"
                    : this.pluginUrl + "assets/images/folder.png"
                : (-1 == t.indexOf("base64,") &&
                      ("tempf" == e && (t = pdappUploadUrl + "thumbnails/templates/template-folder-" + t),
                      "artf" == e && (t = pdappUploadUrl + "thumbnails/arts/art-folder-" + t),
                      "temp" == e && (t = pdappUploadUrl + "thumbnails/templates/template-" + t),
                      "art" == e && (t = pdappUploadUrl + "thumbnails/arts/art-" + t)),
                  t);
        },
        changeThumbFile(t) {
            if (void 0 === t.target.files[0]) return !1;
            const e = t.target.files[0];
            let o = this;
            pdappAPI.tool.changeThumb(
                e,
                function (t) {
                    o.modal.data.thumb = t;
                },
                500
            );
        },
        previewScreen() {
            let t = this;
            (t.loadingPage = !0),
                setTimeout(() => {
                    (t.tempModal.modal = {
                        show: !0,
                        header: !0,
                        size: "lg modal-dialog-scrollable",
                        title: t.langs.temp.preview_title,
                        type: "preview",
                        data: "",
                    }),
                        pdappAPI.tool.previewScreen(t.photoStores, function (e) {
                            (t.loadingPage = !1), (t.tempModal.modal.data = e);
                        });
                });
        },
        updatePrintSize(t, e) {
            let o = this;
            void 0 !== o.tempModal &&
                void 0 !== o.tempModal.data &&
                (o.tempModal.data = pdappAPI.tool.updatePrintSize(t, e, o.tempModal.data));
        },
        toggleFullScreen() {
            let t = this;
            pdappAPI.tool.toggleFullScreen(function (e) {
                t.isFullScreen = e;
            });
        },
        setHistory(t) {
            this.history.values.length > 0 &&
                this.history.values.length - 1 != this.history.active &&
                void 0 !== this.history.values[this.history.active + 1] &&
                this.history.values.splice(this.history.active + 1),
                this.history.values.length > 50 && this.history.values.splice(0, 1),
                this.history.values.push(t),
                (this.history.active = this.history.values.length - 1),
                (this.history.undo = !0),
                (this.history.redo = !1);
        },
        doHistory(t) {
            let e = this;
            if (0 == this.history[t] || 0 == this.history.values.length) return !1;
            if (
                ((pdappAPI.tool.pdappMoveAbleRef.target = null),
                "redo" == t && (this.history.active = this.history.active + 1),
                void 0 !== this.history.values[this.history.active])
            ) {
                let o = this.history.values[this.history.active][t];
                null != e.menuOptions.childID &&
                    void 0 !== e.menuOptions.details[e.menuOptions.childID] &&
                    ((e.menuOptions.details[e.menuOptions.childID].dropdown = ""), (e.menuOptions.childID = null)),
                    setTimeout(() => {
                        void 0 !== pdappAPI.history[o.action] && pdappAPI.history[o.action](o);
                    }),
                    "createPhoto" == o.action && void 0 !== o.value.id && (e.photoStores[o.target] = o.value),
                    "cropPhoto" == o.action && void 0 !== o.value.width && (e.photoStores[o.target].crop = o.value),
                    "replacePhoto" == o.action && void 0 !== o.value.id && (e.photoStores[o.target] = o.value),
                    "deletePhoto" == o.action && void 0 !== e.photoStores[o.target] && delete e.photoStores[o.target],
                    ["createText", "changeFont", "deleteText", "addFilter", "deletePhoto"].includes(o.action) &&
                        setTimeout(() => {
                            e.setSvgStyle();
                        }, 100);
            }
            "undo" == t && (this.history.active = this.history.active - 1),
                this.history.active < 0 ? (this.history.undo = !1) : (this.history.undo = !0),
                this.history.values.length - 1 == this.history.active
                    ? (this.history.redo = !1)
                    : (this.history.redo = !0);
        },
        async getListShape() {
            let t = this;
            if (t.shapePhoto.length) return !1;
            let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-settings&shape=1&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                t.shapePhoto = o.data.shape;
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !1,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
            }
        },
        async getListFilter() {
            let t = this;
            if (t.filterPhoto.length) return !1;
            let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-settings&filter=1&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                t.filterPhoto = o.data.filter;
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !1,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
            }
        },
        async getListText() {
            let t = this;
            void 0 === t.listMenus.text.search &&
                ((t.listMenus.text.search = ""), (t.listMenus.text.page = { paged: 1, perpage: 20 })),
                (t.loadTextTemp = !0);
            let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-settings&text=1&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                t.listMenus.text.options.values = o.data.text;
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !1,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
            }
            (t.loadTextTemp = !1),
                setTimeout(() => {
                    pdappAPI.tool.loadMore(".pdapp-menu-options-text", function () {
                        t.listTextTemp.total > t.listTextTemp.temps.length && t.listMenus.text.page.paged++;
                    });
                }, 1);
        },
        openMenu(t) {
            let e = this;
            if (void 0 !== e.listMenus[t]) {
                if ("template" == t) {
                    let o = "";
                    for (let t in e.listMenus) "" == o && "template" != t && (o = t);
                    t = o;
                }
                if (
                    ((e.activeMenu = t),
                    pdappAPI.tool.setLocalVar("pdappActiveMenuTemp", t),
                    (e.groupItem.show = !1),
                    pdappAPI.layer.unselect(),
                    "text" == t)
                )
                    return (
                        0 == e.listMenus.text.options.values.length
                            ? e.getListText()
                            : setTimeout(() => {
                                  pdappAPI.tool.loadMore(".pdapp-menu-options-text", function () {
                                      e.listTextTemp.total > e.listTextTemp.temps.length &&
                                          e.listMenus.text.page.paged++;
                                  });
                              }, 1),
                        (e.listMenus.text.options.childID = null),
                        !1
                    );
                if ("artwork" == t)
                    return (
                        (e.listMenus.artwork.options.childID = null),
                        void 0 === e.artFolders[0]
                            ? e.getArtFolders()
                            : setTimeout(() => {
                                  pdappAPI.tool.loadMore(".pdapp-menu-options-artwork", function () {
                                      e.listArtworks.total > e.listArtworks.arts.length &&
                                          e.listMenus.artwork.options.values.page.paged++;
                                  });
                              }, 1),
                        !1
                    );
                if ("photo" == t)
                    return (
                        (e.listMenus.photo.options.childID = null),
                        e.getListShape(),
                        e.getListFilter(),
                        0 == e.listMenus.photo.options.values.length
                            ? e.getPhotos()
                            : setTimeout(() => {
                                  pdappAPI.tool.loadMore(".pdapp-photo-libraries", function () {
                                      e.getPhotos();
                                  });
                              }, 1),
                        !1
                    );
                if ("barcode" == t) {
                    e.listMenus.barcode.options.childID = null;
                    let t = e.settings.general.barcode.font,
                        o = t.replaceAll(" ", "+");
                    return (
                        void 0 === e.loadedFonts[o] && e.selectFont({ title: t, variants: ["700"], category: "" }),
                        (e.listMenus.barcode.options.values = []),
                        !1
                    );
                }
                if ("layer" == t)
                    return (
                        (e.listMenus.layer.options.childID = null),
                        (e.listMenus.layer.options.values = pdappAPI.layer.loadLayers()),
                        !1
                    );
            }
        },
        addNewText(t) {
            let e = this;
            (e.loadingPage = !0),
                pdappAPI.text.create(t, function (t, o) {
                    e.selectFont(
                        { title: o.fontFamily, variants: ["700"], category: "" },
                        function () {
                            e.loadingPage = !1;
                            let o = t.attr("id");
                            pdappAPI.layer.afterAdded(o), e.activeLayer(t);
                            let a = {};
                            (a.undo = { action: "deleteText", target: o }),
                                (a.redo = {
                                    action: "createText",
                                    target: o,
                                    index: pdappAPI.history.getIndex(t),
                                    value: "",
                                    svg: t.clone(),
                                    arc: pdappAPI.history.getTextArc(t),
                                    gradient: {},
                                }),
                                e.setHistory(a);
                        },
                        t
                    );
                });
        },
        addTextTemplate(t) {
            let e = this;
            (e.loadingPage = !0),
                pdappAPI.text.create(t, function (t, o) {
                    e.selectFont(
                        { title: o.fontFamily, variants: ["700"], category: "" },
                        function () {
                            e.loadingPage = !1;
                            let o = t.attr("id");
                            pdappAPI.layer.afterAdded(o), e.activeLayer(t);
                            let a = {};
                            (a.undo = { action: "deleteText", target: o }),
                                (a.redo = {
                                    action: "createText",
                                    target: o,
                                    index: pdappAPI.history.getIndex(t),
                                    value: "",
                                    svg: t.clone(),
                                    arc: pdappAPI.history.getTextArc(t),
                                    gradient: {},
                                }),
                                e.setHistory(a);
                        },
                        t
                    );
                });
        },
        updateText() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = t.menuOptions.details[t.menuOptions.childID].text;
            void 0 !== t.settings.general.text &&
                t.settings.general.text.emoji &&
                ((e = pdappAPI.tool.removeEmoij(e)), (t.menuOptions.details[t.menuOptions.childID].text = e));
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
            e.length < 1 &&
                ((t.menuOptions.details[t.menuOptions.childID].text = o.attr("data-text").substring(0, 1)),
                (e = t.menuOptions.details[t.menuOptions.childID].text));
            let a = pdappAPI.history.getTextArc(o),
                p = "" != a ? o.clone() : "",
                i = {};
            (i.undo = {
                action: "updateText",
                target: o.attr("id"),
                value: o.attr("data-text"),
                transform: pdappAPI.tool.getTransform(o),
                svg: p,
                arc: a,
            }),
                pdappAPI.text.updateText(e, function () {
                    (o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target)),
                        "" != a && (a = pdappAPI.history.getTextArc(o)),
                        (p = "" != a ? o.clone() : ""),
                        (i.redo = {
                            action: "updateText",
                            target: o.attr("id"),
                            value: e,
                            transform: pdappAPI.tool.getTransform(o),
                            svg: p,
                            arc: a,
                        }),
                        t.setHistory(i);
                });
        },
        changeFont(t) {
            if (
                ((self = this),
                null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
            )
                return !1;
            self.loadingPage = !0;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = pdappAPI.history.getTextArc(e),
                a = "" != o ? e.clone() : "",
                p = {};
            (p.undo = {
                action: "changeFont",
                target: e.attr("id"),
                value: e.find("text").attr("font-family"),
                transform: pdappAPI.tool.getTransform(e),
                svg: a,
                arc: o,
            }),
                self.selectFont(
                    t,
                    function () {
                        (self.loadingPage = !1),
                            0 == self.addedFonts.includes(t.title) && self.addedFonts.push(t.title),
                            (a = "" != o ? e.clone() : ""),
                            (p.redo = {
                                action: "changeFont",
                                target: e.attr("id"),
                                value: t.title,
                                transform: pdappAPI.tool.getTransform(e),
                                svg: a,
                                arc: o,
                            }),
                            self.setHistory(p);
                    },
                    e
                );
        },
        selectFont(t, e, o) {
            let a = this,
                p = t.title.replaceAll(" ", "+");
            if (void 0 === a.loadedFonts[p])
                pdappAPI.tool.loadFontData(t.title, function (i) {
                    (a.loadedFonts[p] = i),
                        pdappAPI.tool.loadFontFace(t.title, i, function () {
                            "function" == typeof e && e(o),
                                setTimeout(() => {
                                    a.setSvgStyle();
                                }, 10);
                        });
                });
            else if (void 0 !== o) {
                let p = a.addedFonts.includes(t.title) ? 20 : 200;
                pdappAPI.text.changeFont(
                    t.title,
                    p,
                    function () {
                        200 == p && a.addedFonts.push(t.title),
                            "function" == typeof e && e(o),
                            setTimeout(() => {
                                a.setSvgStyle();
                            }, 10);
                    },
                    o
                );
            } else "function" == typeof e && e(o);
            null != a.activeMenu &&
                void 0 !== a.listMenus[a.activeMenu].options.details &&
                void 0 !== a.listMenus[a.activeMenu].options.details[a.menuOptions.childID] &&
                (a.listMenus[a.activeMenu].options.details[a.menuOptions.childID].fontFamily = t.title);
        },
        updateTextSize(t) {
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            "" == t
                ? (t = this.menuOptions.details[this.menuOptions.childID].fontSize)
                : (this.menuOptions.details[this.menuOptions.childID].fontSize = t);
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = pdappAPI.history.getTextArc(e),
                a = "" != o ? e.clone() : "",
                p = {};
            p.undo = {
                action: "textSize",
                target: e.attr("id"),
                value: e.find("text").attr("font-size"),
                transform: pdappAPI.tool.getTransform(e),
                svg: a,
                arc: o,
            };
            let i = this;
            pdappAPI.text.setSize(t, function () {
                (a = "" != o ? e.clone() : ""),
                    "" != o && (o = pdappAPI.history.getTextArc(e)),
                    (p.redo = {
                        action: "textSize",
                        target: e.attr("id"),
                        value: t,
                        transform: pdappAPI.tool.getTransform(e),
                        svg: a,
                        arc: o,
                    }),
                    i.setHistory(p);
            });
        },
        formatText(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = JSON.parse(JSON.stringify(e.menuOptions.details[e.menuOptions.childID])),
                p = pdappAPI.history.getFormatText(o, a, t),
                i = p.res;
            pdappAPI.text.formatText(t, e.menuOptions.details[e.menuOptions.childID], function (t, a) {
                e.menuOptions.details[e.menuOptions.childID][t] = a;
                let l = "" != i.arc ? pdappAPI.history.getTextArc(o) : "",
                    s = "" != i.arc ? o.clone() : "",
                    d = {};
                (d.undo = { action: "formatText", target: o.attr("id"), value: i, svg: p.svg }),
                    (d.redo = {
                        action: "formatText",
                        target: o.attr("id"),
                        value: { key: t, value: a, arc: l },
                        svg: s,
                    }),
                    e.setHistory(d);
            });
        },
        dropdownText(t) {
            let e = this;
            if (e.menuOptions.details[e.menuOptions.childID].dropdown == t)
                return (e.menuOptions.details[e.menuOptions.childID].dropdown = ""), !1;
            (e.menuOptions.details[e.menuOptions.childID].dropdown = t),
                "color" == t &&
                    setTimeout(() => {
                        pdappAPI.tool.colorPicker("#pdapp-text-colorpicker", e.langs.options, function (t, o) {
                            (e.menuOptions.details[e.menuOptions.childID].color = o), e.updateTextStyle("color");
                        });
                    }, 1),
                "outline" == t &&
                    setTimeout(() => {
                        pdappAPI.tool.colorPicker("#pdapp-outline-colorpicker", e.langs.options, function (t, o) {
                            (e.menuOptions.details[e.menuOptions.childID].stroke = o), e.updateTextStyle("outline");
                        });
                    }, 1),
                "font" == t &&
                    void 0 !== e.fontLibrary.page &&
                    setTimeout(() => {
                        pdappAPI.tool.loadMore(".pdapp-font-list", function () {
                            e.listFonts.total > e.listFonts.fonts.length && e.fontLibrary.page.paged++;
                        });
                    }, 1);
        },
        closeTextDropdown() {
            this.menuOptions.details[this.menuOptions.childID].dropdown = "";
        },
        updateTextStyle(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = pdappAPI.history.getTextStyle(t),
                p = {};
            p.undo = { action: "updateTextStyle", target: o.attr("id"), value: a };
            let i = { type: t, value: "", arc: "" },
                l = "";
            "outline" == t
                ? ((value = {
                      stroke: e.menuOptions.details[e.menuOptions.childID].stroke,
                      strokeWidth: e.menuOptions.details[e.menuOptions.childID].strokeWidth,
                  }),
                  pdappAPI.text.updateTextStyle(t, value, function () {
                      (i.arc = "" != a.arc ? pdappAPI.history.getTextArc(o) : ""),
                          (i.value = value),
                          (p.redo = { action: "updateTextStyle", target: o.attr("id"), value: i, svg: l }),
                          e.setHistory(p);
                  }))
                : void 0 !== e.menuOptions.details[e.menuOptions.childID][t] &&
                  pdappAPI.text.updateTextStyle(t, e.menuOptions.details[e.menuOptions.childID][t], function (s) {
                      (i.arc = "" != a.arc ? pdappAPI.history.getTextArc(o) : ""),
                          (i.value = s),
                          "" == a.arc || ("radius" != t && "letterSpacing" != t) || (l = o.clone()),
                          (p.redo = { action: "updateTextStyle", target: o.attr("id"), value: i, svg: l }),
                          e.setHistory(p);
                  });
        },
        alignText(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = {};
            (p.undo = { action: "updateTransform", target: a, value: pdappAPI.tool.getTransform(o) }),
                pdappAPI.text.alignText(t),
                setTimeout(() => {
                    (p.redo = { action: "updateTransform", target: a, value: pdappAPI.tool.getTransform(o) }),
                        e.setHistory(p);
                });
        },
        moveText(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = {};
            (p.undo = { action: "updateTransform", target: a, value: pdappAPI.tool.getTransform(o) }),
                pdappAPI.text.moveText(t),
                setTimeout(() => {
                    (p.redo = { action: "updateTransform", target: a, value: pdappAPI.tool.getTransform(o) }),
                        e.setHistory(p);
                });
        },
        gradientText(t) {
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o =
                    void 0 !== e.attr("data-gradient") && "" != e.attr("data-gradient")
                        ? e.attr("data-gradient").split("-")[0]
                        : "normal",
                a =
                    void 0 !== e.attr("data-gradient") && "" != e.attr("data-gradient")
                        ? "#" + e.attr("data-gradient").split("-").pop()
                        : e.attr("fill"),
                p = {};
            (p.undo = { action: "textGradient", target: e.attr("id"), value: { color: a, type: o } }),
                pdappAPI.text.gradient(t, this.menuOptions.details[this.menuOptions.childID].color),
                (this.menuOptions.details[this.menuOptions.childID].colorType = t),
                (p.redo = {
                    action: "textGradient",
                    target: e.attr("id"),
                    value: { color: this.menuOptions.details[this.menuOptions.childID].color, type: t },
                }),
                this.setHistory(p);
        },
        deleteText() {
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let t = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                e = this,
                o = {};
            void 0 !== t.attr("data-gradient") &&
                "" != t.attr("data-gradient") &&
                ((o.type = t.attr("data-gradient").split("-")[0]),
                (o.color = t.attr("data-gradient").split("-").pop()));
            let a = {};
            (a.undo = {
                action: "createText",
                target: t.attr("id"),
                index: pdappAPI.history.getIndex(t),
                value: "",
                svg: t.clone(),
                arc: pdappAPI.history.getTextArc(t),
                gradient: o,
            }),
                pdappAPI.text.delete(function (t) {
                    e.menuOptions.details.splice(e.menuOptions.childID, 1),
                        (e.menuOptions.childID = null),
                        setTimeout(() => {
                            e.setSvgStyle();
                        }, 1),
                        (a.redo = { action: "deleteText", target: t }),
                        e.setHistory(a);
                });
        },
        lockText() {
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let t = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                e = this,
                o = {};
            (o.undo = { action: "lockText", target: t.attr("id"), value: t.hasClass("pdapp-lock") }),
                pdappAPI.text.lock(e.menuOptions.details[e.menuOptions.childID].textLock, function (a) {
                    (e.menuOptions.details[e.menuOptions.childID].textLock = a),
                        e.closeTextDropdown(),
                        (o.redo = { action: "lockText", target: t.attr("id"), value: a }),
                        e.setHistory(o);
                });
        },
        copyText() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            pdappAPI.text.copy(t.langs.options, function (e) {
                t.activeLayer(e),
                    (t.toast = { show: !0, type: "success", text: t.langs.options.copy_text_success }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
                let o = {};
                void 0 !== e.attr("data-gradient") &&
                    "" != e.attr("data-gradient") &&
                    ((o.type = e.attr("data-gradient").split("-")[0]),
                    (o.color = e.attr("data-gradient").split("-").pop()));
                let a = {};
                (a.undo = { action: "deleteText", target: e.attr("id") }),
                    (a.redo = {
                        action: "createText",
                        target: e.attr("id"),
                        index: pdappAPI.history.getIndex(e),
                        svg: e.clone(),
                        arc: pdappAPI.history.getTextArc(e),
                        gradient: o,
                    }),
                    t.setHistory(a);
            });
        },
        flipText() {
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let t = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                e = this,
                o = pdappAPI.history.getTextArc(t),
                a = "" != o ? t.clone() : "",
                p = {};
            (p.undo = {
                action: "flipText",
                target: t.attr("id"),
                flip: t.hasClass("pdapp-flip"),
                value: t.attr("data-text"),
                svg: a,
                arc: o,
            }),
                pdappAPI.text.flip(e.menuOptions.details[e.menuOptions.childID].textFlip, function (i) {
                    (e.menuOptions.details[e.menuOptions.childID].textFlip = i),
                        (t = jQuery(pdappAPI.tool.pdappMoveAbleRef.target)),
                        "" != o && (o = pdappAPI.history.getTextArc(t)),
                        (a = "" != o ? t.clone() : ""),
                        (p.redo = {
                            action: "flipText",
                            target: t.attr("id"),
                            flip: i,
                            value: t.attr("data-text"),
                            svg: a,
                            arc: o,
                        }),
                        e.setHistory(p);
                });
        },
        async getArtFolders() {
            let t = this;
            t.listMenus.artwork.options.values = {
                activeFolder: 0,
                loadFolder: !0,
                loadArt: !1,
                search: "",
                page: { paged: 1, perpage: 20 },
            };
            let e = pdappAdminUrl + "admin-ajax.php?action=pdapp-art-folders&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let o = await pdappAPI.tool.getData(e);
                (t.artFolders = o.data), (t.breadcrs = []);
                let a = { to: "", title: {} };
                for (let e in this.listLang.list) void 0 === a.title[e] && (a.title[e] = t.langs.options.root);
                t.breadcrs.push(a), t.getArtworks(0);
            } catch (e) {
                if (-1 == e.error)
                    return (
                        (t.modal = {
                            show: !1,
                            header: !1,
                            size: "md modal-dialog-centered",
                            title: "",
                            type: "confirmReload",
                        }),
                        !1
                    );
                (t.toast = { show: !0, type: "error", text: e.msg }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
            }
            t.listMenus.artwork.options.values.loadFolder = !1;
        },
        openArtFolder(t) {
            let e = this;
            e.listMenus[e.activeMenu].options.values.activeFolder = t;
            let o = [];
            e.getArtworks(t),
                (o = e.artFolders),
                (e.listMenus.artwork.options.values.page.paged = 1),
                (e.breadcrs = []);
            let a = { id: 0, pid: 0, title: {} };
            for (let t in this.listLang.list) void 0 === a.title[t] && (a.title[t] = e.langs.options.root);
            pdappAPI.folder.getFolderBreads(o, a, t, function (o) {
                for (let a = 0; a < o.length; a++) {
                    let p = o[a].id == t ? "" : o[a].id;
                    e.breadcrs.push({ to: p, title: o[a].title });
                }
            });
        },
        async getArtworks(t) {
            let e = this;
            if (void 0 === e.artworks[t]) {
                e.listMenus.artwork.options.values.loadArt = !0;
                let o =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-arts&folder=" +
                    t +
                    "&admin=1&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let a = await pdappAPI.tool.getData(o);
                    e.artworks[t] = a.data;
                } catch (t) {
                    if (-1 == t.error)
                        return (
                            (e.modal = {
                                show: !1,
                                header: !1,
                                size: "md modal-dialog-centered",
                                title: "",
                                type: "confirmReload",
                            }),
                            !1
                        );
                    (e.toast = { show: !0, type: "error", text: t.msg }),
                        setTimeout(() => {
                            e.toast.show = !1;
                        }, 5e3);
                }
                (e.listMenus.artwork.options.values.loadArt = !1),
                    setTimeout(() => {
                        pdappAPI.tool.loadMore(".pdapp-menu-options-artwork", function () {
                            e.listArtworks.total > e.listArtworks.arts.length &&
                                e.listMenus.artwork.options.values.page.paged++;
                        });
                    }, 1);
            }
        },
        updateColor(t, e) {
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            if (t != e) {
                let o = this,
                    a = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                    p = [];
                if (o.groupItem.show && a.length > 1) {
                    for (let o = 0; o < a.length; o++) {
                        let i = jQuery(a[o]);
                        if (void 0 === i.attr("data-color") || i.hasClass("pdapp-svg")) {
                            void 0 !== i.attr("fill") && i.attr("fill", i.attr("fill").replaceAll(t, e)),
                                void 0 !== i.attr("data-color") &&
                                    i.attr("data-color", i.attr("data-color").replaceAll(t, e)),
                                void 0 !== i.attr("data-background") &&
                                    i.attr("data-background", i.attr("data-background").replaceAll(t, e)),
                                (a[o].innerHTML = a[o].innerHTML.replaceAll(t, e));
                            let l = i.attr("id");
                            p.push(l);
                        }
                    }
                    for (let a = 0; a < o.groupItem.colors.length; a++)
                        o.groupItem.colors[a] == t && (o.groupItem.colors[a] = e);
                } else if (void 0 !== a[0]) {
                    let i = jQuery(a[0]);
                    void 0 !== i.attr("fill") && i.attr("fill", i.attr("fill").replaceAll(t, e)),
                        void 0 !== i.attr("data-color") && i.attr("data-color", i.attr("data-color").replaceAll(t, e)),
                        void 0 !== i.attr("data-background") &&
                            i.attr("data-background", i.attr("data-background").replaceAll(t, e)),
                        (a[0].innerHTML = a[0].innerHTML.replaceAll(t, e));
                    for (let a = 0; a < o.menuOptions.details[o.menuOptions.childID].colors.length; a++)
                        o.menuOptions.details[o.menuOptions.childID].colors[a] == t &&
                            (o.menuOptions.details[o.menuOptions.childID].colors[a] = e);
                    let l = i.attr("id");
                    p.push(l);
                }
                let i = {};
                (i.undo = { action: "updateColor", target: p, value: { old: e, new: t } }),
                    (i.redo = { action: "updateColor", target: p, value: { old: t, new: e } }),
                    o.setHistory(i);
            }
        },
        async addArtwork(t) {
            let e = this;
            (e.waitDesign = !0), (e.listMenus.artwork.options.values.loadArt = t.id);
            let o = "artwork-" + t.id,
                a = "";
            void 0 !== e.photoStores[o] && (a = e.photoStores[o]);
            let p = "pdapp-target-" + pdappAPI.tool.uID();
            if ("" == a && void 0 === t.artFile) {
                let o =
                    pdappAdminUrl +
                    "admin-ajax.php?action=pdapp-artwork&id=" +
                    t.id +
                    "&type=" +
                    t.filetype +
                    "&admin=1&pdapp-nonce=" +
                    pdappNonce;
                try {
                    let e = await pdappAPI.tool.getData(o);
                    t.artFile = e.data;
                } catch (t) {
                    return -1 == t.error
                        ? ((e.modal = {
                              show: !1,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "confirmReload",
                          }),
                          !1)
                        : ((e.toast = { show: !0, type: "error", text: t.msg }),
                          setTimeout(() => {
                              e.toast.show = !1;
                          }, 5e3),
                          (e.listMenus.artwork.options.values.loadArt = !1),
                          (e.waitDesign = !1),
                          !1);
                }
            }
            "" == a && (a = t),
                pdappAPI.artwork.create(
                    a,
                    t.filetype,
                    function (a, p) {
                        (e.waitDesign = !1), e.activeLayer(a);
                        let i = a.attr("id");
                        a.attr("data-artid", t.id);
                        let l = "";
                        "svg" != t.filetype &&
                            void 0 !== p &&
                            ((l = { id: o, crop: "" }),
                            (e.photoStores[i] = l),
                            void 0 === e.photoStores[o] && (e.photoStores[o] = p)),
                            setTimeout(() => {
                                pdappAPI.photo.fitPhotoInside();
                                let t = {};
                                (t.undo = { action: "deletePhoto", target: i }),
                                    (t.redo = {
                                        action: "createPhoto",
                                        target: i,
                                        index: pdappAPI.history.getIndex(a),
                                        value: l,
                                        svg: a.clone(),
                                    }),
                                    e.setHistory(t),
                                    (e.listMenus.artwork.options.values.loadArt = !1);
                            }, 2);
                    },
                    p
                );
        },
        copyArtwork() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                o = {};
            (o.undo = { action: "deletePhoto", target: e }),
                pdappAPI.artwork.copy(t.langs.options, function (a) {
                    t.activeLayer(a);
                    let p = void 0 !== t.photoStores[e] ? t.photoStores[e] : "";
                    (o.redo = {
                        action: "createPhoto",
                        target: a.attr("id"),
                        index: pdappAPI.history.getIndex(a),
                        value: p,
                        svg: a.clone(),
                    }),
                        t.setHistory(o),
                        (t.toast = { show: !0, type: "success", text: t.langs.options.copy_artwork_success }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                });
        },
        deleteArtwork() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = void 0 !== t.photoStores[o] ? t.photoStores[o] : "",
                p = {};
            (p.undo = {
                action: "createPhoto",
                target: o,
                index: pdappAPI.history.getIndex(e),
                value: a,
                svg: e.clone(),
            }),
                pdappAPI.photo.delete(function (e) {
                    t.menuOptions.details.splice(t.menuOptions.childID, 1),
                        (t.menuOptions.childID = null),
                        void 0 !== t.photoStores[e] && delete t.photoStores[e],
                        (p.redo = { action: "deletePhoto", target: e }),
                        t.setHistory(p);
                });
        },
        changePhoto(t) {
            let e = this;
            if (void 0 === t.target.files[0]) return !1;
            const o = t.target.files[0];
            let a = pdappAPI.upload.verify(o, e.settings, e.langs);
            if ("" === a) return e.startUploadPhoto(o), jQuery("#pdapp-upload-a-photo").val(""), !1;
            (e.toast = { show: !0, type: "error", text: a }),
                setTimeout(() => {
                    e.toast.show = !1;
                }, 5e3);
        },
        startUploadPhoto(t) {
            let e = this;
            (e.uploading = !0), (e.loadingPage = !0), (e.waitDesign = !0);
            let o = "pdapp-target-" + pdappAPI.tool.uID();
            if ("image/svg+xml" == t.type)
                pdappAPI.upload.readFile(t, function (t) {
                    let a = t.split("base64,"),
                        p = pdappAPI.tool.decodeBase64(a[1]);
                    pdappAPI.photo.create(
                        p,
                        function (t) {
                            (e.uploading = !1),
                                (e.loadingPage = !1),
                                (e.waitDesign = !1),
                                e.activeLayer(t),
                                setTimeout(() => {
                                    pdappAPI.photo.fitPhotoInside();
                                    let a = {};
                                    (a.undo = { action: "deletePhoto", target: o }),
                                        (a.redo = {
                                            action: "createPhoto",
                                            target: o,
                                            index: pdappAPI.history.getIndex(t),
                                            value: "",
                                            svg: t.clone(),
                                        }),
                                        e.setHistory(a),
                                        "photo" == e.activeMenu && (e.listMenus.photo.options.values.loadArt = !1);
                                }, 10);
                        },
                        o,
                        "svg"
                    );
                });
            else {
                let o = "file-" + t.lastModified + "-" + t.size;
                if (void 0 !== e.photoStores[o]) {
                    let t = e.photoStores[o];
                    e.createPhoto(t, o);
                } else
                    (e.photoStores[o] = {}),
                        pdappAPI.photo.readMediumImage(
                            t,
                            function (a) {
                                (e.photoStores[o] = a), e.uploadImage(o, t), e.createPhoto(a, o);
                            },
                            0.85
                        );
            }
        },
        async uploadImage(t, e) {
            let o = this;
            pdappWorker
                ? pdappWorker.postMessage({ id: t, action: "toBase64", type: "origBase64", value: e })
                : pdappAPI.upload.readFile(e, function (e) {
                      -1 != e.indexOf(";base64,") && (o.photoStores[t].origBase64 = e);
                  });
        },
        getPhotos() {
            let t = this;
            void 0 !== t.settings.general.photo &&
                void 0 !== t.settings.general.photo.library &&
                ((t.listMenus.photo.loading = 1),
                pdappAPI.photo.getPhotos(t.settings.general.photo, t.listMenus.photo, function (e) {
                    if (1 == t.listMenus.photo.page)
                        (t.listMenus.photo.options.values = e), jQuery(".pdapp-photo-libraries").scrollTop(0);
                    else for (let o = 0; o < e.length; o++) t.listMenus.photo.options.values.push(e[o]);
                    (t.listMenus.photo.loading = 0),
                        (t.listMenus.photo.page = parseInt(t.listMenus.photo.page) + 1),
                        setTimeout(() => {
                            pdappAPI.tool.loadMore(".pdapp-photo-libraries", function () {
                                t.getPhotos();
                            });
                        }, 1);
                }));
        },
        findPhotos() {
            (this.listMenus.photo.page = 1), this.getPhotos();
        },
        addPhoto(t) {
            let e = this;
            if (
                ((e.loadingPage = !0),
                (e.waitDesign = !0),
                (e.listMenus.photo.loading = 1),
                void 0 !== e.photoStores[t.id])
            ) {
                let o = e.photoStores[t.id];
                e.createPhoto(o, t.id);
            } else {
                e.photoStores[t.id] = {};
                let o = { id: t.id, action: "getPhoto", type: "blob", value: t.regular };
                pdappWorker
                    ? pdappWorker.postMessage(o)
                    : pdappAPI.photo.getPhoto(t.regular, function (t) {
                          (o.value = t), e.actionWorker(o);
                      }),
                    setTimeout(() => {
                        e.loadOriginPhoto(t.id, t.url, "getPhoto");
                    }, 10);
            }
        },
        createPhoto(t, e) {
            let o = this,
                a = "pdapp-target-" + pdappAPI.tool.uID();
            pdappAPI.photo.create(
                t,
                function (t) {
                    (o.loadingPage = !1),
                        (o.waitDesign = !1),
                        (o.uploading = !1),
                        (o.listMenus.photo.loading = 0),
                        o.activeLayer(t),
                        setTimeout(() => {
                            pdappAPI.photo.fitPhotoInside(), (o.photoStores[a] = { id: e, crop: "" });
                            let p = o.history.values.length,
                                i = {};
                            (i.undo = { action: "deletePhoto", target: a }),
                                (i.redo = {
                                    action: "createPhoto",
                                    target: a,
                                    index: pdappAPI.history.getIndex(t),
                                    value: o.photoStores[a],
                                    svg: t.clone(),
                                }),
                                o.setHistory(i),
                                o.dropdownPhoto("crop", p);
                        }, 10);
                },
                a,
                t.color
            );
        },
        loadOriginPhoto(t, e, o) {
            let a = this,
                p = { id: t, action: o, type: "origBase64", value: e };
            pdappWorker
                ? pdappWorker.postMessage(p)
                : pdappAPI.photo.getPhoto(e, function (t) {
                      (p.value = t), a.actionWorker(p);
                  });
        },
        closePhotoDropdown() {
            this.menuOptions.details[this.menuOptions.childID].dropdown = "";
        },
        dropdownPhoto(t, e, o) {
            let a = this;
            if (a.menuOptions.details[a.menuOptions.childID].dropdown == t)
                return (a.menuOptions.details[a.menuOptions.childID].dropdown = ""), !1;
            if ("crop" == t) {
                let t = void 0 !== o && "replace" == o,
                    p = pdappAPI.photo.getCrop(t);
                return (
                    (a.tempModal.modal = {
                        show: !0,
                        header: !0,
                        size: "full-width",
                        title: a.langs.options.crop_photo,
                        type: "crop",
                        data: p,
                        hisID: e,
                        replace: t,
                    }),
                    t ||
                        void 0 === a.photoStores[p.id] ||
                        "" == a.photoStores[p.id].crop ||
                        (a.tempModal.modal.data = a.photoStores[p.id].crop),
                    !1
                );
            }
            "color" == t &&
                a.menuOptions.details[a.menuOptions.childID].editColor &&
                a.menuOptions.details[a.menuOptions.childID].colors.length &&
                setTimeout(() => {
                    pdappAPI.tool.colorPicker(".pdapp-edit-color", a.langs.options, function (t, e) {
                        (oldcolor = jQuery(t).attr("data-color")), a.updateColor(oldcolor, e);
                    });
                }, 1),
                (a.menuOptions.details[a.menuOptions.childID].dropdown = t);
        },
        useOriginPhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id");
            if (
                void 0 !== t.photoStores[o] &&
                "" != t.photoStores[o].crop &&
                void 0 !== t.photoStores[t.photoStores[o].id]
            ) {
                let a = {};
                (a.undo = {
                    action: "cropPhoto",
                    target: o,
                    value: t.photoStores[o].crop,
                    svg: jQuery("#" + o).clone(),
                }),
                    pdappAPI.photo.originPhoto(e, t.photoStores[t.photoStores[o].id], function (e) {
                        (t.menuOptions.details[t.menuOptions.childID].photo = e),
                            (t.photoStores[o].crop = ""),
                            (a.redo = { action: "cropPhoto", target: o, value: "", svg: jQuery("#" + o).clone() }),
                            t.setHistory(a);
                    });
            }
            t.tempModal.modal.show = !1;
        },
        cropPhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id");
            if (void 0 === t.photoStores[e]) return !1;
            (t.loadingPage = !0), (t.waitDesign = !0);
            let o = void 0 !== t.photoStores[e].crop ? t.photoStores[e].crop : "",
                a = {},
                p = t.tempModal.modal.hisID;
            "" === p && (a.undo = { action: "cropPhoto", target: e, value: o, svg: jQuery("#" + e).clone() }),
                pdappAPI.photo.crop(t.shapePhoto, t.tempModal.modal.replace, function (o, i) {
                    if (((t.loadingPage = !1), (t.waitDesign = !1), void 0 === o.blob || "" == o.blob)) return !1;
                    (t.tempModal.modal.show = !1),
                        (t.menuOptions.details[t.menuOptions.childID].photo = o.blob),
                        (t.photoStores[e].crop = o),
                        "" === p
                            ? ((a.redo = { action: "cropPhoto", target: i, value: o, svg: jQuery("#" + i).clone() }),
                              t.setHistory(a))
                            : void 0 === t.history.values[p] ||
                              ("createPhoto" != t.history.values[p].redo.action &&
                                  "replacePhoto" != t.history.values[p].redo.action) ||
                              ((t.history.values[p].redo.value = JSON.parse(JSON.stringify(t.photoStores[e]))),
                              (t.history.values[p].redo.svg = jQuery("#" + e).clone())),
                        setTimeout(() => {
                            "" === p && (p = t.history.values.length - 1), t.cropOriginPhoto(e, o, p);
                        }, 1);
                });
        },
        cropOriginPhoto(t, e, o) {
            let a = this;
            void 0 !== e.width &&
                (void 0 !== a.photoStores[t] &&
                void 0 !== a.photoStores[a.photoStores[t].id] &&
                void 0 !== a.photoStores[a.photoStores[t].id].origBase64
                    ? ((a.waitDesign = !0),
                      pdappAPI.photo.cropOriginImage(
                          a.photoStores[a.photoStores[t].id].origBase64,
                          e,
                          t,
                          o,
                          function (t, e, o) {
                              (a.waitDesign = !1),
                                  -1 != t.indexOf(";base64,") &&
                                      ((a.photoStores[e].crop.origBase64 = t),
                                      void 0 !== a.history.values[o] &&
                                          ("createPhoto" == a.history.values[o].redo.action
                                              ? (a.history.values[o].redo.value = JSON.parse(
                                                    JSON.stringify(a.photoStores[e])
                                                ))
                                              : (a.history.values[o].redo.value = JSON.parse(
                                                    JSON.stringify(a.photoStores[e].crop)
                                                ))));
                          }
                      ))
                    : void 0 !== a.photoStores[t] &&
                      void 0 !== a.photoStores[t].id &&
                      (a.waitCropPhoto[a.photoStores[t].id] = { id: t, crop: e, hisID: o }));
        },
        changeCropRatio() {
            pdappAPI.photo.changeCropRatio(this.tempModal.modal.data.ratio);
        },
        fitPhotoInside() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = {};
            (a.undo = { action: "transformPhoto", target: o, value: pdappAPI.tool.getTransform(e) }),
                pdappAPI.photo.fitPhotoInside(),
                setTimeout(() => {
                    (a.redo = { action: "transformPhoto", target: o, value: pdappAPI.tool.getTransform(e) }),
                        t.setHistory(a);
                });
        },
        fitPhotoOutside() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = {};
            (a.undo = { action: "transformPhoto", target: o, value: pdappAPI.tool.getTransform(e) }),
                pdappAPI.photo.fitPhotoOutside(),
                setTimeout(() => {
                    (a.redo = { action: "transformPhoto", target: o, value: pdappAPI.tool.getTransform(e) }),
                        t.setHistory(a);
                });
        },
        updatePhotoStyle(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            if (void 0 !== e.menuOptions.details[e.menuOptions.childID][t] && "transparency" == t) {
                let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                    a = o.attr("id"),
                    p = {};
                (p.undo = { action: "opacity", target: a, value: o.attr("opacity") }),
                    pdappAPI.photo.updatePhotoStyle(t, e.menuOptions.details[e.menuOptions.childID][t]),
                    (p.redo = { action: "opacity", target: a, value: e.menuOptions.details[e.menuOptions.childID][t] }),
                    e.setHistory(p);
            }
        },
        addShape(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = a + "-shape",
                i = {};
            (i.path = o.attr("clip-path")), (i.slug = o.attr("data-shape"));
            let l = "";
            void 0 === i.path && (i.path = ""), void 0 === i.slug ? (i.slug = "") : (l = jQuery("#" + p).clone());
            let s = {};
            (s.undo = { action: "addShape", target: a, value: i, svg: l }),
                pdappAPI.photo.addShape(t, function () {
                    (e.menuOptions.details[e.menuOptions.childID].photoShape = "" == t ? "" : t.slug),
                        (o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target));
                    let p = { path: "", slug: "" },
                        i = "";
                    "" != t &&
                        ((p.path = o.attr("clip-path")),
                        (p.slug = t.slug),
                        (i = 0 != o.find("defs").length ? o.find("defs").clone() : "")),
                        (s.redo = { action: "addShape", target: a, value: p, svg: i }),
                        e.setHistory(s);
                });
        },
        addFilter(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = o.attr("data-filter");
            void 0 === p && (p = "");
            let i = {};
            (i.undo = { action: "addFilter", target: a, value: p, svg: "" }),
                pdappAPI.photo.addFilter(t, function () {
                    (e.menuOptions.details[e.menuOptions.childID].photoFilter = "" == t ? "" : t.slug),
                        (o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target));
                    let p = "",
                        l = "";
                    if ("" != t) {
                        p = o.attr("data-filter");
                        let t = o.parent("g.pdapp-g-photo");
                        l = 0 != t.length && 0 != t.find("defs").length ? t.find("defs").clone() : "";
                    }
                    (i.redo = { action: "addFilter", target: a, value: p, svg: l }),
                        e.setHistory(i),
                        setTimeout(() => {
                            e.setSvgStyle();
                        }, 10);
                });
        },
        alignPhoto(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = {};
            (p.undo = { action: "transformPhoto", target: a, value: pdappAPI.tool.getTransform(o) }),
                pdappAPI.photo.alignPhoto(t),
                setTimeout(() => {
                    (p.redo = { action: "transformPhoto", target: a, value: pdappAPI.tool.getTransform(o) }),
                        e.setHistory(p);
                });
        },
        movePhoto(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                a = o.attr("id"),
                p = {};
            (p.undo = { action: "transformPhoto", target: a, value: pdappAPI.tool.getTransform(o) }),
                pdappAPI.photo.movePhoto(t),
                setTimeout(() => {
                    (p.redo = { action: "transformPhoto", target: a, value: pdappAPI.tool.getTransform(o) }),
                        e.setHistory(p);
                });
        },
        deletePhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = void 0 !== t.photoStores[o] ? t.photoStores[o] : "",
                p = {};
            (p.undo = {
                action: "createPhoto",
                target: o,
                index: pdappAPI.history.getIndex(e),
                value: a,
                svg: e.clone(),
            }),
                pdappAPI.photo.delete(function (e) {
                    void 0 !== t.photoStores[e] && delete t.photoStores[e],
                        t.menuOptions.details.splice(t.menuOptions.childID, 1),
                        (t.menuOptions.childID = null),
                        (p.redo = { action: "deletePhoto", target: e }),
                        t.setHistory(p),
                        setTimeout(() => {
                            t.setSvgStyle();
                        }, 1);
                });
        },
        lockPhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                o = {};
            (o.undo = {
                action: "lockPhoto",
                target: e,
                value: t.menuOptions.details[t.menuOptions.childID].photoLock,
            }),
                pdappAPI.photo.lock(t.menuOptions.details[t.menuOptions.childID].photoLock, function (a) {
                    (t.menuOptions.details[t.menuOptions.childID].photoLock = a),
                        t.closePhotoDropdown(),
                        (o.redo = { action: "lockPhoto", target: e, value: a }),
                        t.setHistory(o);
                });
        },
        copyPhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            pdappAPI.photo.copy(t.langs.options, function (e, o) {
                t.activeLayer(e),
                    (t.toast = { show: !0, type: "success", text: t.langs.options.copy_photo_success }),
                    setTimeout(() => {
                        t.toast.show = !1;
                    }, 5e3);
                let a = e.attr("id"),
                    p = {};
                (p.undo = { action: "deletePhoto", target: a }),
                    void 0 !== t.photoStores[o] && (t.photoStores[a] = JSON.parse(JSON.stringify(t.photoStores[o]))),
                    (p.redo = {
                        action: "createPhoto",
                        target: a,
                        index: pdappAPI.history.getIndex(e),
                        value: t.photoStores[a],
                        svg: e.clone(),
                    }),
                    t.setHistory(p);
            });
        },
        flipPhoto() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            pdappAPI.photo.flip(t.menuOptions.details[t.menuOptions.childID].photoFlip, function (e) {
                let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                    a = {};
                (a.undo = { action: "flipPhoto", target: o, value: e }),
                    (t.menuOptions.details[t.menuOptions.childID].photoFlip = e),
                    (a.redo = { action: "flipPhoto", target: o, value: !e }),
                    t.setHistory(a);
            });
        },
        activeLayer(t) {
            let e = this;
            if (void 0 === t.length || 0 == t.length) return e.closeMenuOption(), e.closeGroup(), !1;
            if (t.length > 1) {
                let o = !1;
                for (let e = t.length - 1; e >= 0; e--)
                    jQuery(t[e]).hasClass("pdapp-lock") && (t.splice(e, 1), (o = !0));
                if (0 == t.length) return e.closeMenuOption(), !1;
                o && ((pdappAPI.tool.targets = t), (pdappAPI.tool.pdappMoveAbleRef.target = t));
            } else if (jQuery(t[0]).hasClass("pdapp-group")) {
                let e = jQuery(t[0]).attr("data-group"),
                    o = [];
                jQuery(".pdapp-viewport.active .pdapp-viewport-area.active g.pdapp-group").each(function () {
                    jQuery(this).attr("data-group") == e && o.push(this);
                }),
                    o.length && ((t = o), (pdappAPI.tool.pdappMoveAbleRef.target = o), (pdappAPI.tool.targets = o));
            }
            pdappAPI.layer.active(t, e.langs.options, function (o, a, p) {
                if (null == e.activeMenu && "group" == a) {
                    let t = "text";
                    if ("template" == t) {
                        let o = "";
                        for (let t in e.listMenus) "" == o && "template" != t && (o = t);
                        t = o;
                    }
                    (e.activeMenu = t), pdappAPI.tool.setLocalVar("pdappActiveMenu", t);
                }
                if (null == o && t.length > 1)
                    return (
                        pdappAPI.group.getGroup(t, function (o) {
                            (e.groupItem = o),
                                pdappAPI.group.getColors(t, function (t) {
                                    for (let o = 0; o < t.length; o++) {
                                        let a = pdappAPI.tool.rgbToHex(t[o]);
                                        0 == e.groupItem.colors.includes(a) &&
                                            -1 != a.indexOf("#") &&
                                            e.groupItem.colors.push(a);
                                    }
                                });
                        }),
                        !1
                    );
                if (
                    ("group" != a &&
                        "unselect" != a &&
                        (e.listMenus[a], 1) &&
                        ((e.activeMenu = a), pdappAPI.tool.setLocalVar("pdappActiveMenu", a)),
                    "text" == a || "artwork" == a || "photo" == a || "qrcode" == a || "barcode" == a)
                ) {
                    let o = e.listTextOptions;
                    if (
                        ("artwork" == a && (o = e.listArtworkOptions),
                        "photo" == a && (o = e.listPhotoOptions),
                        "qrcode" == a && (o = e.listQrcodeOptions),
                        "barcode" == a && (o = e.listBarcodeOptions),
                        p.length > 0 && void 0 !== p[0].settings)
                    ) {
                        pdappAPI.tool.setHideOptions(p[0].settings);
                        let t = [];
                        for (let e = 0; e < o.length; e++) p[0].settings.includes(o[e]) ? t.push(!0) : t.push(!1);
                        p[0].settings = t;
                    }
                    jQuery(document).trigger("after_layer_active", { type: a, evt: jQuery(t), self: e });
                }
                return (
                    (e.listMenus[e.activeMenu].options.childID = o),
                    (e.listMenus[e.activeMenu].options.details = p),
                    (e.groupItem.show = !1),
                    "text" == e.activeMenu && 0 == e.listMenus.text.options.values.length
                        ? e.getListText()
                        : "text" == e.activeMenu &&
                          null == e.menuOptions.childID &&
                          setTimeout(() => {
                              pdappAPI.tool.loadMore(".pdapp-menu-options-text", function () {
                                  e.listTextTemp.total > e.listTextTemp.temps.length && e.listMenus.text.page.paged++;
                              });
                          }, 1),
                    "text" == e.activeMenu &&
                    null != e.menuOptions.childID &&
                    void 0 !== e.menuOptions.details[e.menuOptions.childID].dropdown
                        ? ("color" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                              setTimeout(() => {
                                  pdappAPI.tool.colorPicker(
                                      "#pdapp-text-colorpicker",
                                      e.langs.options,
                                      function (t, o) {
                                          if (null == e.menuOptions.childID) return !1;
                                          (e.menuOptions.details[e.menuOptions.childID].color = o),
                                              e.updateTextStyle("color");
                                      }
                                  );
                              }, 1),
                          "outline" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                              setTimeout(() => {
                                  pdappAPI.tool.colorPicker(
                                      "#pdapp-outline-colorpicker",
                                      e.langs.options,
                                      function (t, o) {
                                          if (null == e.menuOptions.childID) return !1;
                                          (e.menuOptions.details[e.menuOptions.childID].stroke = o),
                                              e.updateTextStyle("outline");
                                      }
                                  );
                              }, 1),
                          "font" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                              void 0 !== e.fontLibrary.page &&
                              setTimeout(() => {
                                  pdappAPI.tool.loadMore(".pdapp-font-list", function () {
                                      e.listFonts.total > e.listFonts.fonts.length && e.fontLibrary.page.paged++;
                                  });
                              }, 1),
                          !1)
                        : "artwork" == e.activeMenu && null != e.menuOptions.childID
                          ? (void 0 === e.artFolders[0]
                                ? e.getArtFolders()
                                : null == e.menuOptions.childID &&
                                  setTimeout(() => {
                                      pdappAPI.tool.loadMore(".pdapp-menu-options-artwork", function () {
                                          e.listArtworks.total > e.listArtworks.arts.length &&
                                              e.listMenus.artwork.options.values.page.paged++;
                                      });
                                  }, 1),
                            (e.menuOptions.details[e.menuOptions.childID].colors = []),
                            e.menuOptions.details[e.menuOptions.childID].editColor &&
                                pdappAPI.tool.getColors(jQuery(t), function (t) {
                                    (e.menuOptions.details[e.menuOptions.childID].colors = t),
                                        "color" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                            setTimeout(() => {
                                                pdappAPI.tool.colorPicker(
                                                    ".pdapp-edit-color",
                                                    e.langs.options,
                                                    function (t, o) {
                                                        (oldcolor = jQuery(t).attr("data-color")),
                                                            e.updateColor(oldcolor, o);
                                                    }
                                                );
                                            }, 1);
                                }),
                            !1)
                          : "photo" == e.activeMenu && null != e.menuOptions.childID
                            ? (e.getListShape(),
                              e.getListFilter(),
                              0 == e.listMenus.photo.options.values.length
                                  ? e.getPhotos()
                                  : null == e.menuOptions.childID &&
                                    setTimeout(() => {
                                        pdappAPI.tool.loadMore(".pdapp-photo-libraries", function () {
                                            e.getPhotos();
                                        });
                                    }, 1),
                              (e.menuOptions.details[e.menuOptions.childID].colors = []),
                              e.menuOptions.details[e.menuOptions.childID].editColor &&
                                  pdappAPI.tool.getColors(jQuery(t), function (t) {
                                      (e.menuOptions.details[e.menuOptions.childID].colors = t),
                                          "color" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                              setTimeout(() => {
                                                  pdappAPI.tool.colorPicker(
                                                      ".pdapp-edit-color",
                                                      e.langs.options,
                                                      function (t, o) {
                                                          (oldcolor = jQuery(t).attr("data-color")),
                                                              e.updateColor(oldcolor, o);
                                                      }
                                                  );
                                              }, 1);
                                  }),
                              !1)
                            : "qrcode" == e.activeMenu && null != e.menuOptions.childID
                              ? (setTimeout(() => {
                                    if (
                                        (pdappAPI.tool.colorPicker(
                                            "#pdapp-qrcode-colorpicker",
                                            e.langs.options,
                                            function (t, o) {
                                                if (null == e.menuOptions.childID) return !1;
                                                (e.menuOptions.details[e.menuOptions.childID].color = o),
                                                    void 0 === e.menuOptions.details[e.menuOptions.childID].type &&
                                                        (e.menuOptions.details[e.menuOptions.childID].type = "text"),
                                                    e.updateQrcode();
                                            }
                                        ),
                                        null == e.menuOptions.childID)
                                    )
                                        return !1;
                                    "background" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                        "transparent" != e.menuOptions.details[e.menuOptions.childID].background &&
                                        pdappAPI.tool.colorPicker(
                                            "#pdapp-qrcode-bg-colorpicker",
                                            e.langs.options,
                                            function (t, o) {
                                                if (null == e.menuOptions.childID) return !1;
                                                (e.menuOptions.details[e.menuOptions.childID].background = o),
                                                    e.updateQrcode();
                                            }
                                        );
                                }, 1),
                                !1)
                              : "barcode" == e.activeMenu && null != e.menuOptions.childID
                                ? (setTimeout(() => {
                                      if (
                                          (pdappAPI.tool.colorPicker(
                                              "#pdapp-barcode-colorpicker",
                                              e.langs.options,
                                              function (t, o) {
                                                  if (null == e.menuOptions.childID) return !1;
                                                  (e.menuOptions.details[e.menuOptions.childID].lineColor = o),
                                                      e.updateBarcode();
                                              }
                                          ),
                                          null == e.menuOptions.childID)
                                      )
                                          return !1;
                                      "background" == e.menuOptions.details[e.menuOptions.childID].dropdown &&
                                          "transparent" != e.menuOptions.details[e.menuOptions.childID].background &&
                                          pdappAPI.tool.colorPicker(
                                              "#pdapp-barcode-bg-colorpicker",
                                              e.langs.options,
                                              function (t, o) {
                                                  if (null == e.menuOptions.childID) return !1;
                                                  (e.menuOptions.details[e.menuOptions.childID].background = o),
                                                      e.updateBarcode();
                                              }
                                          );
                                  }, 1),
                                  !1)
                                : void 0
                );
            });
        },
        closeMenuOption() {
            let t = this;
            if (
                null == t.activeMenu ||
                void 0 === t.listMenus[t.activeMenu] ||
                void 0 === t.listMenus[t.activeMenu].options ||
                "undefined" == t.listMenus[t.activeMenu].options.childID ||
                null == t.listMenus[t.activeMenu].options.childID
            )
                return !1;
            (t.listMenus[t.activeMenu].options.childID = null),
                (pdappAPI.tool.pdappMoveAbleRef.target = null),
                (t.groupItem.active = ""),
                (pdappAPI.tool.targets = []),
                (t.groupItem.show = !1),
                ("text" != t.activeMenu && "artwork" != t.activeMenu && "photo" != t.activeMenu) ||
                    setTimeout(() => {
                        let e =
                            "photo" == t.activeMenu ? ".pdapp-photo-libraries" : ".pdapp-menu-options-" + t.activeMenu;
                        pdappAPI.tool.loadMore(e, function () {
                            "text" == t.activeMenu &&
                                t.listTextTemp.total > t.listTextTemp.temps.length &&
                                t.listMenus.text.page.paged++,
                                "artwork" == t.activeMenu &&
                                    t.listArtworks.total > t.listArtworks.arts.length &&
                                    t.listMenus.artwork.options.values.page.paged++,
                                "photo" == t.activeMenu && t.getPhotos();
                        });
                    }, 1);
        },
        closeGroup() {
            let t = this;
            null != t.activeMenu &&
                void 0 !== t.listMenus[t.activeMenu] &&
                (t.listMenus[t.activeMenu].options.childID = null),
                (pdappAPI.tool.pdappMoveAbleRef.target = null),
                (pdappAPI.tool.targets = []),
                (t.groupItem.show = !1);
        },
        setSvgStyle() {
            pdappAPI.tool.setSvgStyle(this.loadedFonts);
        },
        setActiveLayer(t) {
            let e = jQuery("#" + t.id);
            this.activeLayer(e);
        },
        moveLayer(t, e) {
            let o = this;
            pdappAPI.layer.moveLayer(t, e),
                null != o.activeMenu &&
                    void 0 !== o.listMenus[o.activeMenu] &&
                    (o.listMenus[o.activeMenu].options.values = pdappAPI.layer.loadLayers());
        },
        toggleShowRuler() {
            (this.showRuler = !this.showRuler), pdappAPI.tool.ruler.setShow(this.showRuler);
        },
        changeQrcodeType() {
            "text" == this.menuOptions.details[this.menuOptions.childID].qrtype
                ? (this.menuOptions.details[this.menuOptions.childID].text =
                      void 0 !== listMenus[activeMenu].text && "" != listMenus[activeMenu].text
                          ? listMenus[activeMenu].text
                          : this.langs.options.qrcode_text)
                : "url" == this.menuOptions.details[this.menuOptions.childID].qrtype
                  ? (this.menuOptions.details[this.menuOptions.childID].text = this.langs.options.qrcode_url)
                  : "phone" == this.menuOptions.details[this.menuOptions.childID].qrtype
                    ? (this.menuOptions.details[this.menuOptions.childID].text = this.langs.options.qrcode_phone)
                    : "sms" == this.menuOptions.details[this.menuOptions.childID].qrtype
                      ? ((this.menuOptions.details[this.menuOptions.childID].text = this.langs.options.qrcode_sms),
                        (this.menuOptions.details[this.menuOptions.childID].message =
                            this.langs.options.qrcode_message))
                      : "mail" == this.menuOptions.details[this.menuOptions.childID].qrtype &&
                        ((this.menuOptions.details[this.menuOptions.childID].text = this.langs.options.qrcode_email),
                        (this.menuOptions.details[this.menuOptions.childID].subject =
                            this.langs.options.qrcode_subject),
                        (this.menuOptions.details[this.menuOptions.childID].message =
                            this.langs.options.qrcode_message)),
                this.updateQrcode();
        },
        addQrcode() {
            let t = this;
            (t.loadingPage = !0),
                pdappAPI.qrcode.create(t.listMenus[t.activeMenu], function (e) {
                    (t.loadingPage = !1), t.activeLayer(e);
                    let o = e.attr("id"),
                        a = {};
                    (a.undo = { action: "deleteQr", target: o }),
                        (a.redo = { action: "createQr", target: o, value: e.clone() }),
                        t.setHistory(a);
                });
        },
        dropdownQrcode(t) {
            let e = this;
            if (e.menuOptions.details[e.menuOptions.childID].dropdown == t)
                return (e.menuOptions.details[e.menuOptions.childID].dropdown = ""), !1;
            (e.menuOptions.details[e.menuOptions.childID].dropdown = t),
                setTimeout(() => {
                    "edit" == t &&
                        pdappAPI.tool.colorPicker("#pdapp-qrcode-colorpicker", e.langs.options, function (t, o) {
                            (e.menuOptions.details[e.menuOptions.childID].color = o),
                                e.settings.layout.qrcode.type &&
                                    void 0 === e.menuOptions.details[e.menuOptions.childID].type &&
                                    (e.menuOptions.details[e.menuOptions.childID].type = "text"),
                                e.updateQrcode();
                        }),
                        "background" == t &&
                            "transparent" != e.menuOptions.details[e.menuOptions.childID].background &&
                            pdappAPI.tool.colorPicker("#pdapp-qrcode-bg-colorpicker", e.langs.options, function (t, o) {
                                (e.menuOptions.details[e.menuOptions.childID].background = o), e.updateQrcode();
                            });
                }, 1);
        },
        changeUpdateQrcode(t, e) {
            let o = this;
            "background" == t
                ? jQuery("#pdapp-qrcode-background").prop("checked")
                    ? (jQuery("#pdapp-qrcode-bg-box .sp-container").remove(),
                      (o.menuOptions.details[o.menuOptions.childID].background = "transparent"))
                    : ((o.menuOptions.details[o.menuOptions.childID].background = "#ffffff"),
                      setTimeout(() => {
                          pdappAPI.tool.colorPicker("#pdapp-qrcode-bg-colorpicker", o.langs.options, function (t, e) {
                              (o.menuOptions.details[o.menuOptions.childID].background = e), o.updateQrcode();
                          });
                      }, 1))
                : (o.menuOptions.details[o.menuOptions.childID][t] = e),
                o.updateQrcode();
        },
        updateQrcode() {
            let t = this,
                e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
            void 0 !== t.menuOptions.details[t.menuOptions.childID].text &&
                0 == t.menuOptions.details[t.menuOptions.childID].text.length &&
                (t.menuOptions.details[t.menuOptions.childID].text = e.attr("data-text").substring(0, 1)),
                "mail" == t.menuOptions.details[t.menuOptions.childID].qrtype &&
                    0 == t.menuOptions.details[t.menuOptions.childID].subject.length &&
                    (t.menuOptions.details[t.menuOptions.childID].subject = e.attr("data-subject").substring(0, 1)),
                ("sms" != t.menuOptions.details[t.menuOptions.childID].qrtype &&
                    "mail" != t.menuOptions.details[t.menuOptions.childID].qrtype) ||
                    0 != t.menuOptions.details[t.menuOptions.childID].message.length ||
                    (t.menuOptions.details[t.menuOptions.childID].message = e.attr("data-message").substring(0, 1));
            let o = e.attr("id"),
                a = {};
            (a.undo = { action: "updateQr", target: o, value: e.clone() }),
                pdappAPI.qrcode.update(t.menuOptions.details[t.menuOptions.childID], function (e) {
                    (a.redo = { action: "updateQr", target: o, value: e.clone() }), t.setHistory(a);
                });
        },
        deleteQrcode() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = {};
            (a.undo = {
                action: "createPhoto",
                target: o,
                index: pdappAPI.history.getIndex(e),
                value: "",
                svg: e.clone(),
            }),
                pdappAPI.photo.delete(function (e) {
                    t.menuOptions.details.splice(t.menuOptions.childID, 1),
                        (t.menuOptions.childID = null),
                        (a.redo = { action: "deletePhoto", target: e }),
                        t.setHistory(a);
                });
        },
        copyQrcode() {
            let t = this,
                e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                o = {};
            (o.undo = { action: "deleteQr", target: e }),
                pdappAPI.qrcode.copy(t.langs.options, function (e) {
                    t.activeLayer(e),
                        (o.redo = { action: "createQr", target: e.attr("id"), value: e.clone() }),
                        t.setHistory(o),
                        (t.toast = { show: !0, type: "success", text: t.langs.options.copy_qrcode_success }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                });
        },
        addBarcode() {
            let t = this;
            (t.loadingPage = !0),
                pdappAPI.barcode.create(t.listMenus[t.activeMenu], t.loadedFonts, function (e) {
                    (t.loadingPage = !1), t.activeLayer(e);
                    let o = e.attr("id"),
                        a = {};
                    (a.undo = { action: "deleteBar", target: o }),
                        (a.redo = { action: "createBar", target: o, value: e.clone() }),
                        t.setHistory(a);
                });
        },
        dropdownBarcode(t) {
            let e = this;
            if (e.menuOptions.details[e.menuOptions.childID].dropdown == t)
                return (e.menuOptions.details[e.menuOptions.childID].dropdown = ""), !1;
            (e.menuOptions.details[e.menuOptions.childID].dropdown = t),
                setTimeout(() => {
                    "edit" == t &&
                        pdappAPI.tool.colorPicker("#pdapp-barcode-colorpicker", e.langs.options, function (t, o) {
                            (e.menuOptions.details[e.menuOptions.childID].lineColor = o), e.updateBarcode();
                        }),
                        "background" == t &&
                            "transparent" != e.menuOptions.details[e.menuOptions.childID].background &&
                            pdappAPI.tool.colorPicker(
                                "#pdapp-barcode-bg-colorpicker",
                                e.langs.options,
                                function (t, o) {
                                    (e.menuOptions.details[e.menuOptions.childID].background = o), e.updateBarcode();
                                }
                            );
                }, 1);
        },
        checkBarcode() {
            let t = this;
            0 ==
                pdappAPI.barcode.checkBarcode(
                    t.menuOptions.details[t.menuOptions.childID].text,
                    t.menuOptions.details[t.menuOptions.childID].format,
                    t.langs.options
                ) && t.updateBarcode();
        },
        changeUpdateBarcode(t, e) {
            let o = this;
            "background" == t
                ? jQuery("#pdapp-barcode-background").prop("checked")
                    ? (jQuery("#pdapp-barcode-bg-box .sp-container").remove(),
                      (o.menuOptions.details[o.menuOptions.childID].background = "transparent"))
                    : ((o.menuOptions.details[o.menuOptions.childID].background = "#ffffff"),
                      setTimeout(() => {
                          pdappAPI.tool.colorPicker("#pdapp-barcode-bg-colorpicker", o.langs.options, function (t, e) {
                              (o.menuOptions.details[o.menuOptions.childID].background = e), o.updateBarcode();
                          });
                      }, 1))
                : (o.menuOptions.details[o.menuOptions.childID][t] = e),
                o.updateBarcode();
        },
        updateBarcode() {
            let t = this,
                e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                o = e.attr("id"),
                a = {};
            (a.undo = { action: "updateBar", target: o, value: e.clone() }),
                pdappAPI.barcode.update(t.menuOptions.details[t.menuOptions.childID], t.loadedFonts, function (e) {
                    (a.redo = { action: "updateBar", target: o, value: e.clone() }), t.setHistory(a);
                });
        },
        copyBarcode() {
            let t = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let e = jQuery(pdappAPI.tool.pdappMoveAbleRef.target).attr("id"),
                o = {};
            (o.undo = { action: "deletePhoto", target: e }),
                pdappAPI.barcode.copy(t.langs.options, function (e) {
                    t.activeLayer(e),
                        (o.redo = {
                            action: "createPhoto",
                            target: e.attr("id"),
                            index: pdappAPI.history.getIndex(e),
                            value: "",
                            svg: e.clone(),
                        }),
                        t.setHistory(o),
                        (t.toast = { show: !0, type: "success", text: t.langs.options.copy_barcode_success }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                });
        },
        startDownload(t) {
            let e = this;
            if (e.waitDesign) {
                e.loadingPage = !0;
                let o = !1;
                return (
                    "" == t ? (e.waitTiming = pdappAPI.tool.getTime()) : (o = pdappAPI.tool.checkTime(e.waitTiming, 1)),
                    o
                        ? ((e.loadingPage = !1),
                          (e.tempModal.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "message",
                              data: {
                                  type: "warning",
                                  title: e.langs.msg.processing_design_error,
                                  text: e.langs.msg.processing_design_error_desc,
                              },
                          }),
                          !1)
                        : (setTimeout(() => {
                              (e.loadingPage = !1), e.startDownload("recall");
                          }, 300),
                          !1)
                );
            }
            (e.loadingPage = !0),
                (e.designsData = pdappAPI.download.renderDesigns(e.photoStores, function (t) {
                    (e.loadingPage = !1),
                        "" != t
                            ? pdappAPI.download.downloadFile(t)
                            : ((e.toast = { show: !0, type: "error", text: e.langs.msg.download_error_msg }),
                              setTimeout(() => {
                                  e.toast.show = !1;
                              }, 5e3));
                }));
        },
        importTemplate(t) {
            let e = this;
            if (void 0 === t.target.files[0]) return !1;
            const o = t.target.files[0];
            pdappAPI.upload.importTemplate(o, function (t) {
                let e = new DOMParser().parseFromString(t, "image/svg+xml");
                jQuery("#pdapp-viewer-area .pdapp-viewport .pdapp-viewport-area .pdapp-selecto-area").remove(),
                    jQuery("#pdapp-viewer-area .pdapp-viewport .pdapp-viewport-area")[0].appendChild(e.documentElement);
            }) ||
                ((e.toast = { show: !0, type: "error", text: e.langs.upload_type_error + " .pda" }),
                setTimeout(() => {
                    e.toast.show = !1;
                }, 5e3));
        },
        onResizeScreen() {
            let t = this;
            void 0 !== t.tempModal.data &&
                void 0 !== t.tempModal.data.size &&
                (jQuery("#pdapp-viewer-area").css({ width: "100%", height: "100%" }),
                (t.tempModal.data.zoom = "fit"),
                pdappAPI.tool.setScroll());
        },
        openTempModal() {
            let t = this;
            pdappAPI.tool.previewScreen(
                t.photoStores,
                function (e) {
                    t.tempModal.data.thumb = e;
                },
                !0
            ),
                (t.loadingPage = !0),
                (t.designsData = pdappAPI.download.renderDesigns(t.photoStores, function (e) {
                    (t.loadingPage = !1),
                        "" != e
                            ? (t.tempModal.data.file = e)
                            : ((t.toast = { show: !0, type: "error", text: t.langs.msg.download_error_msg }),
                              setTimeout(() => {
                                  t.toast.show = !1;
                              }, 5e3),
                              (t.tempModal.modal.show = !1));
                }));
            let e = t.langs.temp.save_template;
            "" != t.tempModal.data.id && (e = t.langs.temp.update_template),
                (t.tempModal.modal = { show: !0, header: !0, size: "lg", title: e, type: "savetemp", saving: !1 });
        },
        async saveTempModal(t) {
            let e = this;
            if (e.waitDesign) {
                e.loadingPage = !0;
                let o = !1;
                return (
                    "" == t ? (e.waitTiming = pdappAPI.tool.getTime()) : (o = pdappAPI.tool.checkTime(e.waitTiming, 1)),
                    o
                        ? ((e.loadingPage = !1),
                          (e.tempModal.modal = {
                              show: !0,
                              header: !1,
                              size: "md modal-dialog-centered",
                              title: "",
                              type: "message",
                              data: {
                                  type: "warning",
                                  title: e.langs.msg.processing_design_error,
                                  text: e.langs.msg.processing_design_error_desc,
                              },
                          }),
                          !1)
                        : (setTimeout(() => {
                              (e.loadingPage = !1), e.saveTempModal("recall");
                          }, 300),
                          !1)
                );
            }
            if ("" == e.tempModal.data.file)
                return (
                    (e.toast = { show: !0, type: "error", text: e.langs.msg.download_error_msg }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3),
                    !1
                );
            e.tempModal.modal.saving = !0;
            for (let t in e.listLang.list)
                void 0 === e.tempModal.data.title[t] &&
                    (e.tempModal.data.title[t] =
                        "" != typeof e.tempModal.data.title[e.tempModal.langCode]
                            ? e.tempModal.data.title[e.tempModal.langCode]
                            : "Untitled");
            let o = void 0 !== e.tempModal.data.created ? e.tempModal.data.created : "",
                a = pdappAdminUrl + "admin-ajax.php?action=pdapp-save-temp&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let t = {
                        id: e.tempModal.data.id,
                        pid: e.tempModal.data.pid,
                        title: e.tempModal.data.title,
                        type: "temp",
                        price: e.tempModal.data.price,
                        thumb: e.tempModal.data.thumb,
                        file: e.tempModal.data.file,
                        size: JSON.stringify(e.tempModal.data.size),
                        created: o,
                    },
                    p = await pdappAPI.tool.postData(a, t);
                if ("" == e.tempModal.data.id)
                    void 0 === e.listTempsData[e.folderID] && (e.listTempsData[e.folderID] = []),
                        e.listTempsData[e.folderID].push(p.data);
                else
                    for (let t = 0; t < e.listTempsData[e.folderID].length; t++)
                        e.listTempsData[e.folderID][t].id == e.tempModal.data.id &&
                            (e.listTempsData[e.folderID][t] = p.data);
                (e.toast = { show: !0, type: "success", text: p.msg }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3),
                    (e.tempModal.modal.show = !1);
            } catch (t) {
                (e.toast = { show: !0, type: "warning", text: t.msg }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3);
            }
            e.tempModal.modal.saving = !1;
        },
        updateColor(t, e) {
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            if (t != e) {
                let o = this,
                    a = jQuery(pdappAPI.tool.pdappMoveAbleRef.target),
                    p = [];
                if (o.groupItem.show && a.length > 1) {
                    for (let o = 0; o < a.length; o++) {
                        let i = jQuery(a[o]);
                        if (void 0 === i.attr("data-color") || i.hasClass("pdapp-svg")) {
                            void 0 !== i.attr("fill") && i.attr("fill", i.attr("fill").replaceAll(t, e)),
                                void 0 !== i.attr("data-color") &&
                                    i.attr("data-color", i.attr("data-color").replaceAll(t, e)),
                                void 0 !== i.attr("data-background") &&
                                    i.attr("data-background", i.attr("data-background").replaceAll(t, e)),
                                (a[o].innerHTML = a[o].innerHTML.replaceAll(t, e));
                            let l = i.attr("id");
                            p.push(l);
                        }
                    }
                    for (let a = 0; a < o.groupItem.colors.length; a++)
                        o.groupItem.colors[a] == t && (o.groupItem.colors[a] = e);
                } else if (void 0 !== a[0]) {
                    let i = jQuery(a[0]);
                    void 0 !== i.attr("fill") && i.attr("fill", i.attr("fill").replaceAll(t, e)),
                        void 0 !== i.attr("data-color") && i.attr("data-color", i.attr("data-color").replaceAll(t, e)),
                        void 0 !== i.attr("data-background") &&
                            i.attr("data-background", i.attr("data-background").replaceAll(t, e)),
                        (a[0].innerHTML = a[0].innerHTML.replaceAll(t, e));
                    for (let a = 0; a < o.menuOptions.details[o.menuOptions.childID].colors.length; a++)
                        o.menuOptions.details[o.menuOptions.childID].colors[a] == t &&
                            (o.menuOptions.details[o.menuOptions.childID].colors[a] = e);
                    let l = i.attr("id");
                    p.push(l);
                }
                let i = {};
                (i.undo = { action: "updateColor", target: p, value: { old: e, new: t } }),
                    (i.redo = { action: "updateColor", target: p, value: { old: t, new: e } }),
                    o.setHistory(i);
            }
        },
        dropdownGroup(t) {
            let e = this;
            if (e.groupItem.active == t) return (e.groupItem.active = ""), !1;
            "color" == t &&
                e.groupItem.colors.length &&
                setTimeout(() => {
                    pdappAPI.tool.colorPicker(".pdapp-edit-color", e.langs.options, function (t, o) {
                        (oldcolor = jQuery(t).attr("data-color")), e.updateColor(oldcolor, o);
                    });
                }, 1),
                (e.groupItem.active = t);
        },
        selectAllGroup() {
            let t = this,
                e = jQuery(".pdapp-viewport.active .pdapp-viewport-area.active g.pdapp-target");
            return 0 == e.length
                ? ((t.toast = { show: !0, type: "warning", text: t.langs.select_item_not_found }),
                  setTimeout(() => {
                      t.toast.show = !1;
                  }, 5e3),
                  !1)
                : 1 == e.length
                  ? (t.activeLayer(e), !1)
                  : void pdappAPI.group.selectAll(function (e, o) {
                        (pdappAPI.tool.pdappMoveAbleRef.target = e),
                            (pdappAPI.tool.targets = e),
                            (t.groupItem = o),
                            pdappAPI.group.getColors(e, function (e) {
                                for (let o = 0; o < e.length; o++) {
                                    let a = pdappAPI.tool.rgbToHex(e[o]);
                                    0 == t.groupItem.colors.includes(a) &&
                                        -1 != a.indexOf("#") &&
                                        t.groupItem.colors.push(a);
                                }
                            });
                    });
        },
        copyGroup() {
            let t = this,
                e = [],
                o = [],
                a = [],
                p = [],
                i = [];
            pdappAPI.group.copyGroup(t.langs.options, function (l, s, d, r, n) {
                if ((e.push(jQuery("#" + l)[0]), o.push(l), a.push(s), p.push(d), "" != r)) {
                    let e = { id: l, value: "" };
                    void 0 !== t.photoStores[r] &&
                        ((t.photoStores[l] = t.photoStores[r]), (e.value = t.photoStores[r])),
                        i.push(e);
                }
                if (n) {
                    let l = {};
                    (l.undo = { action: "removeGroup", target: o, value: i }),
                        (l.redo = { action: "createGroup", index: a, value: i, svg: p }),
                        t.setHistory(l),
                        setTimeout(() => {
                            (pdappAPI.tool.pdappMoveAbleRef.target = e), (pdappAPI.tool.targets = e);
                        }, 1),
                        (t.toast = { show: !0, type: "success", text: t.langs.options.copy_text_success }),
                        setTimeout(() => {
                            t.toast.show = !1;
                        }, 5e3);
                }
            });
        },
        setGroup() {
            let t = this,
                e = [];
            pdappAPI.group.setGroup(t.groupItem.isGroup, function (o, a) {
                if ((e.push(o), a)) {
                    let o = {};
                    (o.undo = { action: "setGroup", target: e, value: t.groupItem.isGroup }),
                        (t.groupItem.isGroup = !t.groupItem.isGroup),
                        (o.redo = { action: "setGroup", target: e, value: t.groupItem.isGroup }),
                        t.setHistory(o),
                        t.groupItem.isGroup ||
                            (null != t.activeMenu &&
                                void 0 !== t.listMenus[t.activeMenu] &&
                                (t.listMenus[t.activeMenu].options.childID = null),
                            (pdappAPI.tool.pdappMoveAbleRef.target = null),
                            (pdappAPI.tool.targets = []),
                            (t.groupItem.show = !1));
                }
            });
        },
        alignGroup(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = pdappAPI.tool.pdappMoveAbleRef.target;
            (pdappAPI.tool.pdappMoveAbleRef.target = null),
                (pdappAPI.tool.targets = []),
                pdappAPI.group.alignGroup(t, o, function (t, a, p) {
                    let i = {};
                    (i.undo = { action: "alignGroup", target: t, value: a }),
                        (i.redo = { action: "alignGroup", target: t, value: p }),
                        e.setHistory(i),
                        setTimeout(() => {
                            (pdappAPI.tool.pdappMoveAbleRef.target = o), (pdappAPI.tool.targets = o);
                        }, 1);
                });
        },
        moveGroup(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target || 0 == pdappAPI.tool.pdappMoveAbleRef.target.length)
                return !1;
            let o = "top";
            "top" == t ? (o = "bot") : "right" == t ? (o = "left") : "left" == t && (o = "right");
            let a = pdappAPI.tool.pdappMoveAbleRef.target;
            (pdappAPI.tool.pdappMoveAbleRef.target = null),
                (pdappAPI.tool.targets = []),
                pdappAPI.group.moveGroup(t, a, function (p) {
                    let i = {};
                    (i.undo = { action: "moveGroup", target: p, value: o }),
                        (i.redo = { action: "moveGroup", target: p, value: t }),
                        e.setHistory(i),
                        setTimeout(() => {
                            (pdappAPI.tool.pdappMoveAbleRef.target = a), (pdappAPI.tool.targets = a);
                        }, 1);
                });
        },
        deleteGroup() {
            let t = this;
            pdappAPI.group.deleteGroup(function (e, o, a, p) {
                for (let e = 0; e < p.length; e++) {
                    let o = p[e].id;
                    void 0 !== t.photoStores[o] && (p[e].value = t.photoStores[o]);
                }
                let i = {};
                (i.undo = { action: "createGroup", index: o, value: p, svg: a }),
                    (i.redo = { action: "removeGroup", target: e, value: p }),
                    t.setHistory(i),
                    t.closeGroup();
            });
        },
        changeSettingOption(t) {
            if (
                void 0 !== this.menuOptions.details &&
                void 0 !== this.menuOptions.details[this.menuOptions.childID] &&
                void 0 !== this.menuOptions.details[this.menuOptions.childID].settings
            ) {
                let e = this.listTextOptions;
                "art" == t && (e = this.listArtworkOptions),
                    "photo" == t && (e = this.listPhotoOptions),
                    "qrcode" == t && (e = this.listQrcodeOptions),
                    "barcode" == t && (e = this.listBarcodeOptions),
                    pdappAPI.tool.changeOptionVisibles(this.menuOptions.details[this.menuOptions.childID].settings, e);
            }
        },
        showSettingOption(t, e, o) {
            if (t) {
                let a = 0;
                for (let t = 0; t < e.length; t++)
                    void 0 !== this.menuOptions.details &&
                        void 0 !== this.menuOptions.details[this.menuOptions.childID] &&
                        void 0 !== this.menuOptions.details[this.menuOptions.childID].settings &&
                        (void 0 === o
                            ? void 0 !== this.menuOptions.details[this.menuOptions.childID].settings[e[t]] &&
                              this.menuOptions.details[this.menuOptions.childID].settings[e[t]] &&
                              a++
                            : "text" == o
                              ? ((3 == e[t] && void 0 === this.menuOptions.details[this.menuOptions.childID].radius) ||
                                    (void 0 !== this.menuOptions.details[this.menuOptions.childID].settings[e[t]] &&
                                        this.menuOptions.details[this.menuOptions.childID].settings[e[t]])) &&
                                a++
                              : "art" == o
                                ? ((4 == e[t] &&
                                      void 0 !== this.menuOptions.details[this.menuOptions.childID].editColor &&
                                      this.menuOptions.details[this.menuOptions.childID].editColor) ||
                                      (void 0 !== this.menuOptions.details[this.menuOptions.childID].settings[e[t]] &&
                                          this.menuOptions.details[this.menuOptions.childID].settings[e[t]])) &&
                                  a++
                                : "photo" == o &&
                                  ((0 == e[t] &&
                                      1 == e[t] &&
                                      4 == e[t] &&
                                      7 == e[t] &&
                                      this.menuOptions.details[this.menuOptions.childID].editColor) ||
                                      (3 == e[t] &&
                                          (0 == this.menuOptions.details[this.menuOptions.childID].editColor ||
                                              0 == this.menuOptions.details[this.menuOptions.childID].colors.length)) ||
                                      (void 0 !== this.menuOptions.details[this.menuOptions.childID].settings[e[t]] &&
                                          this.menuOptions.details[this.menuOptions.childID].settings[e[t]])) &&
                                  a++);
                a == e.length && (t = !1);
            }
            return t;
        },
        changePhotoOption() {
            void 0 !== this.menuOptions.details[this.menuOptions.childID].clickUpload &&
                void 0 !== this.menuOptions.details[this.menuOptions.childID].clickPhoto &&
                pdappAPI.photo.changePhotoOption(
                    this.menuOptions.details[this.menuOptions.childID].clickUpload,
                    this.menuOptions.details[this.menuOptions.childID].clickPhoto
                );
        },
        showReplacePhoto() {
            let t = this;
            return (
                "photo" == t.activeMenu &&
                null != t.menuOptions.childID &&
                void 0 !== t.menuOptions.details[t.menuOptions.childID] &&
                void 0 !== t.menuOptions.details[t.menuOptions.childID].clickUpload &&
                !(
                    !t.menuOptions.details[t.menuOptions.childID].clickUpload &&
                    !t.menuOptions.details[t.menuOptions.childID].clickPhoto
                ) &&
                (t.menuOptions.details[t.menuOptions.childID].clickPhoto
                    ? ((t.tempModal.modal = {
                          show: !0,
                          header: !0,
                          size: "lg modal-dialog-scrollable",
                          title: t.langs.options.replace_photo,
                          type: "replacePhoto",
                          data: "",
                      }),
                      void setTimeout(() => {
                          pdappAPI.tool.loadMore(".pdapp-photo-libraries", function () {
                              t.getPhotos();
                          });
                      }, 1))
                    : (jQuery("#pdapp-upload-a-photo-replace").trigger("click"), !1))
            );
        },
        changePhotoReplace(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target) return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
            if (void 0 === t.target.files[0]) return !1;
            const a = t.target.files[0];
            let p = JSON.parse(JSON.stringify(e.settings));
            p.general.upload.type = ["png", "jpg", "jpeg"];
            let i = pdappAPI.upload.verify(a, p, e.langs);
            if ("" === i) {
                (e.loadingPage = !0), (e.waitDesign = !0);
                let t = "file-" + a.lastModified + "-" + a.size;
                if (void 0 !== e.photoStores[t]) {
                    let a = e.photoStores[t];
                    e.replacePhoto(a, t, o);
                } else
                    (e.photoStores[t] = {}),
                        pdappAPI.photo.readMediumImage(
                            a,
                            function (p) {
                                (e.photoStores[t] = p), e.uploadImage(t, a), e.replacePhoto(p, t, o);
                            },
                            0.85
                        );
                return jQuery("#pdapp-upload-a-photo-replace").val(""), !1;
            }
            (e.toast = { show: !0, type: "error", text: i }),
                setTimeout(() => {
                    e.toast.show = !1;
                }, 5e3);
        },
        replacePhoto(t, e, o) {
            let a = this,
                p = o.attr("id"),
                i = a.history.values.length,
                l = {};
            (l.undo = { action: "replacePhoto", target: p, value: a.photoStores[p], svg: o.clone() }),
                pdappAPI.photo.replace(t, o, function () {
                    (a.loadingPage = !1),
                        (a.waitDesign = !1),
                        (a.uploading = !1),
                        (a.listMenus.photo.loading = 0),
                        (a.photoStores[p] = { id: e, crop: "" }),
                        (l.redo = { action: "replacePhoto", target: p, value: a.photoStores[p], svg: o.clone() }),
                        a.setHistory(l),
                        a.dropdownPhoto("crop", i, "replace");
                });
        },
        addPhotoReplace(t) {
            let e = this;
            if (null == pdappAPI.tool.pdappMoveAbleRef.target) return !1;
            let o = jQuery(pdappAPI.tool.pdappMoveAbleRef.target);
            if (
                ((e.loadingPage = !0),
                (e.waitDesign = !0),
                (e.listMenus.photo.loading = 1),
                void 0 !== e.photoStores[t.id])
            ) {
                let a = e.photoStores[t.id];
                e.replacePhoto(a, t.id, o);
            } else {
                e.photoStores[t.id] = {};
                let o = { id: t.id, action: "getPhotoReplace", type: "blob", value: t.regular };
                pdappWorker
                    ? pdappWorker.postMessage(o)
                    : pdappAPI.photo.getPhoto(t.regular, function (t) {
                          (o.value = t), e.actionWorker(o);
                      }),
                    setTimeout(() => {
                        e.loadOriginPhoto(t.id, t.url, "getPhotoReplace");
                    }, 10);
            }
        },
        verifyPurchased() {
            "" != this.modal.purchased &&
                ((this.modal.verifing = !0),
                postToChild(document.getElementById("pdapp-login-frame"), "verifycode", {
                    purchased: this.modal.purchased,
                    domain: pdappDomain,
                }));
        },
        showVerifyModal() {
            this.modal = {
                show: !0,
                type: "verifycode",
                purchased: this.pdappPurchasedCode,
                error: "",
                checked: !0,
                verifing: !1,
            };
        },
        async updatePurchased(t) {
            let e = this,
                o = pdappAdminUrl + "admin-ajax.php?action=pdapp-dashboard-purchased&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                await pdappAPI.tool.postData(o, { purchased: e.modal.purchased });
                (e.pdappPurchasedCode = e.modal.purchased), e.checkAuthCode(t.data);
            } catch (t) {
                (e.toast = { show: !0, type: "warning", text: t.msg }),
                    setTimeout(() => {
                        e.toast.show = !1;
                    }, 5e3);
            }
        },
        checkAuthCode(t) {
            let e = this;
            void 0 !== t.refreshToken &&
                "" != t.refreshToken &&
                ((e.pdappApiToken = t.refreshToken), pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken)),
                "shop" == t.scope
                    ? ((e.modal.show = !1), e.showStore || ((e.showStore = !0), e.showTempStore()))
                    : "confirm" == t.scope
                      ? ((e.modal = {
                            show: !0,
                            type: "confirmemail",
                            code: t.code,
                            email: t.email,
                            verifing: !1,
                            error: "",
                            scope: t.scope,
                        }),
                        (e.confirmEmail.timeLess = parseInt(t.time)),
                        e.countDown())
                      : ("verify" != t.scope && "code" != t.scope) ||
                        (e.modal = {
                            show: !0,
                            type: "verifyemail",
                            code: t.code,
                            email: t.email,
                            verifing: !1,
                            error: "",
                            scope: t.scope,
                        });
        },
        codeValidate() {
            let t = this.confirmEmail.code.toString();
            t.length > 6 && (t = t.substring(0, 6)), (this.confirmEmail.code = parseInt(t));
        },
        expireConfirmCode(t) {
            let e = this;
            t && ((e.pdappApiToken = ""), pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken)),
                (e.modal.show = !1);
        },
        countDown() {
            let t = this;
            0 == t.confirmEmail.timeLess && t.expireConfirmCode(!0),
                (t.confirmEmail.timeLess = t.confirmEmail.timeLess - 1),
                t.confirmEmail.timeLess > 0 &&
                    setTimeout(() => {
                        t.countDown();
                    }, 1e3);
        },
        refreshCode() {
            postToChild(document.getElementById("pdapp-login-frame"), "refreshemail", { token: this.pdappApiToken });
        },
        confirmEmailCode() {
            let t = this;
            (t.confirmEmail.verifing = !0),
                postToChild(document.getElementById("pdapp-login-frame"), "confirmemail", {
                    emailcode: t.confirmEmail.code,
                    token: t.pdappApiToken,
                });
        },
        verifyEmail() {
            let t = this;
            return "" == t.modal.email
                ? ((t.modal.error = "A email is required."), !1)
                : /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
                        String(t.modal.email).toLowerCase()
                    )
                  ? ((t.modal.error = ""),
                    (t.modal.verifing = !0),
                    void postToChild(document.getElementById("pdapp-login-frame"), "verifyemail", {
                        email: t.modal.email,
                        token: t.pdappApiToken,
                    }))
                  : ((t.modal.error = "A email is invalid."), !1);
        },
        onAuthCode(t) {
            let e = this;
            if (0 == t.error)
                return (
                    void 0 !== e.modal.type && "verifycode" == e.modal.type
                        ? void 0 !== t.data && void 0 !== t.data.platform && t.data.platform == pdappPlatform
                            ? e.updatePurchased(t)
                            : ((e.modal.error = "Your platform verify incorrect"), (e.modal.verifing = !1))
                        : e.checkAuthCode(t.data),
                    !1
                );
            void 0 !== e.modal.type && "verifycode" == e.modal.type
                ? ((e.modal.error = t.msg), (e.modal.verifing = !1))
                : "" != e.pdappApiToken && "" != e.pdappPurchasedCode
                  ? ((e.pdappApiToken = ""),
                    pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken),
                    postToChild(document.getElementById("pdapp-login-frame"), "verifycode", {
                        purchased: e.pdappPurchasedCode,
                        domain: pdappDomain,
                    }))
                  : (e.modal = {
                        show: !0,
                        type: "verifycode",
                        purchased: e.pdappPurchasedCode,
                        error: "",
                        checked: !1,
                        verifing: !1,
                    });
        },
        onAuthEmail(t) {
            let e = this;
            if (((e.modal.verifing = !1), 0 == t.error))
                return (
                    (e.modal.show = !0),
                    (e.modal.email = t.data.email),
                    (e.modal.code = t.data.code),
                    (e.modal.scope = t.data.scope),
                    (e.pdappApiToken = t.data.refreshToken),
                    pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken),
                    (e.confirmEmail.timeLess = parseInt(t.data.time)),
                    e.countDown(),
                    (e.modal.type = "confirmemail"),
                    !1
                );
            e.modal.error = t.msg;
        },
        onAuthRefreshEmail(t) {
            let e = this;
            (e.confirmEmail.refresh = !1),
                0 == t.error
                    ? ((e.pdappApiToken = t.data.refreshToken),
                      pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken),
                      (e.confirmEmail.timeLess = parseInt(t.data.time)))
                    : (e.confirmEmail.error = t.msg);
        },
        onAuthConfirmEmail(t) {
            let e = this;
            0 == t.error
                ? ((e.modal.email = t.data.email),
                  (e.modal.code = t.data.code),
                  (e.modal.scope = t.data.scope),
                  (e.confirmEmail.timeLess = -1),
                  e.expireConfirmCode(!1),
                  (e.pdappApiToken = t.data.refreshToken),
                  pdappAPI.tool.setLocalVar("pdapp_api_token", e.pdappApiToken),
                  (e.confirmEmail.timeLess = parseInt(t.data.time)))
                : (e.confirmEmail.error = t.msg),
                (e.confirmEmail.verifing = !1);
        },
        showTempStore() {
            let t = this;
            "" != t.pdappPurchasedCode
                ? t.showStore
                    ? ((t.modal = { store: !0 }),
                      "" != t.pdappApiToken &&
                          postToChild(document.getElementById("pdapp-resource-frame"), "startdesign", t.pdappApiToken),
                      (t.loadingStore = !1))
                    : ((t.pdappApiToken = pdappAPI.tool.getLocalVar("pdapp_api_token", "")),
                      "" != t.pdappApiToken && "" != t.pdappApiToken
                          ? postToChild(document.getElementById("pdapp-login-frame"), "verifytoken", t.pdappApiToken)
                          : postToChild(document.getElementById("pdapp-login-frame"), "verifycode", {
                                purchased: t.pdappPurchasedCode,
                                domain: pdappDomain,
                            }),
                      (t.loadingStore = !0),
                      setTimeout(() => {
                          t.loadingStore = !1;
                      }, 1500))
                : t.showVerifyModal();
        },
        onImportTemp(t) {
            if (void 0 === t.id || void 0 === t.data) return !1;
            this.startUploadDesign(t.data, t.id);
        },
        async startUploadDesign(t, e) {
            let o = this,
                a = JSON.parse(JSON.stringify(t));
            (a.pid = o.folderID), (a.size = JSON.stringify(a.size));
            let p = pdappAdminUrl + "admin-ajax.php?action=pdapp-upload-temp&admin=1&pdapp-nonce=" + pdappNonce;
            try {
                let t = await pdappAPI.tool.postData(p, a);
                postToChild(document.getElementById("pdapp-resource-frame"), "addeddesign", e),
                    o.listTempsData[o.folderID].push(t.data);
            } catch (t) {
                (o.toast = { show: !0, type: "warning", text: t.msg }),
                    setTimeout(() => {
                        o.toast.show = !1;
                    }, 5e3);
            }
        },
    },
}).mount("#productdesignerapp-app");
function postToChild(t, e, o) {
    t.contentWindow.postMessage({ type: e, data: o }, pdappHomeUrl);
}
window.onmessage = function (t) {
    if (void 0 !== t.data.type) {
        let e = t.data.type,
            o = t.data.data;
        "loadedstore" == e && "ok" == o && (pdappVueApp.loadedStore = !0),
            "importdesign" == e && pdappVueApp.onImportTemp(o),
            "authcode" == e && pdappVueApp.onAuthCode(o),
            "authemail" == e && pdappVueApp.onAuthEmail(o),
            "authrefreshemail" == e && pdappVueApp.onAuthRefreshEmail(o),
            "authconfirmemail" == e && pdappVueApp.onAuthConfirmEmail(o);
    }
};