(() => {
"use strict";const{Vue:Vue$1,defineComponent}=window.wu_vue||{},hooks=wp.hooks||{},loadApp=(element,app_id,callback=null)=>{window["wu_"+app_id]&&!["add_checkout_form_field"].includes(app_id)||(window["wu_"+app_id]=new Vue$1(defineComponent({name:typeof app_id=="string"?app_id:"",el:element,directives:{init:{bind(el,binding,vnode){vnode.context[binding.arg]=binding.value}},initempty:{bind(el,binding,vnode){vnode.context[binding.arg]===""&&(vnode.context[binding.arg]=binding.value)}}},data(){let prefix=wu_settings.currency_symbol,suffix="";wu_settings.currency_position==="%v%s"?(prefix="",suffix=wu_settings.currency_symbol):wu_settings.currency_position==="%s %v"?prefix=wu_settings.currency_symbol+" ":wu_settings.currency_position==="%v %s"&&(prefix="",suffix=" "+wu_settings.currency_symbol);const settings={money_settings:{prefix,suffix,decimal:wu_settings.decimal_separator,thousands:wu_settings.thousand_separator,precision:parseInt(wu_settings.precision,10),masked:!1}};return Object.assign({},JSON.parse(element.dataset.state||"{}"),settings)},computed:{hooks:()=>hooks,console:()=>console,window:()=>window,shortcode(){return typeof this.id>"u"||typeof this.attributes>"u"?"":"["+(this.id+" "+Object.entries(this.attributes).map(([key,value])=>value===this.defaults[key]||typeof value=="object"||this.attributes[key+"_shortcode_requires"]&&Object.entries(this.attributes[key+"_shortcode_requires"]).some(([k,v])=>this.attributes[k]!==v)?"":key+'="'+(typeof value=="string"?value.trim():value)+'"').filter(value=>value).join(" ")).trim()+"]"}},mounted(){wu_on_load(),hooks.doAction("wu_"+app_id+"_mounted",this.$data);const cb=element.dataset.onLoad;typeof window[cb]=="function"&&window[cb](),callback&&callback(),this.$nextTick(function(){window.wu_initialize_code_editors(),window.wubox.refresh()})},updated(){this._priorState||(this._priorState=this.$options.data());const self=this,changedProp=Object.keys(this._data).find(key=>JSON.stringify(this._data[key])!==JSON.stringify(self._priorState[key]));this._priorState={...this._data},this.$nextTick(function(){hooks.doAction("wu_"+app_id+"_changed",changedProp,self.$data),window.wu_initialize_code_editors(),window.wubox.refresh()})},methods:{send(scope,function_name,value,cb){return scope==="window"?window[function_name](value,cb):window[scope][function_name](value,cb)},get_value(variable_name){return window[variable_name]},set_value(key,value){this[key]=value},get_state_value(value,default_value){return typeof this[value]>"u"?default_value:this[value]},duplicate_and_clean($event,query){var _a;const elements=document.querySelectorAll(query),target=elements.item(elements.length-1),clone=target.cloneNode(!0);clone.id=clone.id+"_copy",clone.querySelectorAll("input, textarea").forEach(el=>el.value=""),(_a=target.parentNode)==null||_a.insertBefore(clone,target.nextSibling)},wu_format_money(value){return wu_format_money(value)},require(data,value){return Object.prototype.toString.call(this[data])==="[object Array]"?this[data].indexOf(value)>-1:Object.prototype.toString.call(value)==="[object Array]"?value.indexOf(this[data])>-1:this[data]==value},open($event){$event.preventDefault(),this.edit=!0}}})),window["wu_"+app_id].$watch("section",function(new_value){try{const url=new URL(window.location.href);url.searchParams.set(app_id,new_value),history.pushState({},"",url)}catch(err){console.warn("Browser does not support pushState.",err)}}))},{Vue}=window.wu_vue||{},loadApps=()=>{document.querySelectorAll("[data-wu-app]").forEach(element=>{if(!Vue)return;const appId=element.dataset.wuApp;appId&&loadApp(element,appId)})};document.addEventListener("DOMContentLoaded",()=>{Vue.component("colorPicker",{props:["value"],template:'',mounted(){const vm=this;jQuery(this.$el).val(this.value).wpColorPicker({width:200,defaultColor:this.value,change(event,ui){vm.$emit("input",ui.color.toString())}})},watch:{value(value){jQuery(this.$el).wpColorPicker("color",value)}},destroyed(){jQuery(this.$el).off().wpColorPicker("destroy")}}),Vue.component("wpEditor",{props:["value","id","name"],template:'',mounted(){if(typeof wp.editor>"u")return;const that=this;wp.editor.remove(this.id),wp.editor.initialize(this.id,{tinymce:{setup(editor){editor.on("init",function(){wubox.refresh()}),editor.on("keyup",()=>{editor.isDirty()&&that.$emit("input",editor.getContent())})}}})},destroyed(){typeof wp.editor>"u"||wp.editor.remove(this.id)}}),document.body.addEventListener("wubox:unload",function(){const app_name="wu_"+document.getElementById("WUB_window").querySelector("ul[data-wu-app]").dataset.wuApp;delete window[app_name],delete window[app_name+"_errors"]}),document.body.addEventListener("wubox:load",loadApps),loadApps()});
})()