PageSourceSearch

https://www.scalabad.no/scripts/customerregistration.js

js scalabad.no collected 2026-10-08 01:16:12 UTC 50,987 bytes, 1 lines download raw bytes

1mcWeb.customerRegistration=new function(){var n=jQuery;this.events={onChangedCustomerData:"mcWeb.customerRegistration.onChangedCustomerData",onChangedZipCode:"mcWeb.customerRegistration.onChangedZipCode",onChangedCity:"mcWeb.customerRegistration.onChangedCity",onChangedCustomerType:"mcWeb.customerRegistration.onChangedCustomerType",reloadRegistration:"mcWeb.customerRegistration.reloadRegistration",onChangedUsePrintPackingList:"mcWeb.customerRegistration.onChangedUsePrintPackingList",onRememberedUserNotMe:"mcWeb.customerRegistration.onRememberedUserNotMe",updateOrgNr:"mcWeb.customerRegistration.updateOrgNr",onChangeEmail:"mcWeb.customerRegistration.onChangeEmail",onCustomerRegLoaded:"mcWeb.customerRegistration.onCustomerRegLoaded"};this.LoadView=function(t){var i=new WebApiService("CustomerRegistration");i.GetAction("RegistrationSettingsJson",{isCheckout:n(".body-checkout").length>0,token:t!=null?t:null}).then(function(n){n!=null&&(n.ShowCustomerRegistration===!0||t!==null)&&(PubSub.publish(mcWeb.lightbox.events.onShowLightbox),t&&(n.Token=t),mcWeb.customerRegistration.lightbox.load(n))})};this.vm=function(t){var r=this,u,f;this.id="#"+t;this.settings=null;this.registrationVM=null;this.conditionVM=new mcWeb.conditions.vm(r.id);this.conditionsStatus={isFunctionalConditionAccepted:ko.observable(!1),acceptDocuments:ko.observableArray([]),usageArea:2};this.hasLoadedView=!1;this.service=new WebApiService("CustomerRegistration");this.load=function(n,t){r.settings=t;r.registrationVM=new f(t);r.getAvailableCountries();r.getTelephonePrefixes();r.getAvailableDealers(0,"");t.IsLoggedIn===!0?r.registrationVM.showRegTypes():(r.registrationVM.selectedCountry(r.settings.SessionLandI
1d),r.registrationVM.invoiceSelectedCountry(r.settings.SessionLandId));t.IsCheckout||r.conditionVM.load(null,{usageArea:2,functionName:"CUSTOMERREGISTRATION",forUnknownUser:!0,isInLightbox:!0,status:r.conditionsStatus});r.loadInitialView(r.registrationVM.isLoggedIn(),r.registrationVM.hasSelectedBusiness())};this.getAvailableCountries=function(){r.service.GetAction("GetAvailableCountries",null).then(function(n){return n==null||n.length<1?null:(r.registrationVM.availableCountries(n),null)})};this.getTelephonePrefixes=function(){r.service.GetAction("GetTelephonePrefixes",null).then(function(n){return n==null||n.length<1?null:(r.registrationVM.telephonePrefixes(n),r.setInitalTelephonePrefix(),null)})};this.setInitalTelephonePrefix=function(){const t=r.registrationVM.selectedCountry(),i=r.registrationVM.telephonePrefixes(),n=i.find(n=>n.LandId==t);n!==undefined&&r.registrationVM.telephoneLandId(n.LandId)};this.getAvailableDealers=function(n,t){var i,u;if(!r.registrationVM.settings.ShowAvsAdresseSelectionInRegistration)return null;i=r.registrationVM.showAllDealersChecked();i&&(t="0");t||(t="");u={landId:n,postnr:t};r.service.GetAction("GetAvailableDealers",u).then(function(n){if(n==null||n.length<1)return null;r.registrationVM.availableDealers(n);var t=r.registrationVM.selectedDealer();return r.registrationVM.availableDealers().some(n=>n.AvsAdresseIdAndWarehouse===t)||document.getElementById("dealer")&&(document.getElementById("dealer").value="-1"),null})};this.setInitialCustomerType=function(n){n==1?r.registrationVM.customerType("business"):r.registrationVM.customerType("private");r.service.GetAction("SetCustomerType",{customerType:n}).then(function(n){(n==null||n.length<1)&&alert("Error - Can't select select cutomer type")})};this.loadInitialView=function(n,t){r.registrationVM.customerType()===undefined&&(r.settings.Bedriftskunde||t?r.registrationVM.customerType("business"):r.registrationVM.customerType("private"));var i=r.settings.OnlyBussines,u=r.settings.OnlyPrivate;i&&r.setInitialCustomerType(1);u&&r.setInitialCustomerType(0);!n&&i?r.loadBusinessView():!n&&u?r.loadPrivateView():r.registrationVM.customerType()==="business"?r.loadBusinessView():r.registrationVM.customerType()==="private"&&r.loadPrivateView();r.settings.User&&r.settings.User.EniroJson&&getLibrary("mcWeb.eniro").then(()=>{mcWeb.eniro.showResults(r.settings.User.EniroJson,r.settings.IsVippsLogin)})};this.loadPrivateView=function(){getLibrary("mcWeb.loginCheckout").then(()=>{mcWeb.loginCheckout.ResetLoginCheckoutPosision()});n(".qtip").remove();var t=n(r.id+" #registrationFieldContainer");if(t.hide(),PubSub.publish(mcWeb.lightbox.events.contentChanged),n(r.id+" #privateCustomerRegistration").length>0){r.registrationVM.isLoggedIn()&&t.fadeIn();return}getLibrary("mcWeb.eniro").then(()=>{t.load("/Webpages/ViewProvider.aspx?view=PrivateCustomer",function(){if(r.hasLoadedView=!0,t.fadeTo("slow",1),PubSub.publish(mcWeb.payments.events.onHideUpdateIcon,null),!(n(r.id+" #privateCustomerRegistration").length<1)){u();r.registrationVM.customerType("private");r.registrationVM.validationRules=[];ko.applyBindings(r.registrationVM,n(r.id+" #privateCustomerRegistration")[0]);r.registrationVM.getErrorMessages();!r.registrationVM.usingPorterbuddy()&&r.registrationVM.hasDefaultDeliveryAddressSelected()&&(r.settings.DisableDeliveryAddressEdit&&r.settings.IsCheckout||r.registrationVM.useDifferentDeliveryAddress())&&n(r.i
1d+" #otherDeliveryAddressContainer").show();r.settings.SoftAdressValidation&&n(r.id+" #address1").prev().removeClass("icon-star");r.registrationVM.phoneMandatory()||n(r.id+" #phone").prev().removeClass("icon-star");r.registrationVM.phoneDeliveryMandatory()||n(r.id+" #levPhone").prev().removeClass("icon-star");r.registrationVM.receiveoffers(r.settings.EdmEmailCheckedPrivate);!mcWeb.inlineEditor||mcWeb.inlineEditor.init(!0);r.disableEnterKey();var i=r.registrationVM.invoiceSelectedCountry();!r.registrationVM.invoiceCountryId()||!r.registrationVM.landID()||r.registrationVM.landID()===r.registrationVM.invoiceCountryId()||(i=r.registrationVM.landID());r.registrationVM.setZipCodeMaskDelivery(i);r.registrationVM.setZipCodeMaskInvoice(r.registrationVM.invoiceSelectedCountry());r.registrationVM.isLoggedIn()&&t.show();r.registrationVM.showCustomerType()||r.conditionVM.isVisible(!0);PubSub.publish(mcWeb.events.customerRegistration.onCustomerRegLoaded)}})})};this.IsPublishMode=function(){return n("body.publish-mode").length>0?!0:!1};u=function(){var t,i,u,f,e,o,s,h,c,l,a,v,y,p;r.IsPublishMode()||(t=n(".customer-reg-pub #PanelAreaPreviewHelp"),t.length<1)||(i=t.detach(),i.appendTo("#pub-area-preview-help"),u=n("#PanelAreaPreviewTop"),f=u.detach(),f.appendTo("#pub-area-preview-top"),e=n("#PanelAreaPreviewBottom"),o=e.detach(),o.appendTo("#pub-area-preview-bottom"),s=n("#PanelAreaPreviewBottomOutside"),h=s.detach(),h.appendTo("#pub-area-preview-bottom-out"),c=n("#PanelAreaBlocKPrivate"),l=c.detach(),l.appendTo("#pub-area-block-cust-private"),a=n("#PanelAreaBlocKBusiness"),v=a.detach(),v.appendTo("#pub-area-block-cust-business"),y=n("#PanelAreaBlocKReadonly"),p=y.detach(),p.appendTo("pub-area-block-cust-readonly"))};this.loadBusinessView=function(){r.registrationVM.showCustomerType()||r.conditionVM.isVisible(!0);getLibrary("mcWeb.loginCheckout").then(()=>{mcWeb.loginCheckout.ResetLoginCheckoutPosision()});n(".qtip").remove();n("#privateCustomer").removeClass("active");n("#companyCustomer").addClass("active");n("#govermentCustomer").removeClass("active");var t=n(r.id+" #registrationFieldContainer");if(t.hide(),PubSub.publish(mcWeb.lightbox.events.contentChanged),n(r.id+" #businessRegistrationView").length>0){r.registrationVM.isLoggedIn()&&t.fadeIn();return}getLibrary("mcWeb.eniro").then(()=>{t.load("/Webpages/ViewProvider.aspx?view=BusinessCustomer",function(){if(r.hasLoadedView=!0,t.fadeTo("slow",1),PubSub.publish(mcWeb.payments.events.onHideUpdateIcon,null),!(n(r.id+" #businessRegistrationView").length<1)){u();r.registrationVM.customerType("business");r.registrationVM.validationRules=[];ko.applyBindings(r.registrationVM,n(r.id+" #businessRegistrationView")[0]);r.registrationVM.getErrorMessages();!r.registrationVM.usingPorterbuddy()&&r.registrationVM.hasDefaultDeliveryAddressSelected()&&(r.settings.DisableDeliveryAddressEdit&&r.settings.IsCheckout||r.registrationVM.useDifferentDeliveryAddress())&&n(r.i
1d+" #otherDeliveryAddressContainer").show();r.settings.SoftAdressValidation&&n(r.id+" #address1").prev().removeClass("icon-star");r.registrationVM.phoneMandatory()||n(r.id+" #phone").prev().removeClass("icon-star");r.registrationVM.phoneDeliveryMandatory()||n(r.id+" #levPhone").prev().removeClass("icon-star");r.registrationVM.receiveoffers(r.settings.EdmEmailCheckedCompany);!mcWeb.inlineEditor||mcWeb.inlineEditor.init(!0);r.disableEnterKey();var i=r.registrationVM.invoiceSelectedCountry();!r.registrationVM.invoiceCountryId()||!r.registrationVM.landID()||r.registrationVM.landID()===r.registrationVM.invoiceCountryId()||(i=r.registrationVM.landID());r.registrationVM.setZipCodeMaskDelivery(i);r.registrationVM.setZipCodeMaskInvoice(r.registrationVM.invoiceSelectedCountry());r.registrationVM.isLoggedIn()&&t.fadeIn();PubSub.publish(mcWeb.events.customerRegistration.onCustomerRegLoaded)}})})};this.disableEnterKey=function(){n(".reg-textbox").on("keypress",function(n){n.keyCode===13&&n.preventDefault()})};this.getJsonData=function(n){return r.registrationVM.getJsonData(n)};this.validate=function(){return r.registrationVM.validate()};this.validateCustomerSelectionType=function(){return!r.registrationVM.readOnly()&&r.registrationVM.showCustomerType()?(mcWeb.validation.qTipActionShow(jQuery("#privateCustomerRegistration .customerTypeSelector"),jQuery(".customerTypeSelectionValidationError").text(),!1),!1):!0};this.requireLogin=function(){return r.registrationVM.requireLogin()};f=function(t){function e(n){return n.landKode3?n.landKode3:n.landKode2?n.landKode2:""}var u=this,f;u.settings=t;u.id=r.id;this.forceInvoiceReadOnly=ko.observable(t.ForceInvoiceReadOnly);this.usingPorterbuddy=ko.observable(t.IsPorterbuddy);this.deliveryWindow=ko.observable({});this.hasDefaultDeliveryAddressSelected=ko.observable(t.HasDefaultDeliveryAddressSelected);this.phoneMandatory=ko.observable(t.PhoneMandatory);this.phoneDeliveryMandatory=ko.observable(t.PhoneDeliveryMandatory);this.address1Mandatory=ko.observable(t.Address1Mandatory);this.onlyPrivate=ko.observable(t.OnlyPrivate);this.onlyBusiness=ko.observable(t.OnlyBussines);this.isLoggedIn=ko.observable(t.IsLoggedIn);this.calculateCarrierEventByAddress=ko.observable(t.CalculateCarrierEventByAddress);this.deliveryAddressFormExpanded=ko.observable(t.DeliveryAddressFormExpanded);this.hasSelectedBusiness=ko.observable(t.BusinessCustomerSelected);this.listDeliveryAddressValidation=function(){return null};this.saveDeliveryAddressChanges=function(){return Promise.resolve({Success:!0})};this.isNotLoggedIn=ko.computed(function(){return!u.isLoggedIn()});this.token=t.Token;this.token!=null&&t.User!=null?(f=t.User,this.epost=ko.observable(f.Username.toLowerCase()),this.epostCustomer=ko.observable(f.Username.toLowerCase()),this.firstName=ko.observable(f.Firstname),this.lastName=ko.observable(f.Lastname),this.invoiceAddressPrev=ko.observable(f.Address),this.invoiceAddress=ko.observable(f.Address),this.invoiceZipCodePrev=ko.observable(f.ZipCode),this.invoiceZipCode=ko.observable(f.ZipCode),this.invoiceCity=ko.observable(f.City),this.telephoneno=ko.observable(f.Phone),this.orgnr=ko.observable(f.Orgnr)):(this.epost=ko.observable(),this.epostCustomer=ko.observable(""),this.firstName=ko.observable(),this.lastName=ko.observable(),this.invoiceAddress=ko.observable(),this.invoiceAddressPrev=ko.observable(),this.invoiceZipCode=ko.observable(),this.invoiceZipCodePrev=ko.observable(),this.invoiceCity=ko.observable(),this.telephoneno=ko.observable(""),this.orgnr=ko.observable(""));this.populateAddress=function(n,t){u.showCustomerType(!1);u.showRegButtons(!0);u.customerType()!=="private"&&PubSub.publish(mcWeb.events.customerRegistration.onChangedCustomerType,0);n&&(this.epost(n.Username.toLowerCase()),this.epostCustomer(n.Username.toLowerCase()),this.firstName(n.Firstname),this.lastName(n.Lastname),this.invoiceAddressPrev(n.Address),this.invoiceAddress(n.Address),this.invoiceZipCodePrev(n.ZipCode),this.invoiceZipCode(n.ZipCode),this.invoiceCity(n.City),this.telephoneno(n.Phone),this.orgnr(n.Orgnr),n.EniroJson&&getLibrary("mcWeb.eniro").then(()=>{mcWeb.eniro.showResults(n.EniroJson,t)}))};this.hasCartItems=ko.observable(!1);this.discountCode=ko.observable("");this.usePrintPackingList=ko.observable(!1);this.postbox=ko.observable("");this.adresstilleg=ko.observable();this.adresstilleg2=ko.observable();this.adress=ko.observable();this.postnrPrev=ko.observable();this.postnr=ko.observable();this.poststed=ko.observable();this.receiveoffers=ko.observable();this.useDifferentDeliveryAddress=ko.observable(t.IsCheckout&&(this.usingPorterbuddy()||!t.HasDefaultDeliveryAddressSelected));this.useDifferentDeliveryAddressPrev=ko.observable(t.IsCheckout&&(this.usingPorterbuddy()||!t.HasDefaultDeliveryAddressSelected));this.showAllDealersChecked=ko.observable(!1);this.nameDelivery=ko.observable();this.adressDelivery=ko.observable();this.adressDeliveryPrev=ko.observable();this.adresstillegDelivery=ko.observable();this.adresstilleg2Delivery=ko.observable();this.postnrDeliveryPrev=ko.observable();this.postnrDelivery=ko.observable();this.poststedDelivery=ko.observable();this.phoneDelivery=ko.observable();this.emailDelivery=ko.observable();this.contactPerson=ko.observable();this.companyName=ko.observable();this.customerType=ko.observable();this.country=ko.observable();this.landID=ko.observable(0);this.invoiceCompanyName=ko.observable();this.invoiceAddress2=ko.observable();this.invoiceAddress3=ko.observable();this.invoicePOBox=ko.observable();this.invoiceCountryId=ko.observable();this.invoiceCountry=ko.observable();this.invoiceReadOnly=ko.observable(!1);this.invoiceSelectedCountry=ko.observable(1);this.readonlyInvoiceAddress=!1;this.telephoneLandId=ko.observable();this.orgnr.subscribe(function(n){PubSub.publish(mcWeb.payments.events.updateOrgNr,n)});this.orgnrSsn=ko.observable();this.birthDate=ko.observable();this.registeredZip=ko.observable();this.validationRules=[];this.lastValidationResult=[];this.errorMessages=[];this.addressWarningFlag=0;this.zipcodeWarningFlag=0;this.cityDoesNotMatch=ko.observable(!0);this.hideOrgnrSsn=ko.observable(!1);this.hideExperianBetBet=ko.observable(!1);this.experianBetBetId=ko.observable();this.readOnlyPrev=ko.observable(t.ReadOnly);this.readOnly=ko.observable(t.ReadOnly);this.locked=ko.observable(!1);this.zipCodeMask=null;this.zipCodeDeliveryMask=null;this.blockedCustomer=ko.observable(!1);this.showPreviewHelp=ko.observable(!1);this.tempShowCustomerEdit=u.isLoggedIn()&&t.ShowCustomerEdit?!0:!1;this.disableFields=ko.observable(t.UseBusinessAutofillBySearchRegisterForm);this.regBedriftKundeTvungetAvsender=ko.observable(t.RegBedriftKundeTvungetAvsender);this.customerExist=ko.observable(!1);this.avsAdresseID=ko.observable(0);this.customerExistsdialog=ko.observable("");this.customerCareLink=ko.observable("");this.disableTelephoneno=ko.observable(!0);
1this.companyNameFieldLocked=ko.computed(()=>u.isLoggedIn()||u.readOnly()||u.disableFields());this.invoiceAddressFieldLocked=ko.computed(()=>u.invoiceReadOnly()||u.disableFields());this.invoicePostboxFieldLocked=ko.computed(()=>u.invoiceReadOnly()||u.disableFields());this.invoiceZipCodeFieldLocked=ko.computed(()=>u.invoiceReadOnly()||u.disableFields());this.invoiceCityFieldLocked=ko.computed(()=>u.invoiceReadOnly()||u.disableFields());this.orgnrFieldLocked=ko.computed(()=>u.readOnly()||u.disableFields());this.phoneFieldLocked=ko.computed(()=>u.readOnly()||u.disableFields()&&u.disableTelephoneno());this.firstNameFieldLocked=ko.computed(()=>u.readOnly()||u.disableFields()&&u.orgnr()==="");this.lastNameFieldLocked=ko.computed(()=>u.readOnly()||u.disableFields()&&u.orgnr()==="");this.epostFieldLocked=ko.computed(()=>u.isLoggedIn()||this.token!=null||u.disableFields()&&u.orgnr()==="");this.validateUniqueUsername=ko.computed(function(){if(t.UseBusinessAutofillBySearchRegisterForm&&!u.isLoggedIn()&&u.customerType()==="business")return!1;return t.IsCheckout&&(u.isLoggedIn()||u.readOnly())?!1:!0});this.onChangedCountry=function(n){const t=n.invoiceSelectedCountry();if(mcWeb.countrySelector!==undefined){mcWeb.countrySelector.selectedCountryByIdNoPageReload(t);const i=r.registrationVM.telephonePrefixes(),n=i.find(n=>n.LandId==t);n!==undefined&&r.registrationVM.telephoneLandId(n.LandId)}};this.validateAddress1Empty=ko.computed(function(){return u.address1Mandatory()?!t.SoftAdressValidation:!1},this);this.validateByPostbox=ko.computed(function(){if(!u.address1Mandatory())return!1;return u.postbox().length>0?!1:!0},this);this.clickShowPreviewHelp=function(){u.showPreviewHelp(!0)};this.clickHidePreviewHelp=function(){u.showPreviewHelp(!1)};this.clickViewLoginEmail=function(){PubSub.publish(mcWeb.customerRegistration.onRememberedUserNotMe,null);var n=new WebApiService("CustomerRegistration");n.GetAction("ChangeSessionToDefaultCustomer").then(function(n){n!=null&&(window.StorageService.sessionStorage.removeItem("authenticatedGuid"),window.location.href="/")})};this.clickLoginChangeAddress=function(){u.tempShowCustomerEdit=!0;PubSub.publish(mcWeb.loginCheckout.events.onShowLoginPassword,null)};this.clickLogin=function(){PubSub.publish(mcWeb.loginCheckout.events.onShowLoginPassword,null)};this.showCustomerType=ko.observable(t.ShowCustomerType);this.showRegButtons=function(t){var f=n("#privateActionButtons"),i,u;f.length>0&&(t==!0?f.fadeIn("slow"):f.hide());i=n(".registration-req-info");i.length>0&&(t==!0?i.fadeIn("slow"):i.hide());u=n("#McPaymentAddOrderbottom");u.length>0&&(t==!0?u.fadeIn("slow"):u.hide());t?r.conditionVM.isVisible(!0):r.conditionVM.isVisible(!1)};t.ShowCustomerType===!0&&u.showRegButtons(!1);this.clickPrivate=function(t,i){return i==null?!1:(n(".qtip").remove(),i.preventDefault(),i.stopPropagation(),u.showCustomerType(!1),u.showRegButtons(!0),u.customerType()!=="private"&&PubSub.publish(mcWeb.events.customerRegistration.onChangedCustomerType,0),!1)};this.clickBusiness=function(t,i){return i==null?!1:(n(".qtip").remove(),i.preventDefault(),i.stopPropagation(),u.showCustomerType(!1),u.showRegButtons(!0),u.customerType()!=="business"&&PubSub.publish(mcWeb.events.customerRegistration.onChangedCustomerType,1),!1)};this.clickNewDeliveryAddress=function(){PubSub.publish("DeliveryAddress.ShowCreateNew")};this.clickRemoveDeliveryAddress=function(){PubSub.publish("DeliveryAddress.RemoveSelectedAddress")};PubSub.subscribe("DeliveryAddress.ChangedSelectedDeliveryAddress",function(t,i){u.hasDefaultDeliveryAddressSelected()||i||!u.useDifferentDeliveryAddress()||n(r.id+" #otherDeliveryAddressContainer").slideUp();u.hasDefaultDeliveryAddressSelected(i)});u.hasDefaultDeliveryAddressSelected.subscribe(function(t){if(!u.useDifferentDeliveryAddress()||u.usingPorterbuddy()){n(r.id+" #otherDeliveryAddressContainer").slideUp();return}t?n(r.id+" #otherDeliveryAddressContainer").slideDown():n(r.id+" #otherDeliveryAddressContainer").slideUp()});u.showDeliveryAddress=ko.computed(function(){return r.settings.ShowExtraDeliveryAddresses&&!u.hasDefaultDeliveryAddressSelected()?!1:t.IsCheckout&&u.useDifferentDeliveryAddress()?!0:u.usingPorterbuddy()?t.IsCheckout?!1:!0:!0});this.clickChangeAddress=function(){var t,i,f;u.isLoggedIn&&(u.showCustomerType(!1),t=n(".preview-content"),i=t.height(),t.css("min-height",i+"px"),t.fadeOut(function(){u.readOnly(!1)}));f=!u.isLoggedIn()&&u.readOnly();r.registrationVM.deliveryAddressFormExpanded()&&!f?(r.registrationVM.useDifferentDeliveryAddressPrev(!0),r.registrationVM.useDifferentDeliveryAddress(!0)):!r.registrationVM.deliveryAddressFormExpanded()&&r.registrationVM.hasDefaultDeliveryAddressSelected()&&r.registrationVM.deliveryAddressFormExpanded(!0);r.settings.ShowExtraDeliveryAddresses&&u.useDifferentDeliveryAddress()&&u.isLoggedIn()&&(r.hasLoadedView?PubSub.publish("DeliveryAddress.ShowCurrentAddress",{targetSelector:"#vue-current-delivery-info",deleteTargetSelector:"#delivery-address-delete-info-placeholder",isDeleteActive:!u.hasDefaultDeliveryAddressSelected(),isPreview:!1,isReadOnly:r.registrationVM.settings.ExtraDeliveryaddressesReadOnly||!u.isLoggedIn(),RegistrationVM:r.registrationVM}):setTimeout(()=>{PubSub.publish("DeliveryAddress.ShowCurrentAddress",{targetSelector:"#vue-current-delivery-info",deleteTargetSelector:"#delivery-address-delete-info-placeholder",isDeleteActive:!u.hasDefaultDeliveryAddressSelected(),isPreview:!1,isReadOnly:r.registrationVM.settings.ExtraDeliveryaddressesReadOnly||!u.isLoggedIn(),RegistrationVM:r.registrationVM})},300))};this.selectedDealer=ko.observable(-1);this.availableDealers=ko.observableArray();this.onClickShowAllDealers=function(){var n=u.invoiceSelectedCountry(),t;u.showAllDealersChecked()?r.getAvailableDealers(n,"0"):(t=u.invoiceZipCode(),r.getAvailableDealers(n,t))};this.availableCountries=ko.observableArray();this.selectedCountry=ko.observable(1);this.selectedCountryName=ko.computed(function(){var n=ko.utils.arrayFirst(u.availableCountries(),function(n){return u.isLoggedIn()?n.LandId===u.landID():n.LandId===u.invoiceSelectedCountry()});if(n)return n.CountryName});this.telephonePrefixes=ko.observableArray();this.getTelephonePrefixText=function(n){return n.LandKode2.toUpperCase()+" +"+n.TlfPrefix};this.storeDeliveryAddress=ko.observable(!1);this.invoiceZipCode.subscribe(function(n){if(u.invoiceZipCodePrev()!=n){if(u.useDifferentDeliveryAddress()){u.invoiceZipCodePrev(n);u.invoiceZipCode(n);n.indexOf("*")==-1&&(u.invoiceCity()==null&&u.invoiceCity(""),u.getCity(u.invoiceCity,u.invoiceZipCode(),!1,u.invoiceSelectedCountry()));r.getAvailableDealers(u.invoiceSelectedCountry(),u.invoiceZipCode());return}if(n!=null&&n.length>=3){var t={zipCode:u.invoiceZipCode()};PubSub.publish(mcWeb.events.customerRegistration.onChangedZipCode,t)}}});this.delayedInvoiceAddress=ko.pureComputed(this.invoiceAddress).extend({rateLimit:{method:"notifyWhenChangesStop",t
1imeout:2e3}});this.delayedInvoiceAddress.subscribe(function(n){u.calculateCarrierEventByAddress()&&(u.useDifferentDeliveryAddress()||n!=null&&u.invoiceAddressPrev()!==n&&(u.invoiceAddressPrev(n),u.updateDeliveryZipCode(u.invoiceZipCode(),u.invoiceCity(),u.invoiceAddress(),u.invoiceAddress2(),u.invoiceAddress3())))});this.delayedAdressDelivery=ko.pureComputed(this.adressDelivery).extend({rateLimit:{method:"notifyWhenChangesStop",timeout:2e3}});this.delayedAdressDelivery.subscribe(function(n){u.calculateCarrierEventByAddress()&&u.useDifferentDeliveryAddress()&&n!=null&&u.adressDeliveryPrev()!==n&&(u.adressDeliveryPrev(n),u.updateDeliveryZipCode(u.postnrDelivery(),u.poststedDelivery(),u.adressDelivery(),u.adresstillegDelivery(),u.adresstilleg2Delivery()))});this.postnrDelivery.subscribe(function(n){if(u.postnrDeliveryPrev()!=n&&n!=null&&n.length>=3){var t={zipCode:u.postnrDelivery()};PubSub.publish(mcWeb.events.customerRegistration.onChangedZipCode,t)}});this.invoiceSelectedCountry.subscribe(function(){var n=u.invoiceSelectedCountry();!u.invoiceCountryId()||!u.landID()||u.landID()===u.invoiceCountryId()||(n=u.landID());u.setZipCodeMaskDelivery(n);u.setZipCodeMaskInvoice(u.invoiceSelectedCountry())});PubSub.subscribe(mcWeb.events.customerRegistration.onChangedUsePrintPackingList,function(n,t){(t===!0||t===!1)&&u.usePrintPackingList(t)});PubSub.subscribe(mcWeb.shipment.onSelectedShipmentForCustomerRefresh,function(t,i){i&&(u.locked(i.DeliveryAddressIsLocked),i.DeliveryAddressIsLocked&&(i.DeliveryAddressIsLocked?n(r.id+" #otherDeliveryAddressContainer").slideDown():u.useDifferentDelivery()||n(r.id+" #otherDeliveryAddressContainer").slideUp(),u.nameDelivery(i.nameDelivery==null?"":i.nameDelivery),u.adressDelivery(i.adressDelivery==null?"":i.adressDelivery),u.adresstillegDelivery(i.adresstillegDelivery==null?"":i.adresstillegDelivery),u.adresstilleg2Delivery(i.adresstilleg2Delivery==null?"":i.adresstilleg2Delivery),u.telephoneno(i.telephoneno==null?"":i.telephoneno),u.postnrDelivery(i.postnrDelivery==null?"":i.postnrDelivery),u.poststedDelivery(i.poststedDelivery==null?"":i.poststedDelivery),u.phoneDelivery(i.phoneDelivery==null?"":i.phoneDelivery),u.emailDelivery(i.emailDelivery==null?"":i.emailDelivery)))});PubSub.subscribe(mcWeb.events.customerRegistration.updateOrgNr,function(n,t){var i=r.registrationVM!==null&&r.registrationVM.orgnr()!==undefined&&r.registrationVM.orgnr()!==t;i&&r.registrationVM.orgnr(t)});PubSub.subscribe(mcWeb.events.customerRegistration.onChangeEmail,function(n,t){t&&r.registrationVM.epost(t)});this.useDifferentDeliveryAddress.subscribe(function(){var i,f=u.useDifferentDeliveryAddress()!=u.useDifferentDeliveryAddressPrev(),t;u.useDifferentDeliveryAddressPrev(u.useDifferentDeliveryAddress());u.useDifferentDeliveryAddress()?(u.hasDefaultDeliveryAddressSelected(!0),r.settings.ShowExtraDeliveryAddresses&&u.isLoggedIn()&&(r.hasLoadedView?PubSub.publish("DeliveryAddress.ShowCurrentAddress",{targetSelector:"#vue-current-delivery-info",deleteTargetSelector:"#delivery-address-delete-info-placeholder",isDeleteActive:!0,isPreview:!1,isReadOnly:r.registrationVM.settings.ExtraDeliveryaddressesReadOnly,RegistrationVM:r.registrationVM}):setTimeout(()=>{PubSub.publish("DeliveryAddress.ShowCurrentAddress",{targetSelector:"#vue-current-delivery-info",deleteTargetSelector:"#delivery-address-delete-info-placeholder",isDeleteActive:!0,isPreview:!1,isReadOnly:r.registrationVM.settings.ExtraDeliveryaddressesReadOnly,RegistrationVM:r.registrationVM})},300)),i=u.postnrDeliveryPrev(),u.usingPorterbuddy()||n(r.id+" #otherDeliveryAddressContainer").slideDown()):(u.hasDefaultDeliveryAddressSelected(!0),r.service.PostAction("ClearSelectedDeliveryAddress").then(n=>{n||console.log("ClearSelectedDeliveryAddress failed to update cart")}),i=u.invoiceZipCodePrev(),n(r.id+" #otherDeliveryAddressContainer").slideUp(),PubSub.publish("DeliveryAddress.ClearAndHideDeliveryAddress"),r.registrationVM.deliveryAddressFormExpanded(!1));f&&u.postnrDeliveryPrev()!=u.invoiceZipCodePrev()&&(u.invoiceZipCodePrev(""),u.postnrDeliveryPrev(""),t={zipCode:i},PubSub.publish(mcWeb.events.customerRegistration.onChangedZipCode,t),t=r.registrationVM.getJsonData(),t.isLoggedIn&&(t.useSoftlog=!1,u.tempShowCustomerEdit=!0),t.skipDeliveryAddressInit=!0,PubSub.publish(mcWeb.events.customerRegistration.onChangedCustomerData,t))});PubSub.subscribe("EniroResultSelected",function(n,i){t.UseBusinessAutofillBySearchRegisterForm?u.applyResultValues(i):u.applyEniroResultValuesToRegistrationViewModel(i)});this.applyResultValues=function(n){const t={orgNr:n.OrgNo};r.service.GetAction("IsCustomerRegisteredByOrganisationNumber",t).then(function(n){u.customerExist(n.Exist);u.customerExistsdialog(n.Line1);u.customerCareLink(n.CustomerCareLink);u.avsAdresseID(n.AvsAdresseID)});u.adress(n.StreetAddress);u.invoiceZipCodePrev("");u.invoiceZipCode(n.PostCode);u.invoiceCity(n.Location);u.orgnr(n.OrgNo);u.disableTelephoneno(!1);n.SelectedPhone()?u.telephoneno(n.SelectedPhone().replace(/ /g,"")):u.telephoneno(n.Telephone.length>0?n.Telephone[0].replace(/\s+/g,""):"");u.checkTelephoneno()&&u.disableTelephoneno(!0);u.companyName(n.LastName);u.invoiceCompanyName(n.LastName);u.invoiceAddress(n.StreetAddress);u.invoiceAddressPrev(n.StreetAddress);u.invoiceZipCode(n.PostCode);u.invoiceCity(n.Location)};this.checkTelephoneno=function(){if(u.telephoneno()==="")return!1;var n=u.telephoneno().replace(/ /g,""),t=n.length;return t<8||t>30?!1:t==8&&!/^\d+$/.test(n)?!1:t>8&&!/^\d+$/.test(n.substr(n.length-6))?!1:!0};PubSub.subscribe(mcWeb.events.customerRegistration.onChangedCustomerData,function(n,i){i!=null&&((i.isLoggedIn!=undefined&&(u.isLoggedIn(i.isLoggedIn),u.isLoggedIn()===!0&&(r.registrationVM.deliveryAddressFormExpanded()?u.showCustomerType(!0):u.showCustomerType(!1))),t.IsPorterbuddy||i.epost===null||u.epostCustomer(i.epost.toLowerCase()),u.readOnly(i.useSoftlog),u.locked(i.LockedDelivery),r.registrationVM.showRegTypes(),u.popuateModelFromLoggedInCustomer(i),i.experianBetBetId&&i.experianBetBetId!==0&&u.customerType("undefined"),i.customerType==="private"?PubSub.publish(mcWeb.events.customerRegistration.onChangedCustomerType,0):i.customerType==="business"&&PubSub.publish(mcWeb.events.customerRegistration.onChangedCustomerType,1),u.hasDefaultDeliveryAddressSelected())||r.settings.ShowExtraDeliveryAddresses&&(i.skipDeliveryAddressInit===undefined||!i.skipDeliveryAddressInit)&&(r.hasLoadedView?PubSub.publish("DeliveryAddress.ShowCurrentAddress",{targetSelector:r.getTeleportTargetLocation(i.isLoggedIn),deleteTargetSelector:r.getTeleportDeleteTargetLocation(i.isLoggedIn),isDeleteActive:!1,isPreview:!u.deliveryAddressFormExpanded()||r.registrationVM.settings.ExtraDeliveryaddressesReadOnly||i.use
1Softlog,isReadOnly:r.registrationVM.settings.ExtraDeliveryaddressesReadOnly||!i.isLoggedIn,RegistrationVM:r.registrationVM}):setTimeout(()=>{PubSub.publish("DeliveryAddress.ShowCurrentAddress",{targetSelector:r.getTeleportTargetLocation(i.isLoggedIn),deleteTargetSelector:r.getTeleportDeleteTargetLocation(i.isLoggedIn),isDeleteActive:!1,isPreview:!u.deliveryAddressFormExpanded()||r.registrationVM.settings.ExtraDeliveryaddressesReadOnly||i.useSoftlog,isReadOnly:r.registrationVM.settings.ExtraDeliveryaddressesReadOnly||!i.isLoggedIn,RegistrationVM:r.registrationVM})},300)))});r.getTeleportTargetLocation=function(n){return r.settings.DeliveryAddressFormExpanded&&!(!n&&r.settings.ReadOnly)?"#vue-current-delivery-info":"#vue-teleport-loc-preview-delivery-address"};r.getTeleportDeleteTargetLocation=function(n){return r.settings.DeliveryAddressFormExpanded&&!(!n&&r.settings.ReadOnly)?"#delivery-address-delete-info-placeholder":"#vue-teleport-loc-preview-delivery-address"};this.updateDeliveryZipCode=function(n,t,i,u,f){var e,o;n!=null&&(e={zipCode:n,city:t===undefined?null:t,address1:i===undefined?null:i,address2:u===undefined?null:u,address3:f===undefined?null:f,isCheckout:r.settings.IsCheckout},PubSub.publish(mcWeb.payments.events.onShowUpdateIcon,null),o=new WebApiService("Cart"),o.GetAction("UpdateDeliveryZipCode",e).then(function(n){(PubSub.publish(mcWeb.payments.events.onHideUpdateIcon,null),n!=null)&&PubSub.publish(mcWeb.shipment.events.reloadShipment,"")}))};PubSub.subscribe(mcWeb.events.customerRegistration.onChangedZipCode,function(n,t){var i,s,o,f;if(t&&(i=t.zipCode,i!=null)){if(s=e(t),o=null,u.useDifferentDeliveryAddress()||u.usingPorterbuddy()&&r.settings.IsCheckout){if(u.postnrDeliveryPrev()===i)return;u.postnrDeliveryPrev(i);u.postnrDelivery(i);f=u.landID();i.indexOf("*")==-1&&(u.poststedDelivery()==null&&u.poststedDelivery(""),(!u.isLoggedIn()||u.usingPorterbuddy())&&(f=u.invoiceSelectedCountry()),o=u.getCity(u.poststedDelivery,u.postnrDelivery(),!0,f,s),r.getAvailableDealers(f,i));o!==null?o.then(function(){u.updateDeliveryZipCode(i,u.poststedDelivery(),u.adressDelivery(),u.adresstillegDelivery(),u.adresstilleg2Delivery());var n={zipCode:u.postnrDelivery()};PubSub.publish(mcWeb.events.customerRegistration.onChangedZipCode,n);PubSub.publish(mcWeb.events.customerRegistration.onChangedCity,u.poststedDelivery())}):u.updateDeliveryZipCode(i,u.poststedDelivery(),u.adressDelivery(),u.adresstillegDelivery(),u.adresstilleg2Delivery());return}if(u.invoiceZipCodePrev()!==i){u.invoiceZipCodePrev(i);u.invoiceZipCode(i);i.indexOf("*")==-1&&(u.invoiceCity()==null&&u.invoiceCity(""),f=u.invoiceSelectedCountry(),t.land
1Id&&(f=t.landId),o=u.getCity(u.invoiceCity,u.invoiceZipCode(),!1,f,s));r.getAvailableDealers(f,i);o!==null?o.then(function(){u.updateDeliveryZipCode(i,u.invoiceCity(),u.invoiceAddress(),u.invoiceAddress2(),u.invoiceAddress3());var n={zipCode:u.invoiceZipCode()};PubSub.publish(mcWeb.events.customerRegistration.onChangedZipCode,n);PubSub.publish(mcWeb.events.customerRegistration.onChangedCity,u.invoiceCity())}):u.updateDeliveryZipCode(i,u.invoiceCity(),u.invoiceAddress(),u.invoiceAddress2(),u.invoiceAddress3());return}}});PubSub.subscribe(mcWeb.events.customerRegistration.onChangedCustomerType,function(n,i){(typeof u.customerType()=="undefined"||i!==0||u.customerType()!=="private")&&(typeof u.customerType()=="undefined"||i!==1||u.customerType()!=="business")&&(PubSub.publish(mcWeb.payments.events.onShowUpdateIcon,null),r.service.GetAction("SetCustomerType",{customerType:i}).then(function(n){if(n==null||n.length<1){alert("Error - Can't select select cutomer type");return}i===0?(r.loadPrivateView(),u.isLoggedIn()||u.readOnly()||u.blockedCustomer(t.BlockedPrivateCustomer)):(r.loadBusinessView(),u.isLoggedIn()||u.readOnly()||u.blockedCustomer(t.BlockedBusinessCustomer));u.blockedCustomer()===!0&&mcWeb.checkout!==undefined&&PubSub.publish(mcWeb.checkout.events.onShowSendOrder,{showBtn:!1,disabledBtn:!0});PubSub.publish(mcWeb.shipment.events.reloadShipment,null);PubSub.publish(mcWeb.payments.events.reloadPayments,null);u.usingPorterbuddy()&&t.IsCheckout&&porterbuddy!==undefined&&porterbuddy.refresh&&porterbuddy.refresh()}))});this.getCity=function(n,t,i,f,e){if(t==null||t.length<3)return PubSub.publish(mcWeb.payments.events.onHideUpdateIcon,null),null;var o={zipCode:t,landId:f,landKode:e};return r.service.GetAction("GetCity",o).then(function(t){if(PubSub.publish(mcWeb.payments.events.onHideUpdateIcon,null),i===!0&&PubSub.publish(mcWeb.events.customerRegistration.onChangedCity,t),t==null||t.length<1){u.cityDoesNotMatch=!0;return}return n(t),u.cityDoesNotMatch=!1,t})};this.setZipCodeMaskInvoice=function(n){var t="#zipCode";jQuery(t).length<1||(u.zipCodeMask!==null&&u.zipCodeMask.destroy(),n>4)||getLibrary("cleave").then(()=>{n===2?u.zipCodeMask=new Cleave(t,{blocks:[3,2],numericOnly:!0}):n===4?u.zipCodeMask=new Cleave(t,{blocks:[5],numericOnly:!0}):(n===1||n===3)&&(u.zipCodeMask=new Cleave(t,{blocks:[4],numericOnly:!0}))})};this.setZipCodeMaskDelivery=function(n){var t="#levZzipCode";jQuery(t).length<1||(u.zipCodeDeliveryMask!==null&&u.zipCodeDeliveryMask.destroy(),n>4)||getLibrary("cleave").then(()=>{n===2?u.zipCodeDeliveryMask=new Cleave(t,{blocks:[3,2],numericOnly:!0}):n===4?u.zipCodeDeliveryMask=new Cleave(t,{blocks:[5],numericOnly:!0}):(n===1||n===3)&&(u.zipCodeDeliveryMask=new Cleave(t,{blocks:[4],numericOnly:!0}))})};this.checkPostnr=function(n){var t={zipCode:n};return r.service.GetAction("GetCity",t)};this.tryRegisterCustomer=function(n,t){var i={isFunctionalConditionAccepted:r.conditionsStatus.isFunctionalConditionAccepted,acceptDocuments:r.conditionsStatus.acceptDocuments(),usageArea:r.conditionsStatus.usageArea};(r.conditionsStatus==null||r.conditionsStatus.acceptDocuments==null||r.conditionsStatus.acceptDocuments().length<=0)&&(i.isFunctionalConditionAccepted(!0),r.registrationVM.registerCustomer(i,t));r.conditionsStatus.isFunctionalConditionAccepted()?r.registrationVM.registerCustomer(i,t):r.conditionVM.highlightRequired()};this.RequestAccessMail=function(){n("#UpdateIcon").show();const t={CompanyName:u.companyName(),Orgnr:u.orgnr(),Firstname:u.firstName(),Lastname:u.lastName(),Email:u.epost(),Telephoneno:u.telephoneno(),AvsAdresseId:u.avsAdresseID()};u.validate().then(function(i){i&&!!i.success?mcWeb.customerRegistration.lightbox.SendRequestAccessMail(t):n("#UpdateIcon").hide()})};this.registerCustomer=function(i,f){n("#UpdateIcon").show();u.epost()!=null&&u.epost(u.epost().toLowerCase());u.adress()||u.adress(u.invoiceAddress());u.adresstilleg()||u.adresstilleg(u.invoiceAddress2());u.adresstilleg2()||u.adresstilleg2(u.invoiceAddress3());u.postnr()||u.postnr(u.invoiceZipCode());u.poststed()||u.poststed(u.invoiceCity());u.validate().then(function(e){t.UseBusinessAutofillBySearchRegisterForm&&r.service.GetAction("IsUsern
1ameNewGetAvsender",{username:u.epost()}).then(function(t){if(t&&t.AvsAdresseID>0){u.customerExist(t.Exist);u.customerExistsdialog(t.Line1);u.customerCareLink(t.CustomerCareLink);u.avsAdresseID(t.AvsAdresseID);n("#UpdateIcon").hide();return}});e&&!!e.success&&t.ShowAvsAdresseSelectionInRegistration&&r.registrationVM.customerType()==="business"&&u.selectedDealer()=="-1"&&(e.success=!1,e.message=mcWeb.validation.getErrorMessage("VALIDATION,DealerNotSelected"));e&&!!e.success?(mcWeb.customerRegistration.lightbox.sendRegistrationRequest(u,i,f.target),window.dataLayer=window.dataLayer||[],dataLayer.push({event:"RegisterNewUser"})):(mcWeb.validation.qTipActionShow(f.target,e.message),n("#UpdateIcon").hide())})};this.popuateModelFromLoggedInCustomer=function(n){if(n!=null){u.firstName(n.firstName==null?"":n.firstName);u.lastName(n.lastName==null?"":n.lastName);u.postbox(n.postbox==null?"":n.postbox);u.adress(n.adress==null?"":n.adress);u.adresstilleg(n.adresstilleg==null?"":n.adresstilleg);u.adresstilleg2(n.adresstilleg2==null?"":n.adresstilleg2);u.postnrPrev(n.postnr==null?"":n.postnr);u.postnr(n.postnr==null?"":n.postnr);u.poststed(n.poststed==null?"":n.poststed);(n.epost!=null&&u.epost()!=null||u.epost()!="")&&u.epost(n.epost==null?"":n.epost.toLowerCase());u.landID(n.landID);u.telephoneno(n.telephoneno==null?"":n.telephoneno);u.isLoggedIn()&&u.receiveoffers(n.receiveoffers);u.nameDelivery(n.nameDelivery==null?"":n.nameDelivery);u.usingPorterbuddy()||u.adressDelivery(n.adressDelivery==null?"":n.adressDelivery);u.adressDeliveryPrev(n.adressDelivery==null?"":n.adressDelivery);u.adresstillegDelivery(n.adresstillegDelivery==null?"":n.adresstillegDelivery);u.adresstilleg2Delivery(n.adresstilleg2Delivery==null?"":n.adresstilleg2Delivery);u.phoneDelivery(n.phoneDelivery==null?n.telephoneno==null||n.LockedDelivery?"":n.telephoneno:n.phoneDelivery);u.emailDelivery(n.emailDelivery==null?"":n.emailDelivery);u.usingPorterbuddy()||(u.postnrDeliveryPrev(n.postnrDelivery==null?"":n.postnrDelivery),u.postnrDelivery(n.postnrDelivery==null?"":n.postnrDelivery),u.poststedDelivery(n.poststedDelivery==null?"":n.poststedDelivery));u.hideOrgnrSsn(n.hideOrgnrSsn==null?"false":n.hideOrgnrSsn);u.hideExperianBetBet(n.hideExperianBetBet==null?"false":n.hideExperianBetBet);u.experianBetBetId(n.experianBetBetId==null?"":n.experianBetBetId);u.country(n.country==null?"":n.country);n.customerType==="business"&&(u.companyName(n.companyName==null?"":n.companyName),u.orgnr(n.orgnr==null?"":n.orgnr),u.invoiceCompanyName(u.companyName()));u.invoiceAddress(n.invoiceAddress==null?"":n.invoiceAddress);u.invoiceAddressPrev(n.invoiceAddress==null?"":n.invoiceAddress);u.invoiceAddress2(n.invoiceAddress2==null?"":n.invoiceAddress2);u.invoiceAddress3(n.invoiceAddress3==null?"":n.invoiceAddress3);u.invoicePOBox(n.invoicePOBox==null?"":n.invoicePOBox);u.invoiceZipCodePrev(n.invoiceZipCode==null?"":n.invoiceZipCode);u.invoiceZipCode(n.invoiceZipCode==null?"":n.invoiceZipCode);u.invoiceCity(n.invoiceCity==null?"":n.invoiceCity);u.invoiceCountryId(n.invoiceCountryId==null?"1":n.invoiceCountryId);u.invoiceCountry(n.invoiceCountry==null?"":n.invoiceCountry);n.invoiceCountryId!=null&&n.invoiceCountryId!==0&&u.invoiceSelectedCountry(n.invoiceCountryId);n.readonlyInvoiceAddress!=undefined&&(u.readonlyInvoiceAddress=n.readonlyInvoiceAddress);n.landID!=n.invoiceCountryId||n.readonlyInvoiceAddress||u.readonlyInvoiceAddress?u.invoiceReadOnly(!0):u.invoiceReadOnly(!1);u.forceInvoiceReadOnly()&&u.invoiceReadOnly(!0);u.usingPorterbuddy()||(u.useDifferentDeliveryAddressPrev(n.useDifferentDeliveryAddress),u.useDifferentDeliveryAddress(n.useDifferentDeliveryAddress));var i=u.useDifferentDeliveryAddress()?u.postnrDelivery():u.invoiceZipCode(),f={zipCode:i};PubSub.publish(mcWeb.events.customerRegistration.onChangedZipCode,f);
1n.usePrintPackingList!==!0&&n.usePrintPackingList!==!1||n.emptyCustomer||PubSub.publish(mcWeb.events.customerRegistration.onChangedUsePrintPackingList,n.usePrintPackingList);n.emptyCustomer?u.blockedCustomer(u.customerType()==="private"?t.BlockedPrivateCustomer:t.BlockedBusinessCustomer):(t.BlockedBusinessCustomer=!1,t.BlockedPrivateCustomer=!1,u.blockedCustomer(n.blockedCustomer));u.blockedCustomer()==!0&&PubSub.publish(mcWeb.checkout.events.onShowSendOrder,{showBtn:!1,disabledBtn:!0});u.tempShowCustomerEdit===!0?(u.tempShowCustomerEdit=!1,u.isLoggedIn()&&u.readOnly(!1)):u.readOnly(n.useSoftlog||u.isLoggedIn());r.registrationVM.deliveryAddressFormExpanded()&&u.isLoggedIn()&&u.clickChangeAddress()}};this.applyEniroResultValuesToRegistrationViewModel=function(n){u.customerType()!=="business"&&(u.firstName(n.FirstName),u.lastName(n.LastName));u.adress(n.StreetAddress);u.invoiceZipCodePrev("");u.invoiceZipCode(n.PostCode);u.invoiceCity(n.Location);u.orgnr(n.OrgNo);n.SelectedPhone()?u.telephoneno(n.SelectedPhone().replace(/ /g,"")):u.telephoneno(n.Telephone.length>0?n.Telephone[0].replace(/\s+/g,""):"");u.companyName(n.LastName);u.invoiceCompanyName(n.LastName);u.invoiceAddress(n.StreetAddress);u.invoiceAddressPrev(n.StreetAddress);u.invoiceZipCode(n.PostCode);u.invoiceCity(n.Location);u.validateModel()};this.getConditionsData=function(n){var r,u,t,f;if(n!=null&&n!=undefined){if(r=[],n.acceptDocuments!=null&&n.acceptDocuments.length>0)for(u=n.acceptDocuments,i=0;i<u.length;i++)t=u[i],f={Accepted:t.Accepted,DocUsageID:t.DocUsageID,DocumentID:t.DocumentID,RevDataID:t.RevDataID,FunctionReferenceString:t.FunctionReferenceString},r.push(f);return r}return null};this.getJsonData=function(n){var e=u.epost(),o="",s,h,l,i,f;e!==null&&e!==undefined&&(o=e.toLowerCase());u.isLoggedIn()||!u.readOnly()||u.usingPorterbuddy()||(o=u.epostCustomer().toLowerCase());s=u.getConditionsData(n);h=mcWeb.currentUser.getAuthenticationGUID();const a=u.telephoneLandId(),v=r.registrationVM.telephonePrefixes(),c=v.find(n=>n.LandId==a),y=c!==undefined?c.TlfPrefix:"";return l=(r.settings.ShowCountrySelectionInRegistration&&!u.isLoggedIn()?"+"+y:"")+u.telephoneno(),i={firstName:u.firstName(),lastName:u.lastName(),postbox:u.postbox(),adress:u.adress(),adresstilleg:u.adresstilleg(),adresstilleg2:u.adresstilleg2(),postnr:u.invoiceZipCode(),poststed:u.invoiceCity(),epost:o.toLowerCase(),epostCustomer:u.epostCustomer(),telephoneno:l,receiveoffers:u.receiveoffers(),useDifferentDeliveryAddress:u.useDifferentDelivery(),nameDelivery:u.nameDelivery(),adressDelivery:u.adressDelivery(),adresstillegDelivery:u.adresstillegDelivery(),adresstilleg2Delivery:u.adresstilleg2Delivery(),phoneDelivery:u.phoneDelivery(),postnrDelivery:u.postnrDelivery(),poststedDelivery:u.poststedDelivery(),contactPerson:u.contactPerson(),companyName:u.companyName(),customerType:u.customerType(),orgnr:u.orgnr(),landID:u.landID(),storeDeliveryAddress:u.storeDeliveryAddress(),birthDate:u.birthDate(),discountCode:u.discountCode(),usePrintPackingList:u.usePrintPackingList(),useSoftlog:u.readOnly(),isLoggedIn:u.isLoggedIn(),blockedCustomer:u.blockedCustomer(),LockedDelivery:u.locked(),invoiceCompanyName:u.invoiceCompanyName(),invoiceAddress:u.invoiceAddress(),invoiceAddress2:u.invoiceAddress2(),invoiceAddress3:u.invoiceAddress3(),invoicePOBox:u.invoicePOBox(),invoiceZipCode:u.invoiceZipCode(),invoiceCity:u.invoiceCity(),invoiceCountryId:u.invoiceSelectedCountry(),invoiceCountry:u.invoiceCountry(),invoiceReadOnly:u.invoiceReadOnly(),acceptDocuments:s,AuthenticationGuid:h,readonlyInvoiceAddress:u.readonlyInvoiceAddress,token:u.token,emailDelivery:u.emailDelivery(),selectedDealer:u.selectedDealer()},u.usingPorterbuddy()&&t.IsCheckout&&(f=r.registrationVM.deliveryWindow(),i.deliveryWindow={start:f.start,end:f.end,token:f.token,expiresAt:f.expiresAt}),i.adress||(i.adress=i.invoiceAddress),i.adresstilleg||(i.adresstilleg=i.invoiceAddress2),i.adresstilleg2||(i.adresstilleg2=i.invoiceAddress3),i.landID===0&&(i.landID=i.invoiceCountryId),i};this.useDifferentDelivery=function(){return!t.IsCheckout&&u.customerType()==="private"?!1:u.useDifferentDeliveryAddress()};this.getErrorMessage=function(n,t){for(var i=0;i<u.errorMessages.length;i++)if(u.errorMessages[i].elem===n&&u.errorMessages[i].rule==t)return u.errorMessages[i].text};this.getErrorMessages=function(){var i,f=[],n,t,r=0;mcWeb.validation.getErrorMessages(u.validationRules).then(function(e){var o;for(i=e,n=0;n<u.validationRules.length;n++)for(o=u.validationRules[n].element,t=0;t<u.validationRules[n].rules.length;t++){var h=u.validationRules[n].rules[t],c=h.rule,s="";r<i.length&&(s=i[r].Value);f.push({elem:o,rule:c,text:s});r++}u.errorMessages=f})};this.validate=function(){return u.validateModel().then(function(t){var i={success:!1,message:"",invalidElements:[]};return u.lastValidationResult=t,t.every(mcWeb.validation.elementIsValid)?!u.settings.SoftAdressValidation||u.adress()||u.
1invoiceAddress()||u.addressWarningFlag!=0?i.success=!0:(i.message=n(".text-street-address-missing").html(),u.addressWarningFlag=1,u.clickChangeAddress()):(t.forEach(function(n){n.valid||i.invalidElements.push(n)}),i.message=n("#validation-error-text").html()),i})};this.validateModel=function(){n(".qtip").remove();var t,i=mcWeb.validation.validateModel(u.validationRules);const r=u.hasDefaultDeliveryAddressSelected();return i.then(function(n){for(t=0;t<n.length;t++)if(n[t].valid){mcWeb.validation.setValidCss(n[t].elem);continue}else{mcWeb.validation.removeValidCss(n[t].elem);mcWeb.validation.addErrorClass(n[t].elem);mcWeb.validation.qTipActionShow(n[t].elem,u.getErrorMessage(n[t].elem,n[t].rule));break}return n}).then(function(n){if(r)return n;let t=u.listDeliveryAddressValidation();if(t!==null){let i=!1;t.forEach(function(t){n.push(t);i||t.valid||(mcWeb.validation.qTipActionShowClickHide(t.elem,t.message),i=!0)})}return n})};this.validateElement=function(n,t){mcWeb.validation.validateElement(u.validationRules,t.target).then(function(n){n.valid?mcWeb.validation.setValidCss(t.target):mcWeb.validation.removeValidCss(t.target)})};this.validateOrgNr=function(){return!0};this.validateTel=function(){if(u.readOnly())return!0;var n=u.telephoneno().replace(/ /g,""),t=n.length;return r.settings.ShowCountrySelectionInRegistration&&/\+/.test(n)?!1:t<8||t>30?!1:t==8&&!/^\d+$/.test(n)?!1:t>8&&!/^\d+$/.test(n.substr(n.length-6))?!1:!0};this.validatePhoneDelivery=function(){var n,t;return u.readOnly()?!0:(n=u.phoneDelivery(),n===undefined||n===null)?!1:(n=n.replace(/ /g,""),t=n.length,t<8||t>30)?!1:t==8&&!/^\d+$/.test(n)?!1:t>8&&!/^\d+$/.test(n.substr(n.length-6))?!1:!0};this.validateEmailDelivery=function(){return u.emailDelivery()==null?!1:u.emailDelivery().length<=0?!1:u.isEmail(u.emailDelivery())};this.isEmail=function(n){if(n===undefined||n===null)return!1;if(n=n.toLowerCase(),r.settings.InvalidEmailExtensions&&r.settings.InvalidEmailExtensions.length>0)for(var t=0;t<r.settings.InvalidEmailExtensions.length;t++)if(n.endsWith(r.settings.InvalidEmailExtensions[t]))return!1;return/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/.test(n)};this.requireLogin=function(){if(u.isLoggedIn())return!1;var n=!1;return u.lastValidationResult.forEach(function(t){t.rule==="usernameUnique"&&(n=t.valid)}),!n};this.showRegTypes=function(){(r.registrationVM.isLoggedIn()||r.registrationVM.readOnly()||!r.registrationVM.hasCartItems())&&t.IsCheckout||n(".registration-type").show()};PubSub.subscribe(mcWeb.login.events.onIsloggedIn,function(n,t){u.isLoggedIn(t);t==!0&&u.readOnly(!1);r.registrationVM.showRegTypes()})};PubSub.subscribe(mcWeb.cart.events.hasCartItems,function(n,t){r.registrationVM.hasCartItems(t)})}};mcWeb.customerRegistration.lightbox=new function(){var n=jQuery,t=this;t.service=new WebApiService("CustomerRegistration");this.load=function(i){PubSub.publish(mcWeb.lightbox.events.onShowSpinicon);n("#lightbox-placeholder").load("/Webpages/ViewProvider.aspx?view=LightboxCustomerRegistration",function(){if(!(n("#lightboxCustomerRegistration").length<1)){var r="lightboxCustomerRegistration";loadModule(mcWeb.customerRegistration,r,r,null,i);t.activateView();PubSub.publish(mcWeb.lightbox.events.onHideSpinicon);!mcWeb.inlineEditor||mcWeb.inlineEditor.init(!0)}})};this.activateView=function(){PubSub.publish(mcWeb.lightbox.events.modifyOptions,{backdrop:"static"})};this.loadPrivateConfirmation=function(){PubSub.publish(mcWeb.lightbox.events.onShowSpinicon);mcWeb.customerRegistration.lightbox.clearEntireRegistrationContainer();n("#lightbox-placeholder").load("/Webpages/Kunde/PrivateCustomerRegistrationConfirmationView.aspx",function(){(PubSub.publish(mcWeb.lightbox.events.onHideSpinicon),n("#lightbox-placeholder").length<1)||!mcWeb.inlineEditor||mcWeb.inlineEditor.init(!0)})};this.loadBusinessConfirmation=function(){PubSub.publish(mcWeb.lightbox.events.onShowSpinicon);mcWeb.customerRegistration.lightbox.clearEntireRegistrationContainer();n("#lightbox-placeholder").load("/Webpages/Kunde/BusinessCustomerRegistrationConfirmationView.aspx",function(){(PubSub.publish(mcWeb.lightbox.events.onHideSpinicon),n("#lightbox-placeholder").length<1)||!mcWeb.inlineEditor||mcWeb.inlineEditor.init(!0)})};this.loadClosedBusinessConfirmation=function(){mcWeb.customerRegistration.lightbox.clearEntireRegistrationContainer();n("#lightbox-placeholder").load("/Webpages/Kunde/BusinessCustomerClosedRegistrationConfirmationView.aspx",function(){(PubSub.publish(mcWeb.lightbox.events.onHideSpinicon),n("#lightbox-placeholder").length<1)||!mcWeb.inlineEditor||mcWeb.inlineEditor.init(!0)})};this.clearEntireRegistrationContainer=function(){n("#lightbox-placeholder").children().remove()};this.handleLoadingConfirmationPage=function(n,t){switch(n.customerType()){case"private":mcWeb.customerRegistration.lightbox.loadPrivateConfirmation();break;case"business":window.nyKundeSperret==="True"?mcWeb.customerRegistration.lightbox.loadClosedBusinessConfirmation():mcWeb.customerRegistration.lightbox.loadBusinessConfirmation()}window.StorageService.localStorage.removeItem("remember");n.epost()!==mcWeb.currentUser.getUser()&&mcWeb.currentUser.setUser(n.epost());t.AuthenticatedGuid!==mcWeb.currentUser.getAuthenticationGUID()&&mcWeb.currentUser.setAuthenticationGUID(t.AuthenticatedGuid)};this.SendRequestAccessMail=function(i){t.service.PostAction("SendRequestAccessMail",i).then(function(t){t?mcWeb.customerRegistration.lightbox.loadAccessRequestSent():console.log("SendRequestAccessMail fail");n("#UpdateIcon").hide()})};this.sendRegistrationRequest=function(i,r,u){var f=i.getJsonData(r);f.invoiceCountryId!==0&&(f.landID=f.invoiceCountryId);t.service.PostAction("Register",f).then(function(t){if(t!=null&&t.ReturnCode==="Success")i.token!=null?location.href="/":mcWeb.customerRegistration.lightbox.handleLoadingConfirmationPage(i,t,r);else{var f=n("#reg-error-text").html();t.ErrorMessageSpecified&&(f='<i class="icon-attention"><\/i>'+t.ErrorMessage);mcWeb.validation.qTipActionShow(u,f,!1)}n("#UpdateIcon").hide()})};this.loadAccessRequestSent=function(){mcWeb.customerRegistration.lightbox.clearEntireRegistrationContainer();n("#lightbox-placeholder").load("/Webpages/Kunde/BusinessCustomerRequestAccessSent.aspx",function(){(PubSub.publish(mcWeb.lightbox.events.onHideSpinicon),n("#lightbox-placeholder").length<1)||!mcWeb.inlineEditor||mcWeb.inlineEditor.init(!0)})}}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.