1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[61746],{746:(e,t,i)=>{i.r(t),i.d(t,{default:()=>r});class r extends window.PluginBaseClass{init(){}registerEvents(){this.accountTypeSelectBox.addEventListener("change",this.onAccountTypeChange.bind(this))}onAccountTypeChange(){this.handleCustomerComment(),this.handleCompany(),this.handleVatId(),this.handleDepartment()}handleCompany(){if(!this.companyField)return;let e=this.options.pluginConfig.customerGroupsRequiredFieldCompany,t=this.options.pluginConfig.registerRequiredFieldCompany;this._handleContactField(this.companyField,t,e)}handleDepartment(){if(!this.departmentField)return;let e=this.options.pluginConfig.customerGroupsRequiredFieldDepartment,t=this.options.pluginConfig.registerRequiredFieldDepartment;this._handleContactField(this.departmentField,t,e)}handleVatId(){if(!this.vatIdsField)return;let e=this.isVatIdRequiredForCurrentCountry(),t=this.options.pluginConfig.customerGroupsRequiredFieldVatId,i=this.options.pluginConfig.registerRequiredFieldVatId;this._handleContactField(this.vatIdsField,i,t,e)}handleCustomerComment(){if(!this.customerCommentField)return;let e=this._getCurrentAccountType(),t=this.options.pluginConfig.customerGroupsRequiredFieldCommentOnRegistration,i=this.options.pluginConfig.displayCommentOnRegistration&&this.options.pluginConfig.isCommentOnRegistrationRequired,r=this.isArrayEmptyOrNull(t),n=this.includesInArrayIfArrayNotEmpty(t,e)||r;this._toggleRequiredAttributeFor(this.customerCommentField,i&&n)}_toggleRequiredAttributeFor(e,t){e.toggleAttribute("required",t),this._setRequiredForLabel(e,t)}_setRequiredForLabel(e,t){let i=document.querySelector('label[for="'.concat(e.id,'"]'));i&&(t?i.textContent.trim().endsWith("*")||(i.textContent=i.textContent.trimEnd()+"*"):i.textContent=i.textContent.trimEnd().replace(/\*$/,"").trim())}isArrayEmptyOrNull(e){return!e||0===e.length}includesInArrayIfArrayNotEmpty(e,t){return!this.isArrayEmptyOrNull(e)&&e.includes(t)}_getCurrentAccountType(){return this.accountTypeSelectBox?this.accountTypeSelectBox.value:this.options.defaultAccountType}_getFirstElementFromDom(e){return e.map(e=>document.querySelector(e)).find(e=>e)||null}_handleContactField(e,t,i){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!e)return;if(r){this._toggleRequiredAttributeFor(e,!0);return}if(!t){this._toggleRequiredAttributeFor(e,!1);return}let n=this.options.pluginConfig.businessFormCustomerGroups,o=this._getCurrentAccountType();if("business"===o){this._toggleRequiredAttributeFor(e,t);return}if(!this.isArrayEmptyOrNull(i)){let t=this.includesInArrayIfArrayNotEmpty(i,o);this._toggleRequiredAttributeFor(e,t);return}let s=this.includesInArrayIfArrayNotEmpty(n,o);this._toggleRequiredAttributeFor(e,s)}isVatIdRequiredForCurrentCountry(){let e=document.getElementById("billingAddressAddressCountry");if(!e)return!1;let t=e.options[e.selectedIndex];return!!t&&t.hasAttribute("data-vat-id-required")&&"1"===t.getAttribute("data-vat-id-required")}constructor(...e){super(...e);let t=this.options.defaultFields;if(this.accountTypeSelectBox=this._getFirstElementFromDom(t.accountTypeSelectBoxSelectors),!this.accountTypeSelectBox)return;this.customerCommentField=document.getElementById(t.customerComment),this.companyField=document.getElementById(t.company),this.departmentField=document.getElementById(t.department),this.vatIdsField=document.getElementById(t.vatId),this.onAccountTypeChange(),this.registerEvents()}}r.options={defaultAccountType:null,pluginConfig:{customerGroupsRequiredFieldCompany:[],registerRequiredFieldCompany:!1,customerGroupsRequiredFieldDepartment:[],registerRequiredFieldDepartment:!1,customerGroupsRequiredFieldVatId:[],registerRequiredFieldVatId:!1,customerGroupsRequiredFieldCommentOnRegistration:[],displayCommentOnRegistration:!1,isCommentOnRegistrationRequired:!1,businessFormCustomerGroups:[]},defaultFields:{accountTypeSelectBoxSelectors:["#accountType",'input[name="accountType"]'],company:"billingAddresscompany",department:"billingAddressdepartment",vatId:"vatIds",customerComment:"netiAccessManagerCustomerComment"}}}}]);
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.