1(()=>{"use strict";var t={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!==s},s="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(t,e){return!1!==e.clone&&e.isMergeableObject(t)?a(Array.isArray(t)?[]:{},t,e):t}function n(t,e,s){return t.concat(e).map(function(t){return i(t,s)})}function o(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 a(t,s,l){(l=l||{}).arrayMerge=l.arrayMerge||n,l.isMergeableObject=l.isMergeableObject||e,l.cloneUnlessOtherwiseSpecified=i;var d,u,c=Array.isArray(s);return c!==Array.isArray(t)?i(s,l):c?l.arrayMerge(t,s,l):(u={},(d=l).isMergeableObject(t)&&o(t).forEach(function(e){u[e]=i(t[e],d)}),o(s).forEach(function(e){(!r(t,e)||Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))&&(r(t,e)&&d.isMergeableObject(s[e])?u[e]=(function(t,e){if(!e.customMerge)return a;var s=e.customMerge(t);return"function"==typeof s?s:a})(e,d)(t[e],s[e],d):u[e]=i(s[e],d))}),u)}a.all=function(t,e){if(!Array.isArray(t))throw Error("first argument should be an array");return t.reduce(function(t,s){return a(t,s,e)},{})},t.exports=a}},e={};function s(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,s),o.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i=s(156),n=s.n(i);class o{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 s=o.toUpperCamelCase(t,e);return o.lcFirst(s)}static toUpperCamelCase(t,e){return e?t.split(e).map(t=>o.ucFirst(t.toLowerCase())).join(""):o.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]:{},s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=new CustomEvent(t,{detail:e,cancelable:s});return this.el.dispatchEvent(i),i}subscribe(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=this,n=t.split("."),o=s.scope?e.bind(s.scope):e;if(s.once&&!0===s.once){let e=o;o=function(s){i.unsubscribe(t),e(s)}}return this.el.addEventListener(n[0],o),this.listeners.push({splitEventName:n,opts:s,cb:o}),!0}unsubscribe(t){let e=t.split(".");return this.listeners=this.listeners.reduce((t,s)=>([...s.splitEventName].sort().toString()===e.sort().toString()?this.el.removeEventListener(s.splitEventName[0],s.cb):t.push(s),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 a{constructor(t,e={},s=!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(s),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=o.toDashCase(this._pluginName),s=this.el.getAttribute(`data-${e}-config`);return s?window.PluginConfigManager.get(this._pluginName,s):t}_getOptionsFromDataAttribute(){let t={};if("function"!=typeof this.el.getAttribute)return t;let e=o.toDashCase(this._pluginName),s=this.el.getAttribute(`data-${e}-options`);if(s)try{return JSON.parse(s)}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}}class l{static isNode(t){return"object"==typeof t&&null!==t&&(t===document||t===window||t instanceof Node)}static hasAttribute(t,e){if(!l.isNode(t))throw Error("The element must be a valid HTML Node!");return"function"==typeof t.hasAttribute&&t.hasAttribute(e)}static getAttribute(t,e){let s=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(s&&!1===l.hasAttribute(t,e))throw Error(`The required property "${e}" does not exist!`);if("function"!=typeof t.getAttribute){if(s)throw Error("This node doesn't support the getAttribute function!");return}return t.getAttribute(e)}static getDataAttribute(t,e){let s=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=e.replace(/^data(|-)/,""),n=o.toLowerCamelCase(i,"-");if(!l.isNode(t)){if(s)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===t.dataset){if(s)throw Error("This node doesn't support the dataset attribute!");return}let r=t.dataset[n];if(void 0===r){if(s)throw Error(`The required data attribute "${e}" does not exist on ${t}!`);return r}return o.parsePrimitive(r)}static querySelector(t,e){let s=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(s&&!l.isNode(t))throw Error("The parent node is not a valid HTML Node!");let i=t.querySelector(e)||!1;if(s&&!1===i)throw Error(`The required element "${e}" does not exist in parent node!`);return i}static querySelectorAll(t,e){let s=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(s&&!l.isNode(t))throw Error("The parent node is not a valid HTML Node!");let i=t.querySelectorAll(e);if(0===i.length&&(i=!1),s&&!1===i)throw Error(`At least one item of "${e}" must exist in parent node!`);return i}static getFocusableElements(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body,e=` 2 input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]), 3 select:not([tabindex^="-"]):not([disabled]), 4 textarea:not([tabindex^="-"]):not([disabled]), 5 button:not([tabindex^="-"]):not([disabled]), 6 a[href]:not([tabindex^="-"]):not([disabled]),
7 [tabindex]:not([tabindex^="-"]):not([disabled]) 8 `;return t.querySelectorAll(e)}static getFirstFocusableElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(t)[0]}static getLastFocusableElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,e=this.getFocusableElements(t);return e[e.length-1]}}class d{static iterate(t,e){if(t instanceof Map||Array.isArray(t))return t.forEach(e);if(t instanceof FormData){for(var s of t.entries())e(s[1],s[0]);return}if(t instanceof NodeList)return t.forEach(e);if(t instanceof HTMLCollection)return Array.from(t).forEach(e);if(t instanceof Object)return Object.keys(t).forEach(s=>{e(t[s],s)});throw Error(`The element type ${typeof t} is not iterable!`)}}let u="biloba-open-ai-dsgvo-consent",c="biloba-open-ai-dsgvo-consent-logged-version",h="bilobaOpenAiAssistantDismissed",p={a:["href","rel"],img:["src","alt","width","height"],ul:[],ol:[],li:[],strong:[],em:[],b:[],i:[],br:[],p:[],span:[]};window.PluginManager.register("BilobaOpenAi",class extends a{init(){this._inputField=l.querySelector(this.el,"#question-input",!1),this._messages=l.querySelector(this.el,".messages",!1),this._submitButton=l.querySelector(this.el,"#send-button",!1),this._refreshButton=l.querySelector(this.el,"#refresh-button",!1),this._closeButton=l.querySelector(this.el,"#close-button",!1),this._optionButtons=l.querySelectorAll(this.el,".options button",!1),this._openButton=l.querySelector(this.el,"#open-button",!1),this._dsgvoOverlay=l.querySelector(this.el,".dsgvo-consent-overlay",!1),this._dsgvoAcceptButton=l.querySelector(this.el,"#dsgvo-accept-button",!1),this._dsgvoDeclineButton=l.querySelector(this.el,"#dsgvo-decline-button",!1),this._dsgvoActive="true"===this.el.getAttribute("data-biloba-assistant-frontend-dsgvo-active"),this._dsgvoConsented=!this._dsgvoActive||"accepted"===this._getCookie(u),this._dismissButton=l.querySelector(this.el,"#dismiss-button",!1),this._dismissMode=this.el.getAttribute("data-biloba-assistant-frontend-dismiss-mode")||"off",this._visibility=this.el.getAttribute("data-biloba-assistant-frontend-visibility")||"all",this._restoreDismissedState(),this.threadId=sessionStorage.getItem("bilobaOpenAiAssistantFrontendThreadId");let t=sessionStorage.getItem("bilobaOpenAiAssistantFrontendLastMessage");this.threadId&&t&&(new Date().getTime()-t>864e5?(sessionStorage.removeItem("bilobaOpenAiAssistantFrontendThreadId"),sessionStorage.removeItem("bilobaOpenAiAssistantFrontendLastMessage"),this.threadId=""):this.el.setAttribute("data-biloba-assistant-frontend-thread-id",this.threadId)),this._registerEvents(),this._shouldAutoOpen()&&this._openChat(!0)}_isDesktopViewport(){return window.matchMedia("(min-width: 768px)").matches}_isHiddenForViewport(){let t=this._isDesktopViewport();return"desktop"===this._visibility&&!t||"mobile"===this._visibility&&t}_isDismissed(){return this.el.classList.contains("chat-dismissed")}_restoreDismissedState(){"session"===this._dismissMode&&"true"===sessionStorage.getItem(h)&&this.el.classList.add("chat-dismissed")}_shouldAutoOpen(){let t="true"===this.el.getAttribute("data-biloba-assistant-frontend-open-on-load"),e="true"===localStorage.getItem("bilobaOpenAiAssistantManuallyClosed"),s=this._dsgvoActive&&"declined"===this._getCookie(u);return t&&!e&&this._isDesktopViewport()&&!s&&!this._isHiddenForViewport()&&!this._isDismissed()}_dismissWidget(t){t.preventDefault(),t.stopPropagation(),this.el.classList.remove("open","chat-opened-manually"),this.el.classList.add("chat-dismissed"),"session"===this._dismissMode&&sessionStorage.setItem(h,"true")}_registerEvents(){let t=this;t.uniqueBind(t.el,"focusin",t=>t.stopPropagation()),t._inputField?t.uniqueBind(t._inputField,"keypress",t._inputChange.bind(t)):console.info("Input field not found"),t._submitButton?t.uniqueBind(t._submitButton,"click",t.sendChat.bind(t)):console.info("Submit button not found"),t._refreshButton?t.uniqueBind(t._refreshButton,"click",t._refreshChat.bind(t)):console.info("Refresh button not found"),t._optionButtons&&d.iterate(t._optionButtons,e=>{t.uniqueBind(e,"click",t._optionClick.bind(t))}),t._closeButton?t.uniqueBind(t._closeButton,"click",t._closeChat.bind(t)):console.info("Close button not found"),t._openButton?t.uniqueBind(t._openButton,"click",()=>{t._openChat(!1)}):console.info("Open button not found"),t._dismissButton&&t.uniqueBind(t._dismissButton,"click",t._dismissWidget.bind(t)),t._dsgvoAcceptButton&&t.uniqueBind(t._dsgvoAcceptButton,"click",t._acceptDsgvoConsent.bind(t)),t._dsgvoDeclineButton&&t.uniqueBind(t._dsgvoDeclineButton,"click",t._declineDsgvoConsent.bind(t))}_openChat(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this;if(t||(localStorage.removeItem("bilobaOpenAiAssistantManuallyClosed"),e.el.classList.add("chat-opened-manually")),e.el.classList.add("open"),e._dsgvoActive&&!e._dsgvoConsented){e._showDsgvoConsentOverlay();return}let s=!1;if(e.el.classList.contains("history-loaded")&&(s=!0),e.threadId&&!1==s){e.el.classList.add("history-loaded");let t=l.querySelector(e.el,".typing-indicator",!1);t.style.display="flex";let s=e.el.getAttribute("data-biloba-assistant-frontend-shop-url"),i=e.el.getAttribute("data-biloba-assistant-frontend-shop-id"),n=e.el.getAttribute("data-biloba-assistant-frontend-assistant-id");fetch(s+"/shopware6-frontend/assistant-frontend/loadThread",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:{shopId:i,url:window.location.origin},assistantId:n,threadId:e.threadId})}).then(t=>t.json()).then(s=>{200==s.status?s.messages&&(t.style.display="none",s.messages.forEac
8h(t=>{let s=document.createElement("li");t.value?(s.classList.add("assistant"),s.innerHTML=e._sanitizeHtml(t.value)):(s.classList.add("user"),s.textContent=t),e._messages.appendChild(s)}),e._scrollToBottom()):(console.error(s),t.style.display="none")}).catch(e=>{console.error("Error:",e),t.style.display="none"})}}_closeChat(){this.el.classList.remove("open","chat-opened-manually"),localStorage.setItem("bilobaOpenAiAssistantManuallyClosed","true")}_inputChange(t){"Enter"===t.key&&this.sendChat()}sendChat(){if(this._dsgvoActive&&!this._dsgvoConsented)return;let t=this._inputField.value;if(""!==t.trim()){let e=this.el.getAttribute("data-biloba-assistant-frontend-shop-url"),s=this.el.getAttribute("data-biloba-assistant-frontend-shop-id"),i=this.el.getAttribute("data-biloba-assistant-frontend-assistant-id"),n=this.el.getAttribute("data-biloba-assistant-frontend-thread-id"),o=e+"/shopware6-frontend/assistant-frontend/chat",r={"Content-Type":"application/json"},a={source:{shopId:s,url:window.location.origin},assistantId:i,threadId:n,message:t,streaming:!0},d=this.el.getAttribute("data-biloba-assistant-frontend-product-id");d&&(a.productId=d),this._updateButtons();let u=document.createElement("li");u.classList.add("user"),u.textContent=t,this._messages.appendChild(u),this._inputField.value="";let c=l.querySelector(this.el,".typing-indicator",!1);c.style.display="flex",this._scrollToBottom(),"undefined"!=typeof EventSource?this._sendChatWithStreaming(o,r,a,c):(a.streaming=!1,this._sendChatWithoutStreaming(o,r,a,c))}}_sendChatWithStreaming(t,e,s,i){let n=this;fetch(t,{method:"POST",headers:e,body:JSON.stringify(s)}).then(t=>{if(401===t.status)throw Error("AUTHENTICATION_FAILED");let e=t.body.getReader(),s=new TextDecoder,o="",r="",a=null,l=!1,d=null,u=0;function c(){a&&(a.innerHTML=n._parseMarkdown(r))}return e.read().then(function t(h){let{done:p,value:b}=h;if(p){c(),i.style.display="none",n._scrollToBottom(),n._updateButtons(!0);return}let g=(o+=s.decode(b,{stream:!0})).split("\n");for(let t of(o=g.pop(),g)){if(""===(t=t.trim())||!t.startsWith("data: "))continue;let e=t.substring(6);if("[DONE]"===e){c(),i.style.display="none",n._scrollToBottom(),n._updateButtons(!0);return}try{let t=JSON.parse(e);if("thread.created"===t.type&&t.threadId)n.el.setAttribute("data-biloba-assistant-frontend-thread-id",t.threadId),sessionStorage.setItem("bilobaOpenAiAssistantFrontendThreadId",t.threadId),sessionStorage.setItem("bilobaOpenAiAssistantFrontendLastMessage",new Date().getTime()),n._backfillConsentThread(t.threadId);else if("response.output_text.delta"===t.type&&t.delta)l||(l=!0,i.style.display="none",(a=document.createElement("li")).classList.add("assistant"),n._messages.appendChild(a)),void 0!==t.output_index&&t.output_index!==d&&(d=t.output_index,r="",a&&(a.innerHTML="")),function(t){r+=t;let e=Date.now();e-u<60||(u=e,a.innerHTML=n._parseMarkdown(r))}(t.delta),n._scrollToBottom();else if("response.completed"===t.type){if(i.style.display="none",t.response&&t.response.output&&t.response.output.length>0){let e=null;for(let s=t.response.output.length-1;s>=0;s--){let i=t.response.output[s];if("message"===i.type&&i.content&&i.content[0]&&i.content[0].text){e=i.content[0].text;break}}e&&(a||((a=document.createElement("li")).classList.add("assistant"),n._messages.appendChild(a)),a.innerHTML=n._parseMarkdown(e))}else a&&(a.innerHTML=n._parseMarkdown(r));n._scrollToBottom(),n._updateButtons(!0);return}else if("error"===t.type)throw Error(t.error||"Streaming error occurred")}catch(e){console.error("Error parsing SSE event:",e,"Line:",t)}}return e.read().then(t)})}).catch(t=>{console.error("Streaming error:",t),i.style.display="none";let e=document.createElement("li");e.classList.add("assistant"),"AUTHENTICATION_FAILED"===t.message?e.textContent="The chat assistant could not authenticate with the backend. Please contact support.":e.textContent="A general error occurred. Please try again.",n._messages.appendChild(e),n._updateButtons(!0)})}_sendChatWithoutStreaming(t,e,s,i){let n=this;fetch(t,{method:"POST",headers:e,body:JSON.stringify(s)}).then(t=>{if(401===t.status)throw Error("AUTHENTICATION_FAILED");return t.json()}).then(t=>{if(i.style.display="none",200==t.status){t.threadId&&(n.el.setAttribute("data-biloba-assistant-frontend-thread-id",t.threadId),sessionStorage.setItem("bilobaOpenAiAssistantFrontendThreadId",t.threadId),sessionStorage.setItem("bilobaOpenAiAssistantFrontendLastMessage",new Date().getTime()));let e=document.createElement("li");e.classList.add("assistant"),e.innerHTML=n._sanitizeHtml(t.message.value),n._messages.appendChild(e),n._scrollToBottom(),n._updateButtons(!0)}else console.log(t),n._updateButtons(!0)}).catch(t=>{console.error("Error:",t);let e=document.createElement("li");e.classList.add("assistant"),"AUTHENTICATION_FAILED"===t.message?e.textContent="The chat assistant could not authenticate with the backend. Please contact support.":e.textContent="A general error occurred. Please try again.",n._messages.appendChild(e),n._updateButtons(!0),i.style.display="none"})}_updateButtons(t){t?(this._inputField.disabled=!1,this._inputField.classList.remove("disabled"),this._submitButton.disabled=!1,this._submitButton.classList.remove("disabled"),this._refreshButton.classList.remove("disabled"),this._closeButton.classList.remove("disabled")):(this._inputField.disabled=!0,this._inputField.classList.add("disabled"),this._submitButton.disabled=!0,this._submitButton.classList.add("disabled"),this._refreshButton.classList.add("disabled"),this._closeButton.classList.add("disabled"))}_scrollToBottom(){let t=l.querySelector(this.el,".chat-body",!1);t.scrollTop=t.scrollHeight}_refreshChat(){this._refreshButton.classList.contains("disabled")||(this.el.setAttribute("data-biloba-assistant-frontend-thread-id",""),this._messages.innerHTML="",sessionStorage.removeItem("bilobaOpenAiAssistantFrontendThreadId"),sessionStorage.removeItem("bilobaOpenAiAssistantFrontendLastMessage"))}uniqueBind(t,e,s){var i=t.getAttribute("id");i||(i="_"+Math.random().toString(36).substring(2,11),t.setAttribute("id",i)),this.listeners=this.listeners||{},this.listeners[i]=this.listeners[i]||{},this.listeners[i][e]&&t.removeEventListener(e,this.listeners[i][e]),this.listeners[i][e]=s,t.addEventListener(e,s)}_optionClick(t){if(this._dsgvoActive&&!this._dsgvoConsented)return;let e=t.target.getAttribute("data-option");e&&(this._inputField.value=e,this.sendChat())}_showDsgvoConsentOverlay(){this.el.classList.add("needs-consent")}_hideDsgvoConsentOverlay(){this.el.classList.remove("needs-consent")}_acceptDsgvoConsent(){this._dsgvoConsented=!0,this._setCookie(u,"accepted",365),this._logDsgvoConsent(),this._hideDsgvoConsentOverlay(),this._openChat(!1)}_logDsgvoConsent(){console.log("[biloba-consent] _logDsgvoConsent() fired");let t=this.el.getAttribute("data-biloba-assistant-frontend-dsgvo-consent-text")||"";if(!t){console.warn("[biloba-consent] abort: data-biloba-assistant-frontend-dsgvo-consent-text missing");return}if(!window.crypto||!window.crypto.subtle||!window.TextEncoder){console.warn("[biloba-consent] abort: WebCrypto / TextEncoder not available");return}let e=this.el.getAttribute("data-biloba-assistant-frontend-shop-url"),s=this.el.getAttribute("data-biloba-assistant-frontend-shop-id"),i=this.el.getAttribute("data-biloba-assistant-frontend-assistant-id");if(console.log("[biloba-consent] context",{shopUrl:e,shopId:s,assistantId:i}),!e||!s||!i){console.warn("[biloba-consent] abort: missing shopUrl/shopId/assistantId data attribute");return}let n=sessionStorage.getItem("bilobaOpenAiAssistantFrontendThreadId")||null,o=new TextEncoder;window.crypto.subtle.digest("SHA-256",o.encode(t)).then(function(o){let r=Array.from(new Uint8Array(o)).map(function(t){return t.toString(16).padStart(2,"0")}).join(""),a=null;try{a=sessionStorage.getItem(c)}catch(t){}if(a===r){console.log("[biloba-consent] skip: already logged this version",r);return}let l=e+"/shopware6-frontend/assistant-frontend/consent";console.log("[biloba-consent] POST",l,{consentVersion:r,threadId:n}),fetch(l,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({source:{shopId:s,url:window.location.origin},assistantId:i,thread_id:n,consent_text_version:r,consent_text:t})}).then(function(t){if(console.log("[biloba-consent] response",t.status,t.ok),t&&t.ok){try{
8sessionStorage.setItem(c,r)}catch(t){}t.json().then(function(t){if(t&&t.update_token)try{sessionStorage.setItem("bilobaConsentUpdateToken",t.update_token),console.log("[biloba-consent] update_token stored for thread backfill")}catch(t){}}).catch(function(){})}}).catch(function(t){console.error("[biloba-consent] fetch error",t)})}).catch(function(t){console.error("[biloba-consent] SHA-256 digest failed",t)})}_backfillConsentThread(t){let e=null;try{e=sessionStorage.getItem("bilobaConsentUpdateToken")}catch(t){return}if(!e)return;let s=this.el.getAttribute("data-biloba-assistant-frontend-shop-url"),i=this.el.getAttribute("data-biloba-assistant-frontend-shop-id");s&&i&&(console.log("[biloba-consent] backfilling thread_id",{threadId:t,updateToken:e}),fetch(s+"/shopware6-frontend/assistant-frontend/consent-thread",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({source:{shopId:i,url:window.location.origin},update_token:e,thread_id:t})}).then(function(t){console.log("[biloba-consent] backfill response",t.status,t.ok);try{sessionStorage.removeItem("bilobaConsentUpdateToken")}catch(t){}}).catch(function(t){console.error("[biloba-consent] backfill error",t)}))}_declineDsgvoConsent(){this._setCookie(u,"declined",0),this._hideDsgvoConsentOverlay(),this._closeChat()}_getCookie(t){let e=document.cookie.match(RegExp("(?:^|; )"+t.replace(/([.$?*|{}()[\]\\/+^])/g,"\\$1")+"=([^;]*)"));return e?decodeURIComponent(e[1]):null}_setCookie(t,e,s){let i=encodeURIComponent(t)+"="+encodeURIComponent(e)+"; path=/; SameSite=Lax; Secure";if(s>0){let t=new Date;t.setTime(t.getTime()+864e5*s),i+="; expires="+t.toUTCString()}document.cookie=i}_parseMarkdown(t){if(!t)return"";let e=t;return/<[a-z][\s\S]*>/i.test(e)||(e=e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")),e=(e=(e=(e=(e=e.replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>")).replace(/__(.*?)__/g,"<strong>$1</strong>")).replace(/\*(?!\s)(.*?)(?<!\s)\*/g,"<em>$1</em>")).replace(/(?<!\w)_(?!\s)(.*?)(?<!\s)_(?!\w)/g,"<em>$1</em>")).replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),/<[ou]l[^>]*>|<li[^>]*>/i.test(t)||(e=this._renderLists(e)),e=(e=(e=(e=(e=(e=e.replace(/\n\n/g,"<br><br>")).replace(/(?<!>)\n(?!<)/g,"<br>")).replace(/<br>(<\/?[ou]l>)/g,"$1")).replace(/(<\/?[ou]l>)<br>/g,"$1")).replace(/<\/ol>\s*<ol>/g,"")).replace(/<\/ul>\s*<ul>/g,""),this._sanitizeHtml(e)}_renderLists(t){let e=t.split("\n"),s=[],i=[],n=t=>{for(;i.length>t;)s.push("</li>"),s.push("</"+i.pop().type+">")};return e.forEach(t=>{let e=t.match(/^(\s*)(\d+\.|[-*])\s+(.*)$/);if(!e){if(/^\s*$/.test(t)&&i.length>0)return;n(0),s.push(t);return}let o=e[1].replace(/\t/g," ").length,r=/^\d/.test(e[2])?"ol":"ul",a=e[3];if(0===i.length||o>i[i.length-1].indent)i.push({type:r,indent:o}),s.push("<"+r+">");else{for(;i.length>1&&o<i[i.length-1].indent;)s.push("</li>"),s.push("</"+i.pop().type+">");s.push("</li>"),i[i.length-1].type!==r&&(s.push("</"+i.pop().type+">"),i.push({type:r,indent:o}),s.push("<"+r+">"))}s.push("<li>"+a)}),n(0),s.join("\n")}_sanitizeHtml(t){if(!t)return"";let e=document.createElement("template");e.innerHTML=t;let s=t=>{Array.from(t.children).forEach(e=>{s(e);let i=e.tagName.toLowerCase();if(!Object.prototype.hasOwnProperty.call(p,i)){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e);return}Array.from(e.attributes).forEach(t=>{let s=t.name.toLowerCase();if(!p[i].includes(s)){e.removeAttribute(t.name);return}"a"===i&&"href"===s&&e.setAttribute("href",this._rewriteShopLink(t.value)),"href"!==s&&"src"!==s||this._isSafeUrl(e.getAttribute(s),"img"===i)||e.removeAttribute(t.name)}),"a"===i&&e.removeAttribute("target")})};return s(e.content),e.innerHTML}_rewriteShopLink(t){if(!t)return t;let e=null,s=t.match(/(?:^|\/)((?:detail|navigation|landingpage)\/[0-9a-f]{32})/i);if(s)e=s[1];else{let s=t.match(/^\/?(blog\/[^\s"'?#]+)/i);s&&(e=s[1])}if(!e)return t;let i=this.el.getAttribute("data-biloba-storefront-url")||this.el.getAttribute("data-biloba-storefront-absolute-url")||window.location.origin;return(i=i.replace(/\/+$/,""))+"/"+e}_isSafeUrl(t,e){let s=(t||"").replace(/[\u0000-\u001F\u007F]/g,"").replace(/\\/g,"/").trim();if(""===s||/^\/\//.test(s))return!1;if(/^(\/|\.\/|\.\.\/|#|\?)/.test(s))return!0;let i=s.match(/^([a-z][a-z0-9+.-]*):/i);if(!i)return!0;let n=i[1].toLowerCase();return e?"http"===n||"https"===n:"http"===n||"https"===n||"mailto"===n}},"[data-biloba-assistant-frontend]")})();
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.