require(["jquery","xwiki-meta"],function(e,l){const m=["Poor","Satisfactory","Good","Very good","Excellent"],n=(new XWiki.Document("RatingsUIX","XWiki.Ratings")).getURL("get");var p=function(b,c,a,f){var d=new XWiki.widgets.Notification("Your vote is being saved...","inprogress");e.post(n,{outputSyntax:"plain",vote:a,doc:c,form_token:l.form_token}).then(g=>{var h=g.avgvote;g=g.totalvotes;(h=parseFloat(h))?(h=20*h+"%",b.find("li.current-rating").first().width(h),f.text(g+" Votes"),f.previousMessage=
"",d.replace(new XWiki.widgets.Notification("Your vote has been saved!","done"))):d.replace(new XWiki.widgets.Notification("Error when saving your vote.","error"))}).catch(g=>{d.replace(new XWiki.widgets.Notification("Error when saving your vote. "+g,"error"))})},q=function(b,c,a,f,d){c=e(c);a.previousMessage="";c.on("click",function(){p(d,f,b+1,a)});c.on("mouseout",function(){""!=a.previousMessage&&a.text(a.previousMessage)});c.on("mouseover",function(){""==a.previousMessage&&(a.previousMessage=
a.text());a.text(m[b])})},r=function(){var b=e(this);if(!b.hasClass("locked")&&!b.hasClass("initialized")){var c=b.data("reference"),a=b.find(".rating-message").first();c&&b.find(".star-rating").first().find("a").each(function(f,d){q(f,d,a,c,b)});b.addClass("initialized")}},k=function(){e(".rating-wrapper").each(r)};e(k);e(document).on("xwiki:dom:updated",k)});