(i=>{i(document).ready(function(){var e,o,a,t,c;e=i(".makeaholic-user-profile__form"),o=i(".avatar",".my-account-profile"),a=i(".tm_user_avatar",e),i(".upload_avatar",e).on("click",function(a){a.preventDefault(),i(this).closest(".makeaholic-user-profile__action").removeClass("active"),i(this).closest(".makeaholic-user-profile__form").find(".tm_user_avatar").trigger("click")}),a.on("change",function(a){var a=a.target.files,t=new FormData(e.get(0)),a=(t.append("action","makeaholic_upload_avatar"),t.append("_ajax_nonce",$makeaholicUpload.update_avatar_nonce),i.each(a,function(a,e){t.append("user_avatar",e)}),i('<img src="'+$makeaholicUpload.image_loader+'" width="100" height="100"/>'));o.html(a),i.ajax({url:$makeaholic.ajaxurl,type:"POST",data:t,cache:!1,dataType:"json",processData:!1,contentType:!1,success:function(a,e,t){o.html(a.html)}})}),e.on("submit",function(a){a.preventDefault()}),t=i(".makeaholic-user-profile__form"),c=i(".avatar",".my-account-profile"),i(".remove_avatar",t).on("click",function(a){a.preventDefault(),i(this).closest(".makeaholic-user-profile__action").removeClass("active");var a=new FormData(t.get(0)),e=(a.append("action","makeaholic_remove_avatar"),a.append("_ajax_nonce",$makeaholicUpload.update_avatar_nonce),i('<img src="'+$makeaholicUpload.image_loader+'" width="100" height="100"/>'));c.html(e),i.ajax({url:$makeaholic.ajaxurl,type:"POST",data:a,cache:!1,dataType:"json",processData:!1,contentType:!1,success:function(a,e,t){c.html(a.html)}})}),i(document.body).on("click",".my-account-profile .toggle_upload_action",function(a){a.preventDefault(),i(this).closest(".my-avatar").siblings(".makeaholic-user-profile").find(".makeaholic-user-profile__action").toggleClass("active")})})})(jQuery);