1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[49710],{156:t=>{var e=function(t){var e;return!!t&&"object"==typeof t&&"[object RegExp]"!==(e=Object.prototype.toString.call(t))&&"[object Date]"!==e&&t.$$typeof!==i},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function s(t,e){return!1!==e.clone&&e.isMergeableObject(t)?l(Array.isArray(t)?[]:{},t,e):t}function n(t,e,i){return t.concat(e).map(function(t){return s(t,i)})}function a(t){return Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[])}function r(t,e){try{return e in t}catch(t){return!1}}function l(t,i,o){(o=o||{}).arrayMerge=o.arrayMerge||n,o.isMergeableObject=o.isMergeableObject||e,o.cloneUnlessOtherwiseSpecified=s;var c,d,u=Array.isArray(i);return u!==Array.isArray(t)?s(i,o):u?o.arrayMerge(t,i,o):(d={},(c=o).isMergeableObject(t)&&a(t).forEach(function(e){d[e]=s(t[e],c)}),a(i).forEach(function(e){(!r(t,e)||Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))&&(r(t,e)&&c.isMergeableObject(i[e])?d[e]=(function(t,e){if(!e.customMerge)return l;var i=e.customMerge(t);return"function"==typeof i?i:l})(e,c)(t[e],i[e],c):d[e]=s(i[e],c))}),d)}l.all=function(t,e){if(!Array.isArray(t))throw Error("first argument should be an array");return t.reduce(function(t,i){return l(t,i,e)},{})},t.exports=l},710:(t,e,i)=>{i.r(e),i.d(e,{default:()=>n});var s=i(373);class n extends s.A{static #t=this.options={vatIdInputSelector:"#vatIds, #lenzVatIdValidationAddressVatId",countrySelectSelector:".country-select",companyInputSelector:'#personalCompany, [name$="[company]"]',streetInputSelector:'#addressStreet, [name$="[street]"]',zipcodeInputSelector:'#addressZipcode, [name$="[zipcode]"]',cityInputSelector:'#addressCity, [name$="[city]"]',debounceDelay:800,minLength:4,validateUrl:"/lenz-platform-vat-id-validation/ajax-validate"};init(){this._debounceTimer=null,this._lastValidatedValue="",this._applyingSuggestions=!1,this._vatIdInput=this.el.querySelector(this.options.vatIdInputSelector),this._vatIdInput&&(this._createFeedbackElement(),this._registerEvents())}_registerEvents(){this._vatIdInput.addEventListener("input",this._onInput.bind(this)),this._vatIdInput.addEventListener("blur",this._onBlur.bind(this)),[this.options.companyInputSelector,this.options.streetInputSelector,this.options.zipcodeInputSelector,this.options.cityInputSelector,this.options.countrySelectSelector].forEach(t=>{let e=this.el.querySelector(t);e&&e!==this._vatIdInput&&e.addEventListener("change",this._onAddressFieldChange.bind(this))})}_onAddressFieldChange(){if(this._applyingSuggestions)return;let t=this._vatIdInput.value.trim();t.length<this.options.minLength||(this._lastValidatedValue="",clearTimeout(this._debounceTimer),this._debounceTimer=setTimeout(()=>{this._validate(t)},this.options.debounceDelay))}_onInput(){clearTimeout(this._debounceTimer);let t=this._vatIdInput.value.trim();if(t.length<this.options.minLength){this._clearFeedback(),this._lastValidatedValue="";return}this._showFeedback("loading"),this._debounceTimer=setTimeout(()=>{this._validate(t)},this.options.debounceDelay)}_onBlur(){let t=this._vatIdInput.value.trim();t.length>=this.options.minLength&&t!==this._lastValidatedValue&&(clearTimeout(this._debounceTimer),this._validate(t))}_validate(t){if(t===this._lastValidatedValue)return;this._lastValidatedValue=t,this._showFeedback("loading");let e=new FormData;for(let[i,s]of(e.append("vatId",t),Object.entries({countryId:this.options.countrySelectSelector,company:this.options.companyInputSelector,street:this.options.streetInputSelector,zipcode:this.options.zipcodeInputSelector,city:this.options.cityInputSelector}))){let t=this.el.querySelector(s);t&&e.append(i,t.value)}fetch(this.options.validateUrl,{method:"POST",body:e}).then(t=>t.json()).then(t=>this._showResult(t)).catch(()=>this._clearFeedback())}_createFeedbackElement(){this._feedbackEl=document.createElement("div"),this._feedbackEl.classList.add("lenz-vat-id-ajax-feedback"),this._vatIdInput.parentNode.insertBefore(this._feedbackEl,this._vatIdInput.nextSibling)}_showResult(t){this._showFeedback(t.status),t.suggestions&&Object.keys(t.suggestions).length>0&&this._showSuggestions(t.suggestions)}_showSuggestions(t){let e=this.options.snippets||{},i={company:e.suggestionCompany||"Company",street:e.suggestionStreet||"Street",zipcode:e.suggestionZipcode||"Zipcode",city:e.suggestionCity||"City"},s='<ul class="lenz-vat-id-ajax-feedback__suggestions">';for(let[e,n]of Object.entries(t)){let t=i[e]||e;s+=`<li><strong>${t}:</strong> ${n}</li>`}s+="</ul>";let n=e.applyAll||"Apply all";s+=`<button type="button" class="btn btn-sm btn-outline-primary lenz-vat-id-ajax-feedback__apply-all">${n}</button>`,this._feedbackEl.innerHTML=this._feedbackEl.textContent+s,this._feedbackEl.querySelector(".lenz-vat-id-ajax-feedback__apply-all").addEventListener("click",e=>{e.preventDefault(),this._applyAllSuggestions(t)})}_applyAllSuggestions(t){let e={company:this.options.companyInputSelector,street:this.options.streetInputSelector,zipcode:this.options.zipcodeInputSelector,city:this.options.cityInputSelector};for(let[i,s]of(this._applyingSuggestions=!0,Object.entries(t))){let t=e[i];if(!t)continue;let n=this.el.querySelector(t);n&&(n.value=s)}this._applyingSuggestions=!1,this._lastValidatedValue="",clearTimeout(this._debounceTimer),this._val
1idate(this._vatIdInput.value.trim())}_showFeedback(t){this._vatIdInput.classList.remove("is-valid","is-invalid"),this._feedbackEl.className="lenz-vat-id-ajax-feedback",this._feedbackEl.textContent="";let e=this.options.snippets||{};switch(t){case"valid":this._vatIdInput.classList.add("is-valid"),this._feedbackEl.classList.add("lenz-vat-id-ajax-feedback--valid"),this._feedbackEl.textContent=e.valid||"";break;case"invalid":this._vatIdInput.classList.add("is-invalid"),this._feedbackEl.classList.add("lenz-vat-id-ajax-feedback--invalid"),this._feedbackEl.textContent=e.invalid||"";break;case"address_mismatch":this._feedbackEl.classList.add("lenz-vat-id-ajax-feedback--warning"),this._feedbackEl.textContent=e.addressMismatch||"";break;case"api_error":this._feedbackEl.classList.add("lenz-vat-id-ajax-feedback--error"),this._feedbackEl.textContent=e.apiError||"";break;case"loading":this._feedbackEl.classList.add("lenz-vat-id-ajax-feedback--loading"),this._feedbackEl.textContent=e.loading||"";break;default:this._clearFeedback()}}_clearFeedback(){this._vatIdInput.classList.remove("is-valid","is-invalid"),this._feedbackEl.className="lenz-vat-id-ajax-feedback",this._feedbackEl.textContent=""}}},373:(t,e,i)=>{i.d(e,{A:()=>l});var s=i(156),n=i.n(s);class a{static ucFirst(t){return t.charAt(0).toUpperCase()+t.slice(1)}static lcFirst(t){return t.charAt(0).toLowerCase()+t.slice(1)}static toDashCase(t){return t.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(t,e){let i=a.toUpperCamelCase(t,e);return a.lcFirst(i)}static toUpperCamelCase(t,e){return e?t.split(e).map(t=>a.ucFirst(t.toLowerCase())).join(""):a.ucFirst(t.toLowerCase())}static parsePrimitive(t){try{return/^\d+(.|,)\d+$/.test(t)&&(t=t.replace(",",".")),JSON.parse(t)}catch(e){return t.toString()}}}
1class r{constructor(t=document){this._el=t,t.$emitter=this,this._listeners=[]}publish(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=new CustomEvent(t,{detail:e,cancelable:i});return this.el.dispatchEvent(s),s}subscribe(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=this,n=t.split("."),a=i.scope?e.bind(i.scope):e;if(i.once&&!0===i.once){let e=a;a=function(i){s.unsubscribe(t),e(i)}}return this.el.addEventListener(n[0],a),this.listeners.push({splitEventName:n,opts:i,cb:a}),!0}unsubscribe(t){let e=t.split(".");return this.listeners=this.listeners.reduce((t,i)=>([...i.splitEventName].sort().toString()===e.sort().toString()?this.el.removeEventListener(i.splitEventName[0],i.cb):t.push(i),t),[]),!0}reset(){return this.listeners.forEach(t=>{this.el.removeEventListener(t.splitEventName[0],t.cb)}),this.listeners=[],!0}get el(){return this._el}set el(t){this._el=t}get listeners(){return this._listeners}set listeners(t){this._listeners=t}}class l{constructor(t,e={},i=!1){if(!(t instanceof Node))throw Error("There is no valid element given.");this.el=t,this.$emitter=new r(this.el),this._pluginName=this._getPluginName(i),this.options=this._mergeOptions(e),this._initialized=!1,this._registerInstance(),this._init()}init(){throw Error(`The "init" method for the plugin "${this._pluginName}" is not defined.`)}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(t){let e=[this.constructor.options,this.options,t];return e.push(this._getConfigFromDataAttribute()),e.push(this._getOptionsFromDataAttribute()),n().all(e.filter(t=>t instanceof Object&&!(t instanceof Array)).map(t=>t||{}))}_getConfigFromDataAttribute(){let t={};if("function"!=typeof this.el.getAttribute)return t;let e=a.toDashCase(this._pluginName),i=this.el.getAttribute(`data-${e}-config`);return i?window.PluginConfigManager.get(this._pluginName,i):t}_getOptionsFromDataAttribute(){let t={};if("function"!=typeof this.el.getAttribute)return t;let e=a.toDashCase(this._pluginName),i=this.el.getAttribute(`data-${e}-options`);if(i)try{return JSON.parse(i)}catch(t){console.error(`The data attribute "data-${e}-options" could not be parsed to json: ${t.message}`)}return t}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(t){return t||(t=this.constructor.name),t}}}}]);
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.