var VM=VM||{};$(function(){function i(n){n.key.startsWith("Arrow")||n.key=="Enter"||n.key=="Tab"||($(n.target).removeClass("autocompleted"),document.getElementById("BylineId").value="")}const n=new Bloodhound({datumTokenizer:Bloodhound.tokenizers.obj.whitespace("Name"),queryTokenizer:Bloodhound.tokenizers.whitespace,remote:{url:"/authors?query=%QUERY",wildcard:"%QUERY"}});n.initialize();const t=$("#lookup").addClass("init").on("keyup",i).typeahead({minLength:2,highlight:!0},{name:"authors",display:"Name",source:n.ttAdapter(),templates:{suggestion:function(n){return"
"+n.Name+"<\/p>"}}}).on("typeahead:selected",function(n,t){$(n.target).addClass("autocompleted");document.getElementById("BylineId").value=t.Id;const i=document.getElementsByClassName("field-validation-error");Array.prototype.filter.call(i,n=>n.attributes["data-valmsg-for"].value==="AuthorName").forEach(n=>n.remove())});t.hasClass("is-autocompleted")&&t.addClass("autocompleted")})