1"use strict";(self.webpackChunklautsprecher_teufel=self.webpackChunklautsprecher_teufel||[]).push([[1032],{51944:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var i=s(10467),n=s(57142),r=s(83783),a=s(94781);class d extends n.A{constructor(){super(...arguments),this.activePseudoIndex=-1,this.activeSearchString="",this.container=this.createContainer(),this.debouncedOnInputChange=(0,r.s)(this.onInputChange,150),this.isVisible=!1,this.suggestionCache={},this.fieldsObservedForManualChanges=[],this.boundDispatchManualAddressChange=this.dispatchManualAddressChange.bind(this)}createContainer(){var e=document.createElement("div");return e.classList.add(this.name+"__container"),e.setAttribute("tabindex","-1"),e}readyCallback(){}connectedCallback(){this.observeInteractions()}observeInteractions(){var e,t;for(var s of(null==(e=this.addressField)||e.addEventListener("focusin",this.selectExistingSearchString.bind(this)),["input","focus"])){var i;null==(i=this.addressField)||i.addEventListener(s,this.debouncedOnInputChange.bind(this))}this.addEventListener("focusout",this.closeSuggestions.bind(this)),null==(t=this.addressField)||t.addEventListener("keydown",e=>{var{key:t}=e;if("Escape"===t)return this.closeSuggestions();this.isVisible&&(["ArrowDown","Down"].includes(t)&&(e.preventDefault(),this.increasePseudoFocusIndexBy(1)),["ArrowUp","Up"].includes(t)&&(e.preventDefault(),this.increasePseudoFocusIndexBy(-1)),"Enter"===t&&(e.preventDefault(),this.selectSuggestionAtIndex(this.activePseudoIndex)))}),this.container.addEventListener("mousedown",this.onSuggestionClick.bind(this))}selectExistingSearchString(){this.addressField.select()}onInputChange(e){var t=this;return(0,i.A)(function*(){var{target:s}=e;if(t.addressField.matches(":focus")){var i,n=s.value;t.activeSearchString=n;try{i=n.length<2?"":yield t.getSuggestions(n),t.showSuggestions(i)}catch(e){}}})()}getSuggestions(e,t){var s=this;return(0,i.A)(function*(){var i,n;void 0===t&&(t="");var r=s.suggestionCache[e+"_"+t];if(r)return r;null==(i=s.abortController)||i.abort(),"AbortController"in window&&(s.abortController=new AbortController);var a=yield fetch(s.endpointFindAddress,{body:JSON.stringify({inputValue:e,containerId:t}),headers:[["Content-Type","application/json"]],method:"POST",signal:null==(n=s.abortController)?void 0:n.signal});if(200!==a.status)throw new Error;var d=yield a.json(),o=s.activeResultList=JSON.parse(d.addresses).Items,l=s.renderSuggestions(o);return s.suggestionCache[e+"_"+t]=l,l})()}renderSuggestions(e){return e.reduce((e,t)=>e+=this.renderResultItem(t),"")}renderResultItem(e){var t="Container"===e.Type?'<span class="'+this.name+'__container-desc">'+e.Description+"</span>":"",s=this.highlightSubstrings(e.Text,e.Highlight);return'<div class="'+this.name+'__suggestion">'+s+" "+t+"</div>"}highlightSubstrings(e,t){var s='<mark class="'+this.name+'__mark">',i=e.split(""),n=t.split(",").reverse().map(e=>e.split("-").map(e=>parseInt(e)));for(var r of n){var[a,d]=r;i.splice(d,0,"</mark>"),i.splice(a,0,s)}return i.join("")}showSuggestions(e){this.isVisible||""===e||this.dispatchEvent(new CustomEvent(a.mb,{bubbles:!0})),this.isVisible=""!==e,this.activePseudoIndex=-1,this.container.innerHTML=e,this.addressFieldWrap.appendChild(this.container)}onSuggestionClick(e){var t=e.target;e.preventDefault();var s=Array.from(this.container.children).indexOf(t.closest("div"));this.selectSuggestionAtIndex(s)}selectSuggestionAtIndex(e){if(-1!==e){var t=this.activeResultList[e];"Address"===t.Type?(this.copySuggestionTextToFieldValue(t.Text),this.applyAddress(t)):this.getContainerData(t)}}copySuggestionTextToFieldValue(e){this.addressField.value=e}applyAddress(e){var t=this;return(0,i.A)(function*(){var s;t.closeSuggestions(),t.dispatchEvent(new CustomEvent(a.XR,{bubbles:!0})),null==(s=t.abortController)||s.abort(),"AbortController"in window&&(t.abortController=new AbortController);try{var i,n=yield fetch(t.endpointRetrieveAddress,{body:JSON.stringify({addressId:e.Id}),headers:[["Content-Type","application/json"]],method:"POST",signal:null==(i=t.abortController)?void 0:i.signal});if(200!==n.status)throw new Error;var r=yield n.json(),d=JSON.parse(r.address);t.populateFields(d),0===r.attemptsLeft&&t.deactivate()}catch(e){}})()}populateFields(e){var t=[];for(var s in e){var i=this.querySelector('[name="'+s+'"]');i.value=e[s],i.dispatchEvent(new Event("change")),t.push(i)}this.observeManualAddressChange(t)}
1deactivate(){this.addressField.setAttribute("disabled","")}getContainerData(e){var t=this;return(0,i.A)(function*(){t.dispatchEvent(new CustomEvent(a.wo,{bubbles:!0}));var s=yield t.getSuggestions(t.activeSearchString,e.Id);t.showSuggestions(s)})()}closeSuggestions(){var e;this.isVisible=!1,this.activePseudoIndex=-1,null==(e=this.container.parentElement)||e.removeChild(this.container),this.addressField.blur()}increasePseudoFocusIndexBy(e){var t=this.activeResultList.length,s=this.activePseudoIndex+e;-1===s&&(s=t-1),s===t&&(s=0),this.setPseudoFocus(s)}setPseudoFocus(e){var t,s=this.suggestions,i=this.name+"__suggestion--pseudo-focus",n=s[e];null==(t=s[this.activePseudoIndex])||t.classList.remove(i),null==n||n.classList.add(i),this.activePseudoIndex=e,this.scrollElementIntoView(n)}scrollElementIntoView(e){if(e){var t=this.container,{offsetTop:s,offsetHeight:i}=e,{scrollTop:n,offsetHeight:r}=this.container,a=s+i;a>n+r&&t.scrollTo({top:a-r}),s<n&&t.scrollTo({top:s})}}observeManualAddressChange(e){for(var t of(this.unobserveManualAddressChange(),e))t.addEventListener("input",this.boundDispatchManualAddressChange),this.fieldsObservedForManualChanges.push(t)}unobserveManualAddressChange(){for(;this.fieldsObservedForManualChanges.length>0;)this.fieldsObservedForManualChanges.pop().removeEventListener("input",this.boundDispatchManualAddressChange)}dispatchManualAddressChange(){this.dispatchEvent(new CustomEvent(a.IE,{bubbles:!0})),this.unobserveManualAddressChange()}get addressField(){return this.querySelector(this.dataset.addressInputSelector)}get addressFieldWrap(){return this.addressField.parentElement}get endpointFindAddress(){return this.dataset.endpointFindAddress}get endpointRetrieveAddress(){return this.dataset.endpointRetrieveAddress}get suggestions(){return Array.from(this.container.children)}}}}]);
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.