https://einweg-vape.de/theme/05c86c87a83376c310bc4a192f62d6bf/js/c…/cogi-free-products.js?1791476205
1(()=>{"use strict";var e={857:e=>{var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==r},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function o(e,t){return!1!==t.clone&&t.isMergeableObject(e)?s(Array.isArray(e)?[]:{},e,t):e}function i(e,t,r){return e.concat(t).map(function(e){return o(e,r)})}function n(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function a(e,t){try{return t in e}catch(e){return!1}}function s(e,r,l){(l=l||{}).arrayMerge=l.arrayMerge||i,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=o;var c,d,u=Array.isArray(r);return u!==Array.isArray(e)?o(r,l):u?l.arrayMerge(e,r,l):(d={},(c=l).isMergeableObject(e)&&n(e).forEach(function(t){d[t]=o(e[t],c)}),n(r).forEach(function(t){(!a(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(a(e,t)&&c.isMergeableObject(r[t])?d[t]=(function(e,t){if(!t.customMerge)return s;var r=t.customMerge(e);return"function"==typeof r?r:s})(t,c)(e[t],r[t],c):d[t]=o(r[t],c))}),d)}s.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,r){return s(e,r,t)},{})},e.exports=s}},t={};function r(o){var i=t[o];if(void 0!==i)return i.exports;var n=t[o]={exports:{}};return e[o](n,n.exports,r),n.exports}(()=>{r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t}})(),(()=>{r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})}})(),(()=>{r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{var e=r(857),t=r.n(e);class o{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let r=o.toUpperCamelCase(e,t);return o.lcFirst(r)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>o.ucFirst(e.toLowerCase())).join(""):o.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}class i{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!i.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!1===i.hasAttribute(e,t))throw Error('The required property "'.concat(t,'" does not exist!'));if("function"!=typeof e.getAttribute){if(r)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2],n=t.replace(/^data(|-)/,""),a=o.toLowerCamelCase(n,"-");if(!i.isNode(e)){if(r)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(r)throw Error("This node doesn't support the dataset attribute!");return}let s=e.dataset[a];if(void 0===s){if(r)throw Error('The required data attribute "'.concat(t,'" does not exist on ').concat(e,"!"));return s}return o.parsePrimitive(s)}static querySelector(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!i.isNode(e))throw Error("The parent node is not a valid HTML Node!");let o=e.querySelector(t)||!1;if(r&&!1===o)throw Error('The required element "'.concat(t,'" does not exist in parent node!'));return o}static querySelectorAll(e,t){let r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(r&&!i.isNode(e))throw Error("The parent node is not a valid HTML Node!");let o=e.querySelectorAll(t);if(0===o.length&&(o=!1),r&&!1===o)throw Error('At least one item of "'.concat(t,'" must exist in parent node!'));return o}static getFocusableElements(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return e.querySelectorAll('\n input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]),\n select:not([tabindex^="-"]):not([disabled]),\n textarea:not([tabindex^="-"]):not([disabled]),\n button:not([tabindex^="-"]):not([disabled]),\n a[href]:not([tabindex^="-"]):not([disabled]),\n [tabindex]:not
1([tabindex^="-"]):not([disabled])\n ')}static getFirstFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(e)[0]}static getLastFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=this.getFocusableElements(e);return t[t.length-1]}}class n{publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=new CustomEvent(e,{detail:t,cancelable:r});return this.el.dispatchEvent(o),o}subscribe(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=this,i=e.split("."),n=r.scope?t.bind(r.scope):t;if(r.once&&!0===r.once){let t=n;n=function(r){o.unsubscribe(e),t(r)}}return this.el.addEventListener(i[0],n),this.listeners.push({splitEventName:i,opts:r,cb:n}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,r)=>([...r.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(r.splitEventName[0],r.cb):e.push(r),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}}class a{init(){throw Error('The "init" method for the plugin "'.concat(this._pluginName,'" is not defined.'))}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let r=o.toDashCase(this._pluginName),n=i.getDataAttribute(this.el,"data-".concat(r,"-config"),!1),a=i.getAttribute(this.el,"data-".concat(r,"-options"),!1),s=[this.constructor.options,this.options,e];n&&s.push(window.PluginConfigManager.get(this._pluginName,n));try{a&&s.push(JSON.parse(a))}catch(e){throw console.error(this.el),Error('The data attribute "data-'.concat(r,'-options" could not be parsed to json: ').concat(e.message))}return t().all(s.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}constructor(e,t={},r=!1){if(!i.isNode(e))throw Error("There is no valid element given.");this.el=e,this.$emitter=new n(this.el),this._pluginName=this._getPluginName(r),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}}class s{get(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",o=this._createPreparedRequest("GET",e,r);return this._sendRequest(o,null,t)}post(e,t,r){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";o=this._getContentType(t,o);let i=this._createPreparedRequest("POST",e,o);return this._sendRequest(i,t,r)}delete(e,t,r){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";o=this._getContentType(t,o);let i=this._createPreparedRequest("DELETE",e,o);return this._sendRequest(i,t,r)}patch(e,t,r){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";o=this._getContentType(t,o);let i=this._createPreparedRequest("PATCH",e,o);return this._sendRequest(i,t,r)}
1abort(){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,r){return this._registerOnLoaded(e,r),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,r){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),r&&this._request.setRequestHeader("Content-type",r),this._request}constructor(){this._request=null,this._errorHandlingInternal=!1}}class l extends a{init(){this._client=new s,this._currentQuantity=1,this._selectedVariantId=null,this._selectedProductStreamProductId=null,this._currentVariantId=null,this._currentFreeProductId=null,this._replacingVariant=!1,this._replacingLineItemId=null,this._currentType="variant",this._allVariants=[],this._filteredVariants=[],this._registerEvents()}_getBaseUrl(){let e=document.querySelector(this.options.variantModalSelector);return e&&e.dataset.baseUrl?e.dataset.baseUrl:window.location.origin}_registerEvents(){document.addEventListener("click",e=>{let t=e.target.closest(this.options.variantTriggerSelector);t&&(e.preventDefault(),this._openModal(t.dataset.productId,t.dataset.freeProductId,parseInt(t.dataset.quantity)||1,"variant"))}),document.addEventListener("click",e=>{let t=e.target.closest(this.options.streamTriggerSelector);t&&(e.preventDefault(),this._openModal(t.dataset.productStreamId,t.dataset.freeProductId,parseInt(t.dataset.quantity)||1,"stream"))}),document.addEventListener("click",e=>{let t=e.target.closest(this.options.variantChangeBtnSelector);if(t){e.preventDefault(),e.stopPropagation();let r=t.dataset.lineItemId,o=t.dataset.productId,i=t.dataset.freeProductId,n=t.dataset.currentVariantId;if(!r||!o||!i)return;this._replacingVariant=!0,this._replacingLineItemId=r,this._currentVariantId=n||null,this._openModal(o,i,1,"variant")}}),document.addEventListener("change",e=>{if(e.target.matches(this.options.variantRadioSelector)){"stream"===this._currentType?this._selectedProductStreamProductId=e.target.value:this._selectedVariantId=e.target.value;let t=document.querySelector(this.options.variantAddBtnSelector);if(t){let r="stream"===this._currentType?this._selectedProductStreamProductId:this._selectedVariantId;t.disabled=!r||e.target.disabled}this._updateVariantCheckmarks(e.target)}});let e=document.querySelector(this.options.variantModalSelector);e&&e.addEventListener("shown.bs.modal",()=>{this._updateVariantCheckmarks()}),document.addEventListener("click",e=>{let t=e.target.closest(this.options.variantAddBtnSelector);if(t&&!t.disabled){let t=document.querySelector(this.options.variantModalSelector);if(t&&t.hasAttribute("data-stream-replace-mode"))return;e.preventDefault(),e.stopPropagation(),this._addVariantToCart()}}),e&&e.addEventListener("hidden.bs.modal",()=>{this._resetModal()}),document.addEventListener("input",e=>{e.target.matches(this.options.searchInputSelector)&&"stream"===this._currentType&&this._handleSearchAndFilter()}),document.addEventListener("change",e=>{e.target.matches(this.options.filterSelectSelector)&&"stream"===this._currentType&&this._handleSearchAndFilter()})}_openModal(e,t,r){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"variant";this._currentQuantity=r,this._selectedVariantId=null,this._selectedProductStreamProductId=null,this._currentFreeProductId=t,this._currentType=o,this._replacingVariant||(this._currentVariantId=null);let i=document.querySelector(this.options.variantModalSelector),n=document.querySelector(this.options.variantContentSelector),a=document.querySelector(this.options.variantLoadingSelector),s=document.querySelector(this.options.variantAddBtnSelector),l=i?i.querySelector(".modal-title"):null;if(!i||!n||!a)return;if(l){if("stream"===o){let e=l.getAttribute("data-stream-title")||l.dataset.streamTitle||"Produkt auswählen";l.textContent=e}else{let e=l.getAttribute("data-variant-title")||l.dataset.variantTitle||"Variante auswählen";l.textContent=e}}a.style.display="block",n.style.display="none",n.innerHTML="";let c=document.querySelector(this.options.searchFilterSectionSelector);c&&(c.style.display="none"),s&&(s.disabled=!0,this._replacingVariant&&(s.textContent="Variante ersetzen")),new bootstrap.Modal(i).show(),"stream"===o?this._loadStreamProducts(e,n,a,s):this._loadVariants(e,n,a,s)}_loadVariants(e,t,r,o){let i=this._getBaseUrl(),n="".concat(i,"/free-product/variants/").concat(e);this._client.get(n,e=>{r.style.display="none",t.style.display="block",t.innerHTML=e,this._allVariants=Array.from(t.querySelectorAll(".variant-option"));let i=document.querySelector(this.options.searchFilterSectionSelector);if(i&&(i.style.display="none"),0===t.querySelectorAll(this.options.variantRadioSelector).length){o&&(o.disabled=!0);return}if(o&&this._replacingVariant&&(o.textContent="Variante ersetzen"),this._currentVariantId){let e=t.querySelector("".concat(this.options.variantRadioSelector,'[value="').concat(this._currentVariantId,'"]'));e&&!e.disabled?(e.checked=!0,this._selectedVariantId=this._currentVariantId,o&&(o.disabled=!1),this._updateV
1ariantCheckmarks(e)):this._updateVariantCheckmarks()}else this._updateVariantCheckmarks()},"text/html",e=>{r.style.display="none",t.style.display="block",t.innerHTML='<div class="alert alert-danger">Fehler beim Laden der Varianten. Bitte versuchen Sie es erneut.</div>',o&&(o.disabled=!0)})}_addVariantToCart(){let e="stream"===this._currentType?this._selectedProductStreamProductId:this._selectedVariantId;if(!e)return;let t=document.querySelector(this.options.variantAddBtnSelector);t&&(t.disabled=!0,t.textContent=this._replacingVariant?"Wird ersetzt...":"Wird hinzugefügt...");let r=new FormData,o=this._getBaseUrl(),i=this._replacingVariant&&this._replacingLineItemId?"".concat(o,"/checkout/line-item/free-product/replace-variant"):"".concat(o,"/checkout/line-item/free-product/add");this._replacingVariant&&this._replacingLineItemId?(r.append("lineItemId",this._replacingLineItemId),r.append("newVariantId",e)):(r.append("lineItems[0][id]",e),r.append("lineItems[0][type]","product"),r.append("lineItems[0][quantity]",this._currentQuantity),"stream"===this._currentType&&this._currentFreeProductId&&r.append("freeProductId",this._currentFreeProductId));let n=window.location.pathname,a="frontend.cart.offcanvas";n.includes("/checkout/confirm")?a="frontend.checkout.confirm.page":n.includes("/checkout/cart")&&(a="frontend.cart.offcanvas"),r.append("redirectTo",a),this._client.post(i,r,()=>{let e=document.querySelector(this.options.variantModalSelector);if(e){let t=bootstrap.Modal.getInstance(e);t&&t.hide()}window.location.reload()},"text/html",e=>{t&&(t.disabled=!1,t.textContent=this._replacingVariant?"Variante ersetzen":"Zum Warenkorb hinzufügen"),alert(this._replacingVariant?"Fehler beim Ersetzen der Variante. Bitte versuchen Sie es erneut.":"Fehler beim Hinzufügen zum Warenkorb. Bitte versuchen Sie es erneut.")})}_resetModal(){this._currentQuantity=1,this._selectedVariantId=null,this._selectedProductStreamProductId=null,this._currentVariantId=null,this._currentFreeProductId=null,this._replacingVariant=!1,this._replacingLineItemId=null,this._allVariants=[],this._filteredVariants=[];let e=document.querySelector(this.options.variantContentSelector),t=document.querySelector(this.options.variantLoadingSelector),r=document.querySelector(this.options.variantAddBtnSelector),o=document.querySelector(this.options.searchInputSelector),i=document.querySelector(this.options.filterSelectSelector),n=document.querySelector(this.options.searchFilterSectionSelector),a=document.querySelector(this.options.noResultsSelector),s=document.querySelector(this.options.resultsCountSelector);e&&(e.innerHTML="",e.style.display="none"),t&&(t.style.display="block"),r&&(r.disabled=!0),o&&(o.value=""),i&&(i.value="all"),n&&(n.style.display="none"),a&&(a.style.display="none"),s&&(s.style.display="none")}openModalForProduct(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this._openModal(e,t,r,"variant")}openModalForStream(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;this._openModal(e,t,r,"stream")}_loadStreamProducts(e,t,r,o){let i=this._getBaseUrl(),n="".concat(i,"/free-product/product-stream/").concat(e);this._client.get(n,e=>{r.style.display="none",t.style.display="block",t.innerHTML=e,this._allVariants=Array.from(t.querySelectorAll(".variant-option"));let i=document.querySelector(this.options.searchFilterSectionSelector);if(i&&this._allVariants.length>0&&(i.style.display="block"),0===t.querySelectorAll(this.options.variantRadioSelector).length){o&&(o.disabled=!0);return}if(o&&this._replacingVariant&&(o.textContent="Variante ersetzen"),this._currentVariantId){let e=t.querySelector("".concat(this.options.variantRadioSelector,'[value="').concat(this._currentVariantId,'"]'));e&&!e.disabled?(e.checked=!0,this._selectedVariantId=this._currentVariantId,o&&(o.disabled=!1),this._updateVariantCheckmarks(e)):this._updateVariantCheckmarks()}else this._updateVariantCheckmarks();this._handleSearchAndFilter()},"text/html",e=>{r.style.display="none",t.style.display="block",t.innerHTML='<div class="alert alert-danger">Fehler beim Laden der Produkte. Bitte versuchen Sie es erneut.</div>',o&&(o.disabled=!0)})}_updateVariantCheckmarks(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];let e=document.querySelector(this.options.variantContentSelector);
1e&&e.querySelectorAll(".variant-option").forEach(e=>{let t=e.querySelector(this.options.variantRadioSelector),r=e.querySelector(".variant-checkmark");t&&r&&(r.style.display=t.checked?"flex":"none")})}_handleSearchAndFilter(){if("stream"!==this._currentType)return;let e=document.querySelector(this.options.variantContentSelector),t=document.querySelector(this.options.searchInputSelector),r=document.querySelector(this.options.filterSelectSelector),o=document.querySelector(this.options.noResultsSelector),i=document.querySelector(this.options.resultsCountSelector),n=document.querySelector(this.options.resultsTextSelector);if(!e||!t||!r)return;let a=(t.value||"").toLowerCase().trim(),s=r.value||"all",l=Array.from(e.querySelectorAll(".variant-option")),c=0;if(l.forEach(e=>{let t=!0;if(a){var r,o;let i=(((r=e.querySelector(".variant-name"))===null||void 0===r?void 0:r.textContent)||"").toLowerCase(),n=(((o=e.querySelector(".variant-number"))===null||void 0===o?void 0:o.textContent)||"").toLowerCase(),s=Array.from(e.querySelectorAll(".variant-property-value")).map(e=>e.textContent.toLowerCase()).join(" ");"".concat(i," ").concat(n," ").concat(s).includes(a)||(t=!1)}if(t&&"all"!==s){let r=e.querySelector(this.options.variantRadioSelector),o=r&&!r.disabled;"available"!==s||o?"unavailable"===s&&o&&(t=!1):t=!1}t?(e.style.display="",c++):e.style.display="none"}),o&&(0===c&&l.length>0?(o.style.display="block",e.style.display="none"):(o.style.display="none",e.style.display="block")),i&&n){if(a||"all"!==s){let e=l.length,t="".concat(c," von ").concat(e," ").concat(1===e?"Produkt":"Produkte"," gefunden");n.textContent=t,i.style.display="block"}else i.style.display="none"}}}l.options={variantModalSelector:"#freeProductVariantModal",variantTriggerSelector:".free-product-variant-trigger",streamTriggerSelector:".free-product-stream-trigger",variantContentSelector:".free-product-variant-content",variantLoadingSelector:".free-product-variant-loading",variantAddBtnSelector:".free-product-variant-add-btn",variantRadioSelector:".free-product-variant-radio",variantChangeBtnSelector:".free-product-variant-change-btn",searchInputSelector:".free-product-variant-search-input",filterSelectSelector:".free-product-variant-filter-select",searchFilterSectionSelector:".free-product-variant-search-filter",noResultsSelector:".free-product-variant-no-results",resultsCountSelector:".free-product-variant-results-count",resultsTextSelector:".free-product-variant-results-text"};class c extends a{init(){this._isDown=!1,this._startX=0,this._scrollLeft=0,this._container=null,this._registerEvents()}_registerEvents(){document.querySelectorAll(this.options.scrollContainerSelector).forEach(e=>{this._isScrollable(e)&&(this._setupDragScroll(e),e.dataset.dragScrollInitialized="true")}),this._setupObserver()}_isScrollable(e){return e.scrollWidth>e.clientWidth}_updateCursor(e){if(this._shouldUseNativeTouchPan()){e.style.cursor="",e.style.userSelect="";return}this._isScrollable(e)?(e.style.cursor="grab",e.style.userSelect="none"):(e.style.cursor="",e.style.userSelect="")}_shouldUseNativeTouchPan(){if("undefined"==typeof window||!window.matchMedia)return!1;try{if(window.matchMedia("(pointer: coarse)").matches||window.matchMedia("(max-width: 768px)").matches&&"ontouchstart"in window)return!0}catch(e){}return!1}_shouldUsePersistentCustomScrollbar(){if("undefined"==typeof window||!window.matchMedia)return!1;try{if(window.matchMedia("(max-width: 768px)").matches||window.matchMedia("(pointer: coarse)").matches)return!0}catch(e){}return!1}_setupDragScroll(e){if(this._updateCursor(e),this._setupScrollbarVisibilityMode(e),e.addEventListener("mousedown",t=>{!t.target.closest("button, a, form, input, select, textarea")&&this._isScrollable(e)&&(e.classList.contains("cogi-free-products-scroll-container--scrollbar-on-scroll")&&this._bumpOnScrollScrollbarVisibility(e),this._isDown=!0,e.style.cursor="grabbing",this._startX=t.pageX-e.offsetLeft,this._scrollLeft=e.scrollLeft,t.preventDefault())}),e.addEventListener("mouseleave",()=>{this._isDown=!1,this._updateCursor(e)}),e.addEventListener("mouseup",()=>{this._isDown=!1,this._updateCursor(e)}),e.addEventListener("mousemove",t=>{if(!this._isDown)return;t.preventDefault();let r=(t.pageX-e.offsetLeft-this._startX)*2;e.scrollLeft=this._scrollLeft-r}),!this._shouldUseNativeTouchPan()){let t=0,r=0,o=null;e.addEventListener("touchstart",i=>{if(i.target.closest("button, a, form, input, select, textarea")){o=i.target.closest("button, a, form, input, select, textarea");return}t=i.touches[0].pageX-e.offsetLeft,r=e.scrollLeft,o=null},{passive:!0}),e.addEventListener("touchmove",i=>{if(o||!t)return;let n=(i.touches[0].pageX-e.offsetLeft-t)*2;e.scrollLeft=r-n},{passive:!0}),e.addEventListener("touchend",()=>{t=0,o=null})}this._syncScrollbarAlwaysCustomIndicator(e)}_setupScrollbarVisibilityMode(e){if(!e.classList.contains("cogi-free-products-scroll-container--scrollbar-on-scroll")||"true"===e.dataset.cogiScrollbarVisibilityAttached)return;e.dataset.cogiScrollbarVisibilityAttached="true";let t=()=>{this._bumpOnScrollScrollbarVisibility(e)};e.addEventListener("scroll",t,{passive:!0}),e.addEventListener("wheel",t,{passive:!0})}_bumpOnScrollScrollbarVisibility(e){let t=this.constructor.ON_SCROLL_VISIBILITY_CLASS,r=this.constructor.ON_SCROLL_FADE_OUT_CLASS,o=this.options.scrollbarOnScrollIdleHideMs,i=this.options.scrollbarOnScrollFadeOutMs;e.classList.remove(r),e.classList.add(t),window.clearTimeout(e._cogiFreeProductsScrollbarHideTimer),window.clearTimeout(e._cogiFreeProductsScrollbarFadeCompleteTimer),e._cogiFreeProductsScrollbarHideTimer=window.setTimeout(()=>{e.classList.add(r),e._cogiFreeProductsScrollbarFadeCompleteTimer=window.setTimeout(()=>{e.classList.remove(t,r)},i)},o)}_teardownPersistentCustomScrollbar(e){if("true"!==e.dataset.cogiPersistentScrollbarIndicator)return;delete e.dataset.cogiPersistentScrollbarIndicator,e.classList.remove(this.constructor.CUSTOM_SCROLLBAR_CLASS),null!=e._cogiScrollIndicatorScrollRafId&&window.cancelAnimationFrame(e._cogiScrollIndicatorScrollRafId),e._cogiScrollIndicatorScrollRafId=null;let t=e._cogiScrollIndicatorOnScroll,r=e._cogiScrollIndicatorOnLayout;"function"==typeof t&&e.removeEventListener("scroll",t),"function"==typeof r&&window.removeEventListener("resize",r),e._cogiScrollIndicatorOnScroll=null,e._cogiScrollIndicatorOnLayout=null,e._cogiScrollIndicatorResizeObserver&&(e._cogiScrollIndicatorResizeObserver.disconnect(),e._cogiScrollIndicatorResizeObserver=null);let o=e._cogiScrollIndicatorWrap;o&&o.parentNode&&o.parentNode.removeChild(o),e._cogiScrollIndicatorWrap=null,e._cogiScrollIndicatorThumb=null}_updatePersistentCustomScrollbarThumb(e){let t=e._cogiScrollIndicatorThumb;if(!t)return;let r=e.scrollWidth-e.clientWidth;if(r<=0){t.style.width="100%",t.style.left="0%";return}let o=Math.min(100,Math.max(e.clientWidth/e.scrollWidth*100,8)),i=e.scrollLeft/r*(100-o);t.style.width="".concat(o,"%"),t.style.left="".concat(i,"%")}_syncScrollbarAlwaysCustomIndicator(e){if(!e.classList.contains("cogi-free-products-scroll-container--scrollbar-always")||!this._shouldUsePersistentCustomScrollbar()||!this._isScrollable(e)){this._teardownPersistentCustomScrollbar(e);return}if("true"===e.dataset.cogiPersistentScrollbarIndicator){this._updatePersistentCustomScrollbarThumb(e);return}e.dataset.cogiPersistentScrollbarIndicator="true",e.classList.add(this.constructor.CUSTOM_SCROLLBAR_CLASS);let t=document.createElement("div");
1t.className="cogi-free-products-scroll-indicator",t.setAttribute("aria-hidden","true");let r=document.createElement("div");r.className="cogi-free-products-scroll-indicator__track";let o=document.createElement("div");o.className="cogi-free-products-scroll-indicator__thumb",r.appendChild(o),t.appendChild(r),e.parentNode&&e.parentNode.insertBefore(t,e.nextSibling),e._cogiScrollIndicatorWrap=t,e._cogiScrollIndicatorThumb=o,e._cogiScrollIndicatorScrollRafId=null,this._syncCustomScrollbarThemeVars(e);let i=()=>{null==e._cogiScrollIndicatorScrollRafId&&(e._cogiScrollIndicatorScrollRafId=window.requestAnimationFrame(()=>{e._cogiScrollIndicatorScrollRafId=null,this._updatePersistentCustomScrollbarThumb(e)}))},n=()=>{this._syncCustomScrollbarThemeVars(e),this._updatePersistentCustomScrollbarThumb(e)};if(e._cogiScrollIndicatorOnScroll=i,e._cogiScrollIndicatorOnLayout=n,e.addEventListener("scroll",i,{passive:!0}),window.addEventListener("resize",n),"undefined"!=typeof ResizeObserver){let t=new ResizeObserver(n);t.observe(e),e._cogiScrollIndicatorResizeObserver=t}this._updatePersistentCustomScrollbarThumb(e)}_syncCustomScrollbarThemeVars(e){let t=e._cogiScrollIndicatorWrap;if(!t)return;let r=getComputedStyle(e);["--cogi-card-slider-color","--cogi-card-button-hover-color"].forEach(e=>{let o=r.getPropertyValue(e).trim();o&&t.style.setProperty(e,o)})}_setupObserver(){new MutationObserver(()=>{document.querySelectorAll(this.options.scrollContainerSelector).forEach(e=>{e.dataset.dragScrollInitialized?(this._updateCursor(e),this._syncScrollbarAlwaysCustomIndicator(e)):this._isScrollable(e)&&(this._setupDragScroll(e),e.dataset.dragScrollInitialized="true")})}).observe(document.body,{childList:!0,subtree:!0}),window.addEventListener("resize",()=>{document.querySelectorAll(this.options.scrollContainerSelector).forEach(e=>{"true"===e.dataset.dragScrollInitialized&&(this._updateCursor(e),this._syncCustomScrollbarThemeVars(e),this._syncScrollbarAlwaysCustomIndicator(e))})})}}c.options={scrollContainerSelector:".cogi-free-products-scroll-container",scrollbarOnScrollIdleHideMs:900,scrollbarOnScrollFadeOutMs:260},c.ON_SCROLL_VISIBILITY_CLASS="is-cogi-free-products-scrollbar-visible",c.ON_SCROLL_FADE_OUT_CLASS="cogi-free-products-scrollbar--scrollbar-fade-out",c.CUSTOM_SCROLLBAR_CLASS="cogi-free-products-scroll-container--custom-scroll-indicator";class d extends a{init(){this._initTooltips(),this._observeChanges()}_initTooltips(){let e=this.el||document;(e.querySelectorAll?e.querySelectorAll(this.options.selector):document.querySelectorAll(this.options.selector)).forEach(e=>{if(!e.dataset.tooltipInitialized){if(this._isTextTruncated(e)){let t=e.getAttribute("data-product-name");if(e.setAttribute("title",t),e.setAttribute("data-bs-toggle","tooltip"),e.setAttribute("data-bs-placement","top"),"undefined"!=typeof bootstrap&&bootstrap.Tooltip)try{let t=bootstrap.Tooltip.getInstance(e);t&&t.dispose(),new bootstrap.Tooltip(e)}catch(e){}}else if(e.removeAttribute("title"),e.removeAttribute("data-bs-toggle"),e.removeAttribute("data-bs-placement"),"undefined"!=typeof bootstrap&&bootstrap.Tooltip){let t=bootstrap.Tooltip.getInstance(e);t&&t.dispose()}e.dataset.tooltipInitialized="true"}})}_isTextTruncated(e){return e.scrollWidth>e.clientWidth}_observeChanges(){if("undefined"!=typeof MutationObserver){this._observer=new MutationObserver(()=>{setTimeout(()=>{this._initTooltips()},100)});let e=this.el||document.body;this._observer.observe(e,{childList:!0,subtree:!0})}}destroy(){this._observer&&this._observer.disconnect(),super.destroy()}}d.options={selector:".cogi-free-product-card-name[data-product-name]"};class u extends a{init(){this._client=new s,this._registerEvents()}_getBaseUrl(){let e=document.querySelector(this.options.variantModalSelector);return e&&e.dataset.baseUrl?e.dataset.baseUrl:window.location.origin}_registerEvents(){this.el.querySelectorAll(this.options.removeButtonSelector).forEach(e=>{e.addEventListener("click",this._onRemoveClick.bind(this))})}_onRemoveClick(e){e.preventDefault(),e.stopPropagation();let t=e.currentTarget,r=t.getAttribute("data-free-product-id"),o=t.getAttribute("data-product-id"),i="true"===t.getAttribute("data-from-card");if(!r||!o)return;let n=window.location.pathname,a="frontend.cart.offcanvas";n.includes("/checkout/confirm")?a="frontend.checkout.confirm.page":n.includes("/checkout/cart")?a="frontend.cart.offcanvas":(n.includes("offcanvas")||document.querySelector(".offcanvas"))&&(a="frontend.cart.offcanvas");let s=new FormData;s.append("freeProductId",r),s.append("productId",o),s.append("fromCard",i?"1":"0"),s.append("redirectTo",a);let l=this._getBaseUrl(),c="".concat(l).concat(this.options.removeUrl);this._client.post(c,s,this._onRemoveSuccess.bind(this,a),"application/json",!1)}_onRemoveSuccess(e,t){window.location.reload()}}u.options={removeButtonSelector:'[data-remove-variant-product="true"]',removeUrl:"/checkout/free-product/variant/remove",variantModalSelector:"#freeProductVariantModal"};class h extends a{init(){this._client=new s,this._selectedProductId=null,this._currentProductId=null,this._currentFreeProductId=null,this._replacingProduct=!1,this._replacingLineItemId=null,this._allProducts=[],this._registerEvents()}_getBaseUrl(){let e=document.querySelector(this.options.variantModalSelector);return e&&e.dataset.baseUrl?e.dataset.baseUrl:window.location.origin}_registerEvents(){document.addEventListener("click",e=>{let t=e.target.closest(this.options.streamChangeBtnSelector);if(t){e.preventDefault(),e.stopPropagation();let r=t.dataset.lineItemId,o=t.dataset.productStreamId,i=t.dataset.freeProductId,n=t.dataset.currentProductId;if(!r||!o||!i)return;this._replacingProduct=!0,this._replacingLineItemId=r,this._currentProductId=n||null,this._openModal(o,i)}}),document.addEventListener("change",e=>
1{if(e.target.matches(this.options.variantRadioSelector)){this._selectedProductId=e.target.value;let t=document.querySelector(this.options.variantAddBtnSelector);t&&(t.disabled=!this._selectedProductId||e.target.disabled),this._updateProductCheckmarks(e.target)}});let e=document.querySelector(this.options.variantModalSelector);e&&e.addEventListener("shown.bs.modal",()=>{this._updateProductCheckmarks()}),document.addEventListener("click",e=>{let t=e.target.closest(this.options.variantAddBtnSelector);if(t&&!t.disabled){let t=document.querySelector(this.options.variantModalSelector);t&&t.hasAttribute("data-stream-replace-mode")&&(e.preventDefault(),e.stopPropagation(),this._replaceProduct())}}),e&&e.addEventListener("hidden.bs.modal",()=>{this._resetModal()}),document.addEventListener("input",e=>{e.target.matches(this.options.searchInputSelector)&&this._handleSearchAndFilter()}),document.addEventListener("change",e=>{e.target.matches(this.options.filterSelectSelector)&&this._handleSearchAndFilter()})}_openModal(e,t){this._selectedProductId=null,this._currentFreeProductId=t,this._replacingProduct||(this._currentProductId=null);let r=document.querySelector(this.options.variantModalSelector),o=document.querySelector(this.options.variantContentSelector),i=document.querySelector(this.options.variantLoadingSelector),n=document.querySelector(this.options.variantAddBtnSelector),a=r?r.querySelector(".modal-title"):null;if(r&&o&&i){if(a){let e=a.getAttribute("data-stream-title")||a.dataset.streamTitle||"Produkt auswählen";a.textContent=e}i.style.display="block",o.style.display="none",o.innerHTML="",n&&(n.disabled=!0,this._replacingProduct&&(n.textContent="Produkt ersetzen")),this._replacingProduct&&r.setAttribute("data-stream-replace-mode","true"),new bootstrap.Modal(r).show(),this._loadStreamProducts(e,o,i,n)}}_loadStreamProducts(e,t,r,o){let i=this._getBaseUrl(),n="".concat(i,"/free-product/product-stream/").concat(e);this._client.get(n,e=>{r.style.display="none",t.style.display="block",t.innerHTML=e,this._allProducts=Array.from(t.querySelectorAll(".variant-option"));let i=document.querySelector(this.options.searchFilterSectionSelector);if(i&&this._allProducts.length>0&&(i.style.display="block"),0===t.querySelectorAll(this.options.variantRadioSelector).length){o&&(o.disabled=!0);return}if(o&&this._replacingProduct&&(o.textContent="Produkt ersetzen"),this._currentProductId){let e=t.querySelector("".concat(this.options.variantRadioSelector,'[value="').concat(this._currentProductId,'"]'));e&&!e.disabled?(e.checked=!0,this._selectedProductId=this._currentProductId,o&&(o.disabled=!1),this._updateProductCheckmarks(e)):this._updateProductCheckmarks()}else this._updateProductCheckmarks();this._handleSearchAndFilter()},"text/html",e=>{r.style.display="none",t.style.display="block",t.innerHTML='<div class="alert alert-danger">Fehler beim Laden der Produkte. Bitte versuchen Sie es erneut.</div>',o&&(o.disabled=!0)})}_replaceProduct(){if(!this._selectedProductId)return;let e=document.querySelector(this.options.variantAddBtnSelector);e&&(e.disabled=!0,e.textContent="Wird ersetzt...");let t=new FormData;t.append("lineItemId",this._replacingLineItemId),t.append("newProductId",this._selectedProductId),t.append("freeProductId",this._currentFreeProductId);let r=window.location.pathname,o="frontend.cart.offcanvas";r.includes("/checkout/confirm")?o="frontend.checkout.confirm.page":r.includes("/checkout/cart")&&(o="frontend.cart.offcanvas"),t.append("redirectTo",o);let i=this._getBaseUrl();this._client.post("".concat(i,"/checkout/line-item/free-product/replace-stream-product"),t,()=>{let e=document.querySelector(this.options.variantModalSelector);if(e){let t=bootstrap.Modal.getInstance(e);t&&t.hide()}window.location.reload()},"text/html",t=>{e&&(e.disabled=!1,e.textContent="Produkt ersetzen"),alert("Fehler beim Ersetzen des Produkts. Bitte versuchen Sie es erneut.")})}_resetModal(){this._selectedProductId=null,this._currentProductId=null,this._currentFreeProductId=null,this._replacingProduct=!1,this._replacingLineItemId=null,this._allProducts=[];let e=document.querySelector(this.options.variantContentSelector),t=document.querySelector(this.options.variantLoadingSelector),r=document.querySelector(this.options.variantAddBtnSelector),o=document.querySelector(this.options.variantModalSelector),i=document.querySelector(this.options.searchInputSelector),n=document.querySelector(this.options.filterSelectSelector),a=document.querySelector(this.options.searchFilterSectionSelector),s=document.querySelector(this.options.noResultsSelector),l=document.querySelector(this.options.resultsCountSelector);e&&(e.innerHTML="",e.style.display="none"),t&&(t.style.display="block"),r&&(r.disabled=!0),i&&(i.value=""),n&&(n.value="all"),a&&(a.style.display="none"),s&&(s.style.display="none"),l&&(l.style.display="none"),o&&o.removeAttribute("data-stream-replace-mode")}_updateProductCheckmarks(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];let e=document.querySelector(this.options.variantContentSelector);
1e&&e.querySelectorAll(".variant-option").forEach(e=>{let t=e.querySelector(this.options.variantRadioSelector),r=e.querySelector(".variant-checkmark");t&&r&&(r.style.display=t.checked?"flex":"none")})}_handleSearchAndFilter(){let e=document.querySelector(this.options.variantContentSelector),t=document.querySelector(this.options.searchInputSelector),r=document.querySelector(this.options.filterSelectSelector),o=document.querySelector(this.options.noResultsSelector),i=document.querySelector(this.options.resultsCountSelector),n=document.querySelector(this.options.resultsTextSelector);if(!e||!t||!r)return;let a=(t.value||"").toLowerCase().trim(),s=r.value||"all",l=Array.from(e.querySelectorAll(".variant-option")),c=0;if(l.forEach(e=>{let t=!0;if(a){var r,o;let i=(((r=e.querySelector(".variant-name"))===null||void 0===r?void 0:r.textContent)||"").toLowerCase(),n=(((o=e.querySelector(".variant-number"))===null||void 0===o?void 0:o.textContent)||"").toLowerCase(),s=Array.from(e.querySelectorAll(".variant-property-value")).map(e=>e.textContent.toLowerCase()).join(" ");"".concat(i," ").concat(n," ").concat(s).includes(a)||(t=!1)}if(t&&"all"!==s){let r=e.querySelector(this.options.variantRadioSelector),o=r&&!r.disabled;"available"!==s||o?"unavailable"===s&&o&&(t=!1):t=!1}t?(e.style.display="",c++):e.style.display="none"}),o&&(0===c&&l.length>0?(o.style.display="block",e.style.display="none"):(o.style.display="none",e.style.display="block")),i&&n){if(a||"all"!==s){let e=l.length,t="".concat(c," von ").concat(e," ").concat(1===e?"Produkt":"Produkte"," gefunden");n.textContent=t,i.style.display="block"}else i.style.display="none"}}}h.options={variantModalSelector:"#freeProductVariantModal",streamChangeBtnSelector:".free-product-stream-change-btn",variantContentSelector:".free-product-variant-content",variantLoadingSelector:".free-product-variant-loading",variantAddBtnSelector:".free-product-variant-add-btn",variantRadioSelector:".free-product-variant-radio",searchInputSelector:".free-product-variant-search-input",filterSelectSelector:".free-product-variant-filter-select",searchFilterSectionSelector:".free-product-variant-search-filter",noResultsSelector:".free-product-variant-no-results",resultsCountSelector:".free-product-variant-results-count",resultsTextSelector:".free-product-variant-results-text"};let p=window.PluginManager;p.register("FreeProductVariant",l,document),p.register("FreeProductCardScroll",c,".cogi-free-products-scroll-container"),p.register("FreeProductCardAddButton",class extends a{init(){this._registerEvents()}_registerEvents(){this.el.querySelectorAll(".cogi-free-product-card-add-btn").forEach(e=>{e.addEventListener("click",this._onButtonClick.bind(this))})}_onButtonClick(e){let t=e.currentTarget;t&&!t.disabled&&this._showCheckmark(t)}_showCheckmark(e){let t=e.querySelector(".cogi-free-product-card-button-text"),r=e.querySelector(".cogi-free-product-card-plus-icon"),o=e.querySelector(".cogi-free-product-card-check-icon");t&&o?(t.style.visibility="hidden",o.style.display="block",setTimeout(()=>{t&&o&&!e.disabled&&(t.style.visibility="visible",o.style.display="none")},3e3)):r&&o&&(r.style.display="none",o.style.display="block",setTimeout(()=>{r&&o&&!e.disabled&&(r.style.display="block",o.style.display="none")},3e3))}},".cogi-free-product-card-form"),p.register("FreeProductCardNameTooltip",d,document),p.register("FreeProductVariantRemove",u,".cogi-free-product-card"),p.register("FreeProductStreamChange",h,document),p.register("FreeProductQuickview",class extends a{init(){this.modal=this.el.querySelector(".cogi-free-product-quickview-modal"),this.trigger=this.el.querySelector(".cogi-free-product-quickview-trigger"),this.modal&&(document.body.appendChild(this.modal),this._registerEvents(),this._registerGalleryEvents(),this._registerAddBtnEvents())}destroy(){this.modal&&this.modal.parentNode&&this.modal.parentNode.removeChild(this.modal),super.destroy()}_registerEvents(){this.trigger&&this.trigger.addEventListener("click",this._onTriggerClick.bind(this)),window.addEventListener("resize",()=>{this.modal&&this.modal.classList.contains("show")&&this._adjustArrows()})}_onTriggerClick(e){e.preventDefault(),this._adjustArrows();let t=bootstrap.Modal.getOrCreateInstance(this.modal);t&&t.show()}_registerGalleryEvents(){let e=this.modal.querySelectorAll(".quickview-thumbn
1ail"),t=this.modal.querySelector(".quickview-main-img"),r=this.modal.querySelector(".quickview-thumbnails-wrapper"),o=this.modal.querySelector(".quickview-thumbnail-arrow.arrow-prev"),i=this.modal.querySelector(".quickview-thumbnail-arrow.arrow-next");e.length>0&&t&&e.forEach(r=>{r.addEventListener("click",()=>{let o=r.dataset.src;o&&(t.src=o),e.forEach(e=>e.classList.remove("active")),r.classList.add("active")})}),r&&(o&&o.addEventListener("click",()=>{r.scrollBy({left:-160,behavior:"smooth"})}),i&&i.addEventListener("click",()=>{r.scrollBy({left:160,behavior:"smooth"})}))}_registerAddBtnEvents(){let e=this.modal.querySelector(".quickview-action-btn.cogi-free-product-card-add-btn");e&&e.addEventListener("click",()=>{e.disabled||this._showCheckmark(e)})}_showCheckmark(e){let t=e.querySelector(".cogi-free-product-card-button-text"),r=e.querySelector(".cogi-free-product-card-check-icon");t&&r&&(t.style.visibility="hidden",r.style.display="block",setTimeout(()=>{t&&r&&!e.disabled&&(t.style.visibility="visible",r.style.display="none")},3e3))}_adjustArrows(){let e=this.modal.querySelector(".quickview-thumbnails-wrapper"),t=this.modal.querySelector(".quickview-thumbnail-arrow.arrow-prev"),r=this.modal.querySelector(".quickview-thumbnail-arrow.arrow-next"),o=this.modal.querySelectorAll(".quickview-thumbnail").length,i=window.innerWidth<=768?o>3:o>5;t&&r&&(t.style.display=i?"flex":"none",r.style.display=i?"flex":"none"),e&&(e.style.justifyContent=i?"flex-start":"center")}},".cogi-free-product-card")})()})();
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.