'use strict';RMSFrontEnd.controller('emailSignUpController',['formDataOptions','$http',function(formDataOptions,$http){var _this=this;_this.formData={};_this.inProgress=false;_this.finished=false;_this.message="";this.onFinished=function(message){_this.inProgress=false;_this.finished=true;_this.message=message;}
this.onError=function(){_this.inProgress=false;_this.message="An error occured submitting the form.";}
this.sendForm=function(event){_this.showMessage=false;_this.newsLetterForm.$setSubmitted();event.preventDefault();if(_this.newsLetterForm.$valid){_this.inProgress=true;$http.post("/api/email-signup/SignUp",_this.formData).then(function(response){if(response.data.status==="Success"){_this.onFinished(response.data.message);}else{_this.onError();}},function(response){_this.onError();});}}}]);;;
'use strict';RMSFrontEnd.controller('newsLetterController',['formDataOptions','$http',function(formDataOptions,$http){var _this=this;_this.Countries=[];_this.States;_this.formData={};_this.selectedCountryStatesUSA=[];_this.selectedCountryStatesCAN=[];_this.finishedMessage="";_this.successMessage="";_this.showMessage=false;_this.inProgress=false;_this.finished=false;formDataOptions.getOptions(function(data){_this.Countries=data.countryCodes;_this.States=data.stateCodes;function findStates(country){var states=[];_this.Countries.some(function(option){if(option.name===country){states=option;return true;}});return states;}
_this.selectedCountryStatesUSA=_this.States['a'+findStates('United States').code];_this.selectedCountryStatesCAN=_this.States['a'+findStates('Canada').code];});this.filterStates=function(country){_this.selectedCountryStates=[];if(country.name=='United States'){_this.selectedCountryStates=_this.selectedCountryStatesUSA;}
if(country.name=='Canada'){_this.selectedCountryStates=_this.selectedCountryStatesCAN;}}
this.init=function(initOptions){_this.formData.id=initOptions.id;_this.isModal=initOptions.isModal==null?false:initOptions.isModal;_this.modalId="modal-clickdimensions-"+initOptions.id;_this.showMessage=initOptions.showMessage==null?false:initOptions.showMessage;_this.successMessage=initOptions.successMessage==null?"":initOptions.successMessage;}
this.onFinished=function(message){_this.inProgress=false;_this.finished=true;if(_this.isModal){$("#"+_this.modalId).modal("hide");}else{_this.finishedMessage=message;}}
this.onError=function(){_this.inProgress=false;_this.finishedMessage="An error occured submitting the form.";}
this.sendForm=function(event){_this.newsLetterForm.$setSubmitted();event.preventDefault();if(_this.newsLetterForm.$valid){_this.formData.f_f209983f5326e511814414feb5caa464=_this.selectedCountry.code;if(_this.selectedState!=null){_this.formData.f_12baffbc5226e511814414feb5caa464=_this.selectedState.code;}
if(_this.isMedia){_this.formData.f_64592f38011ce811b21f14feb5caa464=1;}
var config={headers:{'Content-Type':'application/x-www-form-urlencoded;charset=utf-8;'}}
_this.inProgress=true;$http.post("/umbraco/Surface/Utils/SubmitSignUp",$.param(_this.formData),config).then(function(response){if(response.data.status===0){_this.onFinished(_this.successMessage.length>0?_this.successMessage:response.data.message);}else{_this.onError();}},function(response){_this.onError();});}}}]);;;
'use strict';RMSFrontEnd.controller('consignController',function(userService,formDataOptions,stateSelection,fileUploaderService,recaptcha,$window,$q){var _this=this;this.formData={};this.formData.Images=[];this.titleOptions=[];this.lengthsOfOwnership=[];this.conditions=[];this.IsModal=false;this.formData.Images.push({},{},{});this.inProgress=false;this.showSuccess=false;this.showForm=true;this.showError=false;this.imagesEmpty=true;formDataOptions.getOptions(function(data){_this.titleOptions=data.titleOptions;_this.lengthsOfOwnership=data.lengthsOfOwnership;_this.conditions=data.carCondition;_this.Countries=data.countries;});this.scrollToTop=function(){$window.scrollTo(0,0);};this.filterStates=function(){stateSelection.getStates(_this.formData.country).then(function(states){_this.selectedCountryStates=states;});};this.addImage=function(inputToCopy){_this.formData.Images.push(angular.copy(inputToCopy));};this.removeImage=function(inputToRemove){if(_this.formData.Images.length>1){var itemIndex=_this.formData.Images.indexOf(inputToRemove);if(itemIndex>-1){_this.formData.Images.splice(itemIndex,1);}}};this.sendForm=function(){if(_this.consignForm.$valid){_this.disableButton=true;_this.inProgress=true;_this.showError=false;_this.errorMessage='';recaptcha.getToken('consign').then(function(token){var result=userService.consign(_this.formData,token);result.success(function(data){if(data.status>0){_this.formError(data);return;}
var id=data.message;var photoRequests=[];for(var i=0;i<_this.formData.Images.length;i++){var image=_this.formData.Images[i];if(image.name!==undefined){var form={Images:[]};form.Images=[image];photoRequests.push(userService.consignPhotoUpload(form,id));}}
$q.all(photoRequests).then(function(results){if(results.length===photoRequests.length){userService.consignConfirm(id).then(function(data){if(data.status==='Error'){_this.formError(data);}else{_this.formSuccess();_this.disableButton=false;}})}},function(error){_this.formError(error);});});result.error(function(data){_this.formError(data);});});}else{_this.formError();}};this.formSuccess=function(){_this.inProgress=false;_this.showSuccess=true;_this.showError=false;_this.showForm=false;};this.formError=function(data){var message='There was an error, please try again.';if(data){_this.errorMessage=data.message||message;}else{_this.errorMessage=message;}
_this.inProgress=false;_this.showSuccess=false;_this.showError=true;};this.resetForm=function(){_this.formData={};_this.formData.Images=[];_this.formData.Images.push({},{},{});_this.showSuccess=false;_this.showError=false;_this.consignForm.$setPristine();};this.dismissError=function(){_this.showError=false;};this.finish=function(){if(!_this.IsModal){var ref=document.referrer;window.location=ref;}
_this.resetForm();};this.initModal=function(){_this.IsModal=true;}});;;
'use strict';RMSFrontEnd.controller('registerToBidController',function($scope,$rootScope,$window,$location,formDataOptions,stateSelection,registerToBidService,userService,paymentService,recaptcha,dictionaryService,currencyService,$q){var _this=this;this.formData={};this.formData.Lots=[];this.formData.Questions=[];this.formCache={};this.biddingOptions={absentee:"Absentee",telephone:"Telephone",internet:"Internet",inPerson:"InPerson"};this.biddingMethodName="";this.memberRoles={VIP:"VIP",Staff:"Staff",FinancialRequirementsWaived:"FinancialRequirementsWaived",CompBidder:"CompBidder"};this.navigationTextOptions={submit:"submit",next:"next",previous:"previous"};this.RegistrationStatusOptions={Approved:0,Pending:1,NotRegistered:2,FailedPreAuth:3,PendingWithPreAuthSuccess:4,ApprovedMemorabilia:5,}
this.Countries=[];this.States=[];this.Months=[];this.Days=[];this.bringLetter=false;this.DocumentAttachmentMethods=["Attach now","Send in advance"];this.DocumentAttachmentMethodsInPerson=["Attach now","Bring on site","Send in advance"];this.BankLetters={"Attach now":"VerifyAttachment","Send in advance":"LetterInAdvance"};this.BankLettersPerson={"Attach now":"VerifyAttachment","Bring on site":"LetterOnSite","Send in advance":"LetterInAdvance"};this.BidderTypes=["Individual","Company","Dealer"];this.DealerOptions=["Yes","No"];this.paymentMethods=[];this.paymentFormId="";this.paymentAdd=false;this.auctionList=[];this.lotList=[];this.memberIsVIP=false;this.memberIsComp=false;this.selectedAuction=null;this.totalChargedPrice=0;this.validationInProgress=false;this.showLogin=true;this.showContact=false;this.showIdentification=false;this.showBidding=false;this.showFinancial=false;this.showLotSelection=false;this.successMessage="";this.errorMessage="";this.inProgress=false;this.showRestricted=false;this.defaultAuction=0;this.referrer=document.referrer;this.braintreeClient=null;this.init=function(auctionId){_this.defaultAuction=auctionId;registerToBidService.getAuctions(auctionId).success(function(data){_this.auctionList=data;selectAuction(_this.defaultAuction);});}
$scope.custom=function(lot){if(_this.selectedAuction&&_this.formData.MemorabiliaOnly){return lot.categoryId===2}
return true;}
dictionaryService.getDictionaryItems(["Forms.Document Option Attach Now","Forms.Document Option Send In Advance","Forms.Document Option Bring On Site",],true).then(function(data){_this.DocumentAttachmentMethods=[data["Forms.Document Option Attach Now"],data["Forms.Document Option Send In Advance"]];_this.DocumentAttachmentMethodsInPerson=[data["Forms.Document Option Attach Now"],data["Forms.Document Option Bring On Site"],data["Forms.Document Option Send In Advance"]];_this.BankLetters=[{key:"VerifyAttachment",text:data["Forms.Document Option Attach Now"]},{key:"LetterInAdvance",text:data["Forms.Document Option Send In Advance"]}];_this.BankLettersPerson=[{key:"VerifyAttachment",text:data["Forms.Document Option Attach Now"]},{key:"LetterOnSite",text:data["Forms.Document Option Bring On Site"]},{key:"LetterInAdvance",text:data["Forms.Document Option Send In Advance"]}];});this.$onInit=function(){dictionaryService.getDictionaryItems(["Forms.Next","Forms.Submit","Forms.Previous",],true).then(function(data){_this.navigationTextOptions.next=data["Forms.Next"];_this.navigationTextOptions.previous=data["Forms.Previous"];_this.navigationTextOptions.submit=data["Forms.Submit"];});}
this.setPaymentFormId=function(id){_this.paymentFormId=id;}
this.getStatusIcon=function(registration){if(registration!==undefined&&registration!==null){switch(registration.status){case _this.RegistrationStatusOptions.Approved:return"fa fa-check"
case _this.RegistrationStatusOptions.ApprovedMemorabilia:return"fa fa-check"
case _this.RegistrationStatusOptions.NotRegistered:return"icon-register"}
return"fa fa-hourglass"}}
$scope.$on('auctionRequest',function(event,args){if(_this.auctionList.length>0){selectAuction(args.id);}else{_this.defaultAuction=args.id;}});function onShowLotSelection(){if(_this.formData.Lots.length===0){_this.addNewLot();}}
$scope.$watch('bid.showLotSelection',function(newValue,oldValue){if(newValue){onShowLotSelection();}});formDataOptions.getOptions(function(data){_this.Countries=data.countries;_this.Months=data.date.months;_this.Days=data.date.days;_this.preferredPaymentMethod=data.preferredPaymentMethod;});registerToBidService.getMemberAccess().then(function(data){_this.memberIsVIP=data.financialRequirementsWaived;_this.memberIsComp=data.comped;});this.updateAuction=function(){if(_this.selectedAuction!==null){_this.formData.auctionId=_this.selectedAuction.id;_this.selectedRegistration=null;registerToBidService.getRegistrationStatus(_this.selectedAuction.id).then(function(data){_this.selectedRegistration=data;})}
_this.lotList=[];_this.formData.Lots=[];_this.formData.MemorabiliaOnly=false;};this.dealerChanged=function(){if(_this.formData.IsDealer=="Yes"){_this.formData.BidderType=_this.BidderTypes[2];}else{if(_this.formData.CompanyName.length>0){_this.formData.BidderType=_this.BidderTypes[1];}else{_this.formData.BidderType=_this.BidderTypes[0];}}};this.allowMemorabiliaOnly=function(){return _this.selectedAuction&&_this.selectedAuction.allowMemorabiliaOnly&&!_this.memberIsVIP&&_this.proofOfFundsRequired()}
function appendFormatted(auction){if(auction.authorizationAmount){auction.authorizationAmountFormatted=currencyService.formatCurrency(auction.authorizationAmount,auction.currencySymbol,auction.currencyCode)}
if(auction.registrationAmount){auction.registrationAmountFormatted=currencyService.formatCurrency(auction.registrationAmount,auction.currencySymbol,auction.currencyCode)}
if(auction.creditCardPaymentThreshold){auction.creditCardPaymentThresholdFormatted=currencyService.formatCurrency(auction.creditCardPaymentThreshold,auction.currencySymbol,auction.currencyCode)}}
this.getRegistrationConfiguration=function(contentId,callback){registerToBidService.getConfiguration(contentId).then(function(data){if(data.status!==1){angular.merge(_this.selectedAuction,data);appendFormatted(_this.selectedAuction);if(_this.selectedAuction.biddingOptions.length===1){_this.formData.BIDOptions=_this.selectedAuction.biddingOptions[0];}else{_this.formData.BIDOptions=undefined;}
if(callback!=null){callback();}}});};this.getAuctionLots=function(contentId){registerToBidService.getLots(contentId).then(function(data){_this.lotList=data;});};this.populateStates=function(country){if(country!=null&&country.length>0){stateSelection.getStates(country).then(function(states){_this.States=states;});}};this.requireAuthorization=function(){return!_this.memberIsVIP&&_this.selectedAuction&&_this.selectedAuction.canRunBidderAuthorization;};this.addNewLot=function(){_this.formData.Lots.push({});};this.removeLot=function(index){_this.formData.Lots.splice(index,1);};this.updateLot=function(index,item){_this.formData.Lots[index]=item;};this.scrollToTop=function(){$window.scrollTo(0,0);};this.updatePaymentToken=function(payment){_this.formData.paymentMethodToken=payment.token;_this.paymentAdd=false;payment.errorMessage="";};this.addNewPaymentToken=function(e){e.preventDefault();_this.formData.paymentMethodToken=null;_this.paymentMethod=null;_this.paymentAdd=true;};this.deletePaymentToken=function(e,payment){e.preventDefault();payment.errorMessage="";paymentService.deletePayment(payment.token).then(function(data){if(data.status===0){_this.formData.paymentMethodToken=null;_this.paymentMethod=null;populatePaymentMethods();}else{payment.errorMessage=data.message;}});};this.paymentMethodRequired=function(){if(_this.selectedAuction&&_this.selectedAuction.creditCardPaymentThreshold>0){return true;}
if(_this.memberIsVIP&&_this.memberIsComp){return false;}
if(_this.memberIsVIP&&_this.totalChargedPrice===0){return false;}
return true;};function populatePaymentMethods(id){paymentService.getPaymentMethods().then(function(data){_this.paymentMethods=data;angular.forEach(_this.paymentMethods,function(v,i){if(v.token===id){_this.paymentMethod=v;}});if(_this.paymentMethods.length==0){_this.paymentAdd=true;}});};this.previousButtonText=function(){return _this.navigationTextOptions.previous;};this.nextButtonText=function(current){if(_this.nextIsSubmit(current)){return _this.navigationTextOptions.submit;}
return _this.navigationTextOptions.next;};this.nextIsSubmit=function(current){switch(current.$name){case"identification":return true;}
return false;};this.validBiddingMethod=function(){return _this.isValidBiddingMethod(_this.formData.BIDOptions);}
this.isValidBiddingMethod=function(method){return _this.selectedAuction&&_this.selectedAuction.biddingOptions&&_this.selectedAuction.biddingOptions.indexOf(method)>-1;}
this.updateBiddingName=function(){if(_this.formData.BIDOptions==_this.biddingOptions.inPerson){_this.biddingMethodName='In Person'}else{_this.biddingMethodName=_this.formData.BIDOptions;}}
this.onlyInternetAvailable=function(){return _this.selectedAuction&&_this.selectedAuction.biddingOptions&&_this.selectedAuction.biddingOptions.indexOf(_this.biddingOptions.internet)>-1&&_this.selectedAuction.biddingOptions.length===1}
this.proofOfFundsRequired=function(){if(_this.selectedAuction&&_this.selectedAuction.endDate){var proofOfFundsExpired=!(new Date(_this.proofOfFundsExpiry)>=new Date(_this.selectedAuction.endDate));return!_this.memberIsVIP&&_this.selectedAuction.requireBankLetter&&proofOfFundsExpired}
return true;};this.canShowLotListing=function(){return(_this.formData.BIDOptions===_this.biddingOptions.absentee||_this.formData.BIDOptions===_this.biddingOptions.telephone)&&_this.lotList.length>0}
this.next=function(e,current){e.preventDefault();current.$setSubmitted();if(current.$valid){_this.bidForm.$setPristine();if(_this.nextIsSubmit(current)){_this.sendForm();}else{this.scrollToTop();switch(current.$name){case"login":if(_this.selectedAuction.redirect){window.open(_this.selectedAuction.redirect,'_blank');return;}
if(_this.formData.Email.length>0){_this.validationInProgress=true;_this.formData.auctionId=_this.selectedAuction.id;_this.getRegistrationConfiguration(_this.selectedAuction.id,function(){_this.showLogin=false;if(_this.selectedAuction.type==="Sealed"||_this.selectedAuction.type==="Timed"){_this.showContact=true;}else{_this.showBidding=true;}
_this.formData.termsAndConditionsVersionId=_this.selectedAuction.termsAndConditionsVersionId;_this.validationInProgress=false;});if(_this.braintreeClient==null){paymentService.createBraintreeClient(_this.paymentFormId).then(function(data){_this.braintreeClient=data;populatePaymentMethods();});}}else{$(e.currentTarget).data("context","Registration-"+_this.selectedAuction.id);$("#loginModal").modal({backdrop:'static',keyboard:false},$(e.currentTarget));}
break;case"bidding":_this.showBidding=false;_this.formData.Lots=[];if(_this.formData.BIDOptions===_this.biddingOptions.absentee||_this.formData.BIDOptions===_this.biddingOptions.telephone){_this.validationInProgress=true;registerToBidService.getLots(_this.selectedAuction.id).then(function(data){_this.validationInProgress=false;_this.lotList=data;_this.showContact=true;});}else{_this.lotList=[];_this.showContact=true;}
if(_this.formData.BIDOptions===_this.biddingOptions.inPerson){_this.totalChargedPrice=_this.selectedAuction.registrationAmount;}else{_this.totalChargedPrice=0;}
_this.totalChargedPriceFormatted=currencyService.formatCurrency(_this.totalChargedPrice,_this.selectedAuction.currencySymbol,_this.selectedAuction.currencyCode);break;case"contact":_this.showContact=false;if(_this.formData.BIDOptions===_this.biddingOptions.inPerson){_this.totalChargedPrice=_this.selectedAuction.registrationAmount;}else{_this.totalChargedPrice=0;}
_this.totalChargedPriceFormatted=currencyService.formatCurrency(_this.totalChargedPrice,_this.selectedAuction.currencySymbol,_this.selectedAuction.currencyCode);if(_this.canShowLotListing()){_this.showLotSelection=true;}else{_this.showIdentification=true;}
break;case"identification":break;case"lotSelection":_this.showLotSelection=false;_this.showIdentification=true;break;}}}};this.previous=function(e,current){e.preventDefault();_this.disableButton=false;_this.errorMessage="";_this.successMessage="";_this.bidForm.$setPristine();this.scrollToTop();switch(current.$name){case"bidding":_this.showLogin=true;_this.showBidding=false;break;case"identification":_this.showIdentification=false;if(_this.canShowLotListing()){_this.showLotSelection=true;}else{_this.showContact=true;}
break;case"contact":if(_this.selectedAuction.type==="Sealed"||_this.selectedAuction.type==="Timed"){_this.showLogin=true;}else{_this.showBidding=true;}
_this.showContact=false;break;case"lotSelection":_this.showContact=true;_this.showLotSelection=false;break;}};function selectAuction(id){angular.forEach(_this.auctionList,function(v,i){if(id===v.id||id===v.legacyId){_this.selectedAuction=v;_this.updateAuction();}});}
function paymentError(data){if(data.state.fields.number.isValid){$(data.state.fields.number.container).removeClass("invalid");}else{$(data.state.fields.number.container).addClass("invalid");}
if(data.state.fields.cvv.isValid){$(data.state.fields.cvv.container).removeClass("invalid");}else{$(data.state.fields.cvv.container).addClass("invalid");}
if(data.state.fields.expirationMonth.isValid){$(data.state.fields.expirationMonth.container).removeClass("invalid");}else{$(data.state.fields.expirationMonth.container).addClass("invalid");}
if(data.state.fields.expirationYear.isValid){$(data.state.fields.expirationYear.container).removeClass("invalid");}else{$(data.state.fields.expirationYear.container).addClass("invalid");}
if(data.state.fields.postalCode.isValid){$(data.state.fields.postalCode.container).removeClass("invalid")}else{$(data.state.fields.postalCode.container).addClass("invalid")}
return data;}
function uploadAttachments(data){if(data.status===0){return registerToBidService.uploadAttachments(_this.formData.id,_this.formData).then(function(data){return data});}else{return data;}}
function setPaymentToken(data){if(data.status===0&&_this.formData.paymentMethodToken==null){return paymentService.getPaymentToken(_this.braintreeClient,_this.selectedAuction.contactEmail).then(function(data){if(data.status===0){_this.formData.paymentMethodToken=data.id;populatePaymentMethods(data.id);return{status:0,message:"Token created"};}else{return{status:2,message:data.message};}},paymentError);}else{return data;}}
function saveRegistration(data){if(data.status===0){return registerToBidService.submitRegistration(_this.formData).then(function(data){if(data.status===0||data.status===3){_this.formData.id=data.id;dataLayer.push({'event':'from_submit_enhance_in_network','enhanced_conversion_data':{"email":_this.formData.Email,"phone_number":_this.formData.mobilePhone}});dataLayer.push({'event':"successfulBidderRegistration",'auctionCode':_this.selectedAuction.auctionCode});}
return data;});}else{return data;}}
function createRegistration(recaptcha){var deferred=$q.defer();if(_this.formData.id==null){return registerToBidService.createRegistration(_this.formData,recaptcha).then(function(data){if(data.status===0||data.status===3){_this.formData.id=data.id;}
return data;});}else{deferred.resolve({status:0})
return deferred.promise;}}
function finished(data){switch(data.status){case 3:case 0:_this.showRestricted=false;_this.errorMessage="";_this.successMessage=data.message;break;case 4:_this.showRestricted=true;break;case 2:_this.errorMessage=data.message===undefined?"Unknown error occured. Please try again.":data.message;break;}
_this.disableButton=false;_this.inProgress=false;}
function error(){_this.inProgress=false;_this.disableButton=false;_this.errorMessage="Unknown error occured. Please try again.";}
this.requireBankLetterAttachment=function(){var requireBankLetterOther=false;var requireBankLetterPerson=false;if(_this.formData.BankLetterOther){requireBankLetterOther=_this.formData.BankLetterOther.key===_this.BankLetters[0].key&&_this.formData.BIDOptions!==_this.biddingOptions.inPerson;}
if(_this.formData.BankLetterPerson){requireBankLetterPerson=_this.formData.BankLetterPerson.key===_this.BankLettersPerson[0].key&&_this.formData.BIDOptions===_this.biddingOptions.inPerson;}
return(requireBankLetterOther||requireBankLetterPerson);};this.sendForm=function(){if(_this.bidForm.$valid){_this.disableButton=true;_this.inProgress=true;if(_this.formData.BIDOptions===_this.biddingOptions.inPerson){if(_this.formData.BankLetterPerson){_this.formData.BankLetter=_this.formData.BankLetterPerson.key;}}else{if(_this.formData.BankLetterOther){_this.formData.BankLetter=_this.formData.BankLetterOther.key;}}
recaptcha.getToken('registerToBid').then(function(token){createRegistration(token).then(uploadAttachments).then(setPaymentToken).then(saveRegistration).then(finished).catch(error);}).catch(error);}};this.resetForm=function(){_this.disableButton=false;_this.formCache=_this.formData;_this.formData={};_this.formData.FirstName=_this.formCache.FirstName;_this.formData.LastName=_this.formCache.LastName;_this.formData.Email=_this.formCache.Email;_this.formData.Country=_this.formCache.Country;_this.formData.CompanyName=_this.formCache.CompanyName;_this.formData.State=_this.formCache.State;_this.formData.AddressLine1=_this.formCache.AddressLine1;_this.formData.AddressLine2=_this.formCache.AddressLine2;_this.formData.homePhone=_this.formCache.homePhone;_this.formData.workPhone=_this.formCache.workPhone;_this.formData.mobilePhone=_this.formCache.mobilePhone;_this.formData.city=_this.formCache.city;_this.formData.zip=_this.formCache.zip;_this.formData.Month=_this.formCache.Month;_this.formData.Day=_this.formCache.Day;_this.formData.Year=_this.formCache.Year;_this.formData.IsDealer=_this.formCache.IsDealer;_this.formData.Questions=[];_this.formData.AcceptWinningCharge=_this.formCache.AcceptWinningCharge;_this.formCache={};_this.showQuestion=0;_this.selectedAnswer="";$('.button--file__name').html('Choose a file');_this.formData.BankLetterAttachment=undefined;_this.formData.PhotoIdAttachment=undefined;_this.formData.AuthorizationLetterAttachment=undefined;_this.showLogin=true;_this.showContact=false;_this.showIdentification=false;_this.showBidding=false;_this.showFinancial=false;_this.showLotSelection=false;_this.showQuestions=false;_this.showRestricted=false;_this.selectedAuction=null;_this.selectedRegistration=null;_this.paymentMethod=null;_this.bidForm.$setPristine();_this.braintreeClient.clearForm();};this.finish=function(){window.location=_this.referrer;_this.resetForm();};this.logout=function(e){e.preventDefault();userService.logout().then(function(data){if(data.status===0){window.location.reload();}});};this.adjustLotAmount=function(index,formattedAmount){if(formattedAmount.length>0){var amountValue=formattedAmount.replace(/[^0-9]/g,'');var foundLot=_this.formData.Lots[index];if(amountValue.length>0){foundLot.amount=parseFloat(amountValue);}else{foundLot.amount=parseFloat(amountValue);lot.amount=0;}}}});;;
'use strict';RMSFrontEnd.controller('mediaCredentialsController',function($scope,$log,$http,ajaxService,recaptcha){var _this=this;$scope.sortType='UserName';$scope.sortReverse=false;this.init=function(userName){_this.upcomingAuctions=null;_this.requestedAuctions=null;_this.userName=userName;_this.credentials=[{auctionKey:"",name:userName?"Loading credentials for "+_this.userName+"...":"Loading pending credentials...",startDate:"",status:""}];$http.get('/api/press/credentials/GetUpcomingAuctions').success(function(data){_this.upcomingAuctions=data;});if(_this.userName){$http.get('/api/press/credentials/GetCredentials').success(function(data){_this.credentials=data;});}};this.requestCredentials=function(){var form={auctionKey:_this.selectedAuction.auctionKey};if(_this.credentials){for(var i=0;i<_this.credentials.length;i++){if(_this.credentials[i].auctionKey===_this.selectedAuction.auctionKey){return;}}}
if(!_this.inProgress){_this.inProgress=true;var promise=$http.post('/api/press/credentials/RequestCredentials',form,{'headers':{'X-Recaptcha':recaptcha}});promise.success(function(data){_this.credentials.push(data);_this.inProgress=false;});promise.error(function(data,status){$log.error("MediaCredentials Error : "+data.message);alert(data.message);_this.inProgress=false;})}};function removeRegistration(key){var index=-1;if(_this.credentials){for(var i=0;i<_this.credentials.length;i++){if(_this.credentials[i].registrationKey===key){index=i;}}}
if(index>-1){_this.credentials.splice(index,1);}}
this.cancelCredentials=function(registrationKey){if(!_this.inProgress){_this.inProgress=true;var promise=$http.post('/api/press/credentials/CancelCredentials',{registrationKey:registrationKey});promise.success(function(data){removeRegistration(response.data.registrationKey);_this.inProgress=false;});promise.error(function(data,status){$log.error("MediaCredentials Error : "+data.message);alert(data.message);_this.inProgress=false;});}};});;;
var storeController=function(){'use strict';var _this=this;this.isInvalid=false;this.validate=function(param){var amount=this.amount[param];if(amount==null||amount==undefined||amount==0){_this.isInvalid=true;}else if(typeof amount=='number'||amount>0){_this.isInvalid=false;}}};storeController.$inject=[];angular.module('RMSFrontEnd').controller('storeController',storeController);;;
'use strict';RMSFrontEnd.controller('editProfileController',function(userService,formDataOptions,stateSelection,recaptcha,$timeout,$window,$q){var _this=this;this.formData={MediaTypes:[]};this.formDataOptions={};this.Countries=[];this.MethodsOfContact=[];this.selectedCountryStates=[];this.selectedEditorCountryStates=[];this.Months=[];this.Days=[];this.MediaInformations=[];this.MediaCoverages=[];this.PrimaryAudiences=[];this.HowDidYouHear=[];this.inProgress=false;this.firstSubmitted=false;this.formData.IsMedia=false;this.showSuccess=false;this.showError=false;this.readOnly=true;this.BidderTypes=["Individual","Company","Dealer"];this.DealerOptions=["Yes","No"];this.MediaTypes=[];this.SocialHandles=[{name:"Instagram",value:""},{name:"Twitter",value:""},{name:"YouTube",value:""},{name:"Facebook",value:""},{name:"TikTok",value:""},{name:"LinkedIn",value:""},{name:"Other",value:""},]
this.emailChangeInProgress=false;this.emailChangeSuccess=false;this.emailChangeSubmitted=false;this.emailChangeMessage="";formDataOptions.getOptions(function(data){_this.formDataOptions=data;_this.Countries=_this.formDataOptions.countries;_this.MethodsOfContact=_this.formDataOptions.methodsOfContact;_this.HowDidYouHear=_this.formDataOptions.howDidYouHear;_this.MediaInformations=_this.formDataOptions.media.MediaInformations;_this.MediaCoverages=_this.formDataOptions.media.MediaCoverages;_this.PrimaryAudiences=_this.formDataOptions.media.PrimaryAudiences;_this.Days=_this.formDataOptions.date.days;_this.Months=_this.formDataOptions.date.months;});formDataOptions.getMediaTypes(function(data){_this.MediaTypes=data;for(const mediaType of _this.formData.MediaTypes){selectMediaType(mediaType);}});this.edit=function(){_this.readOnly=false;}
this.cancel=function(){_this.editProfileForm.$setPristine();_this.readOnly=true;}
function checkMediaType(id){for(let o of _this.MediaTypes){if(o.id===id&&o.selected===true){return true;}}
return false;}
this.anyCheckedMediaType=function(){for(let o of _this.MediaTypes){if(o.selected===true){return true;}}
return false;}
this.anySocialHandle=function(){for(let o of _this.SocialHandles){if((o.value||"").length>0){return true;}}
return false;}
function selectMediaType(id){for(let o of _this.MediaTypes){if(o.id===id){o.selected=true;}}}
function populateSocialHandle(name,value){for(let o of _this.SocialHandles){if(o.name===name){o.value=value;}}}
function hasSocialHandle(){for(let o of _this.SocialHandles){if((o.value||"").length>0){return true;}}
return false;}
this.populateSocialHandles=function(list){var items=list.split(';');for(const item of items){var split=item.split(":");populateSocialHandle(split[0],split[1]);}}
this.selectMediaTypes=function(list){var items=list.split(',');var numberlist=[];for(const item of items){let number=parseInt(item);selectMediaType(number);numberlist.push(number)}
_this.formData.MediaTypes=numberlist;}
this.showMedia=function(){return _this.formData.IsMedia||_this.formData.RequestMediaCredentials;}
this.requireSocialHandle=function(){return!_this.readOnly&&_this.formData.IsMedia&&(checkMediaType(859270006)&&!hasSocialHandle());}
this.requireWebsite=function(){return!_this.readOnly&&_this.formData.IsMedia&&(checkMediaType(859270007)||checkMediaType(859270001));}
this.requireOutletName=function(){return!_this.readOnly&&_this.formData.IsMedia&&_this.formData.Freelance===false&&(checkMediaType(859270005)||checkMediaType(859270000)||checkMediaType(859270004)||checkMediaType(859270003)||checkMediaType(859270008)||checkMediaType(859270002))}
this.requireFeaturePublication=function(){return!_this.readOnly&&_this.formData.IsMedia&&_this.formData.Freelance===true}
this.requireMediaType=function(){return!_this.readOnly&&_this.formData.IsMedia&&!_this.MediaTypes.some(x=>x.selected);}
this.changePassword=function(){$("#changePasswordModal").modal("show");}
this.reloadPage=function(){$timeout(function(){$window.location.reload();},500);};this.validateForm=function(){_this.formSubmitted=true;};this.filterStates=function(){stateSelection.getStates(_this.formData.Country).then(function(states){_this.selectedCountryStates=states;});};this.dealerOptionsRequired=function(){return _this.formData.CompanyName.length>0&&(_this.formData.Country=="United States"||_this.formData.Country=="Canada");}
this.dealerChanged=function(){if(_this.formData.IsDealer=="Yes"){_this.formData.BidderType=_this.BidderTypes[2];}else{if(_this.formData.CompanyName.length>0){_this.formData.BidderType=_this.BidderTypes[1];}else{_this.formData.BidderType=_this.BidderTypes[0];}}};this.getEditorCountry=function(country){stateSelection.getStates(country).then(function(states){_this.selectedEditorCountryStates=states;});};function sanitizedRequest(){var mediaTypes=[];angular.forEach(_this.MediaTypes,function(o){if(o.selected){mediaTypes.push(o.id);}})
_this.formData.MediaTypes=mediaTypes;var socialHandles=[];angular.forEach(_this.SocialHandles,function(o){if((o.value||"").length>0){socialHandles.push(o.name+":"+o.value);}})
_this.formData.socialHandles=socialHandles.join(";");return _this.formData;}
this.save=function(){_this.disableButton=true;if(_this.editProfileForm.$valid){_this.showError=false;_this.errorMessage='';userService.storeProfile(sanitizedRequest());$("#saveProfileModal").modal("show");}}});;;
'use strict';RMSFrontEnd.controller('MediaReleaseController',function(mediaService){var _this=this;this.inProgress=false;this.init=function(){mediaService.getAvailableYears().then(function(data){_this.years=data;_this.year=_this.years[0];_this.getReleases()});};this.getReleases=function(){_this.inProgress=true;mediaService.findReleases(_this.year).then(function(data){_this.inProgress=false;_this.releases=data;},function(){_this.inProgress=false;});};});;;
'use strict';RMSFrontEnd.controller('PaginationLotController',function($scope,$location,$rootScope,searchService,userService,biddingSyncService){var _this=this;_this.select2=[];$rootScope.searchTerm="";$scope.select2Options={minimumResultsForSearch:Infinity,closeOnSelect:false,onload:function(element){var getTerms=function(){return($(element).attr("ui-select2-terms")||",").split(",")}
var getOptionCount=function(){return $(element).find("option:checked").length;}
var searchField=$(element).siblings('.select2').find('.select2-search__field');var getSelectedText=function(count){if(count===0){return"All "+getTerms()[1];}
if(count===1){return count+" "+getTerms()[0]+" Selected";}
return count+" "+getTerms()[1]+" Selected";}
var selector=function(e){var find=$(e.currentTarget).find("option:checked");searchField.attr("placeholder",getSelectedText(find.length));searchField.css("width","100%");};$(element).on('select2:unselect',selector);$(element).on('select2:select',selector);searchField.attr("placeholder",getSelectedText(getOptionCount()));searchField.parent().css("float","none");searchField.parent().prepend("<a href=\"\" style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888;\"><i class=\"fa fa-chevron-down\"></i></a>");searchField.css("width","100%");searchField.attr("autocomplete","none");searchField.focus();searchField.blur();var data=$(element).data();if(data.$ngModelController!==undefined){var callback=function(){var selected=data.$ngModelController.$modelValue||[];searchField.attr("placeholder",getSelectedText(selected.length));searchField.css("width","100%");};callback();_this.select2.push(callback);}}};$scope.select2SingleOptions={minimumResultsForSearch:Infinity,closeOnSelect:true,onload:function(element){var select2=$(element).siblings('.select2');var arrow=select2.find(".select2-selection__arrow");var data=$(element).data();if(data.$ngModelController){var find=select2.find(".select2-selection__rendered");var callback=function(){var selected=data.$ngModelController.$modelValue||"";find.attr("title",selected.name||selected.Name||selected);find.text(selected.name||selected.Name||selected);}
callback();_this.select2.push(callback);}
arrow.find("b").remove();arrow.prepend("<span style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888; width: 20px;\"><i class=\"fa fa-chevron-down\"></i></span>");}};_this.persist=true;_this.title="ALL LOTS";_this.pager={};_this.items=[];_this.formData={};_this.formData.search={};_this.viewsOptions=[{name:'40',value:40},{name:'100',value:100},{name:'200',value:200}];_this.sortList=[{Id:"Default",Name:"Lot"},{Id:"Availability",Name:"Availability"},{Id:"MakeYearModel",Name:"Make"},{Id:"YearDesc",Name:"Year (High-Low)"},{Id:"Year",Name:"Year (Low-High)"},{Id:"Value",Name:"Value (High-Low)"},{Id:"ValueAsc",Name:"Value (Low-High)"},{Id:"DatePosted",Name:"Posted (New-Old)"},{Id:"DatePostedAsc",Name:"Posted (Old-New)"}];_this.gridPClass="col-xs-12 col-md-6 col-sm-6 col-lg-4 grid-item";_this.gridVClass="search-result--small-wrapper";_this.canUseLocalStorage=loadLocalStorage();_this.showLots=false;_this.selectedSortBy=_this.sortList[1];_this.firstTime=true;_this.firstRequest=true;_this.keepAuction=false;_this.redirectUrl="";_this.auctionBid={};_this.searchOptions={};_this.auction="";_this.stillForSaleOnly=false;_this.button=null;if(history.scrollRestoration){history.scrollRestoration='auto';}
$('.mobile-country-select').on('focus',function(){$(this).children(':first-child').removeProp('selected');});if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid;selectPageSize(localStorage.lastViewOption);}else{selectPageSize(_this.viewsOptions[0].value);}
$scope.recordCount=null;$rootScope.$watch('searchTerm',function(data){if(!canRedirect()&&data!==undefined&&data.length>0){_this.formData.search.SearchTerm=data;_this.sendForm();}});$scope.$on('ngRepeatDone',function(){if(!_this.firstTime){goToTop();}
_this.firstTime=false;});function convertToFloat(value){value=value||"0";return parseFloat(value.toString().replace(/[^\d^\.]/g,''));}
function applyChange(){$scope.$apply();}
function updateValue(data){if(data==null)
return;angular.forEach(_this.items,function(item){if(data.Id==item.Id){item.Value=data.Data.Value;item.ValueType=data.Data.ValueType;}});applyChange();}
function listenForBiddingChanges(){biddingSyncService.attachListeners(_this.items,applyChange);biddingSyncService.refresh(1000);}
function fixSelect2(){setTimeout(function(){for(const element of _this.select2){element();}},100);}
this.init=function(redirectUrl,persist,auction,stillForSale,button,privateSalesSold,privateSales){_this.redirectUrl=redirectUrl;_this.persist=persist!==undefined?persist:true;_this.auction=auction||'';_this.stillForSaleOnly=stillForSale||false;_this.button=$(button);_this.privateSalesSold=privateSalesSold;_this.privateSales=privateSales;if(canRedirect())
return;searchService.searchOptions(_this.auction).then(function(data){_this.searchOptions=data;_this.searchOptions.defaultSort=auction?"Default":"Availability";updateFromLocation();if(_this.privateSales){_this.formData.search.OfferStatus={id:"On Offer"}}
if(_this.privateSalesSold){_this.formData.search.OfferStatus={id:"Results"}}
_this.setGrid(_this.gridType);_this.setPage(_this.formData.page);fixSelect2();})};this.countryChange=function(){fixSelect2();}
this.collectionChange=function(){fixSelect2();}
this.dayChange=function(){fixSelect2();}
this.auctionChange=function(){fixSelect2();}
this.winningStatusChange=function(){fixSelect2();}
this.offerStatusChange=function(){fixSelect2();}
this.biddingStatusChange=function(){fixSelect2();}
this.categoryChange=function(){fixSelect2();}
this.categoryChange=function(){fixSelect2();}
this.sortChange=function(){fixSelect2();}
this.target=function(item){return item.newWindow?"_blank":"_self";}
this.resetForm=function(){_this.formData.search=searchService.searchDefaults(_this.searchOptions);fixSelect2();};this.canBid=function(item){return biddingSyncService.canBid(item);}
this.showBid=function(item,e){e.preventDefault();window.open(item.link+"bidding","_blank");}
function getSearch(){if(isAuctionFiltered()){return searchService.searchAuction(_this.auction,_this.stillForSaleOnly,_this.formData.search,_this.formData.page,_this.formData.pageSize);}else{return searchService.search(_this.formData.search,_this.formData.page,_this.formData.pageSize);}}
this.setPage=function(page){if(page<1){return;}
_this.inProgress=true;_this.formData.page=page;_this.formData.pageSize=angular.copy(_this.selected.value);if(_this.formData.pageSize===0||_this.formData.pageSize===undefined){_this.formData.pageSize=20;}
getSearch().then(function(data){if(data){biddingSyncService.unListenForAllResultChanges(_this.items);_this.items=data.items;biddingSyncService.registerResultsListener(_this,applyChange);listenForBiddingChanges();_this.pager=searchService.GetPager(data.pager.totalItems,page,data.pager.pageSize,data.pager.totalPages);_this.showLots=true;if(!_this.firstRequest){updateLocation(true);}
_this.inProgress=false;_this.firstRequest=false;$scope.recordCount=_this.pager.totalItems;if(_this.pager.totalItems<=3){_this.gridType='small-list-view';_setGrid(_this.gridType);}else{if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid;_setGrid(_this.gridType);}}}},function(data){_this.showLots=false;});};this.sendForm=function(){if(canRedirect()){var path=$location.path();var url=$location.url();$location.path("");updateLocation(false);var href=_this.redirectUrl+"#"+$location.url();$location.path(path);$location.url(url);location.href=href;$rootScope.searchTerm=_this.formData.search.SearchTerm;_this.button.click();}else{_this.setPage(1);}};this.setViewOption=function(viewOption){if(_this.canUseLocalStorage){localStorage.lastViewOption=viewOption;}
selectPageSize(viewOption);_this.setPage(1);};this.setGrid=function(gridType){if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid=gridType;}
_setGrid(gridType);};function _setGrid(gridType){switch(gridType){case"list-view":_this.gridPClass="col-xs-12 col-md-12 col-lg-12 grid-item";_this.gridVClass="search-result--listed";break;case"grid-view":_this.gridPClass="col-xs-12 col-md-6 col-lg-6 grid-item";_this.gridVClass="expanded-content-wrapper";break;case"small-grid-view":_this.gridPClass="col-xs-12 col-md-6 col-sm-6 col-lg-3 grid-item";_this.gridVClass="search-result--small-wrapper";break;case"small-list-view":_this.gridPClass="col-xs-12 col-md-12 col-sm-12 col-lg-12 grid-item";_this.gridVClass="search-result--small-listed";break;}}
function canRedirect(){return _this.redirectUrl!==undefined&&_this.redirectUrl.length>0;}
function loadLocalStorage(){try{if(typeof(Storage)!=="undefined"){if(!localStorage.lastGrid){localStorage.lastGrid='small-grid-view';}
if(!localStorage.lastViewOption){localStorage.lastViewOption=_this.viewsOptions[0].value;}
return true;}}catch(e){return false;}}
function selectPageSize(value){var selected=_this.viewsOptions.some(function(option){if(option.value==value){_this.selected=option;return true;}});if(!selected){_this.selected=_this.viewsOptions[0];}}
function isAuctionFiltered(){return(_this.auction||'').trim().length>0;}
function updateLocation(){var searchOptionsCopy=angular.copy(_this.formData);searchService.updateLocation(searchOptionsCopy);}
function updateFromLocation(){var parsedSearch=searchService.searchFromLocation(_this.searchOptions);_this.formData.search=parsedSearch.search;_this.formData.page=parsedSearch.page;_this.formData.pageSize=parsedSearch.pageSize;}
function goToTop(){var viewPort=$('html, body');viewPort.animate({scrollTop:$('.pagination-wrapper').offset().top},100,function(){viewPort.off("wheel DOMMouseScroll mousewheel keyup touchmove");});viewPort.bind("scroll mousedown DOMMouseScroll mousewheel keyup touchstart",function(e){if(e.which>0||e.type==="mousedown"||e.type==="mousewheel"||e.type==="touchstart"){viewPort.stop().unbind('scroll mousedown DOMMouseScroll mousewheel keyup touchstart');}});}});;;
'use strict';RMSFrontEnd.controller('PaginationBlogController',['$scope','$location','searchService',function($scope,$location,searchService){var _this=this;$scope.select2Options={minimumResultsForSearch:Infinity,closeOnSelect:false,onload:function(element){var getTerms=function(){return($(element).attr("ui-select2-terms")||",").split(",")}
var getOptionCount=function(){return $(element).find("option:checked").length;}
var searchField=$(element).siblings('.select2').find('.select2-search__field');var getSelectedText=function(count){if(count===0){return"All "+getTerms()[1];}
if(count===1){return count+" "+getTerms()[0]+" Selected";}
return count+" "+getTerms()[1]+" Selected";}
var selector=function(e){var find=$(e.currentTarget).find("option:checked");searchField.attr("placeholder",getSelectedText(find.length));searchField.css("width","100%");};$(element).on('select2:unselect',selector);$(element).on('select2:select',selector);searchField.attr("placeholder",getSelectedText(getOptionCount()));searchField.parent().css("float","none");searchField.parent().prepend("<a href=\"\" style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888;\"><i class=\"fa fa-chevron-down\"></i></a>");searchField.css("width","100%");searchField.attr("autocomplete","none");searchField.focus();searchField.blur();}};$scope.select2SingleOptions={minimumResultsForSearch:Infinity,closeOnSelect:true,onload:function(element){var arrow=$(element).siblings('.select2').find(".select2-selection__arrow");arrow.find("b").remove();arrow.prepend("<span style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888; width: 20px;\"><i class=\"fa fa-chevron-down\"></i></span>");}};_this.title="ALL POSTS";_this.pager={};_this.items=[];_this.formData={};_this.formData.search={};_this.viewsOptions=[{name:'40',value:40},{name:'100',value:100},{name:'200',value:200}];_this.sortList=[{Id:"Default",Name:"Newest"},{Id:"DatePostedAsc",Name:"Oldest"}];_this.gridPClass="col-xs-12 col-md-3 col-lg-3 grid-item";_this.gridVClass="search-result--small-wrapper";loadLocalStorage();_this.showListing=false;_this.selectedSortBy=_this.sortList[0];_this.firstTime=true;_this.firstRequest=true;_this.redirectUrl="";_this.gridType=localStorage.lastGrid;selectPageSize(localStorage.lastViewOption);$scope.recordCount=null;$scope.$on('ngRepeatDone',function(){if(!_this.firstTime){goToTop();}
_this.firstTime=false;});window.addEventListener('popstate',function(e){if(e.state!=null){_this.pager=e.state.pager;_this.formData=e.state.formData;if(!angular.equals(_this.items,history.state.items)){_this.items=e.state.items;}
$scope.$apply();}});function pushState(url){var data={formData:angular.copy(_this.formData),items:angular.copy(_this.items),pager:angular.copy(_this.pager)};history.pushState(data,"blog-list-page",url);};function replaceState(url){var data={formData:angular.copy(_this.formData),items:angular.copy(_this.items),pager:angular.copy(_this.pager)};history.replaceState(data,"blog-list-page",url);};this.init=function(searchOptions,redirectUrl){_this.redirectUrl=redirectUrl;_this.title="Posts";if(validRedirect()){_this.formData=searchOptions;return;}
if(history.state!=null){_this.pager=history.state.pager;_this.formData=history.state.formData;if(!angular.equals(_this.items,history.state.items)){_this.items=history.state.items;}
$scope.recordCount=_this.pager.totalItems;_this.inProgress=false;_this.showListing=true;_this.firstRequest=false;angular.forEach(_this.sortList,function(x,i){if(x.Id===_this.formData.search.SortBy){_this.selectedSortBy=x;}});return;}else{if(angular.equals({},$location.search())){_this.formData=searchOptions;}else{updateFromLocation();}
angular.forEach(_this.sortList,function(x,i){if(x.Id===_this.formData.search.SortBy){_this.selectedSortBy=x;}});}
_this.setGrid(_this.gridType);_this.setPage(_this.formData.page,true);};this.resetForm=function(){_this.formData.search.SearchTerm="";_this.formData.search.SortBy="Default";};this.setPage=function(page){if(page<1){return;}
_this.inProgress=true;_this.formData.page=page;_this.formData.pageSize=angular.copy(_this.selected.value);if(_this.formData.pageSize===0||_this.formData.pageSize===undefined){_this.formData.pageSize=20;}
searchService.searchBlogPosts(_this.formData,page,_this.formData.pageSize).then(function(data){if(data){_this.items=data.items;_this.pager=searchService.GetPager(data.pager.totalItems,page,data.pager.pageSize,data.pager.totalPages);_this.showListing=true;if(!_this.firstRequest){updateLocation(true);}else{replaceState(location.href);}
_this.inProgress=false;_this.firstRequest=false;$scope.recordCount=_this.pager.totalItems;}},function(data){_this.showListing=false;});};this.sendForm=function(){if(validRedirect()){var path=$location.path();var url=$location.url();$location.path("");updateLocation(false);var href=_this.redirectUrl+"#"+$location.url();$location.path(path);$location.url(url);location.href=href;}else{_this.setPage(1);}};this.setViewOption=function(viewOption){localStorage.lastViewOption=viewOption;selectPageSize(viewOption);_this.setPage(1);};this.setGrid=function(gridType){_this.gridType=localStorage.lastGrid=gridType;switch(gridType){case"list-view":_this.gridPClass="col-xs-12 col-md-12 col-lg-12 grid-item";_this.gridVClass="search-result--listed";break;case"grid-view":_this.gridPClass="col-xs-12 col-md-6 col-lg-6 grid-item";_this.gridVClass="expanded-content-wrapper";break;case"small-grid-view":_this.gridPClass="col-xs-12 col-md-3 col-lg-3 grid-item";_this.gridVClass="search-result--small-wrapper";break;case"small-list-view":_this.gridPClass="col-xs-12 col-md-12 col-lg-12 grid-item";_this.gridVClass="search-result--small-listed";break;}};this.setSort=function(sortBy){_this.formData.search.SortBy=sortBy;};this.isSort=function(sortBy){return _this.formData.search.SortBy===sortBy;};function validRedirect(){return _this.redirectUrl!==undefined&&_this.redirectUrl.length>0;}
function loadLocalStorage(){if(typeof(Storage)!=="undefined"){if(!localStorage.lastGrid){localStorage.lastGrid='small-grid-view';}
if(!localStorage.lastViewOption){localStorage.lastViewOption=_this.viewsOptions[0].value;}}}
function selectPageSize(value){var selected=_this.viewsOptions.some(function(option){if(option.value==value){_this.selected=option;return true;}});if(!selected){_this.selected=_this.viewsOptions[0];}}
function updateLocation(canPushState){var searchOptionsCopy=angular.copy(_this.formData);var searchLocation=searchOptionsCopy.search;searchLocation.page=searchOptionsCopy.page;searchLocation.pageSize=searchOptionsCopy.pageSize;var result=$location.search(searchLocation);if(canPushState){pushState(result.absUrl());}}
function updateFromLocation(){_this.formData.search=$location.search();_this.formData.page=parseInt($location.search().page);_this.formData.pageSize=parseInt($location.search().pageSize);}
function goToTop(){var viewPort=$('html, body');viewPort.animate({scrollTop:$('.pagination-wrapper').offset().top},100,function(){viewPort.off("wheel DOMMouseScroll mousewheel keyup touchmove");});viewPort.bind("scroll mousedown DOMMouseScroll mousewheel keyup touchstart",function(e){if(e.which>0||e.type==="mousedown"||e.type==="mousewheel"||e.type==="touchstart"){viewPort.stop().unbind('scroll mousedown DOMMouseScroll mousewheel keyup touchstart');}});}}]);;;
'use strict';RMSFrontEnd.controller('ModalController',['$scope','modalService',function($scope,modalService){var _this=this;this.modals={};$scope.$on('showModal',function(event,args){if(args.name=="create"){$("#loginModal").modal('hide');}});$scope.$on('requestModal',function(event,args){if(args.name=="bidderRegistration"){modalService.registration(function(data){_this.modals[args.name]=data;});}
if(args.name=="consign"){modalService.consign(function(data){_this.modals[args.name]=data;});}
if(args.name==="bidding"){if($("#bid-"+args.item.Id).length===0){_this.modals[args.name]=modalService.bidding(args.item);}}
if(args.name==="sealed-bidding"){var id="sealed-bid-"+args.item.Id;if($('#'+id).length===0){_this.modals[id]=modalService.sealedBidding(args.item);}}
if(args.name==="timed-bidding"){var id="timed-bid-"+args.item.Id;if($('#'+id).length===0){_this.modals[id]=modalService.timedBidding(args.item);}}});}]);;;
'use strict';RMSFrontEnd.controller('languageSwitchController',['$cookies',function($cookies){var _this=this;this.availableLanguages=[{name:"English",code:"en-US"},{name:"Français",code:"fr"},{name:"Italiano",code:"it"},{name:"Deutsch",code:"de"},{name:"Dansk",code:"da"}];this.languages=[];this.selectedLanguage=this.availableLanguages[0];this.addLanguage=function(code){var newLanguage=getLanguage(code);if(newLanguage!=null){if(_this.languages.indexOf(newLanguage)==-1){_this.languages.push(newLanguage);if(newLanguage==getLanguageFromCookie()){_this.selectedLanguage=newLanguage;}}}}
this.onLanguageChange=function(language){setLanguageCookie(language);}
function getLanguageFromCookie(){if($cookies.get("language")!=null){return getLanguage($cookies.get("language"));}}
function setLanguageCookie(language){var later=new Date();later.setDate(later.getDate()+365*5);$cookies.put("language",language.code,{expires:later,path:"/"});}
function getLanguage(code){for(var i=0;i<_this.availableLanguages.length;i++){if(_this.availableLanguages[i].code==code){return _this.availableLanguages[i];}}}}]);;;
'use strict';RMSFrontEnd.controller('createAccountController',function(userService,formDataOptions,stateSelection,recaptcha,$location){var _this=this;this.formData={CompanyName:"",BidderType:"Individual",Freelance:false};this.Countries=[];this.MethodsOfContact=[];this.selectedCountryStates=[];this.selectedEditorCountryStates=[];this.Months=[];this.Days=[];this.MediaInformations=[];this.MediaCoverages=[];this.PrimaryAudiences=[];this.HowDidYouHear=[];this.BidderTypes=["Individual","Company","Dealer"];this.DealerOptions=["Yes","No"];this.SocialHandles=[{name:"Instagram",value:""},{name:"Twitter",value:""},{name:"YouTube",value:""},{name:"Facebook",value:""},{name:"TikTok",value:""},{name:"LinkedIn",value:""},{name:"Other",value:""},]
$('#createModal').on('show.bs.modal',function(event){var button=$(event.relatedTarget);_this.formData.context=button.data('context');});this.init=function(){var search=location.search.split("?context=");if(search.length>1){_this.formData.context=search[1];}}
formDataOptions.getOptions(function(data){_this.Countries=data.countries;_this.MethodsOfContact=data.methodsOfContact;_this.HowDidYouHear=data.howDidYouHear;_this.MediaInformations=data.media.MediaInformations;_this.MediaCoverages=data.media.MediaCoverages;_this.PrimaryAudiences=data.media.PrimaryAudiences;});formDataOptions.getMediaTypes(function(data){_this.MediaTypes=data;});this.inProgress=false;this.formData.IsMedia=false;this.showFirst=true;this.showSecond=false;this.showThird=false;this.showFourth=false;this.showSuccess=false;this.showError=false;this.showErrorEmail=false;function checkMediaType(id){for(let o of _this.MediaTypes){if(o.id===id&&o.selected===true){return true;}}
return false;}
function hasSocialHandle(){for(let o of _this.SocialHandles){if((o.value||"").length>0){return true;}}
return false;}
this.requireMediaCoverage=function(){return false;}
this.requireSocialHandle=function(){return _this.formData.IsMedia&&(checkMediaType(859270006)&&!hasSocialHandle());}
this.requireWebsite=function(){return _this.formData.IsMedia&&(checkMediaType(859270007)||checkMediaType(859270001));}
this.requireOutletName=function(){return _this.formData.IsMedia&&_this.formData.Freelance===false&&(checkMediaType(859270005)||checkMediaType(859270000)||checkMediaType(859270004)||checkMediaType(859270003)||checkMediaType(859270008)||checkMediaType(859270002))}
this.requireFeaturePublication=function(){return _this.formData.IsMedia&&_this.formData.Freelance===true}
this.requireCountry=function(){return _this.formData.IsMedia;}
this.requireCity=function(){return _this.formData.IsMedia;}
this.requireCounty=function(){return _this.formData.IsMedia&&_this.formData.Country==='United States'}
this.requireStates=function(){return _this.formData.IsMedia&&(_this.formData.Country==='United States'||_this.formData.Country==='Canada')}
this.requireMediaType=function(){return _this.formData.IsMedia&&!_this.MediaTypes.some(x=>x.selected);}
this.filterStates=function(){stateSelection.getStates(_this.formData.Country).then(function(states){_this.selectedCountryStates=states;});};this.filterEditorStates=function(){stateSelection.getStates(_this.formData.EditorCountry).then(function(states){_this.selectedEditorCountryStates=states;});};function sanitizedRequest(){var userInterests=[];angular.forEach(_this.interests,function(o){if(o.Active){userInterests.push(o.Name);}})
_this.formData.interests=userInterests;var mediaTypes=[];angular.forEach(_this.MediaTypes,function(o){if(o.selected){mediaTypes.push(o.id);}})
_this.formData.mediaTypes=mediaTypes;var socialHandles=[];angular.forEach(_this.SocialHandles,function(o){if((o.value||"").length>0){socialHandles.push(o.name+":"+o.value);}})
_this.formData.socialHandles=socialHandles.join(";");return _this.formData;}
this.sendForm=function(){if(_this.createAccountForm.$valid){_this.inProgress=true;_this.showError=false;_this.showErrorEmail=false;_this.errorMessage='';recaptcha.getToken('createAccount').then(function(token){userService.create(sanitizedRequest(),token).then(function(data){_this.inProgress=false;_this.errorMessage='';_this.showSuccess=true;_this.showError=false;_this.showErrorEmail=false;},function(errorData){if(errorData.status===4){_this.inProgress=false;_this.showError=true;_this.showErrorEmail=true;}else{_this.inProgress=false;_this.showSuccess=false;_this.showError=true;_this.showErrorEmail=false;_this.errorMessage=errorData.message;}});});}};this.resetForm=function(){_this.formData={};_this.inProgress=false;_this.formData.IsMedia=false;_this.showFirst=true;_this.showSecond=false;_this.showThird=false;_this.showFourth=false;_this.showSuccess=false;_this.showError=false;_this.showErrorEmail=false;_this.createAccountForm.$setPristine();};this.dismissError=function(){_this.showError=false;_this.showErrorEmail=false;};this.initModal=function(){_this.IsModal=true;};this.finish=function(){if(!_this.IsModal){var ref=document.referrer;window.location=ref;}
_this.resetForm();};this.buttonCssClass=function(interest){if(interest.Active){return"active";}
return"";}});;;
'use strict';RMSFrontEnd.controller('LoginController',function($window,$location,userService){var _this=this;this.formData={};this.submitted=false;this.showError=false;this.showUnverified=false;this.inProgress=false;this.formData.context="";this.accountUrl=$("a#createAccountModalLink").attr("href");$('#loginModal').on('show.bs.modal',function(event){var button=$(event.relatedTarget);_this.formData.context=button.data('context')||"";var a=$("a#createAccountModalLink");a.data('context',_this.formData.context);a.attr("href",_this.accountUrl+"?context="+_this.formData.context);});this.init=function(userName,action){_this.formData.Username=userName;if(action&&action.toLowerCase()=="login"){$("#loginModal").modal();}};this.sendForm=function(){_this.submitted=true;if(_this.loginForm.$valid){var result=userService.login(_this.formData);_this.inProgress=true;_this.errorMessage='';_this.showError=false;_this.errortype='';_this.showLocked=false;result.success(function(data){if(data.status===0){_this.errorMessage='';_this.errortype='';_this.showError=false;_this.showLocked=false;var context=_this.formData.context;if(context.length>0){$location.search("context",_this.formData.context);$window.location.href=$location.absUrl();}
$window.location.reload();}else{_this.inProgress=false;_this.errorMessage=data.message;_this.showError=true;if(_this.status===4){_this.showLocked=true;}
if(data.status===3){_this.showUnverified=true;}}});result.error(function(){_this.inProgress=false;_this.showError=true;});}}});;;
'use strict';RMSFrontEnd.controller('ResetPasswordController',['userService',function(userService){var _this=this;this.submitted=false;this.showError=false;this.inProgress=false;this.showSuccess=false;this.init=function(memberId,token){_this.formData={};_this.formData.memberId=memberId;_this.formData.resetToken=token;}
this.sendForm=function(){_this.submitted=true;if(_this.Form.$valid){_this.inProgress=true;_this.errorMessage='';_this.showError=false;var result=userService.resetPassword(_this.formData).then(function(data){_this.inProgress=false;_this.showSuccess=true;},function(data){_this.inProgress=false;_this.errorMessage=data.message;_this.showError=true;})};};}]);;;
'use strict';RMSFrontEnd.controller('VerifyEmailController',function(userService,recaptcha){var _this=this;this.submitted=false;this.showError=false;this.showInvalid=false;this.inProgress=false;this.showSuccess=false;this.successMessage="";this.init=function(valid){_this.showInvalid=!valid;if(_this.showInvalid){$("#verifyEmailModal").modal();}};this.sendForm=function(){_this.submitted=true;if(_this.Form.$valid){_this.inProgress=true;_this.errorMessage='';_this.showError=false;recaptcha.getToken('verifyEmail').then(function(token){_this.formData.Token=token;userService.validateEmail(_this.formData).then(function(data){_this.inProgress=false;_this.showSuccess=true;_this.successMessage=data.message;},function(data){_this.inProgress=false;_this.showError=true;_this.errorMessage=data.message;})});}};});;;
'use strict';RMSFrontEnd.controller('ForgotPasswordController',function(userService,recaptcha){var _this=this;this.submitted=false;this.showError=false;this.showOk=false;this.inProgress=false;this.formData={};this.formData.email="";this.sendForm=function(){_this.submitted=true;if(_this.Form.$valid){_this.inProgress=true;_this.errorMessage='';_this.showError=false;_this.showOk=false;recaptcha.getToken('forgotPassword').then(function(token){_this.formData.Token=token;var result=userService.forgotPassword(_this.formData).then(function(data){_this.inProgress=false;_this.okMessage=data.message;_this.showOk=true;},function(errorData){_this.inProgress=false;_this.errorMessage=errorData.message;_this.showError=true;});});}}});;;
'use strict';RMSFrontEnd.controller('paymentController',function($scope,paymentService){var _this=this;this.paymentMethods=[];this.paymentMethod;this.paymentToken;this.paymentAdd=false;this.showError=false;this.braintreeClient=null;this.setPaymentFormId=function(id){paymentService.createBraintreeClient(id).then(function(data){_this.braintreeClient=data;});}
this.addNewPaymentToken=function(e){e.preventDefault();_this.paymentMethod=null;_this.paymentToken=null;_this.paymentAdd=true;};this.deletePaymentToken=function(e,payment){e.preventDefault();paymentService.deletePayment(payment.token).then(function(data){_this.paymentMethod=null;populatePaymentMethods();});};this.updatePaymentToken=function(payment){_this.paymentToken=payment.token;_this.paymentAdd=false;};this.submit=function(e){e.preventDefault();if(_this.paymentToken==null){paymentService.getPaymentToken(_this.braintreeClient).then(function(data){if(data.status===0){_this.showError=false;populatePaymentMethods(data.id);_this.paymentToken=data.id;$('input[name=BraintreeVaultToken]').val(_this.paymentToken);$('form#braintreeCreditCard').submit();}else{_this.showError=true;}},paymentError);}else{$('input[name=BraintreeVaultToken]').val(_this.paymentToken);$('form#braintreeCreditCard').submit();}};this.init=function(id){populatePaymentMethods(id);};function paymentError(data){if(data.State.fields.number.isValid){$(data.State.fields.number.container).removeClass("invalid")}else{$(data.State.fields.number.container).addClass("invalid")}
if(data.State.fields.cvv.isValid){$(data.State.fields.cvv.container).removeClass("invalid")}else{$(data.State.fields.cvv.container).addClass("invalid")}
if(data.State.fields.expirationMonth.isValid){$(data.State.fields.expirationMonth.container).removeClass("invalid")}else{$(data.State.fields.expirationMonth.container).addClass("invalid")}
if(data.State.fields.expirationYear.isValid){$(data.State.fields.expirationYear.container).removeClass("invalid")}else{$(data.State.fields.expirationYear.container).addClass("invalid")}
if(data.State.fields.postalCode.isValid){$(data.State.fields.postalCode.container).removeClass("invalid")}else{$(data.State.fields.postalCode.container).addClass("invalid")}
return data;}
function populatePaymentMethods(id){paymentService.getPaymentMethods().then(function(data){_this.paymentMethods=data;angular.forEach(_this.paymentMethods,function(v,i){if(v.token.value==id){_this.paymentMethod=v;_this.paymentToken=id;}});if(_this.paymentMethods.length==0){_this.paymentAdd=true;}});}});;;
'use strict';RMSFrontEnd.controller('registrationsController',function($rootScope,registerToBidService){var _this=this;this.items=[];this.RegistrationStatusOptions={Approved:0,Pending:1,NotRegistered:2,FailedPreAuth:3,PendingWithPreAuthSuccess:4,ApprovedMemorabilia:5,}
$rootScope.currentRegistration={id:0,auctionCode:""};$rootScope.populateRegistrationDetails=function(){registerToBidService.getRegistrationStatus().then(function(data){_this.items=data;});}
this.getStatusIcon=function(registration){switch(registration.status){case _this.RegistrationStatusOptions.Approved:return"fa fa-check"
case _this.RegistrationStatusOptions.ApprovedMemorabilia:return"fa fa-check"
case _this.RegistrationStatusOptions.NotRegistered:return"icon-register"}
return"fa fa-hourglass"}
$rootScope.populateRegistrationDetails();});;;
'use strict';RMSFrontEnd.controller('inquiryController',function(formDataOptions,stateSelection,recaptcha){var _this=this;this.formData={};this.Countries=[];this.InquiryTypes=[];this.selectedCountryStates=[];this.selectedEditorCountryStates=[];this.Months=[];this.Days=[];formDataOptions.getOptions(function(data){_this.Countries=data.countries;_this.InquiryTypes=data.inquiryTypes;});this.inProgress=false;this.showSuccess=false;this.showError=false;this.showErrorEmail=false;this.filterStates=function(){stateSelection.getStates(_this.formData.Country).then(function(states){_this.selectedCountryStates=states;});};this.sendForm=function(){if(_this.inquiryForm.$valid){_this.inProgress=true;_this.showError=false;_this.showErrorEmail=false;_this.errorMessage='';recaptcha.getToken('sendInquiry').then(function(recaptcha){formDataOptions.requestInquiry(_this.formData,recaptcha).then(function(data){_this.inProgress=false;_this.errorMessage='';_this.showSuccess=true;_this.showError=false;_this.showErrorEmail=false;if(data.status===2){_this.showSuccess=false;_this.showError=true;_this.errorMessage="An error occured submitting the form.";}},function(errorData){_this.inProgress=false;_this.showSuccess=false;_this.showError=true;_this.showErrorEmail=false;_this.errorMessage=errorData.message;});});}};this.resetForm=function(){_this.inProgress=false;_this.showError=false;_this.showErrorEmail=false;_this.inquiryForm.$setPristine();};this.dismissError=function(){_this.showError=false;_this.showErrorEmail=false;};this.initModal=function(){_this.IsModal=true;};});;;
'use strict';RMSFrontEnd.controller('tileController',function($scope,$http){var _this=this;this.tileId=0;this.tileFillerId=0;this.buttonCssClass="fa fa-ellipsis-h";this.showDescription=false;this.showDescriptionLookup=[];$scope.tiles=[];function findStatus(item){if(item===null||item===undefined)
return _this;var found=false;var status=null;angular.forEach(_this.showDescriptionLookup,function(o,i){if(o.Id===item.Id){found=true;status=o;}});if(found===false){status={Id:item.Id,showDescription:false};_this.showDescriptionLookup.push(status)}
return status;}
this.init=function(tileId,tileFillerId){_this.tileId=tileId;_this.tileFillerId=tileFillerId;GetTiles();setInterval(GetTiles,300000)};this.css=function(item){var width=item.Width*2;if(width<12){return"col-xs-12 col-sm-6 col-md-"+width+" col-lg-"+width;}
return"";};this.cssButtonClass=function(item){var status=findStatus(item);if(status.showDescription){return"fa fa-ellipsis-v"}else{return"fa fa-ellipsis-h"}}
this.canShowDescription=function(item){return findStatus(item).showDescription;}
this.toggleDescription=function(item){var status=findStatus(item);status.showDescription=!status.showDescription;}
function GetTiles(){$http({method:'GET',url:'/umbraco/surface/TileProviderSurface/GetJsonTiles?tileSourceId='+_this.tileId+"&tileFillerSourceId="+_this.tileFillerId}).success(function(data){$scope.tiles=data;});}});;;
'use strict';RMSFrontEnd.controller('LotItemController',function($scope,timeService){var _this=this;_this.item={};_this.remoteItem={};_this.templates=timeService.getTimeSpanTemplates();_this.offset=0;_this.callback={lotChanged:function(lot){}};var changedCallback=function(snapshot){if(snapshot.exists()){if(updateChange(_this.item,snapshot.val())){_this.callback.lotChanged(_this.item);$scope.$apply();}}};var fillInChanged=function(){if(updateChange(_this.item,_this.remoteItem||{cb:"",et:0,s:0})){$scope.$apply();}};setInterval(fillInChanged,1000);function convertToFloat(value){value=value||"0";return parseFloat(value.toString().replace(/[^\d^\.]/g,''));}
function updateChange(local,remote){_this.remoteItem=remote;var storedBid=convertToFloat(local.CurrentBid);var currentBid=convertToFloat(remote.cb);var changed=false;var currentDate=new Date();var offsetDate=currentDate.setMilliseconds(_this.offset+currentDate.getMilliseconds());var started=(offsetDate-new Date(remote.st+"Z"))>0;var formattedTimeLeft=timeService.formatTimeSpanInMillis(new Date(remote.et+"Z")-offsetDate,_this.templates);var auctioned=(remote.s===1||remote.s===2);if(started&&formattedTimeLeft!==local.TimeLeft||auctioned!==local.Auctioned){changed=true;local.Auctioned=auctioned;local.Sold=remote.s===2;local.TimeLeft=auctioned?_this.templates.finished:formattedTimeLeft;}
if(started&&storedBid!==currentBid){changed=true;local.CurrentBid=remote.cb;}
return changed;}
this.init=function(local,callback){_this.callback=callback||_this.callback;_this.item=local;timeService.getOffset().then(function(data){_this.offset=data;});timeService.getTimeSpanTemplates().then(function(data){_this.templates=data;})};});;;
'use strict';RMSFrontEnd.controller('videoFeedController',function($scope,$http){var _this=this;$scope.feeds=[];$scope.currentPlayer="";this.init=function(feeds){$scope.feeds=feeds;$scope.currentPlayer=$scope.feeds[0].PlayerLink;$scope.feeds[0].class="active"};this.switchFeed=function(event,feed){angular.forEach($scope.feeds,function(o){if(o.Name==feed.Name){o.class="active";}else{o.class="";}});$scope.currentPlayer=feed.PlayerLink;}});;;
'use strict';RMSFrontEnd.controller('saveProfileController',function(userService,recaptcha,$q){var _this=this;this.inProgress=false;this.showSuccess=false;this.formData={}
this.requireEmail=false;$(document).on('show.bs.modal','#saveProfileModal',function(){initializeModal();});this.validateForm=function(){_this.formSubmitted=true;};function initializeModal(){_this.resetForm();angular.merge(_this.formData,userService.retrieveProfile());_this.requireEmail=_this.formData.Email!=_this.formData.RequestedEmail;}
this.requireEmailChange=function(){return _this.requireEmail;}
this.resetForm=function(){_this.editAccountMessage="";_this.changeEmailMessage="";_this.formData.Password=""
_this.formData.RequestedEmailConfirm=""
_this.errorMessage="";_this.showSuccess=false;_this.formSubmitted=false;_this.saveProfileForm.$setPristine();}
this.finished=function(){}
this.sendForm=function(){var deferred1=$q.defer();var deferred2=$q.defer();var deferred=$q.defer();var done1=false;var done2=false;deferred1.promise.then(function(data){done1=true;if(done2){deferred.resolve({})}},function(data){done1=true;if(done2){deferred.reject({})}})
deferred2.promise.then(function(data){done2=true;if(done1){deferred.resolve({})}},function(data){done2=true;if(done1){deferred.reject({})}})
deferred.promise.then(function(data){_this.inProgress=false;_this.showSuccess=true;_this.disableButton=false;},function(data){_this.inProgress=false;_this.disableButton=false;});if(_this.saveProfileForm.$valid){_this.disableButton=true;_this.showSuccess=false;_this.inProgress=true;_this.errorMessage="";if(_this.requireEmailChange()){userService.requestChangeEmail(_this.formData).then(function(data){if(data.status===3||data.status===0){_this.changeEmailMessage=data.message;deferred1.resolve(data);}else{var newMessage=data.message+"\n";if(_this.errorMessage!=newMessage){_this.errorMessage+=newMessage;}
deferred1.reject(data);}},function(data){var newMessage=data.message+"\n";if(_this.errorMessage!=newMessage){_this.errorMessage+=newMessage;}
deferred1.reject(data);});}else{deferred1.resolve({});}
userService.editProfile(_this.formData).then(function(data){if(data.status===0){_this.editAccountMessage=data.message;deferred2.resolve(data);}else{var newMessage=data.message+"\n";if(_this.errorMessage!=newMessage){_this.errorMessage+=newMessage;}
deferred2.reject(data);}},function(data){var newMessage=data.message+"\n";if(_this.errorMessage!=newMessage){_this.errorMessage+=newMessage;}
deferred2.reject(data)});}}});;;
'use strict';RMSFrontEnd.controller('changePasswordController',function(userService,recaptcha){var _this=this;this.formData={};this.inProgress=false;this.showSuccess=false;this.showError=false;$(document).on('show.bs.modal','#changePasswordModal',function(){initializeModal();});function initializeModal(){_this.changePasswordForm.$setPristine();_this.showSuccess=false;_this.showError=false;_this.errorMessage=''
_this.resetForm();}
this.validateForm=function(){_this.formSubmitted=true;};this.resetForm=function(){_this.formData.Password="";_this.formData.RequestedPasswordConfirm="";_this.formData.RequestedPassword="";}
this.sendForm=function(){_this.disableButton=true;_this.showSuccess=false;if(_this.changePasswordForm.$valid){_this.inProgress=true;_this.showError=false;_this.errorMessage='';userService.requestPasswordChange(_this.formData).then(function(data){_this.inProgress=false;_this.disableButton=false;if(data.status===0){_this.errorMessage='';_this.showSuccess=true;_this.showError=false;_this.disableButton=false;}else{_this.errorMessage=data.message;_this.showSuccess=false;_this.showError=true;}
_this.resetForm();},function(errorData){_this.inProgress=false;_this.showSuccess=false;_this.showError=true;_this.errorMessage=errorData.message;_this.resetForm();});}}});;;
'use strict';RMSFrontEnd.controller('bidController',function($scope,$location,$rootScope,searchService,userService,biddingSyncService){var _this=this;_this.select2=[];$rootScope.searchTerm="";$scope.select2Options={minimumResultsForSearch:Infinity,closeOnSelect:false,onload:function(element){var getTerms=function(){return($(element).attr("ui-select2-terms")||",").split(",")}
var getOptionCount=function(){return $(element).find("option:checked").length;}
var searchField=$(element).siblings('.select2').find('.select2-search__field');var getSelectedText=function(count){if(count===0){return"All "+getTerms()[1];}
if(count===1){return count+" "+getTerms()[0]+" Selected";}
return count+" "+getTerms()[1]+" Selected";}
var selector=function(e){var find=$(e.currentTarget).find("option:checked");searchField.attr("placeholder",getSelectedText(find.length));searchField.css("width","100%");};$(element).on('select2:unselect',selector);$(element).on('select2:select',selector);searchField.attr("placeholder",getSelectedText(getOptionCount()));searchField.parent().css("float","none");searchField.parent().prepend("<a href=\"\" style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888;\"><i class=\"fa fa-chevron-down\"></i></a>");searchField.css("width","100%");searchField.attr("autocomplete","none");searchField.focus();searchField.blur();var data=$(element).data();if(data.$ngModelController!==undefined){var callback=function(){var selected=data.$ngModelController.$modelValue||[];searchField.attr("placeholder",getSelectedText(selected.length));searchField.css("width","100%");};callback();_this.select2.push(callback);}}};$scope.select2SingleOptions={minimumResultsForSearch:Infinity,closeOnSelect:true,onload:function(element){var select2=$(element).siblings('.select2');var arrow=select2.find(".select2-selection__arrow");var data=$(element).data();if(data.$ngModelController){var find=select2.find(".select2-selection__rendered");var callback=function(){var selected=data.$ngModelController.$modelValue||"";find.attr("title",selected.name||selected.Name||selected);find.text(selected.name||selected.Name||selected);}
callback();_this.select2.push(callback);}
arrow.find("b").remove();arrow.prepend("<span style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888; width: 20px;\"><i class=\"fa fa-chevron-down\"></i></span>");}};_this.persist=true;_this.title="ALL LOTS";_this.pager={};_this.items=[];_this.formData={};_this.formData.search={};_this.viewsOptions=[{name:'40',value:40},{name:'100',value:100},{name:'200',value:200}];_this.sortList=[{Id:"Default",Name:"Lot"},{Id:"Availability",Name:"Availability"},{Id:"MakeYearModel",Name:"Make"},{Id:"YearDesc",Name:"Year (High-Low)"},{Id:"Year",Name:"Year (Low-High)"},{Id:"Value",Name:"Value (High-Low)"},{Id:"ValueAsc",Name:"Value (Low-High)"},{Id:"DatePosted",Name:"Posted (New-Old)"},{Id:"DatePostedAsc",Name:"Posted (Old-New)"}];_this.gridPClass="col-xs-12 col-md-6 col-sm-6 col-lg-4 grid-item";_this.gridVClass="search-result--small-wrapper";_this.canUseLocalStorage=loadLocalStorage();_this.showLots=false;_this.selectedSortBy=_this.sortList[1];_this.firstTime=true;_this.firstRequest=true;_this.keepAuction=false;_this.redirectUrl="";_this.auctionBid={};_this.searchOptions={};_this.auction="";_this.stillForSaleOnly=false;_this.button=null;if(history.scrollRestoration){history.scrollRestoration='auto';}
$('.mobile-country-select').on('focus',function(){$(this).children(':first-child').removeProp('selected');});if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid;selectPageSize(localStorage.lastViewOption);}else{selectPageSize(_this.viewsOptions[0].value);}
$scope.recordCount=null;$scope.$on('ngRepeatDone',function(){if(!_this.firstTime){goToTop();}
_this.firstTime=false;});function convertToFloat(value){value=value||"0";return parseFloat(value.toString().replace(/[^\d^\.]/g,''));}
function applyChange(){$scope.$apply();}
function listenForAllChanges(){biddingSyncService.attachListeners(_this.items,applyChange);biddingSyncService.refresh(1000);}
function fixSelect2(){setTimeout(function(){for(const element of _this.select2){element();}},100);}
this.init=function(){searchService.searchBiddingOptions(true).then(function(data){_this.searchOptions=data;updateFromLocation();_this.setGrid(_this.gridType);_this.setPage(_this.formData.page);fixSelect2();});};this.countryChange=function(){fixSelect2();}
this.collectionChange=function(){fixSelect2();}
this.dayChange=function(){fixSelect2();}
this.auctionChange=function(){fixSelect2();}
this.winningStatusChange=function(){fixSelect2();}
this.offerStatusChange=function(){fixSelect2();}
this.biddingStatusChange=function(){fixSelect2();}
this.categoryChange=function(){fixSelect2();}
this.categoryChange=function(){fixSelect2();}
this.sortChange=function(){fixSelect2();}
this.resetForm=function(){_this.formData.search=searchService.searchDefaults(_this.searchOptions);if(isAuctionFiltered()){_this.formData.search.Auction=_this.auction;}
fixSelect2();};this.canBid=function(item){return biddingSyncService.canBid(item);}
this.showBid=function(item,e){return biddingSyncService.showBid(item,e);}
this.setPage=function(page){if(page<1){return;}
_this.inProgress=true;_this.formData.page=page;_this.formData.pageSize=angular.copy(_this.selected.value);if(_this.formData.pageSize===0||_this.formData.pageSize===undefined){_this.formData.pageSize=20;}
if(isAuctionFiltered()){_this.formData.search.Auction=_this.auction;}
searchService.searchMyActiveLots(_this.formData.search,_this.formData.page,_this.formData.pageSize).then(function(data){if(data){biddingSyncService.unListenForAllResultChanges(_this.items);_this.items=data.items;biddingSyncService.registerResultsListener(_this,applyChange);listenForAllChanges();_this.pager=searchService.GetPager(data.pager.totalItems,page,data.pager.pageSize,data.pager.totalPages);_this.showLots=true;if(!_this.firstRequest){updateLocation(true);}
_this.inProgress=false;_this.firstRequest=false;$scope.recordCount=_this.pager.totalItems;if(_this.pager.totalItems<=3){_this.gridType='small-list-view';_setGrid(_this.gridType);}else{if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid;_setGrid(_this.gridType);}}}},function(data){_this.showLots=false;});};this.sendForm=function(){if(canRedirect()){var path=$location.path();var url=$location.url();$location.path("");updateLocation(false);var href=_this.redirectUrl+"#"+$location.url();$location.path(path);$location.url(url);location.href=href;$rootScope.searchTerm=_this.formData.search.SearchTerm;_this.button.click();}else{_this.setPage(1);}};this.setViewOption=function(viewOption){if(_this.canUseLocalStorage){localStorage.lastViewOption=viewOption;}
selectPageSize(viewOption);_this.setPage(1);};this.setGrid=function(gridType){if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid=gridType;}
_setGrid(gridType);};function _setGrid(gridType){switch(gridType){case"list-view":_this.gridPClass="col-xs-12 col-md-12 col-lg-12 grid-item";_this.gridVClass="search-result--listed";break;case"grid-view":_this.gridPClass="col-xs-12 col-md-6 col-lg-6 grid-item";_this.gridVClass="expanded-content-wrapper";break;case"small-grid-view":_this.gridPClass="col-xs-12 col-md-6 col-sm-6 col-lg-3 grid-item";_this.gridVClass="search-result--small-wrapper";break;case"small-list-view":_this.gridPClass="col-xs-12 col-md-12 col-sm-12 col-lg-12 grid-item";_this.gridVClass="search-result--small-listed";break;}}
function canRedirect(){return _this.redirectUrl!==undefined&&_this.redirectUrl.length>0;}
function loadLocalStorage(){try{if(typeof(Storage)!=="undefined"){if(!localStorage.lastGrid){localStorage.lastGrid='small-grid-view';}
if(!localStorage.lastViewOption){localStorage.lastViewOption=_this.viewsOptions[0].value;}
return true;}}catch(e){return false;}}
function selectPageSize(value){var selected=_this.viewsOptions.some(function(option){if(option.value==value){_this.selected=option;return true;}});if(!selected){_this.selected=_this.viewsOptions[0];}}
function isAuctionFiltered(){return(_this.auction||'').trim().length>0;}
function updateLocation(){searchService.updateLocation(_this.formData)}
function updateFromLocation(){var parsedSearch=searchService.searchFromLocation(_this.searchOptions);_this.formData.search=parsedSearch.search;_this.formData.page=parsedSearch.page;_this.formData.pageSize=parsedSearch.pageSize;}
function goToTop(){var viewPort=$('html, body');viewPort.animate({scrollTop:$('.pagination-wrapper').offset().top},100,function(){viewPort.off("wheel DOMMouseScroll mousewheel keyup touchmove");});viewPort.bind("scroll mousedown DOMMouseScroll mousewheel keyup touchstart",function(e){if(e.which>0||e.type==="mousedown"||e.type==="mousewheel"||e.type==="touchstart"){viewPort.stop().unbind('scroll mousedown DOMMouseScroll mousewheel keyup touchstart');}});}});;;
'use strict';RMSFrontEnd.controller('pastBidController',function($scope,$location,$rootScope,searchService,userService,biddingSyncService){var _this=this;_this.select2=[];$rootScope.searchTerm="";$scope.select2Options={minimumResultsForSearch:Infinity,closeOnSelect:false,onload:function(element){var getTerms=function(){return($(element).attr("ui-select2-terms")||",").split(",")}
var getOptionCount=function(){return $(element).find("option:checked").length;}
var searchField=$(element).siblings('.select2').find('.select2-search__field');var getSelectedText=function(count){if(count===0){return"All "+getTerms()[1];}
if(count===1){return count+" "+getTerms()[0]+" Selected";}
return count+" "+getTerms()[1]+" Selected";}
var selector=function(e){var find=$(e.currentTarget).find("option:checked");searchField.attr("placeholder",getSelectedText(find.length));searchField.css("width","100%");};$(element).on('select2:unselect',selector);$(element).on('select2:select',selector);searchField.attr("placeholder",getSelectedText(getOptionCount()));searchField.parent().css("float","none");searchField.parent().prepend("<a href=\"\" style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888;\"><i class=\"fa fa-chevron-down\"></i></a>");searchField.css("width","100%");searchField.attr("autocomplete","none");searchField.focus();searchField.blur();var data=$(element).data();if(data.$ngModelController!==undefined){var callback=function(){var selected=data.$ngModelController.$modelValue||[];searchField.attr("placeholder",getSelectedText(selected.length));searchField.css("width","100%");};callback();_this.select2.push(callback);}}};$scope.select2SingleOptions={minimumResultsForSearch:Infinity,closeOnSelect:true,onload:function(element){var select2=$(element).siblings('.select2');var arrow=select2.find(".select2-selection__arrow");var data=$(element).data();if(data.$ngModelController){var find=select2.find(".select2-selection__rendered");var callback=function(){var selected=data.$ngModelController.$modelValue||"";find.attr("title",selected.name||selected.Name||selected);find.text(selected.name||selected.Name||selected);}
callback();_this.select2.push(callback);}
arrow.find("b").remove();arrow.prepend("<span style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888; width: 20px;\"><i class=\"fa fa-chevron-down\"></i></span>");}};_this.persist=true;_this.title="ALL LOTS";_this.pager={};_this.items=[];_this.formData={};_this.formData.search={};_this.viewsOptions=[{name:'40',value:40},{name:'100',value:100},{name:'200',value:200}];_this.sortList=[{Id:"Default",Name:"Lot"},{Id:"Availability",Name:"Availability"},{Id:"MakeYearModel",Name:"Make"},{Id:"YearDesc",Name:"Year (High-Low)"},{Id:"Year",Name:"Year (Low-High)"},{Id:"Value",Name:"Value (High-Low)"},{Id:"ValueAsc",Name:"Value (Low-High)"},{Id:"DatePosted",Name:"Posted (New-Old)"},{Id:"DatePostedAsc",Name:"Posted (Old-New)"}];_this.gridPClass="col-xs-12 col-md-6 col-sm-6 col-lg-4 grid-item";_this.gridVClass="search-result--small-wrapper";_this.canUseLocalStorage=loadLocalStorage();_this.showLots=false;_this.selectedSortBy=_this.sortList[1];_this.firstTime=true;_this.firstRequest=true;_this.keepAuction=false;_this.redirectUrl="";_this.auctionBid={};_this.searchOptions={};_this.auction="";_this.stillForSaleOnly=false;_this.button=null;if(history.scrollRestoration){history.scrollRestoration='auto';}
$('.mobile-country-select').on('focus',function(){$(this).children(':first-child').removeProp('selected');});if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid;selectPageSize(localStorage.lastViewOption);}else{selectPageSize(_this.viewsOptions[0].value);}
$scope.recordCount=null;$scope.$on('ngRepeatDone',function(){if(!_this.firstTime){goToTop();}
_this.firstTime=false;});function convertToFloat(value){value=value||"0";return parseFloat(value.toString().replace(/[^\d^\.]/g,''));}
function applyChange(){$scope.$apply();}
function listenForAllChanges(){biddingSyncService.attachListeners(_this.items,applyChange);biddingSyncService.refresh(1000);}
function fixSelect2(){setTimeout(function(){for(const element of _this.select2){element();}},100);}
this.init=function(){searchService.searchBiddingOptions(false).then(function(data){_this.searchOptions=data;updateFromLocation();fixSelect2();_this.setGrid(_this.gridType);_this.setPage(_this.formData.page);})};this.countryChange=function(){fixSelect2();}
this.collectionChange=function(){fixSelect2();}
this.dayChange=function(){fixSelect2();}
this.auctionChange=function(){fixSelect2();}
this.winningStatusChange=function(){fixSelect2();}
this.offerStatusChange=function(){fixSelect2();}
this.biddingStatusChange=function(){fixSelect2();}
this.categoryChange=function(){fixSelect2();}
this.categoryChange=function(){fixSelect2();}
this.sortChange=function(){fixSelect2();}
this.resetForm=function(){_this.formData.search=searchService.searchDefaults(_this.searchOptions);if(isAuctionFiltered()){_this.formData.search.Auction=_this.auction;}
fixSelect2();};this.canBid=function(item){return biddingSyncService.canBid(item);}
this.showBid=function(item,e){return biddingSyncService.showBid(item,e);}
this.setPage=function(page){if(page<1){return;}
_this.inProgress=true;_this.formData.page=page;_this.formData.pageSize=angular.copy(_this.selected.value);if(_this.formData.pageSize===0||_this.formData.pageSize===undefined){_this.formData.pageSize=20;}
if(isAuctionFiltered()){_this.formData.search.Auction=_this.auction;}
searchService.searchMyPastLots(_this.formData.search,_this.formData.page,_this.formData.pageSize).then(function(data){if(data){biddingSyncService.unListenForAllResultChanges(_this.items);_this.items=data.items;biddingSyncService.registerResultsListener(_this,applyChange);listenForAllChanges();_this.pager=searchService.GetPager(data.pager.totalItems,page,data.pager.pageSize,data.pager.totalPages);_this.showLots=true;if(!_this.firstRequest){updateLocation();}
_this.inProgress=false;_this.firstRequest=false;$scope.recordCount=_this.pager.totalItems;if(_this.pager.totalItems<=3){_this.gridType='small-list-view';_setGrid(_this.gridType);}else{if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid;_setGrid(_this.gridType);}}}},function(data){_this.showLots=false;});};this.sendForm=function(){if(canRedirect()){var path=$location.path();var url=$location.url();$location.path("");updateLocation();var href=_this.redirectUrl+"#"+$location.url();$location.path(path);$location.url(url);location.href=href;$rootScope.searchTerm=_this.formData.search.SearchTerm;_this.button.click();}else{_this.setPage(1);}};this.setViewOption=function(viewOption){if(_this.canUseLocalStorage){localStorage.lastViewOption=viewOption;}
selectPageSize(viewOption);_this.setPage(1);};this.setGrid=function(gridType){if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid=gridType;}
_setGrid(gridType);};function _setGrid(gridType){switch(gridType){case"list-view":_this.gridPClass="col-xs-12 col-md-12 col-lg-12 grid-item";_this.gridVClass="search-result--listed";break;case"grid-view":_this.gridPClass="col-xs-12 col-md-6 col-lg-6 grid-item";_this.gridVClass="expanded-content-wrapper";break;case"small-grid-view":_this.gridPClass="col-xs-12 col-md-6 col-sm-6 col-lg-3 grid-item";_this.gridVClass="search-result--small-wrapper";break;case"small-list-view":_this.gridPClass="col-xs-12 col-md-12 col-sm-12 col-lg-12 grid-item";_this.gridVClass="search-result--small-listed";break;}}
function canRedirect(){return _this.redirectUrl!==undefined&&_this.redirectUrl.length>0;}
function loadLocalStorage(){try{if(typeof(Storage)!=="undefined"){if(!localStorage.lastGrid){localStorage.lastGrid='small-grid-view';}
if(!localStorage.lastViewOption){localStorage.lastViewOption=_this.viewsOptions[0].value;}
return true;}}catch(e){return false;}}
function selectPageSize(value){var selected=_this.viewsOptions.some(function(option){if(option.value==value){_this.selected=option;return true;}});if(!selected){_this.selected=_this.viewsOptions[0];}}
function isAuctionFiltered(){return(_this.auction||'').trim().length>0;}
function updateLocation(){searchService.updateLocation(_this.formData)}
function updateFromLocation(){var parsedSearch=searchService.searchFromLocation(_this.searchOptions);_this.formData.search=parsedSearch.search;_this.formData.page=parsedSearch.page;_this.formData.pageSize=parsedSearch.pageSize;}
function goToTop(){var viewPort=$('html, body');viewPort.animate({scrollTop:$('.pagination-wrapper').offset().top},100,function(){viewPort.off("wheel DOMMouseScroll mousewheel keyup touchmove");});viewPort.bind("scroll mousedown DOMMouseScroll mousewheel keyup touchstart",function(e){if(e.which>0||e.type==="mousedown"||e.type==="mousewheel"||e.type==="touchstart"){viewPort.stop().unbind('scroll mousedown DOMMouseScroll mousewheel keyup touchstart');}});}});;;
'use strict';RMSFrontEnd.controller('mobileVerificationController',function($scope,userService,dictionaryService){var _this=this;this.showSendCodeFailed=false;this.showVerifyCodeFailed=false;this.mobileNumber="";this.verified=false;this.requested=false;this.verifiedNumber="";this.sendCodeText="";this.verifyCodeText="";this.tryAgainText="";this.placeHolderNumber=""
this.placeHolderCode=""
this.onVerified=this.onVerified||function(verified){}
this.$onChanges=function(obj){if((obj.verified||{currentValue:false}).currentValue){this.verified=true;this.verifiedNumber=angular.copy(_this.mobileNumber);}
var disabled=obj.disabled||{currentValue:false}
if(disabled.currentValue){if(!this.hasVerifiedMobileNumber()){this.verifiedNumber="";}}}
dictionaryService.getDictionaryItems(["Forms.Verify Code","Forms.Send Code","Forms.Try Again","Forms.Mobile Phone"]).then(function(data){_this.sendCodeText=_this.sendCodeText||data["Forms.Send Code"];_this.verifyCodeText=_this.verifyCodeText||data["Forms.Verify Code"];_this.tryAgainText=_this.tryAgainText||data["Forms.Try Again"];_this.placeHolderNumber=_this.placeHolderNumber||data["Forms.Mobile Phone"];});this.sendMobileVerification=function(){userService.requestMobileNumberVerification(_this.mobileNumber).then(function(data){if(data.status===0){_this.showSendCodeFailed=false;$("#mobilePhone").removeClass("input-error")}else{_this.showSendCodeFailed=true;$("#mobilePhone").addClass("input-error")}});}
this.getMobilePhoneWidthStyle=function(){if(_this.hasVerifiedMobileNumber()){return{"max-width":"calc(100% - 38px)"}}
return{};}
this.verifyMobileNumber=function(){userService.verifyMobileNumberVerification(_this.mobileNumber,_this.verificationCode).then(function(data){if(data.status===0){_this.verified=true;_this.verifiedNumber=angular.copy(_this.mobileNumber);_this.showVerifyCodeFailed=false;$("#verifyMobilePhone").removeClass("input-error")}else{_this.verified=false;_this.showVerifyCodeFailed=true;$("#verifyMobilePhone").addClass("input-error")}
_this.onVerified({verified:_this.verified,requested:true});_this.requested=true;});}
this.onMobileNumberChange=function(number){var verified=this.hasVerifiedMobileNumber();this.onVerified({verified:verified,requested:false});this.requested=false;}
this.canVerifyMobileNumber=function(){return!this.hasVerifiedMobileNumber();}
this.hasVerifiedMobileNumber=function(){_this.verified=_this.verifiedNumber!==""&&_this.mobileNumber===_this.verifiedNumber
return _this.verified;}});;;
'use strict';RMSFrontEnd.controller('myFavoritesController',function($scope,$location,$rootScope,searchService,userService,biddingSyncService){var _this=this;_this.select2=[];$scope.select2Options={minimumResultsForSearch:Infinity,closeOnSelect:false,onload:function(element){var getTerms=function(){return($(element).attr("ui-select2-terms")||",").split(",")}
var getOptionCount=function(){return $(element).find("option:checked").length;}
var searchField=$(element).siblings('.select2').find('.select2-search__field');var getSelectedText=function(count){if(count===0){return"All "+getTerms()[1];}
if(count===1){return count+" "+getTerms()[0]+" Selected";}
return count+" "+getTerms()[1]+" Selected";}
var selector=function(e){var find=$(e.currentTarget).find("option:checked");searchField.attr("placeholder",getSelectedText(find.length));searchField.css("width","100%");};$(element).on('select2:unselect',selector);$(element).on('select2:select',selector);searchField.attr("placeholder",getSelectedText(getOptionCount()));searchField.parent().css("float","none");searchField.parent().prepend("<a href=\"\" style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888;\"><i class=\"fa fa-chevron-down\"></i></a>");searchField.css("width","100%");searchField.attr("autocomplete","none");searchField.focus();searchField.blur();var data=$(element).data();if(data.$ngModelController!==undefined){var callback=function(){var selected=data.$ngModelController.$modelValue||[];searchField.attr("placeholder",getSelectedText(selected.length));searchField.css("width","100%");};callback();_this.select2.push(callback);}}};$scope.select2SingleOptions={minimumResultsForSearch:Infinity,closeOnSelect:true,onload:function(element){var select2=$(element).siblings('.select2');var arrow=select2.find(".select2-selection__arrow");var data=$(element).data();if(data.$ngModelController){var find=select2.find(".select2-selection__rendered");var callback=function(){var selected=data.$ngModelController.$modelValue||"";find.attr("title",selected.name||selected.Name||selected);find.text(selected.name||selected.Name||selected);}
callback();_this.select2.push(callback);}
arrow.find("b").remove();arrow.prepend("<span style=\"float: right;font-size: 10px;line-height: 3.8;color: #888888; width: 20px;\"><i class=\"fa fa-chevron-down\"></i></span>");}};_this.persist=true;_this.title="ALL LOTS";_this.pager={};_this.items=[];_this.formData={};_this.formData.search={};_this.viewsOptions=[{name:'40',value:40},{name:'100',value:100},{name:'200',value:200}];_this.sortList=[{Id:"Default",Name:"Lot"},{Id:"Availability",Name:"Availability"},{Id:"MakeYearModel",Name:"Make"},{Id:"YearDesc",Name:"Year (High-Low)"},{Id:"Year",Name:"Year (Low-High)"},{Id:"Value",Name:"Value (High-Low)"},{Id:"ValueAsc",Name:"Value (Low-High)"},{Id:"DatePosted",Name:"Posted (New-Old)"},{Id:"DatePostedAsc",Name:"Posted (Old-New)"}];_this.gridPClass="col-xs-12 col-md-6 col-sm-6 col-lg-4 grid-item";_this.gridVClass="search-result--small-wrapper";_this.canUseLocalStorage=loadLocalStorage();_this.showLots=false;_this.selectedSortBy=_this.sortList[1];_this.firstTime=true;_this.firstRequest=true;_this.keepAuction=false;_this.redirectUrl="";_this.auctionBid={};_this.searchOptions={};_this.auction="";if(history.scrollRestoration){history.scrollRestoration='auto';}
$('.mobile-country-select').on('focus',function(){$(this).children(':first-child').removeProp('selected');});if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid;selectPageSize(localStorage.lastViewOption);}else{selectPageSize(_this.viewsOptions[0].value);}
$scope.recordCount=null;$scope.$on('ngRepeatDone',function(){if(!_this.firstTime){goToTop();}
_this.firstTime=false;});function convertToFloat(value){value=value||"0";return parseFloat(value.toString().replace(/[^\d^\.]/g,''));}
function applyChange(){$scope.$apply();}
function listenForAllChanges(){biddingSyncService.attachListeners(_this.items,applyChange);biddingSyncService.refresh(1000);}
function fixSelect2(){setTimeout(function(){for(const element of _this.select2){element();}},100);}
this.init=function(redirectUrl,persist,auction){_this.auction=auction||'';_this.formData.search.Auction=auction;searchService.searchOptions(_this.auction).then(function(data){_this.searchOptions=data
_this.searchOptions.offerStatus=[];updateFromLocation();_this.persist=persist!==undefined?persist:true;_this.setGrid(_this.gridType);_this.setPage(_this.formData.page);fixSelect2();})};this.countryChange=function(){fixSelect2();}
this.collectionChange=function(){fixSelect2();}
this.dayChange=function(){fixSelect2();}
this.auctionChange=function(){fixSelect2();}
this.winningStatusChange=function(){fixSelect2();}
this.offerStatusChange=function(){fixSelect2();}
this.biddingStatusChange=function(){fixSelect2();}
this.categoryChange=function(){fixSelect2();}
this.categoryChange=function(){fixSelect2();}
this.sortChange=function(){fixSelect2();}
this.resetForm=function(){_this.formData.search=searchService.searchDefaults(_this.searchOptions);fixSelect2();};this.canBid=function(item){return biddingSyncService.canBid(item);}
this.showBid=function(item,e){return biddingSyncService.showBid(item,e);}
this.setPage=function(page){if(page<1){return;}
_this.inProgress=true;_this.formData.page=page;_this.formData.pageSize=angular.copy(_this.selected.value);if(_this.formData.pageSize===0||_this.formData.pageSize===undefined){_this.formData.pageSize=20;}
searchService.searchMyFavouriteLots(_this.formData.search,_this.formData.page,_this.formData.pageSize).then(function(data){if(data){biddingSyncService.unListenForAllResultChanges(_this.items);_this.items=data.items;biddingSyncService.registerResultsListener(_this,applyChange);listenForAllChanges();_this.pager=searchService.GetPager(data.pager.totalItems,page,data.pager.pageSize,data.pager.totalPages);_this.showLots=true;if(!_this.firstRequest){updateLocation(true);}
_this.inProgress=false;_this.firstRequest=false;$scope.recordCount=_this.pager.totalItems;if(_this.pager.totalItems<=3){_this.gridType='small-list-view';_setGrid(_this.gridType);}else{if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid;_setGrid(_this.gridType);}}}},function(data){_this.showLots=false;});};this.sendForm=function(){_this.setPage(1);};this.setViewOption=function(viewOption){if(_this.canUseLocalStorage){localStorage.lastViewOption=viewOption;}
selectPageSize(viewOption);_this.setPage(1);};this.setGrid=function(gridType){if(_this.canUseLocalStorage){_this.gridType=localStorage.lastGrid=gridType;}
_setGrid(gridType);};function _setGrid(gridType){switch(gridType){case"list-view":_this.gridPClass="col-xs-12 col-md-12 col-lg-12 grid-item";_this.gridVClass="search-result--listed";break;case"grid-view":_this.gridPClass="col-xs-12 col-md-6 col-lg-6 grid-item";_this.gridVClass="expanded-content-wrapper";break;case"small-grid-view":_this.gridPClass="col-xs-12 col-md-4 col-lg-4 grid-item";_this.gridVClass="search-result--small-wrapper";break;case"small-list-view":_this.gridPClass="col-xs-12 col-md-12 col-sm-12 col-lg-12 grid-item";_this.gridVClass="search-result--small-listed";break;}}
function loadLocalStorage(){try{if(typeof(Storage)!=="undefined"){if(!localStorage.lastGrid){localStorage.lastGrid='small-grid-view';}
if(!localStorage.lastViewOption){localStorage.lastViewOption=_this.viewsOptions[0].value;}
return true;}}catch(e){return false;}}
function selectPageSize(value){var selected=_this.viewsOptions.some(function(option){if(option.value==value){_this.selected=option;return true;}});if(!selected){_this.selected=_this.viewsOptions[0];}}
function updateLocation(){var searchOptionsCopy=angular.copy(_this.formData);searchService.updateLocation(searchOptionsCopy);}
function updateFromLocation(){var parsedSearch=searchService.searchFromLocation(_this.searchOptions);_this.formData.search=parsedSearch.search;_this.formData.page=parsedSearch.page;_this.formData.pageSize=parsedSearch.pageSize;}
function goToTop(){var viewPort=$('html, body');viewPort.animate({scrollTop:$('.pagination-wrapper').offset().top},100,function(){viewPort.off("wheel DOMMouseScroll mousewheel keyup touchmove");});viewPort.bind("scroll mousedown DOMMouseScroll mousewheel keyup touchstart",function(e){if(e.which>0||e.type==="mousedown"||e.type==="mousewheel"||e.type==="touchstart"){viewPort.stop().unbind('scroll mousedown DOMMouseScroll mousewheel keyup touchstart');}});}});;;
RMSFrontEnd.component("mobileVerification",{templateUrl:"/scripts/rms-scripts/components/mobileVerification.template.html",controller:"mobileVerificationController",bindings:{mobileNumber:'=',verified:'<',onVerified:'&',disabled:'<',ngRequired:'<',sendCodeText:'@',verifyCodeText:'@',tryAgainText:'@',placeHolderNumber:'@',placeHolderCode:'@'}});;;
RMSFrontEnd.component("mobileVerificationNotification",{templateUrl:"/scripts/rms-scripts/components/mobileVerificationNotification.template.html",controller:"mobileVerificationController",bindings:{mobileNumber:'=',verified:'<',onVerified:'&',disabled:'<',ngRequired:'<',sendCodeText:'@',verifyCodeText:'@',tryAgainText:'@',placeHolderNumber:'@',placeHolderCode:'@',mobilePhoneLabel:'@',verifyCodeLabel:'@',verifiedText:'@'}});;;
'use strict';RMSFrontEnd.factory("timedBidding",function($http,biddingConnection){var TimedClient=function(biddingConnection){let client=biddingConnection.getClient();client.transformSend(transformSend)
client.transformReceived(transformReceived)
client.onReceive(onReceive)
const commandKeys={authorization:"authorization=>",auctionState:"auction-state=>",lotPhotos:"lot-photos=>",lotChange:"lot-change=>",userPermissions:"user-permissions=>",bidResult:"bid-result=>",bidder:"bidder=>",bidderEngagement:"bidder-engagement=>",biddingAccess:"bidding-access=>",timeOffset:"timing-offset=>",roundBid:"round-bid=>",maxBid:"m-bid=>",forceBid:"f-bid=>",logBid:"log-bid=>",timeSync:"time-sync=>",extendTime:"extend-time=>",bidStats:"bid-stats=>",};const noop=function(){};let onPermissions=noop;let onAuctionChanged=noop;let onLotChanged=noop;let onLotPhotosChanged=noop;let onBidRounded=noop;let onBiddingAccessChanged=noop;let onBidResult=noop;let onBidderConnected=noop;let onBidStatsChanged=noop;let onTimeOffset=noop;let onTimeSync=noop;let onAutoExtendTimeChanged=noop;function transformCurrency(obj){return{code:obj.c,symbol:obj.s}}
function transformAccess(obj){return{access:obj.a,accessList:transformAccessList(obj.l)}}
function transformAccessList(list){const list2=[];for(let index=0;index<list.length;++index){let obj=list[index];list2.push({name:obj.n,access:obj.a,message:obj.m})}
return list2;}
function transformPermissions(list){const list2=[];for(let index=0;index<list.length;++index){const obj=list[index];list2.push({name:obj.n,description:obj.d})}
return list2;}
function transformAuction(obj){return{id:obj.id,name:obj.n,status:transformAuctionStatus(obj.s),currency:transformCurrency(obj.c),running:obj.r,startTime:obj.st,endTime:obj.et,metaData:obj.md}}
function transformLot(obj){return{id:obj.id,name:obj.n,url:obj.u,status:transformLotStatus(obj.s),lotNumber:obj.l,currentBid:obj.b,lowEstimate:obj.le,highEstimate:obj.he,currentAsking:obj.a,viewOnly:obj.v,hasAddendum:obj.ad,reserveStatus:transformReserveStatus(obj.r),currency:transformCurrency(obj.c),startTime:obj.st,finishedTime:obj.ft}}
function transformBidder(obj){if(obj===null)
return null;return{id:obj.id,name:obj.n,bidderNumber:obj.bn}}
function transformAuctionStatus(obj){switch(obj){case"a":return"Available";case"ac":return"Active";case"c":return"Closed";}
return obj;}
function transformLotStatus(obj){switch(obj){case"a":return"Available";case"ac":return"Active";case"s":return"Sold";case"ns":return"NotSold";case"w":return"Withdrawn";}
return obj;}
function transformReserveStatus(obj){switch(obj){case"n":return"NoReserve";case"u":return"UnderReserve";case"m":return"ReserveMet";}
return obj;}
function transformBidStatus(obj){switch(obj){case"a":return"Accepted";case"na":return"NotAccepted";case"e":return"Error";case"p":return"Pending";}
return obj;}
function transformBidType(obj){switch(obj){case"f":return"Force"
case"m":return"Max"
case"um":return"UnderMax"}
return obj;}
function transformBidResult(obj){return{id:obj.id,amount:obj.a,lotId:obj.lid,userId:obj.uid,type:transformBidType(obj.t),status:transformBidStatus(obj.s),reason:obj.r}}
function transformBidStats(obj){return{lotId:obj.id,bidCount:obj.bc,isHighBidder:obj.hb,userBidCount:obj.ubc,userMaxBid:obj.umb}}
function transformReceived(key,obj){let newObj=obj;switch(key+"=>"){case commandKeys.bidder:newObj=transformBidder(obj);break;case commandKeys.biddingAccess:newObj=transformAccess(obj);break;case commandKeys.userPermissions:newObj=transformPermissions(obj);break;case commandKeys.auctionState:newObj=transformAuction(obj);break;case commandKeys.lotChange:newObj=transformLot(obj);break;case commandKeys.bidStats:newObj=transformBidStats(obj);break;case commandKeys.bidResult:newObj=transformBidResult(obj);break;}
return newObj;}
function transformSend(key,obj){let newObj=obj;switch(key+"=>"){case commandKeys.forceBid:case commandKeys.maxBid:case commandKeys.logBid:newObj={a:obj.amount,id:obj.lotId}
break;case commandKeys.bidderEngagement:switch(obj){case"Active":newObj="ac";break;case"Available":newObj="a";break;case"Idle":newObj="i";break;}
break;}
return newObj;}
function onReceive(key,value){switch(key+"=>"){case commandKeys.auctionState:onAuctionChanged(value);break;case commandKeys.lotChange:onLotChanged(value);break;case commandKeys.bidResult:onBidResult(value);break;case commandKeys.lotPhotos:onLotPhotosChanged(value);break;case commandKeys.roundBid:onBidRounded(value);break;case commandKeys.bidder:onBidderConnected(value);break;case commandKeys.biddingAccess:onBiddingAccessChanged(value);break;case commandKeys.userPermissions:onPermissions(value);break;case commandKeys.timeOffset:onTimeOffset(value);break;case commandKeys.timeSync:onTimeSync(value);break;case commandKeys.extendTime:onAutoExtendTimeChanged(value);break;case commandKeys.bidStats:onBidStatsChanged(value);break;}}
return{connect:client.connect,disconnect:client.disconnect,onSessionOpen:client.onSessionOpen,onSessionAccepted:client.onSessionAccepted,onSessionClose:client.onSessionClose,onSessionError:client.onSessionError,onSessionDataReceived:client.onSessionDataReceived,onSendError:client.onSendError,onRequestConnection:client.onRequestConnection,onConnectionRetrying:client.onConnectionRetrying,onConnectionDeclined:client.onConnectionDeclined,onConnectionFailed:client.onConnectionFailed,onAuctionChanged:function(callback){onAuctionChanged=callback||noop;},onLotChanged:function(callback){onLotChanged=callback||noop;},onLotPhotosChanged:function(callback){onLotPhotosChanged=callback||noop;},onBidRounded:function(callback){onBidRounded=callback||noop;},onBidResult:function(callback){onBidResult=callback||noop;},onBidderConnected:function(callback){onBidderConnected=callback||noop;},onBiddingAccessChanged:function(callback){onBiddingAccessChanged=callback||noop;},onPermissions:function(callback){onPermissions=callback||noop;},onTimeOffset:function(callback){onTimeOffset=callback||noop;},onTimeSync:function(callback){onTimeSync=callback||noop;},onAutoExtendTimeChanged:function(callback){onAutoExtendTimeChanged=callback},onBidStatsChanged:function(callback){onBidStatsChanged=callback||noop;},requestBidRound:function(amount){client.send(commandKeys.roundBid,amount);},sendMaxBid:function(amount,lotId){client.send(commandKeys.maxBid,{amount:amount,lotId:lotId});},sendForceBid:function(amount,lotId){client.send(commandKeys.forceBid,{amount:amount,lotId:lotId});},sendTime:function(){client.send(commandKeys.timeOffset,new Date().toISOString());},sendFailedBid:function(amount,lotId){client.send(commandKeys.logBid,{amount:amount,lotId:lotId});},sendEngagement:function(status){client.send(commandKeys.bidderEngagement,status);}};}
return{authenticate:function(auctionId,lotId){return $http.post('/api/bidding/authenticate?auctionId='+auctionId+"&lotId="+lotId).then(function(response){if(response.status===200&&response.data){return response.data;}});},getClient:function(auctionId,lotId){const _this=this;let timedClient=new TimedClient(biddingConnection);timedClient.onRequestConnection(function(connector){_this.authenticate(auctionId,lotId).then(function(data){connector.connection(data.host+"/ws/timed/bid/"+data.auctionId+"/"+data.lotId,data.token);},function(e){if(e.status===-1){connector.failConnection()}else{connector.declineConnection()}});});return timedClient;}}});RMSFrontEnd.controller('timedBiddingController',function($scope,timedBidding,timeService,currencyService,dictionaryService,retryService){var _this=this;_this.item={};_this.item.started=false;_this.remoteItem={};_this.templates=timeService.getTimeSpanTemplates();_this.modes={force:"force",max:"max"};_this.offset=0;_this.label={};_this.label.cb="";_this.label.a="";_this.label.hb="";_this.label.et="";_this.label.pb="...";_this.label.pmb="...";_this.label.headline="";_this.label.owner="Your Consignment";_this.label.confirm={tooLarge:"Your bid of $bid is significantly higher than the current bid and the next recommended increment. Please remember that the auction and the bids placed within it are governed by the Bidders’ Terms and Conditions. Are you sure you want to place this bid?",alreadyHighBidder:"You are already the winning bidder.  Are you sure you want to raise your bid?"};_this.label.error={tooSmall:"Bid must meet or exceed asking price.",tooLargeExtendedTime:"Bid amount exceeds limit for final 2 minutes.",connection:"No connection available. Please try again."};_this.message={};_this.input={};_this.mode=_this.modes.force;_this.availableBids=[];_this.input.amount="";_this.confirmTimeLeft=0;_this.requestingBid=false;_this.maxConfirmTimeLeft=0;_this.requestingMaxBid=false;_this.reserveStatusLookup={}
_this.autoExtendTime=120;_this.lot={};_this.connectionFailed=false;_this.connectionStarted=false;_this.showAbsenteeInfo=false;this.onStart=this.onStart||function(){};this.onLotChanged=this.onLotChanged||function(lot){};var cssWidgetClass="info-widget bid-widget";var cssContentClass="info__content";var cssHeaderClass="info__header";var client;function connect(){console.log("starting....");setupClient(_this.auctionId,_this.id).connect();}
this.retryConnection=function(){_this.connectionFailed=false;connect();}
function declinedConnection(){_this.connectionStarted=true;_this.connectionMessage="Not Authorized."}
function failedConnection(){_this.connectionStarted=true;_this.connectionFailed=true;_this.connectionMessage="Failed."}
function retryingConnection(){_this.connectionStarted=true;const tryingMessage=" Trying to connect...";if(!_this.connectionMessage.endsWith(tryingMessage))
_this.connectionMessage=_this.connectionMessage+tryingMessage;}
function acceptedSession(){_this.connectionStarted=true;_this.connected=true;_this.connectionMessage="";_this.connectionFailed=false;$scope.$apply();}
function closedSession(reason){_this.connectionStarted=true;_this.connected=false;_this.connectionMessage=reason||"Without a reason specified";$scope.$apply();}
function receivedDataSession(){_this.connectionStarted=true;_this.connected=true;$scope.$apply();}
function setupClient(auctionId,lotId){if(!client){client=timedBidding.getClient(auctionId,lotId);client.onConnectionRetrying(retryingConnection);client.onConnectionDeclined(declinedConnection);client.onConnectionFailed(failedConnection);client.onSessionAccepted(acceptedSession);client.onSessionClose(closedSession);client.onSessionError(closedSession);client.onSessionDataReceived(receivedDataSession);client.onSendError(failedConnection)
client.onAuctionChanged(onAuctionChanged);client.onLotChanged(onLotChanged);client.onLotPhotosChanged(ontLotPhotosChanged);client.onBidResult(onBidResult);client.onBidderConnected(onBidderConnected);client.onTimeOffset(onTimeOffset);client.onTimeSync(onTimeSync);client.onAutoExtendTimeChanged(onAutoExtendTimeChanged);client.onBiddingAccessChanged(onBiddingAccessChanged);client.onPermissions(onPermissions);client.onBidRounded(onBidRounded);client.onBidStatsChanged(onBidStatsChanged);}
return client;}
function onAutoExtendTimeChanged(seconds){_this.autoExtendTime=seconds;}
function onBidRounded(amount){var lot=_this.lot;if(amount<lot.currentAsking){_this.bidMessage=_this.label.error.tooSmall;return;}
var extendedTimeThreshold=lot.currentAsking*10;var timing=timeService.getTimingStats(new Date(lot.startTime),new Date(lot.finishedTime),_this.offset);var secondsLeft=_this.autoExtendTime;if(timing.millisRemaining<(1000*secondsLeft)){if(amount>=extendedTimeThreshold){_this.bidMessage=_this.label.error.tooLargeExtendedTime;return;}}
var threshold=lot.currentAsking*10;var amountFormatted=currencyService.formatCurrency(amount,lot.currency.symbol);if(amount>=threshold){if(confirm(_this.label.confirm.tooLarge.replace("$bid",amountFormatted))){if(_this.modes.max===_this.mode){maxBid(amount);}
if(_this.modes.force===_this.mode){bid(amount);}}}else if(_this.modes.force===_this.mode&&_this.lot.isHighBidder){if(confirm(_this.label.confirm.alreadyHighBidder.replace("$bid",amountFormatted))){bid(amount);}}else{_this.confirmTimeLeft=5;_this.bidAmount=amount;_this.bidAmountFormatted=amountFormatted;}}
function onAuctionChanged(auction){_this.auction=auction;}
function onLotChanged(lot){if(_this.lot.status===undefined&&lot.status!=="Active"){window.location.href=window.location.href.replace("/bidding",'');}
setMessage(lot.status);updateLot(_this.lot,lot);appendFormattedText(_this.lot);if(_this.lot.status!=="Active"&&_this.lot.status!=="Available"){_this.disabled=true;}else{if(_this.bidder)
_this.disabled=false;}
updateButtonLabel();_this.onLotChanged({value:lot});}
function onBidStatsChanged(stats){updateBid(_this.lot,stats);updateButtonLabel();}
function updateBid(lot,stats){if(lot.id===stats.lotId){lot.bidCount=stats.bidCount;lot.isHighBidder=stats.isHighBidder;lot.userBidCount=stats.userBidCount;lot.userMaxBid=stats.userMaxBid;_this.isHighBidder=lot.isHighBidder;appendFormattedText(lot);}}
function updateLot(lot,newLot,initial){initial=initial||false;var previousBid=lot.currentBid;lot.id=newLot.id;lot.name=newLot.name;lot.startTime=newLot.startTime;lot.finishedTime=newLot.finishedTime;lot.status=newLot.status;lot.currency=newLot.currency;lot.currentBid=newLot.currentBid;lot.currentAsking=newLot.currentAsking;lot.lowEstimate=newLot.lowEstimate;lot.highEstimate=newLot.highEstimate;lot.reserveStatus=newLot.reserveStatus;lot.auctioned=lot.status==='Sold'||lot.status==='NotSold'
$(".current-bid-animated").removeClass("pulse")
var value={val:lot.currentBid};gsap.from(value,{duration:0.1,ease:'circ.out',val:previousBid,roundProps:'val',onUpdate:function(){$(".current-bid-animated").addClass("pulse")
$(".current-bid-animated")[0].innerText=currencyService.formatCurrency(value.val,lot.currency.symbol,lot.currency.code);},})
appendFormattedText(lot)}
function appendFormattedText(lot){var currencySymbol=lot.currency.symbol;var currencyCode=lot.currency.code;_this.label.currencySymbol=currencySymbol;_this.label.currencyCode=lot.currency.code;lot.statusFormatted=lot.status.replace("NotSold","Not Sold");lot.reserveStatusFormatted=_this.reserveStatusLookup[lot.reserveStatus];if(lot.status==='NotSold'){lot.reserveStatusFormatted=_this.reserveStatusLookup["NotMet"];}
lot.reserveFormatted=currencyService.formatCurrency(lot.reserve,currencySymbol,currencyCode);lot.currentBidFormatted=currencyService.formatCurrency(lot.currentBid,currencySymbol,currencyCode);lot.currentAskingFormatted=currencyService.formatCurrency(lot.currentAsking,currencySymbol,currencyCode);lot.estimateFormatted=currencyService.formatCurrencyRange(lot.lowEstimate,lot.highEstimate,currencySymbol,currencyCode)||currencyService.formatCurrency(0,currencySymbol);if(lot.userMaxBid!=null){lot.userMaxBidFormatted=currencyService.formatCurrency(lot.userMaxBid,currencySymbol);}
if(lot.started){if(lot.currentBid>0){_this.currentBid=_this.label.cb+" "+lot.currentBidFormatted;}else{_this.currentBid=_this.label.cb+" "+lot.currentAskingFormatted;}}}
function onBidResult(bid){var message="";if(bid.type==="Max"&&bid.status==="NotAccepted")message="Bid must exceed the Max Bid you already placed.";if(bid.status==="Error")message=bid.reason;_this.bidMessage=message;_this.bidResult=bid;_this.requestingBid=false;_this.input.amount="";}
function ontLotPhotosChanged(photos){_this.photos=photos;}
function onTimeSync(){client.sendTime();_this.timeSyncRequestedOn=new Date();}
function onTimeOffset(offset){var requestedTimeMs=new Date()-_this.timeSyncRequestedOn;_this.offset=offset-requestedTimeMs;if(_this.lot){var timing=timeService.getTimingStats(new Date(_this.lot.startTime),new Date(_this.lot.finishedTime),_this.offset);if(_this.started!==timing.started){_this.started=timing.started;if(_this.started)
_this.onStart();}}}
function onBidderConnected(bidder){_this.bidder=bidder;}
function onBiddingAccessChanged(summary){_this.biddingAccess=summary;_this.biddingAccess.message="";angular.forEach(_this.biddingAccess.accessList,function(o){if(o.message.length>0){_this.biddingAccess.message=(_this.biddingAccess.message+" "+o.message).trim();}});_this.canBid=summary.access!=="Restricted";}
function onPermissions(permissions){_this.permissions=permissions;_this.isOwner=false;angular.forEach(_this.permissions,function(o){_this.isOwner=_this.isOwner||(o.name==="Consignor");});}
function updateButtonLabel(){if(_this.canBid===false){_this.label.pb=_this.label.pbna;}else{if(_this.lot.isHighBidder){if(_this.mode===_this.modes.force){_this.label.pb=_this.label.rbs;}else{_this.label.pb=_this.label.rmbs;}}else{if(_this.mode===_this.modes.force){_this.label.pb=_this.label.pbs;}else{_this.label.pb=_this.label.pmbs;}}}}
function updateModeLabels(){if(_this.mode===_this.modes.force){_this.label.changeBidMode=_this.label.abm;_this.label.bidModeDescription=_this.label.pbd;}else{_this.label.changeBidMode=_this.label.pbm;_this.label.bidModeDescription=_this.label.abd;}}
this.toggleAbsenteeInfo=function(){_this.showAbsenteeInfo=!_this.showAbsenteeInfo;}
function setMessage(status){switch(status){case'Active':case'Available':_this.label.headline=_this.message.available;break;case'Sold':_this.label.cb=_this.label.cbh;_this.label.headline=_this.message.sold;break;case'NotSold':_this.label.headline=_this.message.noSale;_this.label.cb=_this.label.cbh;break;}}
this.copyInput=function(){if(_this.input.amount==""&&_this.lot.currentAsking!==undefined){_this.input.amount=currencyService.formatNumber(_this.lot.currentAsking);}};this.changeMode=function(){if(!(_this.requestingBid||_this.confirmTimeLeft>0)){if(_this.modes.force===_this.mode){_this.mode=_this.modes.max;}else{_this.mode=_this.modes.force;}
updateModeLabels();updateButtonLabel();}};function bid(amount){_this.confirmTimeLeft=0;_this.requestingBid=true;client.sendForceBid(amount,_this.lot.id);}
function maxBid(amount){_this.confirmTimeLeft=0;_this.requestingBid=true;client.sendMaxBid(amount,_this.lot.id);}
this.amountChange=function(){_this.bidMessage="";_this.confirmTimeLeft=0;};function confirmBid(isMaxBid){_this.bidMessage="";var requestedAmount=currencyService.convertToFloat(_this.input.amount);var lot=_this.lot;if(requestedAmount<lot.currentAsking){client.sendFailedBid(requestedAmount,lot.id);_this.bidMessage=_this.label.error.tooSmall;return;}
if(_this.confirmTimeLeft>0){if(isMaxBid){maxBid(currencyService.convertToFloat(_this.bidAmount));}else{bid(currencyService.convertToFloat(_this.bidAmount));}
return;}
client.requestBidRound(requestedAmount);}
this.confirmBid=function(){confirmBid(_this.modes.max===_this.mode);};this.cssClass=function(){return cssWidgetClass;};this.cssContentClass=function(){return cssContentClass;};this.cssHeaderClass=function(){return cssHeaderClass;};function init(id){connect();if(_this.modal){var containerModal=$("#timed-bid-"+id);containerModal.modal("show");containerModal.on("show.bs.modal",function(){if(!(_this.requestingBid||_this.confirmTimeLeft>0)){_this.mode=_this.modes.force;updateModeLabels();updateButtonLabel();}});containerModal.on("hidden.bs.modal",function(){if(!(_this.requestingBid||_this.confirmTimeLeft>0)){_this.mode=_this.modes.force;updateModeLabels();updateButtonLabel();}});}else{}
timeService.getOffset().then(function(data){_this.offset=data;});timeService.getTimeSpanTemplates().then(function(data){_this.templates=data;});dictionaryService.getDictionaryItems(["Lots.Reserve Status","Lots.Current Bid","Lots.Asking Bid","Lots.You High Bidder","Lots.You Outbid","Lots.Closing","Lots.High Bid","Lots.High Bid Note","Lots.Raise Bid","Lots.Place Bid","Lots.Place Max Bid","Lots.Raise Max Bid","Lots.Absentee","Lots.Max Bid Description","Lots.Force Bid Description","Lots.Max Bid Mode","Lots.Force Bid Mode","Lots.Bid Error Amount Too Small","Lots.Bid Error Amount Too Large Extend","Lots.Bid Confirm Too Large","Lots.You Owner","Lots.Bid Error No Connection","Bid.Bidding Tier Not Allowed","Lots.Bid On This Item","Lots.Bid Sold","Lots.Bid No Sale","Bid.Over limit","Bid.Over cumulative limit","Lots.Bid Confirm High Bidder","Lots.rs1","Lots.rs2","Lots.Without reserve","Lots.Final Bid","Lots.You Won","Lots.Reserve Not Met"],true).then(function(data){_this.label.fb=data["Lots.Final Bid"]||"Final Bid:";_this.label.won=data["Lots.You Won"];_this.label.rs=data["Lots.Reserve Status"];_this.label.cb=data["Lots.Current Bid"];_this.label.a=data["Lots.Asking Bid"];_this.label.hb=data["Lots.You High Bidder"];_this.label.ob=data["Lots.You Outbid"];_this.label.et=data["Lots.Closing"];_this.label.cbh=data["Lots.High Bid"];_this.label.note=data["Lots.High Bid Note"];_this.label.pbs=data["Lots.Place Bid"];_this.label.rbs=data["Lots.Raise Bid"];_this.label.pmbs=data["Lots.Place Max Bid"];_this.label.rmbs=data["Lots.Raise Max Bid"];_this.label.ab=data["Lots.Absentee"];_this.label.abd=data["Lots.Max Bid Description"];_this.label.pbd=data["Lots.Force Bid Description"];_this.label.abm=data["Lots.Max Bid Mode"];_this.label.pbm=data["Lots.Force Bid Mode"];_this.label.pbna=data["Bid.Bidding Tier Not Allowed"];_this.label.confirm.tooLarge=data["Lots.Bid Confirm Too Large"]||_this.label.confirm.tooLarge;_this.label.confirm.alreadyHighBidder=data["Lots.Bid Confirm High Bidder"]||_this.label.confirm.alreadyHighBidder;_this.label.error.tooSmall=data["Lots.Bid Error Amount Too Small"]||_this.label.error.tooSmall;_this.label.error.tooLargeExtendedTime=data["Lots.Bid Error Amount Too Large Extend"]||_this.label.error.tooLargeExtendedTime;_this.label.owner=data["Lots.You Owner"]||_this.label.owner;_this.label.error.connection=data["Lots.Bid Error No Connection"]||_this.label.error.connection;_this.label.overLimit=data["Bid.Over limit"];_this.label.bid=data["Bid.Bids"]||"Bids:";_this.label.overCumulativeLimit=data["Bid.Over cumulative limit"];_this.message={available:data["Lots.Bid On This Item"],sold:data["Lots.Bid Sold"],noSale:data["Lots.Bid No Sale"]};_this.reserveStatusLookup["NoReserve"]=data["Lots.Without reserve"];_this.reserveStatusLookup["ReserveMet"]=data["Lots.rs2"];_this.reserveStatusLookup["UnderReserve"]=data["Lots.rs1"];_this.reserveStatusLookup["NotMet"]=data["Lots.Reserve Not Met"]||"Did not meet reserve";setMessage(_this.lot.status);updateButtonLabel();updateModeLabels();});}
function timeLoop(apply){if(_this.lot){if(_this.confirmTimeLeft>0){_this.confirmTimeLeft--;}
if(_this.maxConfirmTimeLeft>0){_this.maxConfirmTimeLeft--;}
var timing=timeService.getTimingStats(new Date(_this.lot.startTime),new Date(_this.lot.finishedTime),_this.offset);var auctioned=_this.lot.status==="Sold"||_this.lot.status==="NotSold";if(_this.started!==timing.started){_this.started=timing.started;if(_this.started)
_this.onStart();}
var countDownPercent=1;var secondsLeft=_this.autoExtendTime;if(timing.millisRemaining<(1000*secondsLeft)){countDownPercent=((timing.millisRemaining/1000)/secondsLeft);if(countDownPercent<0){countDownPercent=0;}}
_this.lot.timeRemainingPercent=countDownPercent;_this.lot.timeRemainingCssStyle={backgroundColor:_this.lot.isHighBidder?"limegreen":"red",height:"10px",width:_this.lot.timeRemainingPercent*100+"%",margin:"0 auto"};_this.lot.timeLeft=auctioned?_this.templates.finished:timing.formattedTimeRemaining;_this.lot.secondsLeft=timing.millisRemaining*1000;_this.lot.started=timing.started;if(_this.lot.started){if(_this.lot.currentBid>0){_this.currentBid=_this.label.cb+" "+_this.lot.currentBidFormatted;}else{_this.currentBid=_this.label.a+" "+_this.lot.currentAskingFormatted;}
_this.time=_this.label.et+" "+timeService.formatTimeLeft(timing.timeSpan,auctioned,_this.autoExtendTime,_this.templates);}
if(apply!==false){$scope.$apply();}}}
this.initialize=function(auctionId,lotId){_this.id=lotId;_this.auctionId=auctionId;init();setInterval(timeLoop,1000);timeLoop(false);}
this.$ngInit=function(){if(_this.id&&_this.auctionId){_this.initialize(_this.auctionId,_this.id);}}
this.showClosingLabel=function(){return _this.templates?_this.lot.timeLeft!==_this.templates.finishing&&_this.lot.timeLeft!==_this.templates.finished:true;}});;;
RMSFrontEnd.component("timedBidding",{templateUrl:"/scripts/rms-scripts/components/bidding/timed/timedBidding.template.html",controller:"timedBiddingController",bindings:{id:'@',auctionId:'@',modal:'<',onStart:'&',onLotChanged:'&',isHighBidder:'=',time:'=',currentBid:'='}});RMSFrontEnd.component("timedBidding2",{templateUrl:"/scripts/rms-scripts/components/bidding/timed/timedBidding.template2.html",controller:"timedBiddingController",bindings:{id:'@',auctionId:'@',}});;;
'use strict';RMSFrontEnd.controller('editNotificationsController',function(userService,recaptcha){var _this=this;this.formData={};this.inProgress=false;this.firstSubmitted=false;this.showSuccess=false;this.showError=false;this.validateForm=function(){_this.formSubmitted=true;};this.requireMobile=function(){return _this.formData.MobileLotClosing||_this.formData.MobileLotClosed||_this.formData.MobileHighBid||_this.formData.MobileOutBid;};this.onVerifiedMobileNumber=function(verified,requested){_this.verifiedMobileNumber=verified;_this.showVerifiedMobileNumberText=requested;};this.save=function(){_this.disableButton=true;_this.showError=false;_this.showSuccess=false;if(_this.notificationForm.$valid){_this.showError=false;_this.errorMessage='';if(this.requireMobile()&&!_this.verifiedMobileNumber){_this.showError=true;_this.errorMessage='Mobile number verification required.';return;}
_this.inProgress=true;userService.setNotifications(_this.formData).then(function(data){if(data.status===0){_this.showSuccess=true;}else{_this.showSuccess=false;_this.showError=true;_this.errorMessage=data.message;}
_this.inProgress=false;_this.disableButton=false;});_this.notificationForm.$setPristine();}}});;;
'use strict';RMSFrontEnd.controller('shippingQuoteController',function($scope,$http,recaptcha,stateSelection){var _this=this;this.inProgress=false;this.showSuccess=false;this.showError=false;this.formData={Country:"United States"};this.result={};this.selectedCountryStates=[];stateSelection.getStates(_this.formData.Country).then(function(states){_this.selectedCountryStates=states;});$('.modal-window--shipping-quote').on('hide.bs.modal',function(event){_this.close();});this.close=function(){_this.inProgress=false;_this.showSuccess=false;_this.showError=false;_this.formData={Country:"United States"};_this.result={};_this.shippingQuoteForm.$setPristine();$scope.$apply();};this.submit=function(){if(_this.shippingQuoteForm.$valid){_this.inProgress=true;_this.showError=false;recaptcha.getToken('requestShippingQuote').then(function(recaptcha){$http.post('/api/utils/RequestShippingQuote',_this.formData,{headers:{'X-Recaptcha':recaptcha}}).then(function(response){if(response.status===200&&response.data){_this.result=response.data;if(_this.result.status===0){_this.quotePrice=_this.result.message;_this.showSuccess=true;_this.inProgress=false;return;}}
_this.inProgress=false;_this.showError=true;},function(error){_this.inProgress=false;_this.showError=true;});},function(error){_this.inProgress=false;_this.showError=true;});}}});;;
'use strict';RMSFrontEnd.controller('financingController',function($scope,$http,formDataOptions,stateSelection,recaptcha){var _this=this;this.formData={};this.Countries=[];this.selectedCountryStates=[];formDataOptions.getOptions(function(data){_this.Countries=data.countries;_this.InquiryTypes=data.inquiryTypes;});this.inProgress=false;this.showSuccess=false;this.showError=false;this.showErrorEmail=false;this.showForm=false;$(".modal-window--financing").on('hidden.bs.modal',function(){_this.resetForm();$scope.$apply();});this.filterStates=function(){stateSelection.getStates(_this.formData.Country).then(function(states){_this.selectedCountryStates=states;});};this.sendForm=function(){if(_this.financingForm.$valid){_this.inProgress=true;_this.showError=false;_this.showErrorEmail=false;_this.errorMessage='';recaptcha.getToken('sendFinancingRequest').then(function(token){_this.formData.Token=token;$http.post('/umbraco/Surface/Utils/RequestFinancing',_this.formData).then(function(response){if(response.status===200&&response.data){return response.data;}}).then(function(data){if(data.status===0){_this.inProgress=false;_this.errorMessage='';_this.showSuccess=true;_this.showError=false;_this.showErrorEmail=false;}else{_this.inProgress=false;_this.showSuccess=false;_this.showError=true;_this.showErrorEmail=false;_this.errorMessage=data.message;}},function(errorData){_this.inProgress=false;_this.showSuccess=false;_this.showError=true;_this.showErrorEmail=false;_this.errorMessage=errorData.message;});});}};this.resetForm=function(){_this.inProgress=false;_this.showError=false;_this.showSuccess=false;_this.showErrorEmail=false;_this.showForm=false;_this.financingForm.$setPristine();};this.dismissError=function(){_this.showError=false;_this.showErrorEmail=false;};this.initModal=function(){_this.IsModal=true;};});;;
'use strict';RMSFrontEnd.controller('privateSalesRequestController',function(formDataOptions,stateSelection,userService,recaptcha){var _this=this;this.formData={};this.formData.Images=[];this.titleOptions=[];this.lengthsOfOwnership=[];this.conditions=[];this.IsModal=false;this.formData.Images.push({},{},{});this.inProgress=false;this.showSuccess=false;this.showForm=true;this.showError=false;formDataOptions.getOptions(function(data){_this.countries=data.countries;});this.scrollToTop=function(){$window.scrollTo(0,0);};this.filterStates=function(){stateSelection.getStates(_this.formData.country).then(function(states){_this.selectedCountryStates=states;});};this.sendForm=function(){if(_this.form.$valid){_this.disableButton=true;_this.inProgress=true;_this.showError=false;_this.errorMessage='';recaptcha.getToken('privateSalesInquiry').then(function(token){userService.privateSale(_this.formData,token).then(function(){_this.inProgress=false;_this.errorMessage='';_this.showSuccess=true;_this.showError=false;_this.showErrorEmail=false;},function(response){_this.inProgress=false;_this.showSuccess=false;_this.showError=true;_this.showErrorEmail=false;_this.errorMessage=response.message;_this.disableButton=false;});});}else{_this.formError();}};this.formSuccess=function(){_this.inProgress=false;_this.showSuccess=true;_this.showError=false;_this.showForm=false;};this.formError=function(data){var message='There was an error, please try again.';if(data){_this.errorMessage=data.message||message;}else{_this.errorMessage=message;}
_this.inProgress=false;_this.showSuccess=false;_this.showError=true;};this.resetForm=function(){_this.formData={};_this.showSuccess=false;_this.showError=false;_this.form.$setPristine();};this.dismissError=function(){_this.showError=false;};this.finish=function(){_this.resetForm();};});;;
RMSFrontEnd.component("liveBidding",{templateUrl:"/scripts/rms-scripts/components/bidding/live/liveBidding.template.html",controller:"liveBiddingController",bindings:{auctionId:'@',muted:'='}});;;
RMSFrontEnd.factory("liveBidding",function($http,biddingConnection){var LiveClient=function(biddingConnection){let client=biddingConnection.getClient();client.transformSend(transformSend)
client.transformReceived(transformReceived)
client.onReceive(onReceive)
const noop=function(){};const commandKeys={authorization:"authorization=>",bid:"bid=>",bidderEngagement:"bidder-engagement=>",auctionState:"auction-state=>",auctionStatus:"auction-status=>",lotPhotos:"lot-photos=>",lotChange:"lot-change=>",userPermissions:"user-permissions=>",lotStatus:"lot-status=>",lotBid:"lot-bid=>",lotAsking:"lot-asking=>",lotListing:"lot-listing=>",directMessage:"direct-message=>",outgoingDirectMessage:"direct-outgoing-message=>",broadcastMessage:"broadcast=>",recentMessages:"recent-messages=>",pendingBid:"pending-bid=>",currencies:"currencies=>",exchangeRate:"exchange-rate=>",bidResult:"bid-result=>",bidder:"bidder=>",clearPendingBids:"clear-pending-bids=>",biddingAccess:"bidding-access=>"};let onPermissions=noop;let onAuctionChanged=noop;let onAuctionStatusChanged=noop;let onLotChanged=noop;let onLotBidChanged=noop;let onLotStatusChanged=noop;let onLotAskingChanged=noop;let onLotListingChanged=noop;let onLotPhotosChanged=noop;let onBidRequested=noop;let onBiddingAccessChanged=noop;let onClearRequestedBids=noop;let onBidResult=noop;let onMessage=noop;let onDirectMessage=noop;let onMessagesLoaded=noop;let onBidderConnected=noop;let onExchangeRatesLoaded=noop;let onExchangeRateChanged=noop;function transformAccess(obj){return{access:obj.a,accessList:transformAccessList(obj.l)}}
function transformAccessList(list){let list2=[];for(let index=0;index<list.length;++index){let obj=list[index];list2.push({name:obj.n,access:obj.a,message:obj.m})}
return list2;}
function transformPermissions(list){const list2=[];for(let index=0;index<list.length;++index){const obj=list[index];list2.push({name:obj.n,description:obj.d})}
return list2;}
function transformCurrency(obj){return{code:obj.c,symbol:obj.s}}
function transformCurrencyValue(obj){return{currency:transformCurrency(obj.c),value:obj.v}}
function transformBidder(obj){if(obj===null)
return null;return{id:obj.id,name:obj.n,bidderNumber:obj.bn}}
function transformAuction(obj){return{id:obj.id,name:obj.n,status:transformAuctionStatus(obj.s),currency:transformCurrency(obj.c),startTime:obj.st,endTime:obj.et,metaData:obj.md}}
function transformAuctionReferenceAuctionStatus(obj){return{id:obj.id,status:transformAuctionStatus(obj.s),}}
function transformLot(obj){return{id:obj.id,name:obj.n,url:obj.u,status:transformLotStatus(obj.s),lotNumber:obj.l,currentBid:obj.b,lowEstimate:obj.le,highEstimate:obj.he,currentAsking:obj.a,currentIncrement:obj.i,currency:transformCurrency(obj.c),viewOnly:obj.v,isHighBidder:obj.ihb,isOutBid:obj.iob,hasAddendum:obj.ad}}
function transformLotReferenceLotStatus(obj){return{id:obj.id,status:transformLotStatus(obj.s),}}
function transformLotBid(obj){return{id:obj.id,currentBid:obj.b,currentAsking:obj.a,currentIncrement:obj.i,isHighBidder:obj.ihb,isOutBid:obj.iob}}
function transformLotAsking(obj){return{id:obj.id,currentAsking:obj.a,currentIncrement:obj.i}}
function transformLotListItem(obj){return{id:obj.id,name:obj.n,url:obj.u,photoUrl:obj.pu,status:transformLotStatus(obj.s),lotNumber:obj.l,lowEstimate:obj.le,highEstimate:obj.he}}
function transformAuctionStatus(obj){switch(obj){case"a":return"Available";case"ac":return"Active";case"c":return"Closed";case"o":return"Opened";case"s":return"Suspended";}
return obj;}
function transformLotStatus(obj){switch(obj){case"a":return"Available";case"ac":return"Active";case"s":return"Sold";case"ns":return"NotSold";case"w":return"Withdrawn";}
return obj;}
function transformBidStatus(obj){switch(obj){case"a":return"Accepted";case"na":return"NotAccepted";case"e":return"Error";case"p":return"Pending";}
return obj;}
function transformBidType(obj){switch(obj){case"f":return"Force"
case"m":return"Max"
case"um":return"UnderMax"}
return obj;}
function transformBidResult(obj){return{id:obj.id,amount:obj.a,lotId:obj.lid,userId:obj.uid,type:transformBidType(obj.t),status:transformBidStatus(obj.s),reason:obj.r}}
function transformUserReference(obj){return{id:obj.id,name:obj.n}}
function transformMessage(obj){return{text:obj.t,from:obj.f===undefined?undefined:transformUserReference(obj.f),to:obj.to===undefined?undefined:transformUserReference(obj.to),metaData:obj.md}}
function transformReceived(key,obj){let i;switch(key+"=>"){case commandKeys.bidder:return transformBidder(obj);case commandKeys.biddingAccess:return transformAccess(obj);case commandKeys.userPermissions:return transformPermissions(obj);case commandKeys.auctionState:return transformAuction(obj);case commandKeys.auctionStatus:return transformAuctionReferenceAuctionStatus(obj);case commandKeys.currencies:let newObj=[];for(i=0;i<obj.length;i++){newObj.push(transformCurrencyValue(obj[i]))}
return newObj;case commandKeys.exchangeRate:return transformCurrencyValue(obj);case commandKeys.lotChange:return transformLot(obj);case commandKeys.lotStatus:return transformLotReferenceLotStatus(obj);case commandKeys.lotBid:return transformLotBid(obj);case commandKeys.lotAsking:return transformLotAsking(obj);case commandKeys.lotListing:let lotListing=[];for(i=0;i<obj.length;i++){lotListing.push(transformLotListItem(obj[i]))}
return lotListing;case commandKeys.pendingBid:return transformBidResult(obj);case commandKeys.bidResult:return transformBidResult(obj);case commandKeys.recentMessages:let messages=[];for(i=0;i<obj.length;i++){messages.push(transformMessage(obj[i]))}
return messages;case commandKeys.directMessage:case commandKeys.broadcastMessage:return transformMessage(obj);}
return obj;}
function onReceive(key,obj){switch(key+"=>"){case commandKeys.clearPendingBids:onClearRequestedBids(obj);break;case commandKeys.lotPhotos:onLotPhotosChanged(obj);break;case commandKeys.bidder:onBidderConnected(obj);break;case commandKeys.biddingAccess:onBiddingAccessChanged(obj);break;case commandKeys.userPermissions:onPermissions(value);break;case commandKeys.auctionState:onAuctionChanged(obj);break;case commandKeys.auctionStatus:onAuctionStatusChanged(obj);break;case commandKeys.currencies:onExchangeRatesLoaded(obj);break;case commandKeys.exchangeRate:onExchangeRateChanged(obj);break;case commandKeys.lotChange:onLotChanged(obj);break;case commandKeys.lotStatus:onLotStatusChanged(obj);break;case commandKeys.lotBid:onLotBidChanged(obj);break;case commandKeys.lotAsking:onLotAskingChanged(obj);break;case commandKeys.lotListing:onLotListingChanged(obj);break;case commandKeys.pendingBid:onBidRequested(obj);break;case commandKeys.bidResult:onBidResult(obj);break;case commandKeys.recentMessages:onMessagesLoaded(obj);break;case commandKeys.directMessage:onDirectMessage(obj)
break;case commandKeys.broadcastMessage:onMessage(obj);break;}}
function transformSend(key,obj){let newObj=obj;switch(key+"=>"){case commandKeys.bid:newObj={id:obj.lotId,a:obj.amount}
break;case commandKeys.bidderEngagement:switch(obj){case"Active":newObj="ac";break;case"Available":newObj="a";break;case"Idle":newObj="i";break;}
break;}
return newObj;}
return{connect:client.connect,disconnect:client.disconnect,onSessionOpen:client.onSessionOpen,onSessionAccepted:client.onSessionAccepted,onSessionClose:client.onSessionClose,onSessionError:client.onSessionError,onSessionDataReceived:client.onSessionDataReceived,onSendError:client.onSendError,onRequestConnection:client.onRequestConnection,onConnectionRetrying:client.onConnectionRetrying,onConnectionDeclined:client.onConnectionDeclined,onConnectionFailed:client.onConnectionFailed,onAuctionChanged:function(callback){onAuctionChanged=callback||noop;},onAuctionStatusChanged:function(callback){onAuctionStatusChanged=callback||noop;},onLotChanged:function(callback){onLotChanged=callback||noop;},onLotBidChanged:function(callback){onLotBidChanged=callback||noop;},onLotStatusChanged:function(callback){onLotStatusChanged=callback||noop;},onLotAskingChanged:function(callback){onLotAskingChanged=callback||noop;},onLotPhotosChanged:function(callback){onLotPhotosChanged=callback||noop;},onLotListingChanged:function(callback){onLotListingChanged=callback||noop;},onBidRequested:function(callback){onBidRequested=callback||noop;},onClearRequestedBids:function(callback){onClearRequestedBids=callback||noop;},onBidResult:function(callback){onBidResult=callback||noop;},onMessage:function(callback){onMessage=callback||noop;},onDirectMessage:function(callback){onDirectMessage=callback||noop;},onMessagesLoaded:function(callback){onMessagesLoaded=callback||noop;},onBidderConnected:function(callback){onBidderConnected=callback||noop;},onExchangeRatesLoaded:function(callback){onExchangeRatesLoaded=callback||noop;},onExchangeRateChanged:function(callback){onExchangeRateChanged=callback||noop;},onBiddingAccessChanged:function(callback){onBiddingAccessChanged=callback||noop;},onPermissions:function(callback){onPermissions=callback||noop;},requestBid:function(bidRequest){client.send(commandKeys.bid,bidRequest);},sendMessage:function(message){client.send(commandKeys.outgoingDirectMessage,message);},sendEngagement:function(status){if(client.version()===""){client.send("bid-ready=>",status==="Active");}else{client.send(commandKeys.bidderEngagement,status);}}};};return{authenticate:function(id){return $http.post('/api/bidding/authenticate?auctionId='+id).then(function(response){if(response.status===200&&response.data){return response.data;}});},getClient:function(auctionId){const _this=this;const client=new LiveClient(biddingConnection);client.onRequestConnection(function(connector){_this.authenticate(auctionId).then(function(data){connector.connection(data.host+"/ws/live/bid/"+data.auctionId,data.token);},function(e){if(e.status===-1){connector.failConnection()}else{connector.declineConnection()}});});return client;}}});RMSFrontEnd.controller("liveBiddingController",function($rootScope,$scope,$window,liveBidding,dictionaryService,currencyService,retryService){var _this=this;_this.auction=null;_this.lot=null;_this.internetButtonClass="";_this.disabled=true;_this.messages=[];_this.socketMessages=[];_this.isHighBidder=false;_this.bidder=null;_this.biddingAccess={access:'Restricted'};_this.lotListing=[];_this.selectedCurrency=null;_this.convertedAsking={};_this.defaultExchangeRate={};_this.muted=_this.muted||false;_this.connectionMessage="Connecting....";_this.connected=true;_this.currencies=[];_this.label={owner:"Your Consignment",memorabiliaOnly:"You are set to bid on memorabilia only.",confirm:{alreadyHighBidder:"You are already the winning bidder.  Are you sure you want to raise your bid?"}};_this.connectionFailed=false;_this.connectionDeclined=false;_this.connectionUserLoggedIn=false;_this.wonLot=null;_this.wonTimeout=-1;let client;function declinedConnection(){_this.connectionMessage="Not Authorized."}
function failedConnection(){_this.connectionFailed=true;_this.connectionMessage="Failed."}
function retryingConnection(){const tryingMessage=" Trying to connect...";if(!_this.connectionMessage.endsWith(tryingMessage))
_this.connectionMessage=_this.connectionMessage+tryingMessage;}
function acceptedSession(version){_this.connected=true;_this.connectionMessage="";_this.connectionFailed=false;$scope.$apply();}
function closedSession(reason){_this.connected=false;_this.connectionMessage=reason||"Without a reason specified";$scope.$apply();}
function receivedDataSession(){_this.connected=true;$scope.$apply();}
function connect(auctionId){if(!client){client=liveBidding.getClient(auctionId);client.onConnectionRetrying(retryingConnection)
client.onConnectionFailed(failedConnection);client.onConnectionDeclined(declinedConnection)
client.onSessionAccepted(acceptedSession);client.onSessionClose(closedSession);client.onSessionError(closedSession);client.onSessionDataReceived(receivedDataSession);client.onAuctionChanged(onAuctionChanged);client.onAuctionStatusChanged(onAuctionStatusChanged);client.onLotChanged(onLotChanged);client.onLotStatusChanged(onLotStatusChanged);client.onLotBidChanged(onLotBidChanged);client.onLotAskingChanged(onLotAskingChanged);client.onBidResult(onBidResult);client.onBidRequested(onBidRequested);client.onClearRequestedBids(onClearRequestedBids);client.onBidderConnected(onBidderConnected);client.onExchangeRatesLoaded(onExchangeRatesLoaded);client.onLotListingChanged(onLotListingChanged);client.onLotPhotosChanged(ontLotPhotosChanged);client.onExchangeRateChanged(onExchangeRateChanged);client.onDirectMessage(onDirectMessage);client.onMessagesLoaded(onMessagesLoaded);client.onMessage(onMessage);client.onBiddingAccessChanged(onBiddingAccessChanged);client.onPermissions(onPermissions);}
client.connect();}
angular.element($window).bind('resize',function(e){setTimeout(function(){resizeLotList();},250);});$rootScope.$on('listLoaded',function(e,a){if(a==="lotListing"){setTimeout(function(){_this.moveToLot();},500)}});function resizeLotList(){var height=$window.innerHeight-($('.bidding-wrapper').innerHeight()-$('.lot-listing-container').innerHeight());$('.lot-listing-container').css("height",height+"px")}
setTimeout(function(){resizeLotList();},1000)
dictionaryService.getDictionaryItems(["Lots.You Owner","Lots.Bid Confirm High Bidder"],true).then(function(data){_this.label.owner=data["Lots.You Owner"]||_this.label.owner;_this.label.confirm.alreadyHighBidder=data["Lots.Bid Confirm High Bidder"]||_this.label.confirm.alreadyHighBidder;});function onAuctionChanged(auction){_this.auction=auction;var startTime=new Date(_this.auction.startTime);var endTime=new Date(_this.auction.endTime);var ye=new Intl.DateTimeFormat('en-us',{year:'numeric'});var mo=new Intl.DateTimeFormat('en-us',{month:'long'});var da=new Intl.DateTimeFormat('en-us',{day:'numeric'});var startTimeFormatted=da.format(startTime)+" "+mo.format(startTime);var endTimeFormatted=da.format(endTime)+" "+mo.format(endTime);if(startTimeFormatted!==endTimeFormatted){_this.auction.date=da.format(startTime)+" - "+endTimeFormatted;}else{_this.auction.date=startTimeFormatted;}
_this.defaultExchangeRate={currency:_this.auction.currency,value:1};if(_this.selectedCurrency==null){_this.selectedCurrency=_this.defaultExchangeRate;}}
function onAuctionStatusChanged(auction){if(_this.auction.id===auction.id){_this.auction.status=auction.status;}}
function onLotChanged(lot){if(_this.lot!=null&&lot.id!==_this.lot.id){$(".owl-carousel").addClass("owl-loading");}
_this.lot=lot;onLotBidChanged(lot);var currency=_this.lot.currency;_this.lot.estimateFormatted=currencyService.formatCurrencyRange(_this.lot.lowEstimate,_this.lot.highEstimate,currency.symbol,currency.code);onLotStatusChanged(lot,true);if(_this.pendingBid){if(_this.pendingBid.id!==_this.lot.id){_this.pendingBid=null;_this.internetButtonClass="";}}
_this.moveToLot();}
function wonLot(lot){_this.wonLot=lot;_this.wonTimeout=setTimeout(function(){_this.wonLot=null;$scope.$apply();},10000)}
function onLotStatusChanged(lotRef,onload){onload=onload||false;if(_this.lot.id===lotRef.id){_this.lot.status=lotRef.status;_this.lot.statusFormatted=_this.lot.status.replace("NotSold","Not Sold");if(_this.wonLot!==null&&_this.wonLot.id===_this.lot.id&&_this.lot.status==='Active'){_this.wonLot=null;clearTimeout(_this.wonTimeout);}
if(_this.lot.status==='Sold'&&_this.lot.isHighBidder&&!onload){wonLot(angular.copy(_this.lot))}
if(_this.lot.status!=="Active"){_this.disabled=true;}else{if(_this.bidder)
_this.disabled=false;}
applyLotListingFormatting();applyLotListingCssClass();}}
function onLotBidChanged(lotRef){if(_this.lot.id===lotRef.id){_this.lot.currentBid=lotRef.currentBid;_this.lot.isHighBidder=lotRef.isHighBidder;_this.lot.isOutBid=lotRef.isOutBid;_this.bidResult=null;_this.internetButtonClass="";var currencySymbol=_this.lot.currency.symbol;_this.lot.currentBidFormatted=currencyService.formatCurrency(_this.lot.currentBid,currencySymbol);onLotAskingChanged(lotRef)}}
function onLotAskingChanged(lotRef){if(_this.lot.id===lotRef.id){var askingBidChanged=_this.lot==null||lotRef.currentAsking!==_this.lot.currentAsking;_this.lot.currentAsking=lotRef.currentAsking;var currencySymbol=_this.lot.currency.symbol;_this.lot.currentAskingFormatted=currencyService.formatCurrency(_this.lot.currentAsking,currencySymbol);_this.lot.currentAskingSent=_this.lot.currentAsking;_this.currentAskingInput=currencyService.formatNumber(_this.lot.currentAsking);recalculateAskingConversion();if(askingBidChanged){_this.biddingDisabled=true;setTimeout(function(){_this.biddingDisabled=false;$scope.$apply();},500);}}}
function onBidResult(bid){_this.bidResult=bid;if(_this.pendingBid!=null&&_this.pendingBid.id===_this.bidResult.id&&_this.bidResult.status==="Accepted"){_this.internetButtonClass="";}}
function ontLotPhotosChanged(photos){_this.photos=photos;}
function onBidRequested(bid){var currency=_this.lot.currency;_this.pendingBid=bid;_this.pendingBid.amountFormatted=currencyService.formatCurrency(_this.pendingBid.amount,currency.symbol,currency.code);if(_this.pendingBid.amount===_this.lot.currentAsking&&_this.pendingBid.lotId===_this.lot.id){_this.internetButtonClass="pending-bid-button";}}
function cleanUpMessages(){if(_this.messages.length>100){_this.messages.pop();}}
function formatMessage(text){var processed=marked.parse(text);if(processed.indexOf("<a href")>-1){var regex=/(\<a\shref\=\".+\")/gm;processed=processed.replaceAll(regex,'$1 target=_blank')}
return processed;}
function onMessage(msg){if(msg.text.length>0){_this.messages.splice(0,0,{text:formatMessage(msg.text),from:msg.from,to:msg.to,metaData:msg.metaData,cssStyle:{color:msg.metaData.textColor||"inherit"},iconClass:msg.metaData.iconClass});cleanUpMessages();}
playAudio(msg.metaData.audioSrc||"");}
function onMessagesLoaded(broadcasts){_this.messages=[];for(var i=0;i<broadcasts.length;i++){var msg=broadcasts[i];if(msg.from.id===-1){_this.messages.push({text:formatMessage(msg.text),from:msg.from,to:msg.to,cssStyle:{color:msg.metaData.textColor||"inherit"},iconClass:msg.metaData.iconClass})}else{_this.messages.push({text:formatMessage(msg.text),from:msg.from,to:msg.to,cssStyle:{color:msg.metaData.textColor||"inherit"},iconClass:msg.metaData.iconClass})}}}
function onDirectMessage(msg){if(msg.text.length>0){_this.messages.splice(0,0,{text:formatMessage(msg.text),from:msg.from,to:msg.to,cssStyle:{color:msg.metaData.textColor||"inherit"},iconClass:msg.metaData.iconClass});cleanUpMessages();}
playAudio(msg.metaData.audioSrc||"");}
function onBidderConnected(bidder){_this.bidder=bidder;}
function recalculateAskingConversion(){_this.askingCurrencyValue=calculateValue(_this.lot.currentAsking,_this.selectedCurrency);_this.askingConversionFormatted=currencyService.formatCurrency(_this.askingCurrencyValue.value,_this.askingCurrencyValue.currency.symbol);}
function removeEmptyCurrencies(){var temp=[];for(var i=0;i<_this.currencies.length;i++){var found=_this.currencies[i];if(found.value>0){temp.push(found)}else{if(found.currency.code===_this.selectedCurrency.currency.code&&found.currency.symbol===_this.selectedCurrency.currency.symbol){_this.selectedCurrency=_this.currencies[0];}}}
_this.currencies=temp;}
function onExchangeRateChanged(rate){var exists=false;for(var i=0;i<_this.currencies.length;i++){var found=_this.currencies[i];if(found.currency.code===rate.currency.code&&found.currency.symbol===rate.currency.symbol){_this.currencies[i].value=rate.value;exists=true;}}
if(!exists){_this.currencies.push(rate);}
removeEmptyCurrencies();recalculateAskingConversion();}
function onExchangeRatesLoaded(currencies){_this.currencies=currencies;removeEmptyCurrencies();_this.currencies.splice(0,0,{currency:_this.auction.currency,value:1});if(_this.selectedCurrency!==null){_this.selectedCurrency=_this.currencies[0];}}
function onLotListingChanged(newList){var removeLots=[];angular.forEach(_this.lotListing,function(o,i){var contain=false;for(var i=0;i<newList.length;i++){if(newList[i].id===o.id){contain=true;break;}}
if(!contain){removeLots.push(o);}});angular.forEach(removeLots,function(oldLot,i){for(var x=0;x<_this.lotListing.length;x++){if(oldLot.id===_this.lotListing[x].id){_this.lotListing.splice(x,1);break;}}});angular.merge(_this.lotListing,newList);applyLotListingFormatting();applyLotListingCssClass();_this.moveToLot();}
function onClearRequestedBids(ref){if(_this.pendingBid!=null&&_this.pendingBid.id===ref.id){_this.pendingBid=null;_this.internetButtonClass="";}}
function playAudio(source){if(source.length>0&&!_this.muted){var audio=new Audio();audio.src=source;audio.play();}}
function onBiddingAccessChanged(access){_this.biddingAccess=access;_this.biddingAccess.message="";angular.forEach(_this.biddingAccess.accessList,function(o){if(o.message.length>0){_this.biddingAccess.message=(_this.biddingAccess.message+" "+convertAccessMessage(o.message)).trim();}});}
function onPermissions(permissions){_this.permissions=permissions;_this.isOwner=false;angular.forEach(_this.permissions,function(o){_this.isOwner=_this.isOwner||(o.name==="Consignor");});}
function convertAccessMessage(message){switch(message){case"Not approved for this lot.":return _this.label.memorabiliaOnly;}
return message;}
function calculateValue(value,exchangeRate){exchangeRate=exchangeRate||_this.defaultExchangeRate;var newAmount=exchangeRate.value*value;return{currency:exchangeRate.currency,value:newAmount}}
this.moveToLot=function(){if(_this.lot){var element=$('li#'+_this.lot.id)[0];if(element!==undefined){$('.lot-listing-container').animate({scrollTop:element.offsetTop},500)}}}
function applyLotListingCssClass(){for(var i=0;i<_this.lotListing.length;i++){var lot=_this.lotListing[i];if(lot.status==="Available"){_this.lotListing[i].cssClass="available";}
if(lot.status==="Sold"){_this.lotListing[i].cssClass="sold";}
if(lot.status==="NotSold"){_this.lotListing[i].cssClass="not-sold";}
if(_this.lot&&lot.id===_this.lot.id){_this.lotListing[i].cssClass="active";}}}
function applyLotListingFormatting(){var currencyCode=_this.auction.currency.code;var currencySymbol=_this.auction.currency.symbol;angular.forEach(_this.lotListing,function(lot,i){if(_this.lot!==null&&lot.id===_this.lot.id){lot.status=_this.lot.status;}
lot.estimateFormatted=currencyService.formatCurrencyRange(lot.lowEstimate,lot.highEstimate,currencySymbol,currencyCode);lot.statusFormatted=lot.status;if(lot.status==="NotSold"){lot.statusFormatted="Still for Sale";}
if(lot.status==="Available"){lot.statusFormatted="";}
if(lot.status==="Active"){lot.statusFormatted="Current Lot";}});}
this.isBiddingDisabled=function(){return _this.disabled||_this.lot.viewOnly||_this.biddingDisabled||_this.auction.status!=='Active'||_this.biddingAccess.access==='Restricted';};function isTouchDevice(){return(('ontouchstart' in window)||(navigator.maxTouchPoints>0)||(navigator.msMaxTouchPoints>0));}
this.sendActive=function(e){if(!isTouchDevice()){client.sendEngagement("Active");}};this.sendNotActive=function(e){client.sendEngagement("Available");};this.changeCurrency=function(exchangeRate){recalculateAskingConversion()};this.cssClassBiddingAccess=function(access){if(access==="Restricted"){return"alert alert-danger";}
if(access==="Limited"){return"alert alert-warning";}
if(access==="Full"){return"alert alert-info";}};this.requestBid=function(){if(!_this.isBiddingDisabled()){_this.bidResult=null;if(_this.lot.isHighBidder==false||confirm(_this.label.confirm.alreadyHighBidder)){client.requestBid({lotId:_this.lot.id,amount:_this.lot.currentAsking});}}};this.init=function(auctionId){_this.auctionId=auctionId||_this.auctionId;connect(auctionId);};this.retryConnection=function(){_this.connectionFailed=false;connect(_this.auctionId);}});;;
'use strict';RMSFrontEnd.controller('closingSoonController',function($http){var _this=this;_this.lots=[];_this.auctionId=null;_this.loaded=false;var items=[];this.init=function(id){_this.auctionId=id;this.loadLotList();}
this.loadLotList=function(){$http.get('/umbraco/Surface/SearchPageSurface/GetClosingSoonJsonTiles?auctionId='+_this.auctionId).then(function(response){if(response.status===200&&response.data){angular.merge(_this.lots,response.data);angular.merge(items,response.data);_this.loaded=true;}});}
this.lotChanged=function(lot){var foundIndex=-1;angular.forEach(items,function(obj,index){if(obj.Id===lot.Id&&lot.Auctioned){foundIndex=index}});if(foundIndex>-1){items.splice(foundIndex,1);var carousel=$('.owl-carousel[owl-lot-listing]').owlCarousel()
carousel.trigger("remove.owl.carousel",foundIndex);}}});;;
'use strict';RMSFrontEnd.controller('LotResultController',function($scope){var _this=this;_this.item={text:"",estimates:[]};this.init=function(lotId){var connection=new signalR.HubConnectionBuilder().withUrl("/signalr/lot").build();connection.start().then(function(){connection.invoke("Register",lotId).catch(function(err){return console.error(err.toString());});})
connection.on("ReceiveLotMessage",function(id,value,valueType,estimates){_this.item={text:"",estimates:[]};if(value){_this.item.text=value;if(valueType){_this.item.text=value+" | "+valueType;}}else{_this.item.text=valueType;}
if(estimates){_this.item.estimates=[];angular.forEach(estimates,function(o){if(value!==o){_this.item.estimates.push({text:o})}});}else{_this.item.estimates=[];}
$scope.$apply();});};});;;
'use strict';RMSFrontEnd.controller('biddingDataController',function($scope,currencyService,timeService,biddingListener,dictionaryService){var _this=this;_this.type="";_this.lot={};_this.label={};_this.reserveStatusLookup={};_this.stats={};_this.offset=0;this.init=function(type,auctionId,lotId){_this.type=type;listen(type,auctionId,lotId);}
function listen(type,auctionId,lotId){timeService.getTimeSpanTemplates().then(function(data){_this.templates=data;if(type==="Sealed"||type==="Timed"){biddingListener.authenticate(auctionId).then(function(service){var client=biddingListener.getClient(service.auctionId,[lotId],type,service.host,service.token);client.onTimeSync(function(){client.sendTime();_this.timeSyncRequestedOn=new Date();});client.onAutoExtendTimeChanged(function(data){if(type==="Sealed"){_this.sealedAutoExtendTime=data;}
if(type==="Timed"){_this.autoExtendTime=data;}
setInterval(updateTimer,1000);});client.onTimeOffset(function(offset){var requestedTimeMs=new Date()-_this.timeSyncRequestedOn;_this.offset=offset-requestedTimeMs;});if(type==='Sealed'){client.onLotChanged(sealedLotChangedCallback)
client.onBidStatsChanged(sealedLotStatsChangedCallback)
dictionaryService.getDictionaryItems(["Lots.Reserve Status","Lots.You High Bidder","Lots.You Won","Lots.You Rank","Lots.You Bid","Lots.Closing","Lots.High Bid","Lots.Bid Sold","Lots.Bid No Sale","Lots.rs0","Lots.rs1","Lots.rs2","Lots.Without reserve",],true).then(function(data){_this.label.rs=data["Lots.Reserve Status"];_this.label.hb=data["Lots.You High Bidder"];_this.label.rank=data["Lots.You Rank"];_this.label.won=data["Lots.You Won"];_this.label.uhb=data["Lots.You Bid"];_this.label.et=data["Lots.Closing"];_this.label.rs0=data["Lots.rs0"];_this.reserveStatusLookup["NoReserve"]=data["Lots.Without reserve"];_this.reserveStatusLookup["ReserveMet"]=data["Lots.rs2"];_this.reserveStatusLookup["UnderReserve"]=data["Lots.rs1"];_this.reserveStatusLookup["NotMet"]=data["Lots.Reserve Not Met"]||"Did not meet reserve";});}
if(type==='Timed'){dictionaryService.getDictionaryItems(["Lots.Reserve Status","Lots.Current Bid","Lots.Asking Bid","Lots.You Won","Lots.You Lost","Lots.You High Bidder","Lots.You Outbid","Lots.Closing","Lots.High Bid","Lots.High Bid Note","Lots.Absentee","Lots.Bid Sold","Lots.Bid No Sale","Lots.rs1","Lots.rs2","Lots.Without reserve","Lots.Final Bid","Lots.Reserve Not Met"],true).then(function(data){_this.label.rs=data["Lots.Reserve Status"];_this.label.cb=data["Lots.Current Bid"];_this.label.a=data["Lots.Asking Bid"];_this.label.hb=data["Lots.You High Bidder"];_this.label.ob=data["Lots.You Outbid"];_this.label.et=data["Lots.Closing"];_this.label.cbh=data["Lots.High Bid"];_this.label.ab=data["Lots.Absentee"];_this.label.bid=data["Bid.Bids"]||"Bids:";_this.label.fb=data["Lots.Final Bid"]||"Final Bid:";_this.label.won=data["Lots.You Won"];_this.label.lost=data["Lots.You Lost"];_this.label.sold=data["Lots.Bid Sold"];_this.label.closed=data["Lots.Bid No Sale"];_this.reserveStatusLookup["NoReserve"]=data["Lots.Without reserve"];_this.reserveStatusLookup["ReserveMet"]=data["Lots.rs2"];_this.reserveStatusLookup["UnderReserve"]=data["Lots.rs1"];_this.reserveStatusLookup["NotMet"]=data["Lots.Reserve Not Met"]||"Did not meet reserve";});client.onLotChanged(timedLotChangedCallback)
client.onBidStatsChanged(timedLotStatsChangedCallback)}
client.onSessionDataReceived(function(){$scope.$apply();})});}});}
function updateTime(lot){lot=lot||_this.lot;const auctioned=(lot.status==="Sold"||lot.status==="NotSold");const currentDate=new Date();const offsetDate=currentDate.setMilliseconds(_this.offset+currentDate.getMilliseconds());const started=(offsetDate-new Date(lot.startTime))>0;const timeLeft=timeService.getTimeSpan(new Date(lot.finishedTime)-offsetDate);const autoExtendTime=(_this.type==="Sealed")?_this.sealedAutoExtendTime:_this.autoExtendTime;lot.started=started;lot.timeLeft=started?timeService.formatTimeLeft(timeLeft,auctioned,autoExtendTime,_this.templates):"";}
function updateTimer(){updateTime();$scope.$apply();}
function sealedLotChangedCallback(lot){_this.lot=lot;const auctioned=(lot.status==="Sold"||lot.status==="NotSold");updateTime(lot);_this.lot.reserveStatusFormatted=_this.reserveStatusLookup[_this.lot.reserveStatus];if(_this.lot.started){_this.lot.auctioned=auctioned;_this.lot.sold=lot.status==="Sold";if(lot.status==='NotSold'){_this.lot.reserveStatusFormatted=_this.reserveStatusLookup["NotMet"];}}}
function timedLotChangedCallback(lot){_this.lot=lot;const auctioned=(lot.status==="Sold"||lot.status==="NotSold");updateTime(lot);_this.lot.reserveStatusFormatted=_this.reserveStatusLookup[_this.lot.reserveStatus];if(_this.lot.started){_this.lot.auctioned=auctioned;_this.lot.sold=lot.status==="Sold";if(lot.status==='NotSold'){_this.lot.reserveStatusFormatted=_this.reserveStatusLookup["NotMet"];}
if(lot.currentBid>0){_this.lot.askingBidFormatted="";_this.lot.currentBidFormatted=currencyService.formatCurrency(lot.currentBid,lot.currency.symbol,lot.currency.code,0);}else{_this.lot.askingBidFormatted=currencyService.formatCurrency(lot.currentAsking,lot.currency.symbol,lot.currency.code,0);_this.lot.currentBidFormatted="";}}}
function timedLotStatsChangedCallback(stats){_this.stats=stats;_this.lot.isOutBid=stats.userBidCount>0&&!stats.isHighBidder;_this.lot.isHighBidder=stats.isHighBidder;_this.lot.userMaxBid=stats.userMaxBid;_this.lot.userBidCount=stats.userBidCount;if(_this.lot.userMaxBid){_this.lot.userMaxBidFormatted=currencyService.formatCurrency(_this.lot.userMaxBid,_this.lot.currency.symbol);}}
function sealedLotStatsChangedCallback(stats){_this.stats=stats;_this.lot.isHighBidder=stats.isHighBidder;_this.lot.userHighBid=stats.userHighBid;_this.lot.userAskingBid=stats.userAskingBid;_this.lot.userHighBidFormatted=currencyService.formatCurrency(_this.lot.userHighBid,_this.lot.currency.symbol,_this.lot.currency.code);_this.lot.rank=stats.ranking.rank;_this.lot.place=stats.ranking.rank+"th place";if(stats.ranking.rank.endsWith("1"))_this.lot.place=stats.ranking.rank+"st place";if(stats.ranking.rank.endsWith("2"))_this.lot.place=stats.ranking.rank+"nd place";if(stats.ranking.rank.endsWith("3"))_this.lot.place=stats.ranking.rank+"rd place";}
this.$onInit=function(){}
this.showClosingLabel=function(){return _this.templates?_this.lot.timeLeft!==_this.templates.finishing&&_this.lot.timeLeft!==_this.templates.finished:true;}});;;
RMSFrontEnd.component("teamDirectory",{templateUrl:"/scripts/rms-scripts/components/team-directory/teamDirectory.template.html",controller:function(dictionaryService,$filter,$http){var ctrl=this;ctrl.label={};ctrl.team=[];ctrl.all=[]
ctrl.availableDepartments=ctrl.department||[];ctrl.availableRegions=ctrl.region||[];ctrl.availableLanguages=ctrl.language||[];ctrl.languageOptions=[];ctrl.regionOptions=[];ctrl.departmentOptions=[];ctrl.filter={Languages:undefined,Regions:undefined,Departments:undefined}
var names=["Global.Languages","Team.All Languages","Team.All Regions","Team.All Employees"];dictionaryService.getDictionaryItems(names).then(function(data){ctrl.label.languages=data["Global.Languages"];ctrl.label.allLanguages=data["Team.All Languages"]||"All Languages";ctrl.label.allRegions=data["Team.All Regions"]||"All Regions";ctrl.label.allDepartments=data["Team.All Employees"]||"All Employees";ctrl.selectedDepartment=ctrl.label.allDepartments;ctrl.selectedLanguage=ctrl.label.allLanguages;ctrl.selectedRegion=ctrl.label.allRegions;ctrl.languageOptions.push({name:ctrl.label.allLanguages,count:999})
ctrl.regionOptions.push({name:ctrl.label.allRegions,count:999});ctrl.departmentOptions.push({name:ctrl.label.allDepartments,count:999});$http.get("/api/team/getallteam").then(function(response){if(response.data){ctrl.all=[];response.data.forEach(function(item){var filter1=filter(item,'departments','availableDepartments');var filter2=filter(item,'languages','availableLanguages');var filter3=filter(item,'regions','availableRegions');if(filter1&&filter2&&filter3){ctrl.all.push(item);}})
createOptions(ctrl.all,'departments','departmentOptions')
createOptions(ctrl.all,'languages','languageOptions')
createOptions(ctrl.all,'regions','regionOptions')
ctrl.team=angular.copy(ctrl.all);}});});function filter(item,propertyName,filterName){var keep=false;if(ctrl[filterName].length>0){ctrl[filterName].forEach(function(d){if(item[propertyName].indexOf(d)>-1){keep=true;}});}else{keep=true;}
return keep;}
function createOptions(items,propertyName,optionName){var values=[];items.forEach(function(item){item[propertyName].forEach(function(d){var indexOf=values.indexOf(d);if(indexOf>-1){var option=ctrl[optionName][indexOf];ctrl[optionName][indexOf].count=option.count+1;}else{ctrl[optionName].push({name:d,count:1})
values.push(d);}})});}
function disableOption(propertyName,labelPropertyName,value){if(value.name===ctrl.label[labelPropertyName]){return false;}
var disable=true;var excludeMeFilter=angular.copy(ctrl.filter);excludeMeFilter[propertyName]=undefined;$filter('filter')(ctrl.all,excludeMeFilter).forEach(function(member){if(member[propertyName].indexOf(value.name)>-1){disable=false;}})
return disable;}
function filterBy(propertyName,labelPropertyName,value){if(value===ctrl.label[labelPropertyName]){ctrl.filter[propertyName]=undefined;}else{ctrl.filter[propertyName]=value;}
ctrl.team=$filter('filter')(ctrl.all,ctrl.filter)}
function calculateColumnOffset(){var missing=0;if(!ctrl.allowDepartmentFilter()){missing++;}
if(!ctrl.allowRegionFilter()){missing++;}
if(!ctrl.allowLanguageFilter()){missing++;}
return missing*2}
ctrl.cssColumnOffsetDepartment=function(){if(ctrl.allowDepartmentFilter()){return"col-md-offset-"+calculateColumnOffset();}
return"";}
ctrl.cssColumnOffsetLanguage=function(){if(ctrl.allowLanguageFilter()&&!ctrl.allowDepartmentFilter()){return"col-md-offset-"+calculateColumnOffset();}
return"";}
ctrl.cssColumnOffsetRegion=function(){if(ctrl.allowRegionFilter()&&!ctrl.allowLanguageFilter()&&!ctrl.allowDepartmentFilter()){return"col-md-offset-"+calculateColumnOffset();}
return"";}
ctrl.allowFiltering=function(){return ctrl.allowDepartmentFilter()||ctrl.allowRegionFilter()||ctrl.allowLanguageFilter();}
ctrl.allowLanguageFilter=function(){return ctrl.languageOptions.length>1&&ctrl.availableLanguages.length===0;}
ctrl.allowDepartmentFilter=function(){return ctrl.departmentOptions.length>1&&ctrl.availableDepartments.length===0;}
ctrl.allowRegionFilter=function(){return ctrl.regionOptions.length>1&&ctrl.availableRegions.length===0;}
ctrl.disableLanguage=function(language){return disableOption('languages','allLanguages',language);}
ctrl.disableDepartment=function(department){return disableOption('departments','allDepartments',department);}
ctrl.disableRegion=function(region){return disableOption('regions','allRegions',region);}
ctrl.filterByLanguage=function(value){filterBy('languages','allLanguages',value);}
ctrl.filterByDepartment=function(value){filterBy('departments','allDepartments',value);}
ctrl.filterByRegion=function(value){filterBy('regions','allRegions',value);}},bindings:{department:'<',language:'<',region:'<'}});;;
'use strict';RMSFrontEnd.factory("sealedBidding",function($http,biddingConnection){const SealedClient=function(biddingConnection){let client=biddingConnection.getClient();client.transformSend(transformSend)
client.transformReceived(transformReceived)
client.onReceive(onReceive)
const commandKeys={authorization:"authorization=>",auctionState:"auction-state=>",lotPhotos:"lot-photos=>",lotChange:"lot-change=>",userPermissions:"user-permissions=>",bidResult:"bid-result=>",bidder:"bidder=>",bidderEngagement:"bidder-engagement=>",biddingAccess:"bidding-access=>",timeOffset:"timing-offset=>",roundBid:"round-bid=>",bid:"bid=>",logBid:"log-bid=>",timeSync:"time-sync=>",extendTime:"extend-time=>",bidStats:"bid-stats=>",bidRanks:"bid-ranks=>",bidStatsChanged:"bid-stats-changed=>"};const noop=function(){};let onPermissions=noop;let onAuctionChanged=noop;let onLotChanged=noop;let onLotPhotosChanged=noop;let onBidRounded=noop;let onBiddingAccessChanged=noop;let onBidResult=noop;let onBidderConnected=noop;let onBidStatsChanged=noop;let onBidRanksChanged=noop;let onTimeOffset=noop;let onTimeSync=noop;let onAutoExtendTimeChanged=noop;function transformCurrency(obj){return{code:obj.c,symbol:obj.s}}
function transformAccess(obj){return{access:obj.a,accessList:transformAccessList(obj.l)}}
function transformAccessList(list){const list2=[];for(let index=0;index<list.length;++index){const obj=list[index];list2.push({name:obj.n,access:obj.a,message:obj.m})}
return list2;}
function transformPermissions(list){const list2=[];for(let index=0;index<list.length;++index){const obj=list[index];list2.push({name:obj.n,description:obj.d})}
return list2;}
function transformAuction(obj){return{id:obj.id,name:obj.n,status:transformAuctionStatus(obj.s),currency:transformCurrency(obj.c),running:obj.r,startTime:obj.st,endTime:obj.et,metaData:obj.md}}
function transformLot(obj){return{id:obj.id,name:obj.n,url:obj.u,status:transformLotStatus(obj.s),lotNumber:obj.l,lowEstimate:obj.le,highEstimate:obj.he,viewOnly:obj.v,hasAddendum:obj.ad,currency:transformCurrency(obj.c),startTime:obj.st,finishedTime:obj.ft,reserveStatus:transformReserveStatus(obj.r),startingBid:obj.sb,currentBid:obj.cb}}
function transformBidder(obj){if(obj===null)
return null;return{id:obj.id,name:obj.n,bidderNumber:obj.bn}}
function transformAuctionStatus(obj){switch(obj){case"a":return"Available";case"ac":return"Active";case"c":return"Closed";}
return obj;}
function transformLotStatus(obj){switch(obj){case"a":return"Available";case"ac":return"Active";case"s":return"Sold";case"ns":return"NotSold";case"w":return"Withdrawn";}
return obj;}
function transformBidStatus(obj){switch(obj){case"a":return"Accepted";case"na":return"NotAccepted";case"e":return"Error";case"p":return"Pending";}
return obj;}
function transformBidType(obj){switch(obj){case"f":return"Force"
case"m":return"Max"
case"um":return"UnderMax"}
return obj;}
function transformReserveStatus(obj){switch(obj){case"n":return"NoReserve";case"u":return"UnderReserve";case"m":return"ReserveMet";}
return obj;}
function transformLotBidRanking(obj){return{lotId:obj.id,rankings:transformRankings(obj.rs),}}
function transformRankings(list){const list2=[];for(let index=0;index<list.length;++index){list2.push(transformBidRanking(list[index]))}
return list2;}
function transformBidRanking(obj){return{rank:obj.r,reference:obj.re,name:obj.n,id:obj.n,time:obj.t,trend:obj.tr,amount:obj.a}}
function transformBidResult(obj){return{id:obj.id,amount:obj.a,lotId:obj.lid,userId:obj.uid,type:transformBidType(obj.t),status:transformBidStatus(obj.s),reason:obj.r}}
function transformBidStats(obj){return{lotId:obj.id,isHighBidder:obj.hb,userHighBid:obj.uhb,userAskingBid:obj.uab,ranking:transformBidRanking(obj.br)}}
function transformReceived(key,obj){let newObj=obj;switch(key+"=>"){case commandKeys.bidder:newObj=transformBidder(obj);break;case commandKeys.biddingAccess:newObj=transformAccess(obj);break;case commandKeys.userPermissions:newObj=transformPermissions(obj);break;case commandKeys.auctionState:newObj=transformAuction(obj);break;case commandKeys.lotChange:newObj=transformLot(obj);break;case commandKeys.bidStats:newObj=transformBidStats(obj);break;case commandKeys.bidRanks:newObj=transformLotBidRanking(obj);break;case commandKeys.bidResult:newObj=transformBidResult(obj);break;}
return newObj;}
function transformSend(key,obj){let newObj=obj;switch(key+"=>"){case commandKeys.bid:newObj={a:obj.amount,id:obj.lotId}
break;case commandKeys.bidderEngagement:switch(obj){case"Active":newObj="ac";break;case"Available":newObj="a";break;case"Idle":newObj="i";break;}
break;}
return newObj;}
function onReceive(key,value){switch(key+"=>"){case commandKeys.auctionState:onAuctionChanged(value);break;case commandKeys.lotChange:onLotChanged(value);break;case commandKeys.bidResult:onBidResult(value);break;case commandKeys.lotPhotos:onLotPhotosChanged(value);break;case commandKeys.roundBid:onBidRounded(value);break;case commandKeys.bidder:onBidderConnected(value);break;case commandKeys.biddingAccess:onBiddingAccessChanged(value);break;case commandKeys.userPermissions:onPermissions(value);break;case commandKeys.timeOffset:onTimeOffset(value);break;case commandKeys.timeSync:onTimeSync(value);break;case commandKeys.extendTime:onAutoExtendTimeChanged(value);break;case commandKeys.bidStats:onBidStatsChanged(value);break;case commandKeys.bidRanks:onBidRanksChanged(value);break;}}
return{connect:client.connect,disconnect:client.disconnect,onSessionOpen:client.onSessionOpen,onSessionAccepted:client.onSessionAccepted,onSessionClose:client.onSessionClose,onSessionError:client.onSessionError,onSessionDataReceived:client.onSessionDataReceived,onSendError:client.onSendError,onRequestConnection:client.onRequestConnection,onConnectionRetrying:client.onConnectionRetrying,onConnectionDeclined:client.onConnectionDeclined,onConnectionFailed:client.onConnectionFailed,onAuctionChanged:function(callback){onAuctionChanged=callback||noop;},onLotChanged:function(callback){onLotChanged=callback||noop;},onLotPhotosChanged:function(callback){onLotPhotosChanged=callback||noop;},onBidRounded:function(callback){onBidRounded=callback||noop;},onBidResult:function(callback){onBidResult=callback||noop;},onBidderConnected:function(callback){onBidderConnected=callback||noop;},onBiddingAccessChanged:function(callback){onBiddingAccessChanged=callback||noop;},onPermissions:function(callback){onPermissions=callback||noop;},onTimeOffset:function(callback){onTimeOffset=callback||noop;},onTimeSync:function(callback){onTimeSync=callback||noop;},onAutoExtendTimeChanged:function(callback){onAutoExtendTimeChanged=callback},onBidStatsChanged:function(callback){onBidStatsChanged=callback||noop;},onBidRanksChanged:function(callback){onBidRanksChanged=callback||noop;},requestBidRound:function(amount){client.send(commandKeys.roundBid,amount);},sendBid:function(amount,lotId){client.send(commandKeys.bid,{amount:amount,lotId:lotId});},sendFailedBid:function(amount,lotId){client.send(commandKeys.logBid,{amount:amount,lotId:lotId});},sendTime:function(){client.send(commandKeys.timeOffset,new Date().toISOString());},sendEngagement:function(status){client.send(commandKeys.bidderEngagement,status);}};};return{authenticate:function(auctionId,lotId){return $http.post('/api/bidding/authenticate?auctionId='+auctionId+"&lotId="+lotId).then(function(response){if(response.status===200&&response.data){return response.data;}});},getClient:function(auctionId,lotId){let _this=this;let sealedClient=new SealedClient(biddingConnection);sealedClient.onRequestConnection(function(connector){_this.authenticate(auctionId,lotId).then(function(data){connector.connection(data.host+"/ws/sealed/bid/"+data.auctionId+"/"+data.lotId,data.token);},function(e){if(e.status===-1){connector.failConnection()}else{connector.declineConnection()}});});return sealedClient;}}});RMSFrontEnd.controller('sealedBiddingController',function($scope,sealedBidding,timeService,currencyService,dictionaryService,retryService){var _this=this;_this.item={};_this.item.started=false;_this.remoteItem={};_this.templates=timeService.getTimeSpanTemplates();_this.offset=0;_this.label={};_this.label.rank="Rank:"
_this.label.uhb="Your Bid:";_this.label.unb="Next Bid:";_this.label.et="";_this.label.pb="...";_this.label.pmb="...";_this.label.headline="";_this.label.note="";_this.label.noteTemplate="";_this.label.owner="Your Consignment";_this.label.error={tooSmall:"Must be greater than your current bid of {amount}.",tooSmallMinimum:"Must be at least {amount}.",connection:"No connection available. Please try again."};_this.message={};_this.input={};_this.availableBids=[];_this.input.amount="";_this.confirmTimeLeft=0;_this.requestingBid=false;_this.autoExtendTime=120;_this.lot={};_this.connectionFailed=false;_this.connectionStarted=false;_this.ranking=[];_this.reserveStatusLookup={};_this.timeRankTemplates=[{seconds:120,template:"Just now"},{minutes:60,template:"{minutes=| $value minute| $value minutes} ago"},{hours:12,template:"{hours=| $value hour| $value hours} ago "},{unlimited:true,template:"+12 hours ago"},];this.onStart=this.onStart||function(){};this.onLotChanged=this.onLotChanged||function(lot){};var cssWidgetClass="info-widget bid-widget";var cssContentClass="info__content";var cssHeaderClass="info__header";var client;function connect(){console.log("starting....");setupClient(_this.auctionId,_this.id).connect();}
function declinedConnection(){_this.connectionStarted=true;_this.connectionMessage="Not Authorized."}
function failedConnection(){_this.connectionStarted=true;_this.connectionFailed=true;_this.connectionMessage="Failed."}
function retryingConnection(){_this.connectionStarted=true;const tryingMessage=" Trying to connect...";if(!_this.connectionMessage.endsWith(tryingMessage))
_this.connectionMessage=_this.connectionMessage+tryingMessage;}
function acceptedSession(){_this.connectionStarted=true;_this.connected=true;_this.connectionMessage="";_this.connectionFailed=false;$scope.$apply();}
function closedSession(reason){_this.connectionStarted=true;_this.connected=false;_this.connectionMessage=reason||"Without a reason specified";$scope.$apply();}
function receivedDataSession(){_this.connectionStarted=true;_this.connected=true;$scope.$apply();}
this.retryConnection=function(){_this.connectionFailed=false;connect();}
function setupClient(auctionId,lotId){if(!client){client=sealedBidding.getClient(auctionId,lotId);client.onConnectionRetrying(retryingConnection);client.onConnectionDeclined(declinedConnection);client.onConnectionFailed(failedConnection);client.onSessionAccepted(acceptedSession);client.onSessionClose(closedSession);client.onSessionError(closedSession);client.onSessionDataReceived(receivedDataSession);client.onSendError(failedConnection);client.onAuctionChanged(onAuctionChanged);client.onLotChanged(onLotChanged);client.onLotPhotosChanged(ontLotPhotosChanged);client.onBidResult(onBidResult);client.onBidderConnected(onBidderConnected);client.onTimeOffset(onTimeOffset);client.onTimeSync(onTimeSync);client.onAutoExtendTimeChanged(onAutoExtendTimeChanged);client.onBiddingAccessChanged(onBiddingAccessChanged);client.onBidRounded(onBidRounded);client.onBidStatsChanged(onBidStatsChanged);client.onBidRanksChanged(onBidRanksChanged);client.onPermissions(onPermissions);}
return client;}
function onAutoExtendTimeChanged(seconds){_this.autoExtendTime=seconds;}
function onBidRounded(amount){var lot=_this.lot;var amountFormatted=currencyService.formatCurrency(amount,lot.currency.symbol);_this.confirmTimeLeft=5;_this.bidAmount=amount;_this.bidAmountFormatted=amountFormatted;}
function onAuctionChanged(auction){_this.auction=auction;}
function onLotChanged(lot){if(_this.lot.status===undefined&&lot.status!=="Active"){window.location.href=window.location.href.replace("/bidding",'');}
setMessage(lot.status);updateLot(_this.lot,lot);appendFormattedText(_this.lot);if(_this.lot.status!=="Active"&&_this.lot.status!=="Available"){_this.disabled=true;}else{if(_this.bidder)
_this.disabled=false;}
updateButtonLabel();updateNoteLabel();_this.onLotChanged({value:lot});}
function onBidStatsChanged(stats){updateBid(_this.lot,stats);updateButtonLabel();updateNoteLabel();}
function onBidRanksChanged(stats){if(stats.rankings.length>0){var latest=stats.rankings.reduce(function(p,c){if(p===null)return c;var date1=new Date(c.time);var date2=new Date(p.time);if(date1>date2){return c;}else{return p;}});_this.rankingChangedAt=new Date(latest.time);}else{_this.ranking=[];return;}
stats.rankings.forEach((x,i)=>{x.ranked=i;if(x.name.indexOf("i")===0){x.name=x.name.substring(1);}
if(x.amount){x.amountFormatted=currencyService.formatCurrency(x.amount,_this.lot.currency.symbol);}});var drop=[];angular.forEach(_this.ranking,function(o){var rank=stats.rankings.find(x=>x.id===o.id)
if(rank){o.rank=rank.rank;o.ranked=rank.ranked;o.trend=rank.trend;o.reference=rank.reference
o.time=rank.time;o.userBias=_this.lot.myBid===o.reference?0:1;o.amount=rank.amount;o.amountFormatted=rank.amountFormatted;}else{drop.push(o)}});angular.forEach(stats.rankings,function(o){var rank=_this.ranking.find(x=>x.id===o.id)
if(rank===undefined){o.userBias=_this.lot.myBid===o.reference?0:1;_this.ranking.push(o);}});angular.forEach(drop,function(o){var index=_this.ranking.indexOf(o)
if(index!==-1){_this.ranking.splice(index,1)}});}
function updateBid(lot,stats){if(lot.id===stats.lotId){lot.isHighBidder=stats.isHighBidder;lot.userHighBid=stats.userHighBid;lot.userAskingBid=stats.userAskingBid;lot.rank=stats.ranking.rank;lot.myBid=stats.ranking.reference;lot.userNextBid=Math.max(stats.userAskingBid,lot.startingBid)
_this.isHighBidder=lot.isHighBidder;const rank=_this.ranking.find(o=>o.reference===lot.myBid);if(rank!==undefined){rank.userBias=0;}
lot.place=lot.rank+"th place";if(lot.rank.endsWith("1"))lot.place=lot.rank+"st place";if(lot.rank.endsWith("2"))lot.place=lot.rank+"nd place";if(lot.rank.endsWith("3"))lot.place=lot.rank+"rd place";if(lot.rank==="11")lot.place=lot.rank+"th place";if(lot.rank==="12")lot.place=lot.rank+"th place";if(lot.rank==="13")lot.place=lot.rank+"th place";appendFormattedText(lot);}}
function updateLot(lot,newLot,initial){initial=initial||false;lot.id=newLot.id;lot.name=newLot.name;lot.startTime=newLot.startTime;lot.finishedTime=newLot.finishedTime;lot.status=newLot.status;lot.currency=newLot.currency;lot.lowEstimate=newLot.lowEstimate;lot.highEstimate=newLot.highEstimate;lot.reserveStatus=newLot.reserveStatus;lot.startingBid=newLot.startingBid;lot.currentBid=newLot.currentBid;lot.auctioned=lot.status==='Sold'||lot.status==='NotSold'
appendFormattedText(lot)}
function appendFormattedText(lot){var currencySymbol=lot.currency.symbol;var currencyCode=lot.currency.code;_this.label.currencySymbol=currencySymbol;_this.label.currencyCode=lot.currency.code;lot.statusFormatted=lot.status.replace("NotSold","Not Sold");lot.reserveStatusFormatted=_this.reserveStatusLookup[lot.reserveStatus];if(lot.status==='NotSold'){lot.reserveStatusFormatted=_this.reserveStatusLookup["NotMet"];}
lot.estimateFormatted=currencyService.formatCurrencyRange(lot.lowEstimate,lot.highEstimate,currencySymbol,currencyCode)||currencyService.formatCurrency(0,currencySymbol,currencyCode);lot.startingBidFormatted=currencyService.formatCurrency(lot.startingBid,currencySymbol,currencyCode);if(lot.userHighBid!=null){lot.userHighBidFormatted=currencyService.formatCurrency(lot.userHighBid,currencySymbol,currencyCode);}
if(lot.userAskingBid!=null){lot.userAskingBidFormatted=currencyService.formatCurrency(lot.userAskingBid,currencySymbol,currencyCode);}
if(lot.userNextBid!=null){lot.userNextBidFormatted=currencyService.formatCurrency(lot.userNextBid,currencySymbol,currencyCode);}
if(lot.currentBid!=null){lot.currentBidFormatted=currencyService.formatCurrency(lot.currentBid,currencySymbol,currencyCode);}}
function onBidResult(bid){var message=bid.reason;if(bid.status==="NotAccepted"){switch(bid.reason){case"User is over limit.":message=_this.label.overLimit||bid.reason;break;case"User is over cumulative limit.":message=_this.label.overCumulativeLimit||bid.reason;break;}}
if(bid.status==="Accepted"){message="";}
_this.bidMessage=message;_this.bidResult=bid;_this.requestingBid=false;_this.input.amount="";}
function ontLotPhotosChanged(photos){_this.photos=photos;}
function onTimeSync(){client.sendTime();_this.timeSyncRequestedOn=new Date();}
function onTimeOffset(offset){var requestedTimeMs=new Date()-_this.timeSyncRequestedOn;_this.offset=offset-requestedTimeMs;if(_this.lot){var timing=timeService.getTimingStats(new Date(_this.lot.startTime),new Date(_this.lot.finishedTime),_this.offset);if(_this.started!==timing.started){_this.started=timing.started;if(_this.started)
_this.onStart();}}}
function onBidderConnected(bidder){_this.bidder=bidder;}
function onBiddingAccessChanged(accessSummary){_this.biddingAccess=accessSummary;_this.biddingAccess.message="";angular.forEach(_this.biddingAccess.accessList,function(o){if(o.message.length>0){_this.biddingAccess.message=(_this.biddingAccess.message+" "+o.message).trim();}});_this.canBid=accessSummary.access!=="Restricted";}
function onPermissions(permissions){_this.permissions=permissions;_this.isOwner=false;angular.forEach(_this.permissions,function(o){_this.isOwner=_this.isOwner||(o.name==="Consignor");});}
function updateButtonLabel(){if(_this.canBid===false){_this.label.pb=_this.label.pbna;}else{if(_this.lot.userHighBid>0){_this.label.pb=_this.label.rbs;}else{_this.label.pb=_this.label.pbs;}}}
function setMessage(status){switch(status){case'Active':case'Available':_this.label.headline=_this.message.available;break;case'Sold':_this.label.headline=_this.message.sold;break;case'NotSold':_this.label.headline=_this.message.noSale;break;}}
function updateNoteLabel(){_this.label.note=_this.label.noteTemplate.replace("{amount}",_this.lot.startingBidFormatted)}
function bid(amount){_this.confirmTimeLeft=0;_this.requestingBid=true;client.sendBid(amount,_this.lot.id);}
this.copyInput=function(){if(_this.input.amount===""&&_this.lot.userNextBidFormatted!==undefined){_this.input.amount=angular.copy(_this.lot.userNextBidFormatted).replace(/[^0-9,]/g,"");}}
this.amountChange=function(){_this.bidMessage="";_this.confirmTimeLeft=0;};this.confirmBid=function(){_this.bidMessage="";var requestedAmount=currencyService.convertToFloat(_this.input.amount);if(requestedAmount<_this.lot.startingBid){_this.bidMessage=_this.label.error.tooSmallMinimum.replace("{amount}",_this.lot.startingBidFormatted);return;}
if(requestedAmount<(_this.lot.userAskingBid||0)){_this.bidMessage=_this.label.error.tooSmallMinimum.replace("{amount}",_this.lot.userAskingBidFormatted);return;}
if(requestedAmount<=(_this.lot.userHighBid||0)){_this.bidMessage=_this.label.error.tooSmall.replace("{amount}",_this.lot.userHighBidFormatted);return;}
if(_this.confirmTimeLeft>0){bid(currencyService.convertToFloat(_this.bidAmount));return;}
client.requestBidRound(requestedAmount);}
this.cssClass=function(){return cssWidgetClass;};this.rankCssClass=function(r){return{'trending-up':r.trend>0,'trending-down':r.trend<0,'myBid':r.reference===_this.lot.myBid&&r.rank!=='1','myBidWinning':r.reference===_this.lot.myBid&&r.rank==='1'}}
this.cssContentClass=function(){return cssContentClass;};this.cssHeaderClass=function(){return cssHeaderClass;};function init(id){connect();if(_this.modal){var containerModal=$("#sealed-bid-"+id);containerModal.modal("show");containerModal.on("show.bs.modal",function(){if(!(_this.requestingBid||_this.confirmTimeLeft>0)){updateButtonLabel();}});containerModal.on("hidden.bs.modal",function(){if(!(_this.requestingBid||_this.confirmTimeLeft>0)){updateButtonLabel();}});}else{}
timeService.getOffset().then(function(data){_this.offset=data;});timeService.getTimeSpanTemplates().then(function(data){_this.templates=data;});dictionaryService.getDictionaryItems(["Lots.You Won","Lots.Reserve Status","Lots.You High Bidder","Lots.You Rank","Lots.You Bid","Lots.Next Bid","Lots.Closing","Lots.High Bid","Lots.High Bid Note","Lots.Raise Bid","Lots.Place Bid","Lots.Bid Error Amount Small User Bid","Lots.You Owner","Lots.Bid Error No Connection","Bid.Bidding Tier Not Allowed","Lots.Bid On This Item","Lots.Bid Sold","Lots.Bid No Sale","Bid.Over limit","Bid.Over cumulative limit","Lots.rs0","Lots.rs1","Lots.rs2","Lots.Without reserve","Lots.Reserve Not Met"],true).then(function(data){_this.label.won=data["Lots.You Won"];_this.label.rs=data["Lots.Reserve Status"];_this.label.hb=data["Lots.You High Bidder"];_this.label.rank=data["Lots.You Rank"]||_this.label.rank;_this.label.uhb=data["Lots.You Bid"]||_this.label.uhb;_this.label.et=data["Lots.Closing"];_this.label.pbs=data["Lots.Place Bid"];_this.label.rbs=data["Lots.Raise Bid"];_this.label.pbna=data["Bid.Bidding Tier Not Allowed"];_this.label.error.tooSmall=data["Lots.Bid Error Amount Small User Bid"]||_this.label.error.tooSmall;_this.label.owner=data["Lots.You Owner"]||_this.label.owner;_this.label.error.connection=data["Lots.Bid Error No Connection"]||_this.label.error.connection;_this.label.overLimit=data["Bid.Over limit"];_this.label.overCumulativeLimit=data["Bid.Over cumulative limit"];_this.label.noteTemplate=data["Lots.Minimum Bid Note"]||"Please note, this lot has a minimum bid of {amount}";_this.label.rs0=data["Lots.rs0"];_this.label.unb=data["Lots.Next Bid"]||_this.label.unb;_this.message={available:data["Lots.Bid On This Item"],sold:data["Lots.Bid Sold"],noSale:data["Lots.Bid No Sale"]};_this.reserveStatusLookup["NoReserve"]=data["Lots.Without reserve"];_this.reserveStatusLookup["ReserveMet"]=data["Lots.rs2"];_this.reserveStatusLookup["UnderReserve"]=data["Lots.rs1"];_this.reserveStatusLookup["NotMet"]=data["Lots.Reserve Not Met"]||"Did not meet reserve";;setMessage(_this.lot.status);updateButtonLabel();updateNoteLabel()});}
function timeLoop(apply){if(_this.lot){if(_this.confirmTimeLeft>0){_this.confirmTimeLeft--;}
var timing=timeService.getTimingStats(new Date(_this.lot.startTime),new Date(_this.lot.finishedTime),_this.offset);var auctioned=_this.lot.status==="Sold"||_this.lot.status==="NotSold";if(_this.started!==timing.started){_this.started=timing.started;if(_this.started)
_this.onStart();}
var countDownPercent=1;var secondsLeft=_this.autoExtendTime;if(timing.millisRemaining<(1000*secondsLeft)){countDownPercent=((timing.millisRemaining/1000)/secondsLeft);if(countDownPercent<0){countDownPercent=0;}}
_this.lot.timeRemainingPercent=countDownPercent;_this.lot.timeRemainingCssStyle={backgroundColor:_this.lot.isHighBidder?"limegreen":"red",height:"10px",width:_this.lot.timeRemainingPercent*100+"%",margin:"0 auto"};_this.lot.timeLeft=auctioned?_this.templates.finished:timing.formattedTimeRemaining;_this.lot.secondsLeft=timing.millisRemaining*1000;_this.lot.started=timing.started;if(_this.lot.started){_this.time=_this.label.et+" "+timeService.formatTimeLeft(timing.timeSpan,auctioned,_this.autoExtendTime,_this.templates);}
let currentDate=new Date();timeService.adjustDateOffset(currentDate,_this.offset);for(const rank of _this.ranking){const timeMs=new Date(rank.time)-currentDate;let timeSpan=timeService.getTimeSpan(timeMs* -1);rank.timeFormatted=timeSpan.format(_this.timeRankTemplates);if(_this.rankingChangedAt!=null){let lastBidAt=new Date(_this.rankingChangedAt).setSeconds(30+_this.rankingChangedAt.getSeconds());if(lastBidAt<currentDate){rank.trend=0;}}}
if(apply!==false){$scope.$apply();}}}
this.initialize=function(auctionId,lotId){_this.id=lotId;_this.auctionId=auctionId;init();setInterval(timeLoop,1000);timeLoop(false);}
this.showClosingLabel=function(){return _this.templates?_this.lot.timeLeft!==_this.templates.finishing&&_this.lot.timeLeft!==_this.templates.finished:true;}});;;
RMSFrontEnd.component("sealedBidding",{templateUrl:"/scripts/rms-scripts/components/bidding/sealed/sealedBidding.template.html",controller:"sealedBiddingController",bindings:{id:'@',auctionId:'@',modal:'<',onStart:'&',onLotChanged:'&',isHighBidder:'=',time:'=',}});RMSFrontEnd.component("sealedBidding2",{templateUrl:"/scripts/rms-scripts/components/bidding/sealed/sealedBidding.template2.html",controller:"sealedBiddingController",bindings:{id:'@',auctionId:'@',}});;;
'use strict';RMSFrontEnd.factory("sealedBiddingVisual",function(timeService){let rankedBids=[];let _this=this;let finished=false;let startTime=new Date();let endTime=new Date();let offsetMs=0;let countDownSeconds=90;const rootSelector=".racetrack";const vehicleSelector=".car";function RankedBid(name,position,reference,active=false){this.name=name;this.position=position;this.reference=reference;this.active=active;this.isEqual=function(rankedBid){return rankedBid.name===this.name&&rankedBid.position===this.position&&rankedBid.reference===this.reference;}
this.sameIdentity=function(rankedBid){return rankedBid.name===this.name}}
function canRun(){return $('.car').length>0;}
function findRankDomElement(rank,fun){let element=$(rootSelector).find('#'+rank.name);if(element.length>0){element.attr("place",rank.position);return element;}
let elements=$(vehicleSelector);for(let e of elements){if($(e).attr("id")===undefined||$(e).attr("id").length===0||$(e).attr("id")==='_'){return assignRankDomElement(e,rank,fun);}}
if(element.length===0)
throw new Error("Could not find any appropriate lanes")
return element;}
function ValueAccumulator({valueGenerator,startAt}){startAt=startAt||function(){return 0;}
let initialBaseValue=0;let currentBaseValue=0;let currentValue=0;this.reset=function(){initialBaseValue=0;currentBaseValue=0;currentValue=0;}
this.value=function(processing,step,repeated){if(step===0){if(repeated>0){initialBaseValue=currentValue;}else{initialBaseValue=startAt();currentValue=0;}
currentBaseValue=valueGenerator(processing,step,repeated)-initialBaseValue;}
currentValue=initialBaseValue+(currentBaseValue*processing)
return currentValue;}}
function Animator({duration,draw,timing,repeat=-1},obj){let running=false;let elapsed=0;let step=0;let repeated=0;let listeners=[];this.isRunning=function(){return running;}
this.stop=function(){running=false;}
this.addListener=function(onComplete){listeners.push(onComplete);}
this.start=function(){if(running)
return;let start=performance.now();running=true;step=0;repeated=0;requestAnimationFrame(function animate(time){if(!running){return;}
elapsed=time-start;let timeFraction=elapsed/duration;if(timeFraction>1)timeFraction=1;let progress=timing(timeFraction)
if(draw(progress,step,repeated,obj)===false){running=false;return;}
step++;if(timeFraction<1){requestAnimationFrame(animate);}else{if(repeat>-1&&(repeated<repeat||repeat===0)){repeated++;step=0;start=performance.now();requestAnimationFrame(animate);return;}
running=false;for(let listener of listeners){listener(this);}
listeners=[];}});}}
function assignRankDomElement(element,rank,finished){finished=finished||$.noop
$(element)[0].id=rank.name;$(element).show()
$(element).attr("place",rank.position)
$(element).removeClass('me');if(rank.active){$(element).addClass('me');}
let image='/css/svg/car.svg'
let carcolor="#"+rank.name.split('-')[0].substring(0,6)
let accentcolor='white'
$(element).empty();$(element).load(image,null,function(){finished();$(element).find('.carcolor').css('fill',carcolor);$(element).find('.accentcolor').css('fill',accentcolor);})
return $(element);}
function assignRanks(ranking){let firstTime=rankedBids.length===0;for(const rank of ranking){attachAnimations(rank);}
if(finished){rankedBids=ranking;finish();return;}
let dropped=[];let added=[];let up=[];let down=[];let changed=[];for(const rankedBid of rankedBids){let found=false;for(const newRank of ranking){found=newRank.sameIdentity(rankedBid)||found;}
if(!found){dropped.push(rankedBid);}}
for(const newRank of ranking){let anyIdentity=false;for(let rankedBid of rankedBids){let matchIdentity=rankedBid.sameIdentity(newRank);anyIdentity=matchIdentity||anyIdentity;if(matchIdentity){if(rankedBid.position===newRank.position&&rankedBid.reference!==newRank.reference){rankedBid.position=newRank.position;changed.push(rankedBid);}
rankedBid.reference=newRank.reference;if(rankedBid.position>newRank.position){rankedBid.position=newRank.position;up.push(rankedBid);}
if(rankedBid.position<newRank.position){rankedBid.position=newRank.position;down.push(rankedBid);}}}
if(!anyIdentity){if(!firstTime){added.push(newRank)
rankedBids.push(newRank);if(dropped.length===0){newRank.swayAnimation.start();newRank.moveAnimation.start();adjustPositions();}}else{rankedBids.push(newRank);newRank.swayAnimation.start();newRank.moveAnimation.start();}}}
for(const drop of dropped){drop.dropAnimation.start()
drop.dropAnimation.addListener(function(){let element=findRankDomElement(drop);drop.name="_";rankedBids.splice(rankedBids.indexOf(drop),1);drop.swayAnimation.stop();drop.bumpAnimation.stop();drop.dropAnimation.stop();drop.moveAnimation.stop();let shift=added.shift();$(element).attr("id","_");$(element).css("top",$(rootSelector).height())
if(shift!==undefined){findRankDomElement(shift);shift.swayAnimation.start();shift.moveAnimation.start()}
adjustPositions();})}
for(const upElement of up){upElement.bumpAnimation.start();upElement.bumpAnimation.addListener(function(){upElement.moveAnimation.start();adjustPositions();});}
for(let changedElement of changed){if(up.length===0){changedElement.bumpAnimation.start();changedElement.bumpAnimation.addListener(function(){adjustPositions();})}}}
function linear(timeFraction){return timeFraction;}
function easeIn(timeFraction){return Math.pow(timeFraction,5)}
function circ(timeFraction){return 1-Math.sin(Math.acos(timeFraction));}
function back(x,timeFraction){return Math.pow(timeFraction,2)*((x+1)*timeFraction-x)}
function bounce(timeFraction){for(let a=0,b=1;1;a+=b,b/=2){if(timeFraction>=(7-4*a)/11){return-Math.pow((11-6*a-11*timeFraction)/4,2)+Math.pow(b,2)}}}
function elastic(x,timeFraction){return Math.pow(2,10*(timeFraction-1))*Math.cos(20*Math.PI*x/3*timeFraction)}
function reverse(timing){return function(timeFraction){return 1-timing(1-timeFraction);}}
function makeEaseInOut(timing){return function(timeFraction){if(timeFraction<.5)
return timing(2*timeFraction)/2;else
return(2-timing(2*(1-timeFraction)))/2;}}
function randomRange(min,max){return min+(Math.random()*(max-min))}
function calculateDestination(rank){return Math.floor((rank.position-1)*calculateSpacing());}
function calculateSpacing(){let height=$(window).height();let vehicleHeight=$(vehicleSelector).height();let vehiclePadding=0;return(height-vehicleHeight+vehiclePadding)/5;}
function attachAnimations(rank){rank.swayAnimation=rank.swayAnimation||new Animator({duration:randomRange(2000,3000),timing:linear,draw(progress,step,repeated,obj){let element=findRankDomElement(obj);obj.swayAnimation.randomXAcc=obj.swayAnimation.randomXAcc||new ValueAccumulator({valueGenerator(){return randomRange(1,3)}});obj.swayAnimation.randomYAcc=obj.swayAnimation.randomYAcc||new ValueAccumulator({valueGenerator(){return randomRange(1,3)}});element.css('padding',obj.swayAnimation.randomXAcc.value(progress,step,repeated)+'% '+obj.swayAnimation.randomYAcc.value(progress,step,repeated)+'%')},repeat:0},rank);rank.bumpAnimation=rank.bumpAnimation||new Animator({duration:1000,timing:makeEaseInOut(easeIn),draw(progress,step,repeated,obj){if(step===0&&repeated===0){console.log("animating bump on: "+obj.name);}
let element=findRankDomElement(obj);obj.bumpAnimation.topAcc=obj.bumpAnimation.topAcc||new ValueAccumulator({valueGenerator(p,s,r){let diff=(calculateSpacing()/2)* -1;return parseInt(element.css('top'))+diff;},startAt(){return parseInt(element.css('top'))}})
element.css('top',obj.bumpAnimation.topAcc.value(progress,step,repeated)+'px')}},rank);rank.moveAnimation=rank.moveAnimation||new Animator({duration:2000,timing:makeEaseInOut(easeIn),draw(progress,step,repeated,obj){let element=findRankDomElement(obj);obj.moveAnimation.topAcc=obj.moveAnimation.topAcc||new ValueAccumulator({valueGenerator(p,s,r){return calculateDestination(obj);},startAt(){let element=findRankDomElement(obj);return parseInt(element.css('top'))}})
element.css('top',obj.moveAnimation.topAcc.value(progress,step,repeated)+'px')}},rank);rank.dropAnimation=rank.dropAnimation||new Animator({duration:500,timing:linear,draw(progress,step,repeated,obj){if(step===0&&repeated===0){console.log("animating drop on: "+obj.name);}
let element=findRankDomElement(obj);obj.dropAnimation.topAcc=obj.dropAnimation.topAcc||new ValueAccumulator({valueGenerator(p,s,r){return $(rootSelector).height();},startAt(){return parseInt(element.css('top'))}})
element.css('top',obj.dropAnimation.topAcc.value(progress,step,repeated)+'px')}},rank);rank.finishAnimation=rank.finishAnimation||new Animator({duration:500,timing:linear,draw(progress,step,repeated,obj){if(step===0&&repeated===0){console.log("animating finish on: "+obj.name);}
let element=findRankDomElement(obj);obj.finishAnimation.topAcc=obj.finishAnimation.topAcc||new ValueAccumulator({valueGenerator(p,s,r){return $(rootSelector).height()/4;},startAt(){return parseInt(element.css('top'))}})
obj.finishAnimation.leftAcc=obj.finishAnimation.leftAcc||new ValueAccumulator({valueGenerator(p,s,r){return($(rootSelector).width()/2)-(element.width()/2);},startAt(){return parseInt(element.css('left'))}})
element.css('top',obj.finishAnimation.topAcc.value(progress,step,repeated)+'px')
element.css('left',obj.finishAnimation.leftAcc.value(progress,step,repeated)+'px')}},rank);}
function finishPosition(rank){rank.swayAnimation.stop()
rank.finishAnimation.start();}
function adjustPositions(){for(const rankedBid of rankedBids){rankedBid.moveAnimation.start();}}
function fixPositions(){for(const rankedBid of rankedBids){findRankDomElement(rankedBid).css("top",calculateDestination(rankedBid));}}
function dropPosition(rank){console.log("dropped out of top 5 position: "+rank.name+":"+rank.position)
rank.dropAnimation.start();rank.dropAnimation.addListener(function(){const index=rankedBids.indexOf(rank);rankedBids.splice(index,1);let element=findRankDomElement(rank);element.attr("id","");element.css("top",$(rootSelector).height())})}
let timerAnimation=new Animator({duration:100,timing:easeIn,draw(progress,step,repeated){let timing=timeService.getTimingStats(startTime,endTime,offsetMs).timeSpan;let d=timing.Days;let h=timing.Hours;let m=timing.Minutes;let s=timing.Seconds;if(d<10)d="0"+d;if(h<10)h="0"+h;if(m<10)m="0"+m;if(s<10)s="0"+s;let value=d+":"+h+":"+m+":"+s;if(timing.TotalSeconds<countDownSeconds){if(value!==$('.time').text()){$('.time').css("opacity",0);}else{$('.time').css("opacity",1);}
$('.timer').addClass('runningout')
$('.timer').css('opacity')}else{$('.timer').removeClass('runningout')
$('.time').css("opacity","1");}
if(step===0){$('.time').text(d+":"+h+":"+m+":"+s)}},repeat:0},null)
function finish(){finished=true;$('.timer').css('opacity',0);for(let rankedBid of rankedBids){if(rankedBid.position!==1){dropPosition(rankedBid);}else{finishPosition(rankedBid);}}
$(".finish").show()
$(".finish").css("top",0)}
return{adjustTime:function(start,end){startTime=start
endTime=end},adjustOffset:function(offset){offsetMs=offset},adjustCountDown:function(countDown){countDownSeconds=countDown},createRank:function(name,position,reference,active=false){return new RankedBid(name,position,reference,active);},assignRanks:function(ranks){if(!canRun())
return;if(ranks.length>0&&rankedBids.length===0){findRankDomElement(ranks[0],function(){assignRanks(ranks)})}else{assignRanks(ranks)}},start:function(){if(!canRun())
return;timerAnimation.start();},finish:function(){if(!canRun())
return;finish();},rank:function(index){return rankedBids[index];},fixPositions:function(){if(!canRun())
return;fixPositions();}};});RMSFrontEnd.controller('sealedBiddingVisualController',function(sealedBiddingVisual){$(window).resize(sealedBiddingVisual.fixPositions);});;;
RMSFrontEnd.component("sealedBiddingVisual",{templateUrl:"/scripts/rms-scripts/components/bidding/sealed/sealedBiddingVisual.template.html",controller:"sealedBiddingVisualController",bindings:{time:'=',}});;;
'use strict';RMSFrontEnd.controller('biddingController',function($scope,dictionaryService){var _this=this;_this.started=false;_this.label={};_this.alert={};_this.alert.notRegistered="Not Registered"
_this.alert.notStarted="Not Started"
_this.label.ib="Internet Bidding"
_this.connected=false;dictionaryService.getDictionaryItems(["Lots.Internet","Lots.Internet Not Registered","Lots.Not Started"],true).then(function(data){_this.label.ib=data["Lots.Internet"]||_this.label.ib;_this.alert.notRegistered=data["Lots.Internet Not Registered"]||_this.alert.notRegistered;_this.alert.notStarted=data["Lots.Not Started"]||_this.alert.notStarted;});_this.onStart=function(){_this.started=true;}
_this.onLotChanged=function(lot){_this.connected=true;}
_this.openBidding=function(event){$(".pulse").removeClass("pulse");if(!_this.registered&&_this.type==='Sealed'){event.stopPropagation();alert(_this.alert.notRegistered);return;}
if(!_this.started){event.stopPropagation();alert(_this.alert.notStarted);return;}}});;;
RMSFrontEnd.component("bidding",{templateUrl:"/scripts/rms-scripts/components/bidding/bidding.template.html",controller:"biddingController",bindings:{id:'@',auctionId:'@',registered:'=',type:'<',timeLeft:'=',currentBid:'=',}});;;
RMSFrontEnd.component("makeAnOffer",{templateUrl:"/scripts/rms-scripts/components/buying/offer/make-an-offer.template.html",controller:"makeAnOfferController",bindings:{buyingOption:'='}});;;
'use strict';RMSFrontEnd.controller('makeAnOfferController',function(formDataOptions,stateSelection,recaptcha,userService,bidService,dictionaryService){var _this=this;this.states={loading:"loading",notStarted:"notStarted",ready:"ready"};this.state=this.states.loading;this.label={header:"Make an Offer",information:"",sendCopy:"",email:"",firstName:"",lastName:"",city:"",zip:"",state:"",country:"",cellPhone:"",homePhone:"",workPhone:"",message:"",submitButton:"Submit",close:"",sentDescription:"Thank you. An RM Financial Services representative will review and contact you within one business day"};this.formData={};this.init=function(){formDataOptions.getOptions(function(data){_this.countries=data.countries;});userService.info().then(function(data){angular.merge(_this.formData,data);_this.filterStates(_this.formData.Country);});formDataOptions.hasOffer(_this.buyingOption.LotId).then(function(data){if(data){_this.buyingOption.AllowMakeAnOffer=2;}});var terms={header:"Forms.Make An Offer",information:"Forms.Enter your information",sendCopy:"Forms.Send Copy",firstName:"Forms.Name",lastName:"Forms.Last Name",email:"Forms.Enter your email",homePhone:"Forms.Home Phone",cellPhone:"Forms.Mobile Phone",workPhone:"Forms.Work Phone",city:"Forms.City",state:"Forms.State",zip:"Forms.Zip",country:"Forms.Country",message:"Forms.Enter your message",submitButton:"Forms.Submit",close:"Forms.Close Window",sentDescription:"Forms.Offer Sent"};var items=[];angular.forEach(terms,function(o){items.push(o);});dictionaryService.getDictionaryItems(items,true).then(function(data){_this.label.header=data[terms.header]||_this.label.header;_this.label.information=data[terms.information]||_this.label.information;_this.label.sendCopy=data[terms.sendCopy]||_this.label.sendCopy;_this.label.email=data[terms.email]||_this.label.email;_this.label.firstName=data[terms.firstName]||_this.label.firstName;_this.label.lastName=data[terms.lastName]||_this.label.lastName;_this.label.homePhone=data[terms.homePhone]||_this.label.homePhone;_this.label.cellPhone=data[terms.cellPhone]||_this.label.cellPhone;_this.label.workPhone=data[terms.workPhone]||_this.label.workPhone;_this.label.city=data[terms.city]||_this.label.city;_this.label.state=data[terms.state]||_this.label.state;_this.label.country=data[terms.country]||_this.label.country;_this.label.zip=data[terms.zip]||_this.label.zip;_this.label.message=data[terms.message]||_this.label.message;_this.label.submitButton=data[terms.submitButton]||_this.label.submitButton;_this.label.close=data[terms.close]||_this.label.close;_this.label.sentDescription=data[terms.sentDescription]||_this.label.sentDescription;})};this.resetForm=function(){_this.inProgress=false;_this.showError=false;_this.showErrorEmail=false;_this.offerForm.$setPristine();};this.sendForm=function(){if(_this.offerForm.$valid){_this.inProgress=true;_this.showError=false;_this.showErrorEmail=false;_this.errorMessage='';recaptcha.getToken('sendOffer').then(function(recaptcha){_this.formData.LotId=_this.buyingOption.LotId;formDataOptions.requestOffer(_this.formData,recaptcha).then(function(data){_this.inProgress=false;_this.errorMessage='';_this.showSuccess=true;_this.showError=false;_this.showErrorEmail=false;if(data.status===2){_this.showSuccess=false;_this.showError=true;_this.errorMessage="An error occured submitting the form.";}},function(errorData){_this.inProgress=false;_this.showSuccess=false;_this.showError=true;_this.showErrorEmail=false;_this.errorMessage=errorData.message;});});}};this.dismissError=function(){_this.showError=false;_this.showErrorEmail=false;};this.filterStates=function(){stateSelection.getStates(_this.formData.Country).then(function(states){_this.selectedCountryStates=states;});};this.isNotStartedState=function(){return _this.state===_this.states.notStarted;};this.isReadyState=function(){return _this.state===_this.states.ready;};});;;
RMSFrontEnd.component("documents",{templateUrl:"/scripts/rms-scripts/components/documents/documents.template.html",controller:"documentsController",bindings:{id:'=',}});;;
'use strict';RMSFrontEnd.controller('documentsController',function($http,$scope){var _this=this;$scope.currentPath={path:"/"};$scope.currentAncestors=[];this.open=function(event,file){if(file.location!==undefined){event.preventDefault();var path=file.location===""?"/":file.location;var currentAncestors=file.location===""?[]:createBreadCrumbs(file.location);$scope.currentPath={path:path};$scope.currentAncestors=currentAncestors;}}
function createBreadCrumbs(filePath){var list=[];var names=[];var values=filePath.split('/');for(const value of values){names.push(value);list.push({location:names.join("/"),name:value,icon:value===""?"fa-home":""});}
return list;}
this.init=function(){$http.get('/api/document/ListDocuments/'+_this.id).then(function(response){if(response.status===200&&response.data){_this.data=response.data;var availablePaths=[];angular.forEach(_this.data,function(item){item.sortedName=item.name;var contains=false;for(const itemElement of availablePaths){if(itemElement===item.path)contains=true;}
if(!contains){availablePaths.push(item.path);var splitName=item.path.split('/');var name=splitName[splitName.length-1]
splitName.pop();var path=splitName.join('/');if(path.length===0)path="/";if(item.path!=="/"){_this.data.push({name:name,path:path,location:item.path,url:"#",icon:"fa-folder-open",iconColor:"lightgrey",thumbnailUrl:"",sortedName:""})}}});}});}});;;
RMSFrontEnd.component("language",{templateUrl:"/scripts/rms-scripts/components/language/language.template.html",controller:"languageController",bindings:{codes:'=',}});RMSFrontEnd.directive('languageFilter',function(languageService){return{restrict:'A',link:function(scope,element,attributes){function toggleVisibility(language){if(language.code===attributes.languageFilter){$(element).show();}else{$(element).hide();}}
languageService.setOnChanged(function(language){toggleVisibility(language);});toggleVisibility(languageService.getLanguage())}};});;;
'use strict';RMSFrontEnd.controller('languageController',function(languageService){var _this=this;_this.selectedLanguage=languageService.availableLanguages[0];this.$onInit=function(){_this.languages=this.codes.map(languageService.findLanguage)||[];_this.selectedLanguage=languageService.getLanguage();}
languageService.setOnChanged(function(language){_this.selectedLanguage=language;})
this.onLanguageChange=function(language){languageService.setLanguage(language);}});RMSFrontEnd.factory('languageService',function($cookies){var _this=this;this.availableLanguages=[{name:"English",code:"en-US"},{name:"Français",code:"fr"},{name:"Italiano",code:"it"},{name:"Deutsch",code:"de"},{name:"Dansk",code:"da"}];this.listeners=[];function setOnChanged(callback){_this.listeners.push(callback);}
function setLanguage(language){setLanguageCookie(language.code);_this.listeners.forEach(function(value){value(language);});}
function setLanguageCookie(language){var later=new Date();later.setDate(later.getDate()+365*5);$cookies.put("language",language.code,{expires:later,path:"/"});}
function getLanguage(){if($cookies.get("language")!=null){return findLanguage($cookies.get("language"));}
return _this.availableLanguages[0];}
function findLanguage(code){for(var i=0;i<_this.availableLanguages.length;i++){if(_this.availableLanguages[i].code===code){return _this.availableLanguages[i];}}}
return{setLanguage:setLanguage,getLanguage:getLanguage,findLanguage:findLanguage,availableLanguages:_this.availableLanguages,setOnChanged:setOnChanged}});;;
RMSFrontEnd.component("bidEntry",{templateUrl:"/scripts/rms-scripts/components/bid-entry/bidEntry.template.html",controller:"bidEntryController",bindings:{auctionId:'@',}});;;
RMSFrontEnd.controller('bidEntryController',function($scope,bidEntryService){var self=this;self.entry=[];self.errorConnecting=false;self.connected=false;const entryCreateFailedKey="bidEntryCreateFailed:";const entryUpdatedFailedKey="bidEntryUpdatedFailed:";const entryRemoveFailedKey="bidEntryRemoveFailed:";self.status={invalid:"invalid",processing:"processing",processed:"processed",failed:"failed",}
function onReceiveLots(lots){self.lots=lots;self.lots.forEach(lot=>{lot.bids.forEach(bid=>{bid.amountFormatted=formatNumber(bid.amount);bid.status=self.status.processed;});lot.bids.push({});})
$scope.$apply();}
function formatNumber(number){var transformedInput=number.toString().replace(/[^0-9]/g,'');var rgx=/(\d+)(\d{3})/;while(rgx.test(transformedInput)){transformedInput=transformedInput.replace(rgx,'$1'+','+'$2');}
return transformedInput;}
function onReceiveAuction(auction){self.auction=auction;$scope.$apply();}
function onReceiveLotOpened(id){self.lots.forEach(function(lot){if(lot.status==='Active'){lot.status='';}
if(lot.id===id){lot.status='Active';}})
$scope.$apply();}
function onReceiveLotFinished(id,status){self.lots.forEach(function(lot){if(lot.id===id){lot.status=status;}})
$scope.$apply();}
function onReceiveLotProcessed(id){var index=-1;self.lots.forEach(function(lot){if(lot.id===id){index=self.lots.indexOf(lot);}});if(index!==-1){self.lots.splice(index,1);}
$scope.$apply();}
function processStorage(startsWith,process){const items={...localStorage};for(let itemsKey in items){if(itemsKey.startsWith(startsWith)){process(JSON.parse(items[itemsKey]));}}}
function processFailedCreated(){processStorage(entryCreateFailedKey,function(data){bidEntryService.create(data.lotId,data.bidderNumber,data.amount,data.timestamp).then(function(id){removeCreateFailure(data.lotId,data.timestamp);},function(err){console.error(err);});});}
function processFailedUpdated(){processStorage(entryUpdatedFailedKey,function(data){bidEntryService.update(data.id,data.bidderNumber,data.amount).then(function(result){removeUpdateFailure(data.id);},function(err){console.error(err);});});}
function processFailedRemoved(){processStorage(entryRemoveFailedKey,function(data){bidEntryService.remove(data.id).then(function(){removeUpdateFailure(data.id);removeRemoveFailure(data.id);},function(err){console.error(err)});});}
function processFailed(){processFailedCreated();processFailedUpdated();processFailedRemoved();}
function generateCreateKey(lotId,timestamp){return`${entryCreateFailedKey}:${lotId}:${timestamp}`;}
function generateUpdateKey(id){return`${entryUpdatedFailedKey}:${id}`;}
function generateRemoveKey(id){return`${entryRemoveFailedKey}:${id}`;}
function addCreateFailure(lot,entry){const value={lotId:lot.id,bidderNumber:entry.bidderNumber,amount:entry.amount,status:self.status.failed,timestamp:entry.timestamp||Date.now()};const key=generateCreateKey(value.lotId,value.timestamp);localStorage.removeItem(key);localStorage.setItem(key,JSON.stringify(value));}
function removeCreateFailure(lotId,timestamp){localStorage.removeItem(generateCreateKey(lotId,timestamp));}
function addUpdateFailure(entry){const value={id:entry.id,bidderNumber:entry.bidderNumber,amount:entry.amount,status:self.status.failed,timestamp:Date.now()};const key=generateUpdateKey(entry.id);localStorage.removeItem(key);localStorage.setItem(key,JSON.stringify(value));}
function removeUpdateFailure(id){localStorage.removeItem(generateUpdateKey(id));}
function addRemoveFailure(lot,entry){const value={id:entry.id,lotId:lot.id,bidderNumber:entry.bidderNumber,amount:entry.amount,status:self.status.failed,timestamp:Date.now()};const key=generateRemoveKey(entry.id);localStorage.removeItem(key);localStorage.setItem(key,JSON.stringify(value));}
function removeRemoveFailure(id){localStorage.removeItem(generateRemoveKey(id));}
this.valid=function(entry){return entry.bidderNumber&&entry.amount&&entry.bidderNumber.trim().length>0&&entry.amount>0}
this.modify=function(lot,entry){if(lot.bids.indexOf(entry)===(lot.bids.length-1)){if(entry.bidderNumber||entry.amount){lot.bids.push({});}}
if(entry.amountFormatted){entry.amount=parseFloat(entry.amountFormatted.replaceAll(',',"").trim());}
if(self.valid(entry)){entry.status=self.status.processing;if(entry.id){entry.action="Update"
if(entry.status===self.status.failed){addUpdateFailure(entry);processFailedUpdated()
return;}
bidEntryService.update(entry.id,entry.bidderNumber,entry.amount).then(function(result){entry.status=self.status.processed;$scope.$apply();},function(err){console.error(err);entry.errorMessage=err.toString();entry.status=self.status.failed;addUpdateFailure(entry);$scope.$apply();});}else{entry.timestamp=Date.now();entry.action="Create"
if(entry.status===self.status.failed){addCreateFailure(lot,entry);processFailedCreated()
return;}
bidEntryService.create(lot.id,entry.bidderNumber,entry.amount,entry.timestamp).then(function(id){entry.id=id;entry.status=self.status.processed;$scope.$apply();},function(err){console.error(err);entry.errorMessage=err.toString();entry.status=self.status.failed;entry.timestamp=Date.now();addCreateFailure(lot,entry);$scope.$apply();});}}else{entry.status=self.status.invalid;}}
this.remove=function(lot,entry){if(entry.status===self.status.failed){addRemoveFailure(lot,entry);processFailedRemoved()
return;}
entry.status=self.status.processing;entry.action="Remove"
bidEntryService.remove(entry.id).then(function(){var index=lot.bids.indexOf(entry);if(index>-1){lot.bids.splice(index,1);}
removeCreateFailure(lot,entry);removeUpdateFailure(entry);removeRemoveFailure(entry);$scope.$apply();},function(err){console.error(err)
entry.status=self.status.failed;addRemoveFailure(lot,entry);$scope.$apply();});}
this.done=function(lot){bidEntryService.done(lot.id).then(function(){var index=self.lots.indexOf(lot);if(index>-1){self.lots.splice(index,1);}
$scope.$apply();},function(err){console.error(err)});}
this.cssBidClass=function(bid){return{'processing':bid.status===self.status.processing,'processed':bid.status===self.status.processed,'failed':bid.status===self.status.failed,}}
this.cssIconStatusCss=function(bid){return{'fa':true,'fa-2x':true,'fa-circle-o-notch fa-spin fa-fw':bid.status===self.status.processing,'fa-spin':bid.status===self.status.processing,'fa-fw':bid.status===self.status.processing,'fa-circle-check':bid.status===self.status.processed,'fa-circle-exclamation':bid.status===self.status.failed,}}
this.cssIconStatusStyle=function(bid){switch(bid.status){case self.status.failed:return{'color':'red'}}
return{}}
this.cssLotClass=function(lot){return{'active':lot.status==='Active',}}
this.reload=function(){location.reload();}
this.$onInit=function(){console.log("initialized")
bidEntryService.onReconnecting(function(err){self.errorConnecting=true;if(err){self.errorMessage=err+" ";}
self.errorMessage+="Reconnecting...";console.log(err);$scope.$apply();})
bidEntryService.onReconnected(function(connectionId){self.errorConnecting=false;self.connected=true;self.errorMessage="";processFailed();bidEntryService.register()
$scope.$apply();})
bidEntryService.onClose(function(err){self.errorConnecting=true;self.connected=false;self.errorMessage="";if(err){self.errorMessage=err+" ";}
self.errorMessage+="Connection closed, please try again";$scope.$apply();})
bidEntryService.onReceiveLots(onReceiveLots);bidEntryService.onReceiveLotOpened(onReceiveLotOpened);bidEntryService.onReceiveLotFinished(onReceiveLotFinished);bidEntryService.onReceiveAuction(onReceiveAuction);bidEntryService.onReceiveLotProcessed(onReceiveLotProcessed);bidEntryService.connect(self.auctionId,function(connection){processFailed();bidEntryService.register()
self.connected=true;},function(connection,err){console.error(err)
self.connected=false;if(err){self.errorMessage=err+" ";}
self.errorMessage+="Could not connected";})
self.entry.push({});}});;;
'use strict';RMSFrontEnd.controller('paymentMethodsController',function($scope,$q,paymentService,dictionaryService){var _this=this;this.paymentMethods=[];this.braintreeClient=null;this.deleteErrorMessage="";this.updateErrorMessage="";this.createErrorMessage="";this.labels={}
let braintreeClientInstance=null;var hostedFieldsInstance=null;var hostedFieldsInstance2=null;function initialize(){populatePaymentMethods();dictionaryService.getDictionaryItems(["Store.New Payment Method","Store.Update Payment Method","Store.Credit Card Number","Store.Expiry Month","Store.Expiry Year","Store.CVV","Store.Postal Code","Store.Add Card","Store.Update Card","Forms.Token Error Duplicate","Forms.Token Error CVV","Forms.Payment method required"]).then(function(data){_this.labels.newPaymentMethod=data["Store.New Payment Method"];_this.labels.updatePaymentMethod=data["Store.Update Payment Method"];_this.labels.ccNumber=data["Store.Credit Card Number"];_this.labels.ccExpiryMonth=data["Store.Expiry Month"];_this.labels.ccExpiryYear=data["Store.Expiry Year"];_this.labels.ccCvv=data["Store.CVV"];_this.labels.ccPostalCode=data["Store.Postal Code"];_this.labels.buttonAdd=data["Store.Add Card"];_this.labels.buttonUpdate=data["Store.Update Card"];_this.labels.errorCvv=data["Forms.Token Error CVV"];_this.labels.errorDuplicate=data["Forms.Token Error Duplicate"];_this.labels.errorCard=data["Forms.Payment method required"];paymentService.getToken().then(function(data){braintree.client.create({authorization:data.token},function(clientErr,clientInstance){if(clientErr)console.error(clientErr);braintreeClientInstance=clientInstance;braintree.hostedFields.create({client:clientInstance,styles:{'.invalid':{'background-color':'#fff2f2'}},fields:{number:{selector:'#card-number',placeholder:_this.labels.ccNumber},cvv:{selector:'#cvv',placeholder:_this.labels.ccCvv},expirationMonth:{selector:'#expiration-month',select:true,prefill:'',placeholder:_this.labels.ccExpiryMonth},expirationYear:{selector:'#expiration-year',select:true,prefill:'',placeholder:_this.labels.ccExpiryYear},postalCode:{selector:'#postal-code',placeholder:_this.labels.ccPostalCode}}},function(hostedFieldsErr,hostedFields){hostedFieldsInstance=hostedFields
if(hostedFieldsErr)console.error(hostedFieldsErr);})});})});}
this.deletePaymentMethod=function(e,payment){e.preventDefault();payment.errorMessage="";paymentService.deletePayment(payment.token).then(function(data){if(data.status===0){_this.paymentMethod=null;populatePaymentMethods();}else{payment.errorMessage=data.message;}});};function updatePaymentHostedFields(data){if(hostedFieldsInstance2){hostedFieldsInstance2.teardown();}
braintree.hostedFields.create({client:braintreeClientInstance,styles:{'.invalid':{'background-color':'#fff2f2'}},fields:{cvv:{selector:'#cvv-update',placeholder:_this.labels.ccCvv,prefill:data.cvv},expirationMonth:{selector:'#expiration-month-update',prefill:data.expirationMonth,select:true},expirationYear:{selector:'#expiration-year-update',select:true,prefill:data.expirationYear,},postalCode:{selector:'#postal-code-update',placeholder:_this.labels.ccPostalCode,prefill:data.postalCode,}}},function(hostedFieldsErr,hostedFields){if(hostedFieldsErr)console.error(hostedFieldsErr);hostedFieldsInstance2=hostedFields})}
function updatePayment(){var deferred=$q.defer();tokenizeUpdate().then(function(data){if(data.status==="Success"){paymentService.updatePayment(data.payload.nonce,_this.currentPayment.token).then(function(data){deferred.resolve(data);});}else{deferred.resolve(data);}},function(data){deferred.reject(data);});return deferred.promise;}
this.updatePaymentMethod=function(e){e.preventDefault();_this.currentPayment.errorMessage="";updatePayment().then(function(data){if(data.status===0){populatePaymentMethods();hideUpdateModal();}else{_this.currentPayment.errorMessage=data.message;}},paymentError);};function tokenizeCreate(){var deferred=$q.defer();var state=hostedFieldsInstance.getState();const keys=Object.keys(state.fields);var formValid=keys.every(function(key){return state.fields[key].isValid;});if(formValid){hostedFieldsInstance.tokenize({fieldsToTokenize:keys},function(tokenizeErr,payload){if(tokenizeErr){var errorMessage="Unknown error occured. Please try again.";switch(tokenizeErr.code){case'HOSTED_FIELDS_TOKENIZATION_FAIL_ON_DUPLICATE':errorMessage=_this.labels.errorDuplicate;break;case'HOSTED_FIELDS_TOKENIZATION_CVV_VERIFICATION_FAILED':errorMessage=_this.labels.errorCvv;break;}
deferred.resolve({status:"Error",error:tokenizeErr,message:errorMessage});logService.errorLog(JSON.stringify(tokenizeErr));}else{deferred.resolve({status:"Success",payload:payload});}});}else{deferred.reject({status:"Error",state:state,message:_this.labels.errorCard});}
return deferred.promise;}
function tokenizeUpdate(){var deferred=$q.defer();var state=hostedFieldsInstance2.getState();const keys=Object.keys(state.fields);var formValid=keys.every(function(key){return state.fields[key].isValid;});if(formValid){hostedFieldsInstance2.tokenize({fieldsToTokenize:keys},function(tokenizeErr,payload){if(tokenizeErr){var errorMessage="Unknown error occured. Please try again.";switch(tokenizeErr.code){case'HOSTED_FIELDS_TOKENIZATION_FAIL_ON_DUPLICATE':errorMessage=_this.labels.errorDuplicate;break;case'HOSTED_FIELDS_TOKENIZATION_CVV_VERIFICATION_FAILED':errorMessage=_this.labels.errorCvv;break;}
deferred.resolve({status:"Error",error:tokenizeErr,message:errorMessage});logService.errorLog(JSON.stringify(tokenizeErr));}else{deferred.resolve({status:"Success",payload:payload});}});}else{deferred.reject({status:"Error",state:state,message:_this.labels.errorCard});}
return deferred.promise;}
function createPayment(){var deferred=$q.defer();tokenizeCreate().then(function(data){if(data.status==="Success"){paymentService.createPayment(data.payload.nonce).then(function(data){deferred.resolve(data);clear(hostedFieldsInstance);});}else{deferred.resolve(data);}},function(data){deferred.reject(data);});return deferred.promise;}
this.createPaymentMethod=function(e){e.preventDefault();_this.createErrorMessage="";createPayment().then(function(data){if(data.status===0){populatePaymentMethods();hideCreateModal();}else{_this.createErrorMessage=data.message;}},paymentError);};this.paymentMethodLogo=function(payment){const path="/images/cc/square-corners/svg/";switch(payment.type){case"American Express":return path+"american-express.svg";case"Carte Blanche":return path+"cb.svg";case"Discover":return path+"discover.svg";case"JCB":return path+"jcb.svg";case"Maestro":case"UK Maestro":return path+"maestro.svg";case"MasterCard":return path+"mastercard.svg";case"Solo":return path+"solo.svg";case"Switch":return path+"switch.svg";case"Visa":return path+"visa.svg";}
return path+"blank.svg";}
function clear(hostedFieldsInstance){const state=hostedFieldsInstance.getState();if(state.fields.number){hostedFieldsInstance.clear('number');$(state.fields.number.container).removeClass("invalid");}
if(state.fields.cvv){hostedFieldsInstance.clear('cvv');$(state.fields.cvv.container).removeClass("invalid");}
if(state.fields.expirationMonth){hostedFieldsInstance.clear('expirationMonth');$(state.fields.expirationMonth.container).removeClass("invalid")}
if(state.fields.expirationYear){hostedFieldsInstance.clear('expirationYear');$(state.fields.expirationYear.container).removeClass("invalid")}
if(state.fields.postalCode){$(state.fields.postalCode.container).removeClass("invalid")
hostedFieldsInstance.clear('postalCode');}}
function paymentError(data){if(data.state.fields.number){if(data.state.fields.number.isValid){$(data.state.fields.number.container).removeClass("invalid")}else{$(data.state.fields.number.container).addClass("invalid")}}
if(data.state.fields.cvv){if(data.state.fields.cvv.isValid){$(data.state.fields.cvv.container).removeClass("invalid")}else{$(data.state.fields.cvv.container).addClass("invalid")}}
if(data.state.fields.expirationMonth){if(data.state.fields.expirationMonth.isValid){$(data.state.fields.expirationMonth.container).removeClass("invalid")}else{$(data.state.fields.expirationMonth.container).addClass("invalid")}}
if(data.state.fields.expirationYear){if(data.state.fields.expirationYear.isValid){$(data.state.fields.expirationYear.container).removeClass("invalid")}else{$(data.state.fields.expirationYear.container).addClass("invalid")}}
if(data.state.fields.postalCode){if(data.state.fields.postalCode.isValid){$(data.state.fields.postalCode.container).removeClass("invalid")}else{$(data.state.fields.postalCode.container).addClass("invalid")}}
return data;}
function populatePaymentMethods(){paymentService.getPaymentMethods().then(function(data){_this.paymentMethods=data;});}
this.cssExpiration=function(paymentMethod){var now=new Date();const expiring=paymentMethod.expiresMonth===now.getMonth()+1&&paymentMethod.expiresYear===now.getFullYear();const expired=paymentMethod.expired;return{'fa':expiring||expired,'fa-exclamation-circle':expiring||expired,'expired':expired,'expiring':expiring,}}
function showUpdateModal(){$('#updatePaymentMethodModal').modal('show');}
function hideUpdateModal(){$('#updatePaymentMethodModal').modal('hide');}
function showCreateModal(){$('#createPaymentMethodModal').modal('show');}
function hideCreateModal(){$('#createPaymentMethodModal').modal('hide');}
this.onEdit=function(payment){_this.currentPayment=payment;updatePaymentHostedFields({expirationMonth:_this.currentPayment.expiresMonth,expirationYear:_this.currentPayment.expiresYear,postalCode:_this.currentPayment.address.postalCode,})
showUpdateModal();}
this.onAdd=function(){showCreateModal();}
initialize();});;;
RMSFrontEnd.component("paymentMethods",{templateUrl:"/scripts/rms-scripts/components/payment-methods/paymentMethods.template.html",controller:"paymentMethodsController",});;;
