PageSourceSearch

https://baer.tools/theme/c06e77d29f9fca341d68f9138913a5e4/js/store….form-country-state-select.plugin.038d25.js

js baer.tools collected 2026-09-25 05:08:32 UTC 7,643 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[25132],{5132(t,e,i){i.r(e),i.d(e,{default:()=>o});var n=i(4335),s=i(9068);class o extends n.A{static #t=this.options={countrySelectSelector:".country-select",initialCountryAttribute:"data-initial-country-id",countryStateSelectSelector:".country-state-select",initialCountryStateAttribute:"data-initial-country-state-id",countryStatePlaceholderSelector:'[data-placeholder-option="true"]',vatIdFieldInput:"#vatIds",zipcodeFieldInput:'[data-input-name="zipcodeInput"]',vatIdRequired:"data-vat-id-required",vatIdPattern:"data-vat-id-pattern",checkVatIdPattern:"data-check-vat-id-pattern",stateRequired:"data-state-required",stateDisplayed:"data-display-state-in-registration",zipcodeRequired:"data-zipcode-required",scopeElementSelector:null,prefix:null};init(){this.initClient(),this.initSelects(),this._getFormFieldToggleInstance(),this._formFieldToggleInstance&&this._formFieldToggleInstance.$emitter.subscribe("onChange",this._onFormFieldToggleChange.bind(this))}initClient(){this._client=new s.A}initSelects(){this.scopeElement=this.el,this.options.scopeElementSelector&&(this.scopeElement=document.querySelector(this.options.scopeElementSelector));let{countrySelectSelector:t,countryStateSelectSelector:e,initialCountryAttribute:i,initialCountryStateAttribute:n}=o.options,s=this.scopeElement.querySelector(t),r=this.scopeElement.querySelector(e),a=s.getAttribute(i),d=r.getAttribute(n),l=s.options[s.selectedIndex],u=!!l.getAttribute(this.options.vatIdRequired),c=l.getAttribute(this.options.vatIdPattern),p="1"===l.getAttribute(this.options.checkVatIdPattern),h=document.querySelector(this.options.vatIdFieldInput),g=!!l.getAttribute(this.options.stateRequired),q=this._getStateDisplayed(l,g),S=this.scopeElement.querySelectorAll(this.options.zipcodeFieldInput),_=!!l.getAttribute(this.options.zipcodeRequired);s.addEventListener("change",this.onChangeCountry.bind(this)),a&&(this.requestStateData(a,d,g,q),_&&this._updateZipcodeFields(S,_),h&&this._updateVatIdField(h,u,c,p))}onChangeCountry(t){let e=t.target.value,i=t.target.options[t.target.selectedIndex],n=!!i.getAttribute(this.options.stateRequired),s=this._getStateDisplayed(i,n);this.requestStateData(e,null,n,s);let o=!!i.getAttribute(this.options.vatIdRequired),r=i.getAttribute(this.options.vatIdPattern),a="1"===i.getAttribute(this.options.checkVatIdPattern),d=document.querySelector(this.options.vatIdFieldInput),l=this.scopeElement.querySelectorAll(this.options.zipcodeFieldInput),u=!!i.getAttribute(this.options.zipcodeRequired);this._updateZipcodeFields(l,u),d&&this._updateVatIdField(d,o,r,a)}requestStateData(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=!(arguments.length>3)||void 0===arguments[3]||arguments[3];fetch(`${window.router["frontend.country.country-data"]}?countryId=${encodeURIComponent(t)}`,{headers:{"X-Requested-With":"XMLHttpRequest","Content-Type":"application/json"}}).then(t=>t.json()).then(t=>this._updateStateSelect(t.states,i,e,n))}_updateVatIdField(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];(!this._differentShippingCheckbox||"billingAddress"!==this.options.prefix)&&(e?window.formValidation.setFieldRequired(t):window.formValidation.setFieldNotRequired(t),n&&i?t.setAttribute("pattern",i):t.removeAttribute("pattern"),t.value.trim().length>0&&window.formValidation.validateField(t))}_updateZipcodeFields(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&t.forEach(t=>{!0===e?window.formValidation.setFieldRequired(t):window.formValidation.setFieldNotRequired(t)})}_updateStateSelect(t,e,i){let n=!(arguments.length>3)||void 0===arguments[3]||arguments[3],s=this.scopeElement.querySelector(this.options.countryStateSelectSelector),o=s.querySelector(this.options.countryStatePlaceholderSelector);this._removeStateOptions(s),this._addStateOptions(e||n?t:[],i,s),e?(window.formValidation.setFieldRequired(s),o.setAttribute("disabled","disabled")):(window.formValidation.setFieldNotRequired(s),o.removeAttribute("disabled"))}_removeStateOptions(t){let e=`option:not(${this.options.countryStatePlaceholderSelector})`,i=t;t||(i=this.scopeElement.querySelector(this.options.countryStateSelectSelector)),i.querySelectorAll(e).forEach(t=>t.remove())}_addStateOptions(t,e,i){let n=i;if(i||(n=this.scopeElement.querySelector(this.options.countryStateSelectSelector)),0===t.length){n.parentNode.classList.add("d-none"),n.setAttribute("disabled","disabled");return}t.map(t=>
1this._createStateOptionEl(t,e)).forEach(t=>{n.append(t)}),n.parentNode.classList.remove("d-none"),n.removeAttribute("disabled")}_createStateOptionEl(t,e){let i=document.createElement("option");return i.setAttribute("value",t.id),i.innerText=t.translated.name,t.id===e&&i.setAttribute("selected","selected"),i}_getFormFieldToggleInstance(){let t=document.querySelector('[data-form-field-toggle-target=".js-form-field-toggle-shipping-address"]');t&&(this._formFieldToggleInstance=window.PluginManager.getPluginInstanceFromElement(t,"FormFieldToggle"))}_onFormFieldToggleChange(t){this._differentShippingCheckbox=t.target.checked;let e=this._differentShippingCheckbox?".register-shipping":".register-billing",i=document.querySelector(e).querySelector(this.options.countrySelectSelector),n=i.options[i.selectedIndex],s=!!n.getAttribute(this.options.vatIdRequired),o=n.getAttribute(this.options.vatIdPattern),r="1"===n.getAttribute(this.options.checkVatIdPattern),a=document.querySelector(this.options.vatIdFieldInput);a&&this._updateVatIdField(a,s,o,r)}_getStateDisplayed(t,e){if(e||!t.hasAttribute(this.options.stateDisplayed))return!0;let i=t.getAttribute(this.options.stateDisplayed);return""!==i&&"0"!==i&&"false"!==i}}},9068(t,e,i){i.d(e,{A:()=>n});class n{constructor(){this._request=null,this._errorHandlingInternal=!1}get(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",n=this._createPreparedRequest("GET",t,i);return this._sendRequest(n,null,e)}post(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";n=this._getContentType(e,n);let s=this._createPreparedRequest("POST",t,n);return this._sendRequest(s,e,i)}delete(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";n=this._getContentType(e,n);let s=this._createPreparedRequest("DELETE",t,n);return this._sendRequest(s,e,i)}patch(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";n=this._getContentType(e,n);let s=this._createPreparedRequest("PATCH",t,n);return this._sendRequest(s,e,i)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(t){this._errorHandlingInternal=t}_registerOnLoaded(t,e){e&&(!0===this._errorHandlingInternal?(t.addEventListener("load",()=>{e(t.responseText,t)}),t.addEventListener("abort",()=>{console.warn(`the request to ${t.responseURL} was aborted`)}),t.addEventListener("error",()=>{console.warn(`the request to ${t.responseURL} failed with status ${t.status}`)}),t.addEventListener("timeout",()=>{console.warn(`the request to ${t.responseURL} timed out`)})):t.addEventListener("loadend",()=>{e(t.responseText,t)}))}_sendRequest(t,e,i){return this._registerOnLoaded(t,i),t.send(e),t}_getContentType(t,e){return t instanceof FormData&&(e=!1),e}_createPreparedRequest(t,e,i){return this._request=new XMLHttpRequest,this._request.open(t,e),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),i&&this._request.setRequestHeader("Content-type",i),this._request}}}}]);

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.