1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[86300],{6300:(e,t,i)=>{i.r(t),i.d(t,{default:()=>s});var n=i(9568),o=i(4049),r=i(3107);class s extends n.Z{init(){this.initClient(),this.initSelects(),this._getFormFieldToggleInstance(),this._formFieldToggleInstance&&this._formFieldToggleInstance.$emitter.subscribe("onChange",this._onFormFieldToggleChange.bind(this))}initClient(){this._client=new r.Z}initSelects(){this.scopeElement=this.el,this.options.scopeElementSelector&&(this.scopeElement=o.Z.querySelector(document,this.options.scopeElementSelector));let{countrySelectSelector:e,countryStateSelectSelector:t,initialCountryAttribute:i,initialCountryStateAttribute:n}=s.options,r=o.Z.querySelector(this.scopeElement,e),d=o.Z.querySelector(this.scopeElement,t),a=o.Z.getDataAttribute(r,i,!1),l=o.Z.getDataAttribute(d,n,!1),u=r.options[r.selectedIndex],c=!!o.Z.getDataAttribute(u,this.options.vatIdRequired,!1),p=document.querySelector(this.options.vatIdFieldInput),h=!!o.Z.getDataAttribute(u,this.options.stateRequired,!1),S=o.Z.querySelectorAll(this.scopeElement,this.options.zipcodeLabel,!1),q=o.Z.querySelectorAll(this.scopeElement,this.options.zipcodeFieldInput,!1),g=!!o.Z.getDataAttribute(u,this.options.zipcodeRequired,!1);r.addEventListener("change",this.onChangeCountry.bind(this)),a&&(this.requestStateData(a,l,h),g&&(window.Feature.isActive("ACCESSIBILITY_TWEAKS")?this._updateZipcodeFields(q,g):this._updateZipcodeRequired(S,q,g)),p&&(window.Feature.isActive("ACCESSIBILITY_TWEAKS")?this._updateVatIdField(p,c):this._updateRequiredVatId(p,c)))}onChangeCountry(e){let t=e.target.value,i=e.target.options[e.target.selectedIndex],n=!!o.Z.getDataAttribute(i,this.options.stateRequired);this.requestStateData(t,null,n);let r=o.Z.getDataAttribute(i,this.options.vatIdRequired),s=document.querySelector(this.options.vatIdFieldInput),d=o.Z.querySelectorAll(this.scopeElement,this.options.zipcodeLabel,!1),a=o.Z.querySelectorAll(this.scopeElement,this.options.zipcodeFieldInput,!1),l=!!o.Z.getDataAttribute(i,this.options.zipcodeRequired,!1);window.Feature.isActive("ACCESSIBILITY_TWEAKS")?this._updateZipcodeFields(a,l):this._updateZipcodeRequired(d,a,l),s&&(window.Feature.isActive("ACCESSIBILITY_TWEAKS")?this._updateVatIdField(s,r):this._updateRequiredVatId(s,r))}requestStateData(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=JSON.stringify({countryId:e});this._client.post(window.router["frontend.country.country-data"],n,e=>{if(window.Feature.isActive("ACCESSIBILITY_TWEAKS")){let n=JSON.parse(e);this._updateStateSelect(n.states,i,t)}else{let n=JSON.parse(e);!function(e,t,i,n){let{stateRequired:r,states:s}=e,{countryStateSelectSelector:d,countryStatePlaceholderSelector:a}=n,l=o.Z.querySelector(i,d);(function(e,t){e.querySelectorAll(t).forEach(e=>e.remove())})(l,"option:not(".concat(a,")")),function(e,t,i){if(0===t.length){e.parentNode.classList.add("d-none"),e.setAttribute("disabled","disabled");return}t.map(e=>(function(e,t){let i=document.createElement("option");return i.setAttribute("value",e.id),i.innerText=e.translated.name,e.id===t&&i.setAttribute("selected","selected"),i})(e,i)).forEach(t=>{e.append(t)}),e.parentNode.classList.remove("d-none"),e.removeAttribute("disabled")}(l,s,t),function(e,t,i){let n=e.querySelector(i),o=e.parentNode.querySelector("label");if(t){n.setAttribute("disabled","disabled"),e.setAttribute("required","required"),(null==o?void 0:o.textContent)&&"*"!==o.textContent.substr(-1,1)&&(o.textContent="".concat(o.textContent.trim(),"*"));return}(null==o?void 0:o.textContent)&&"*"===o.textContent.substr(-1,1)&&(o.textContent=o.textContent.substr(0,o.textContent.length-1)),n.removeAttribute("disabled"),e.removeAttribute("required")}(l,r,"option".concat(a))}(n={...n,stateRequired:i},t,this.el,s.options)}})}_updateVatIdField(e,t){this._differentShippingCheckbox&&"billingAddress"===this.options.prefix||(t?window.formValidation.setFieldRequired(e):window.formValidation.setFieldNotRequired(e))}_updateRequiredVatId(e,t){if(this._differentShippingCheckbox&&"billingAddress"===this.options.prefix)return;let i=e.parentNode.querySelector("label");if(t){e.setAttribute("required","required"),(null==i?void 0:i.textContent)&&"*"!==i.textContent.substr(-1,1)&&(i.textContent="".concat(i.textContent,"*"));return}(null==i?void 0:i.textContent)&&"*"===i.textContent.substr(-1,1)&&(i.textContent=i.textContent.substr(0,i.textContent.length-1)),e.removeAttribute("required")}_updateZipcodeFields(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];
1e&&e.forEach(e=>{!0===t?window.formValidation.setFieldRequired(e):window.formValidation.setFieldNotRequired(e)})}_updateZipcodeRequired(e,t,i){e&&t&&(e.forEach(e=>{e.className=i?"":"d-none"}),t.forEach(e=>{i?e.setAttribute("required","required"):e.removeAttribute("required")}))}_updateStateSelect(e,t,i){let n=o.Z.querySelector(this.scopeElement,this.options.countryStateSelectSelector),r=n.querySelector(this.options.countryStatePlaceholderSelector);this._removeStateOptions(n),this._addStateOptions(e,i,n),t?(window.formValidation.setFieldRequired(n),r.setAttribute("disabled","disabled")):(window.formValidation.setFieldNotRequired(n),r.removeAttribute("disabled"))}_removeStateOptions(e){let t="option:not(".concat(this.options.countryStatePlaceholderSelector,")"),i=e;e||(i=o.Z.querySelector(this.scopeElement,this.options.countryStateSelectSelector)),i.querySelectorAll(t).forEach(e=>e.remove())}_addStateOptions(e,t,i){let n=i;if(i||(n=o.Z.querySelector(this.scopeElement,this.options.countryStateSelectSelector)),0===e.length){n.parentNode.classList.add("d-none"),n.setAttribute("disabled","disabled");return}e.map(e=>this._createStateOptionEl(e,t)).forEach(e=>{n.append(e)}),n.parentNode.classList.remove("d-none"),n.removeAttribute("disabled")}_createStateOptionEl(e,t){let i=document.createElement("option");return i.setAttribute("value",e.id),i.innerText=e.translated.name,e.id===t&&i.setAttribute("selected","selected"),i}_getFormFieldToggleInstance(){let e=o.Z.querySelector(document,'[data-form-field-toggle-target=".js-form-field-toggle-shipping-address"]',!1);e&&(this._formFieldToggleInstance=window.PluginManager.getPluginInstanceFromElement(e,"FormFieldToggle"))}_onFormFieldToggleChange(e){this._differentShippingCheckbox=e.target.checked;let t=this._differentShippingCheckbox?".register-shipping":".register-billing",i=o.Z.querySelector(document,t),n=o.Z.querySelector(i,this.options.countrySelectSelector),r=n.options[n.selectedIndex],s=!!o.Z.getDataAttribute(r,this.options.vatIdRequired,!1),d=document.querySelector(this.options.vatIdFieldInput);d&&(window.Feature.isActive("ACCESSIBILITY_TWEAKS")?this._updateVatIdField(d,s):this._updateRequiredVatId(d,s))}}s.options={countrySelectSelector:".country-select",initialCountryAttribute:"initial-country-id",countryStateSelectSelector:".country-state-select",initialCountryStateAttribute:"initial-country-state-id",countryStatePlaceholderSelector:'[data-placeholder-option="true"]',vatIdFieldInput:"#vatIds",zipcodeFieldInput:'[data-input-name="zipcodeInput"]',vatIdRequired:"vat-id-required",stateRequired:"state-required",zipcodeRequired:"zipcode-required",zipcodeLabel:"#zipcodeLabel",scopeElementSelector:null,prefix:null}},3107:(e,t,i)=>{i.d(t,{Z:()=>n});class n{get(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",n=this._createPreparedRequest("GET",e,i);return this._sendRequest(n,null,t)}post(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";n=this._getContentType(t,n);let o=this._createPreparedRequest("POST",e,n);return this._sendRequest(o,t,i)}delete(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";n=this._getContentType(t,n);let o=this._createPreparedRequest("DELETE",e,n);return this._sendRequest(o,t,i)}patch(e,t,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";n=this._getContentType(t,n);let o=this._createPreparedRequest("PATCH",e,n);return this._sendRequest(o,t,i)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn("the request to ".concat(e.responseURL," was aborted"))}),e.addEventListener("error",()=>{console.warn("the request to ".concat(e.responseURL," failed with status ").concat(e.status))}),e.addEventListener("timeout",()=>{console.warn("the request to ".concat(e.responseURL," timed out"))})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,i){return this._registerOnLoaded(e,i),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,i){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),i&&this._request.setRequestHeader("Content-type",i),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}}}]);
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.