<?php
/*
* Plugin-Name: Product Designer App
* Plugin-URI: https://productdesignerapp.com
* Author: productdesignerapp
* Page: Settings
*/

if (!defined('ABSPATH'))
{
    exit;
}
?>
<template v-if="modal.type == 'textDefault'">
    <div class="modal-body p-0 pb-2">
        <div class="d-flex flex-column">
            <div class="w-100 bg-white border-bottom">
                <div class="pdapp-text-library-thumb pdapp-h50">
                    <svg id="text_heading_preview" class="invisible" x="0" y="0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%">
                        <text class="pdapp-target" xmlns="http://www.w3.org/2000/svg" x="50%" y="50%" :fill="modal.heading.color" :font-size="modal.heading.fontSize +'px'" :font-weight="modal.heading.fontWeight" stroke-linecap="round" stroke-linejoin="round" text-anchor="middle" :font-family="modal.heading.fontFamily" dominant-baseline="middle">{{ modal.heading.text }}</text>
                    </svg>
                    <img v-if="modal.heading.thumb.indexOf('base64') != -1" :src="modal.heading.thumb" class="mw-100 mh-100 p-1">
                    <div class="pdapp-loading-mask pdapp-loading-page" v-if="modal.render">
                        <div class="pdapp-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
                    </div>
                </div>
            </div>
            <div class="w-100 bg-white border-bottom">
                <div class="pdapp-text-library-thumb pdapp-h50">
                    <svg id="text_body_preview" class="invisible" x="0" y="0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%">
                        <text class="pdapp-target" xmlns="http://www.w3.org/2000/svg" x="50%" y="50%" :fill="modal.body.color" :font-size="modal.body.fontSize +'px'" :font-weight="modal.body.fontWeight" stroke-linecap="round" stroke-linejoin="round" text-anchor="middle" :font-family="modal.body.fontFamily" dominant-baseline="middle">{{ modal.body.text }}</text>
                    </svg>
                    <img v-if="modal.body.thumb.indexOf('base64') != -1" :src="modal.body.thumb" class="mw-100 mh-100 p-1">
                    <div class="pdapp-loading-mask pdapp-loading-page" v-if="modal.render">
                        <div class="pdapp-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
                    </div>
                </div>
            </div>
            <div class="w-100 bg-white border-bottom">
                <div class="pdapp-text-library-thumb">
                    <div id="pdapp-edit-text-arc" class="pdapp-text-arc-box">
                        <div class="pdapp-arc" :style="'position:absolute;top:0px;left:0px;width:100%;height:100%;font-size:'+modal.arc.fontSize+'px;font-family:'+modal.arc.fontFamily+';font-weight: '+modal.arc.fontWeight+';'"></div>
                    </div>
                    <svg id="text_arc_preview" class="invisible" x="0" y="0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%">
                        <g class="pdapp-target">
                            <g v-for="(arc, aid) in modal.arcText" :key="aid" :style="'transform:'+arc.transform+';transform-origin:'+arc.transformO+';'">
                                <text :fill="modal.arc.color" :font-size="modal.arc.fontSize +'px'" :font-weight="modal.arc.fontWeight" stroke-linecap="round" stroke-linejoin="round" text-anchor="start" :font-family="modal.arc.fontFamily">{{ arc.text }}</text>
                            </g>
                        </g>
                    </svg>
                    <img v-if="modal.arc.thumb.indexOf('base64') != -1" :src="modal.arc.thumb" class="mw-100 mh-100 p-1">
                    <div class="pdapp-loading-mask pdapp-loading-page" v-if="modal.render">
                        <div class="pdapp-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
                    </div>
                </div>
            </div>
            <div class="w-100 bg-white">
                <div class="pdapp-text-library-thumb">
                    <div id="pdapp-edit-text-reversearc" class="pdapp-text-arc-box">
                        <div class="pdapp-arc" :style="'position:absolute;top:0px;left:0px;width:100%;height:100%;font-size:'+modal.reversearc.fontSize+'px;font-family:'+modal.reversearc.fontFamily+';font-weight: '+modal.reversearc.fontWeight+';'"></div>
                    </div>
                    <svg id="text_reversearc_preview" class="invisible" x="0" y="0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%">
                        <g class="pdapp-target">
                            <g v-for="(arc, aid) in modal.reversearcText" :key="aid" :style="'transform:'+arc.transform+';transform-origin:'+arc.transformO+';'">
                                <text :fill="modal.reversearc.color" :font-size="modal.reversearc.fontSize +'px'" :font-weight="modal.reversearc.fontWeight" stroke-linecap="round" stroke-linejoin="round" text-anchor="start" :font-family="modal.reversearc.fontFamily">{{ arc.text }}</text>
                            </g>
                        </g>
                    </svg>
                    <img v-if="modal.reversearc.thumb.indexOf('base64') != -1" :src="modal.reversearc.thumb" class="mw-100 mh-100 p-1">
                    <div class="pdapp-loading-mask pdapp-loading-page" v-if="modal.render">
                        <div class="pdapp-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
                    </div>
                </div>
            </div>

            <div class="pdapp-text-options-box w-100 px-2 d-flex flex-column gap-2 overflow-y-auto overflow-x-hidden z-3">
                <div class="w-100">
                    <label class="form-label m-0">{{ langs.setting.text_style }}</label>
                    <div class="btn-group d-flex flex-wrap position-relative w-100 gap-1">
                        <button type="button" class="btn rounded-2 tooltip-bottom d-flex justify-content-center align-items-center" :class="modal.dropdown == 'font' ? 'btn-primary' : 'btn-light border'" :data-tooltip="langs.options.change_font" @click="textOptionDropdown('font')">
                            <span>{{ modal.heading.fontFamily }}</span>
                            <i class="material-icons material-symbols-outlined">arrow_drop_down</i>
                        </button>
                        <button type="button" class="btn rounded-2 tooltip-bottom d-flex justify-content-center align-items-center" :class="modal.dropdown == 'size' ? 'btn-primary' : 'btn-light border'" :data-tooltip="langs.setting.font_size" @click="textOptionDropdown('size')">
                            <span>{{ modal.heading.fontSize }}</span>
                            <i class="material-icons material-symbols-outlined">arrow_drop_down</i>
                        </button>
                        <button type="button" class="btn rounded-2 tooltip-bottom d-flex justify-content-center align-items-center" :class="modal.dropdown == 'color' ? 'btn-primary' : 'btn-light border'" :data-tooltip="langs.setting.text_color" @click="textOptionDropdown('color')">
                            <i class="material-icons material-symbols-outlined">format_color_text</i>
                            <i class="material-icons material-symbols-outlined">arrow_drop_down</i>
                        </button>

                        <div class="card shadow-lg p-0 m-0 border w-100" v-if="modal.dropdown == 'font' || modal.dropdown == 'color' || modal.dropdown == 'size'">
                            <button type="button" class="btn btn-sm btn-danger rounded-pill waves-effect waves-light pdapp-w30 pdapp-h30 p-0 btn-close-dropdown" @click="modal.dropdown = ''">
                                <i class="material-icons material-symbols-outlined">close</i>
                            </button>

                            <div class="pdapp-dropdown-box d-flex flex-column gap-1 p-0 py-2 w-100" v-if="modal.dropdown == 'font'">
                                <div class="input-group input-group-sm input-group-merge px-2">
                                    <span class="input-group-text bg-white ps-2 pe-1">
                                        <i class="material-icons material-symbols-outlined">search</i>
                                    </span>
                                    <input type="text" class="form-control border-start-0 ps-1 pe-1" :class="modal.findFont != '' ? 'border-end-0' : ''" v-model="modal.findFont">
                                    <button type="button" class="input-group-text bg-white  text-danger ps-1 pe-2" v-if="modal.findFont != ''" @click="modal.findFont = ''">
                                        <i class="material-icons material-symbols-outlined">close</i>
                                    </button>
                                </div>
                                <div class="pdapp-font-categories d-flex gap-2 mw-100 overflow-x-auto overflow-y-hidden pb-1 px-2">
                                    <button type="button" class="btn btn-sm p-1 pt-0 pb-0 pdapp-h25 text-nowrap border text-capitalize" :class="modal.fontCate == '' ? 'btn-primary' : 'btn-light'" @click="modal.fontCate = ''">{{ langs.options.all }}</button>
                                    <button type="button" class="btn btn-sm p-1 pt-0 pb-0 pdapp-h25 text-nowrap border text-capitalize" v-for="(category, idx) in listFontTexts.category" :class="modal.fontCate == category ? 'btn-primary' : 'btn-light'" :key="idx" @click="modal.fontCate = category">{{ category.replace('-', ' ') }}</button>
                                </div>
                                <div class="pdapp-font-library btn-group d-flex flex-wrap gap-2 w-100 overflow-y-auto overflow-x-hidden px-2">
                                    <button type="button" class="pdapp-h30 btn d-flex p-1 rounded-2 border justify-content-center" v-for="(font, idx) in listFontTexts.fonts" @click="changeFontDefault(font.title)" :class="font.title == modal.heading.fontFamily ? 'btn-primary' : 'btn-light'">
                                        <img :src="pluginUrl +'assets/images/fonts/'+ font.title.replaceAll(' ', '') +'.png'" :alt="font.title" class="mh-100 mw-100">
                                    </button>
                                </div>
                            </div>

                            <div class="pdapp-dropdown-box d-flex gap-1 p-2 align-items-center w-100" v-if="modal.dropdown == 'size'">
                                <input type="range" step="1" min="20" max="500" class="form-range" :style="'background-size:'+((parseInt(modal.heading.fontSize)-20)*100/480)+'% 100%;'" v-model="modal.heading.fontSize" @input="updateAllDefault('size')">
                                <input type="number" min="20" max="500" step="1" class="form-control form-control-sm pdapp-w70 pe-0" v-model="modal.heading.fontSize" @change="updateAllDefault('size')">
                            </div>

                            <div class="pdapp-dropdown-box d-flex flex-column gap-1 p-2 overflow-y-auto overflow-x-hidden" v-if="modal.dropdown == 'color'">
                                <h5 class="header-title fs-6 m-0 p-0">{{ langs.options.fill_style }}</h5>
                                <input type="color" class="form-control" v-model="modal.heading.color" @input="updateAllDefault('color')">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="w-100">
                    <label class="form-label m-0">{{ langs.setting.text_heading }}</label>
                    <input type="text" class="form-control" v-model="modal.heading.text" :placeholder="langs.setting.text_heading" @input="updateTextDefault('heading')">
                </div>

                <div class="w-100">
                    <label class="form-label m-0">{{ langs.setting.text_body }}</label>
                    <input type="text" class="form-control" v-model="modal.body.text" :placeholder="langs.setting.text_body" @input="updateTextDefault('body')">
                </div>

                <div class="position-relative">
                    <div class="w-100">
                        <label class="form-label m-0">{{ langs.setting.text_arc }}</label>
                        <input type="text" class="form-control" :value="modal.arc.text" :placeholder="langs.setting.text_arc" disabled>
                    </div>
                    <div class="d-flex gap-1 align-items-center w-100">
                        <input type="range" step="1" min="0" max="1000" class="form-range" :style="'background-size:'+ (modal.arc.arc.radius/10) +'% 100%;'" :value="modal.arc.arc.radius" disabled>
                        <input type="number" min="0" max="1000" class="form-control form-control-sm pdapp-w70 pe-0" :value="modal.arc.arc.radius" disabled>
                    </div>

                    <div class="w-100">
                        <label class="form-label m-0">{{ langs.setting.text_reverse_arc }}</label>
                        <input type="text" class="form-control" :value="modal.reversearc.text" :placeholder="langs.setting.text_reverse_arc" disabled>
                    </div>
                    <div class="d-flex gap-1 align-items-center w-100">
                        <input type="range" step="1" min="0" max="1000" class="form-range" :style="'background-size:'+ (modal.reversearc.arc.radius/10) +'% 100%;'" :value="modal.reversearc.arc.radius" disabled>
                        <input type="number" min="0" max="1000" class="form-control form-control-sm pdapp-w70 pe-0" :value="modal.reversearc.arc.radius" disabled>
                    </div>
                    <div class="position-absolute" id="pdapp-mask-upgrade">
                        <h5 class="d-flex justify-content-center align-items-center position-absolute fw-bold w-100 h-100 m-0">
                            <a href="<?php echo esc_url(PDAPP_HOME_URL. '/shop/woocommerce');?>" target="_blank" class="text-danger bg-white p-1 px-2 rounded">{{ langs.upgrade_basic }}</a>
                        </h5>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer py-1 justify-content-between">
        <button type="button" class="btn btn-light border" @click="modal.show = false">{{ langs.close }}</button>
        <div class="d-flex gap-2 align-items-center">
            <button type="button" class="btn btn-primary" :disabled="loading == 'textDefault' || modal.render" @click="saveTextDefault">
                <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" v-if="loading == 'textDefault'"></span>
                {{ langs.save }}
            </button>
        </div>
    </div>
</template>