!function(e){formintorjs.define(["admin/settings/setting"],function(e){return e.extend({className:"wpmudev-browse",events:{"click .wpmudev-open_media":"add_image","click .wpmudev-url--clear":"clear_image"},get_field_html:function(){return this.options.hasPreview?this.options.disableBrowse?'<div class="wpmudev-browse--preview"><button class="wpmudev-preview--image wpmudev-open_media"><span class="wpmudev-get_image" style="background-image: url('+this.get_saved_value()+');"></span></button><div class="wpmudev-preview--url"><input class="wpmudev-url--input" type="url" value="'+this.get_saved_value()+'" placeholder="'+Forminator.l10n.options.placeholder_image_alt+'" /><button class="wpmudev-url--clear">'+Forminator.l10n.options.clear+"</button></div></div>":this.options.previewOnly?'<div class="wpmudev-browse--preview"><button class="wpmudev-preview--image wpmudev-open_media"><span class="wpmudev-get_image" style="background-image: url('+this.get_saved_value()+');"></span></button></div>':'<div class="wpmudev-browse--preview"><div class="wpmudev-preview--image wpmudev-open_media"><div class="wpmudev-get_image" style="background-image: url('+this.get_saved_value()+');"></div></div><div class="wpmudev-preview--url"><input class="wpmudev-url--input" type="url" value="'+this.get_saved_value()+'" placeholder="'+Forminator.l10n.options.placeholder_image+'" /><button class="wpmudev-url--clear">'+Forminator.l10n.options.clear+'</button></div></div><button class="wpmudev-browse--action wpmudev-open_media">'+Forminator.l10n.options.browse+"</button>":'<div class="wpmudev-browse--preview"><div class="wpmudev-preview--url"><input class="wpmudev-url--input" type="url" value="'+this.get_saved_value()+'" placeholder="'+Forminator.l10n.options.placeholder_image+'" /><button class="wpmudev-url--clear">'+Forminator.l10n.options.clear+'</button></div></div><button class="wpmudev-browse--action wpmudev-open_media">'+Forminator.l10n.options.browse+"</button>"},add_image:function(e){e.preventDefault();var i=this,s=this.$el.find(".wpmudev-url--input"),t=wp.media({title:this.options.popup_label,button:{text:this.options.popup_button_label},multiple:!1}).on("select",function(){var e,l=t.state().get("selection").first().toJSON();if(l&&l.url){if(i.options.hasPreview){var a=i.$el.find(".wpmudev-browse--preview"),u=i.$el.find(".wpmudev-get_image");a.addClass("wpmudev-has_image"),u.css("background-image","url({url})".replace("{url}",l.url))}e=_.isUndefined(i.options.imageSize)?l.url:"thumbnail"===i.options.imageSize?l.sizes.thumbnail.url:"medium"===i.options.imageSize?_.isUndefined(l.sizes.medium)?l.sizes.full.url:l.sizes.medium.url:"large"===i.options.imageSize?_.isUndefined(l.sizes.large)?l.sizes.full.url:l.sizes.large.url:l.sizes.full.url,s.val("{url}".replace("{url}",e)),i.save_value(e)}});t.open()},clear_image:function(e){e.preventDefault(),this.save_value(""),this.render()}})})}(jQuery);