jQuery(document).ready(function(t){let i={init:function(){this.initColorPicker(),this.addImage(),this.removeImage(),this.bindEvents()},initColorPicker:function(){t(".widget:has(.color-picker) .color-picker").wpColorPicker({change:function(i,e){t(i.target).val(e.color.toString()),t(i.target).trigger("change")}})},addImage:function(){jQuery(document).on("click",".upload_image_button",function(t){t.preventDefault();var i,e=jQuery(this);(i=wp.media.frames.downloadable_file=wp.media({title:e.attr("data-uploader-title-txt"),button:{text:e.attr("data-uploader-btn-txt")},multiple:!1})).on("select",function(){var t=i.state().get("selection").first().toJSON(),n=t.sizes.thumbnail||t.sizes.full;e.prev().trigger("change").val(t.id);var o='';e.closest(".image-field").find(".image-preview").html(o),e.next().show()}),i.open()})},removeImage:function(){jQuery(document).on("click",".remove_image_button",function(){var t=jQuery(this);return t.closest(".image-field").find(".image-preview").html(" "),t.siblings(".img").trigger("change").val(""),t.hide(),!1})},bindEvents:function(){t(document).on("widget-updated widget-added",i.reinit_controls)},reinit_controls:function(){i.initColorPicker()}};t(function(){i.init()})});