require(["jquery","xwiki-meta"],function(a,e){var d=0,g=function(){var b=a(this).parents(".overrideObject"),c=b.find("input").prop("name").split("_")[1];new XWiki.widgets.ConfirmationBox({onYes:function(){d=new XWiki.widgets.Notification("Deleting...","inprogress");a.ajax({url:XWiki.currentDocument.getURL("get"),type:"POST",dataType:"json",data:{action:"deleteObj",objNumber:c,form_token:e.form_token,outputSyntax:"plain"}}).then(f=>{"success"===f.status?(b.fadeOut(),e.refreshVersion(),d.replace(new XWiki.widgets.Notification("The template has been deleted!",
"done"))):"fail"===f.status&&("form_token"===f.cause?d.replace(new XWiki.widgets.Notification("CSRF validation failed when saving. Refresh your browser to try again.","error")):"rights"===f.cause&&d.replace(new XWiki.widgets.Notification("Failed to save the skins because of insufficient permissions.","error")))})}},{confirmationText:"Are you sure you want to delete this template?",yesButtonText:"Yes, delete it",noButtonText:"No, cancel"});return!1},h=function(){var b=a(this).parent().find(".overrideProperties");
b.hasClass("hidden")?(b.removeClass("hidden"),b.hide(),b.slideDown(400,function(){a(this).addClass("property-slided")})):b.slideToggle({start:function(){a(this).removeClass("property-slided")},complete:function(){a(this).addClass("property-slided")}})},k=function(b){a.ajax({url:XWiki.currentDocument.getURL("get"),type:"GET",data:{action:"displayObj",objNumber:b}}).then(c=>{d.replace(new XWiki.widgets.Notification("The template has been added!","done"));a("#overrideSection").append(c);c=a(".overrideObject").last();
c.find(".overrideTitle").on("click",h);c.find("button").on("click",g);c.find(".overrideProperties").removeClass("hidden");c.hide();c.fadeIn();a("html, body").animate({scrollTop:c.offset().top},500)})};a("#newPathAdd").on("click",function(){a.ajax({url:XWiki.currentDocument.getURL("get"),type:"POST",dataType:"json",data:{action:"newObj",path:a("#newPath").val(),form_token:e.form_token,outputSyntax:"plain"}}).then(b=>{d=new XWiki.widgets.Notification("Adding...","inprogress");"success"===b.status?(e.refreshVersion(),
k(b.objNumber)):"fail"===b.status&&("form_token"===b.cause?d.replace(new XWiki.widgets.Notification("CSRF validation failed when saving. Refresh your browser to try again.","error")):"rights"===b.cause&&d.replace(new XWiki.widgets.Notification("Failed to save the skins because of insufficient permissions.","error")))});return!1});a(".overrideTitle").on("click",h);a(".overrideObject button").on("click",g);a(".deprecatedProperties \x3e dl").hide();a(".deprecatedProperties \x3e h2").on("click",function(){a(".deprecatedProperties \x3e dl").slideToggle()})});