(()=>{"use strict";const e=window.wp.i18n,t=e=>Math.abs(parseInt(e,10)),a=(e,t,a)=>{const n=new CustomEvent(`wpcf7${t}`,{bubbles:!0,detail:a});"string"==typeof e&&(e=document.querySelector(e)),e.dispatchEvent(n)},n=(e,t)=>{const n=new Map([["init","init"],["validation_failed","invalid"],["acceptance_missing","unaccepted"],["spam","spam"],["aborted","aborted"],["mail_sent","sent"],["mail_failed","failed"],["submitting","submitting"],["resetting","resetting"],["validating","validating"],["payment_required","payment-required"]]);n.has(t)&&(t=n.get(t)),Array.from(n.values()).includes(t)||(t=`custom-${t=(t=t.replace(/[^0-9a-z]+/i," ").trim()).replace(/\s+/,"-")}`);const r=e.getAttribute("data-status");if(e.wpcf7.status=t,e.setAttribute("data-status",t),e.classList.add(t),r&&r!==t){e.classList.remove(r);const t={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,prevStatus:r};a(e,"statuschanged",t)}return t},r=e=>{const{root:t,namespace:a="contact-form-7/v1"}=wpcf7.api;return c.reduceRight(((e,t)=>a=>t(a,e)),(e=>{let n,r,{url:c,path:o,endpoint:s,headers:i,body:l,data:p,...d}=e;"string"==typeof s&&(n=a.replace(/^\/|\/$/g,""),r=s.replace(/^\//,""),o=r?n+"/"+r:n),"string"==typeof o&&(-1!==t.indexOf("?")&&(o=o.replace("?","&")),o=o.replace(/^\//,""),c=t+o),i={Accept:"application/json, */*;q=0.1",...i},delete i["X-WP-Nonce"],p&&(l=JSON.stringify(p),i["Content-Type"]="application/json");const f={code:"fetch_error",message:"You are probably offline."},u={code:"invalid_json",message:"The response is not a valid JSON response."};return window.fetch(c||o||window.location.href,{...d,headers:i,body:l}).then((e=>Promise.resolve(e).then((e=>{if(e.status>=200&&e.status<300)return e;throw e})).then((e=>{if(204===e.status)return null;if(e&&e.json)return e.json().catch((()=>{throw u}));throw u}))),(()=>{throw f}))}))(e)},c=[];function o(e,t={}){const{target:a,scope:r=e,...c}=t;if(void 0===e.wpcf7?.schema)return;const o={...e.wpcf7.schema};if(void 0!==a){if(!e.contains(a))return;if(!a.closest(".wpcf7-form-control-wrap[data-name]"))return;if(a.closest(".novalidate"))return}const p=r.querySelectorAll(".wpcf7-form-control-wrap"),d=Array.from(p).reduce(((e,t)=>(t.closest(".novalidate")||t.querySelectorAll(":where(input, textarea, select):enabled").forEach((t=>{if(t.name)switch(t.type){case"button":case"image":case"reset":case"submit":break;case"checkbox":case"radio":t.checked&&e.append(t.name,t.value);break;case"select-multiple":for(const a of t.selectedOptions)e.append(t.name,a.value);break;case"file":for(const a of t.files)e.append(t.name,a);break;default:e.append(t.name,t.value)}})),e)),new FormData),f=e.getAttribute("data-status");Promise.resolve(n(e,"validating")).then((n=>{if(void 0!==swv){const n=swv.validate(o,d,t);for(const t of p){if(void 0===t.dataset.name)continue;const c=t.dataset.name;if(n.has(c)){const{error:t,validInputs:a}=n.get(c);i(e,c),void 0!==t&&s(e,c,t,{scope:r}),l(e,c,null!=a?a:[])}if(t.contains(a))break}}})).finally((()=>{n(e,f)}))}r.use=e=>{c.unshift(e)};const s=(e,t,a,n)=>{const{scope:r=e,...c}=null!=n?n:{},o=`${e.wpcf7?.unitTag}-ve-${t}`.replaceAll(/[^0-9a-z_-]+/gi,""),s=e.querySelector(`.wpcf7-form-control-wrap[data-name="${t}"] .wpcf7-form-control`);(()=>{const t=document.createElement("li");t.setAttribute("id",o),s&&s.id?t.insertAdjacentHTML("beforeend",`<a href="#${s.id}">${a}</a>`):t.insertAdjacentText("beforeend",a),e.wpcf7.parent.querySelector(".screen-reader-response ul").appendChild(t)})(),r.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((e=>{const t=document.createElement("span");t.classList.add("wpcf7-not-valid-tip"),t.setAttribute("aria-hidden","true"),t.insertAdjacentText("beforeend",a),e.appendChild(t),e.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","true")})),e.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.classList.add("wpcf7-not-valid"),e.setAttribute("aria-describedby",o),"function"==typeof e.setCustomValidity&&e.setCustomValidity(a),e.closest(".use-floating-validation-tip")&&(e.addEventListener("focus",(e=>{t.setAttribute("style","display: none")})),t.addEventListener("click",(e=>{t.setAttribute("style","display: none")})))}))}))},i=(e,t)=>{const a=`${e.wpcf7?.unitTag}-ve-${t}`.replaceAll(/[^0-9a-z_-]+/gi,"");e.wpcf7.parent.querySelector(`.screen-reader-response ul li#${a}`)?.remove(),e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${t}"]`).forEach((e=>{e.querySelector(".wpcf7-not-valid-tip")?.remove(),e.querySelectorAll("[aria-invalid]").forEach((e=>{e.setAttribute("aria-invalid","false")})),e.querySelectorAll(".wpcf7-form-control").forEach((e=>{e.removeAttribute("aria-describedby"),e.classList.remove("wpcf7-not-valid"),"function"==typeof e.setCustomValidity&&e.setCustomValidity("")}))}))},l=(e,t,a)=>{e.querySelectorAll(`[data-reflection-of="${t}"]`).forEach((e=>{if("output"===e.tagName.toLowerCase()){const t=e;0===a.length&&a.push(t.dataset.default),a.slice(0,1).forEach((e=>{e instanceof File&&(e=e.name),t.textContent=e}))}else e.querySelectorAll("output").forEach((e=>{e.hasAttribute("data-default")?0===a.length?e.removeAttribute("hidden"):e.setAttribute("hidden","hidden"):e.remove()})),a.forEach((a=>{a instanceof File&&(a=a.name);const n=document.createElement("output");n.setAttribute("name",t),n.textContent=a,e.appendChild(n)}))}))};function p(e,t={}){if(wpcf7.blocked)return d(e),void n(e,"submitting");const c=new FormData(e);t.submitter&&t.submitter.name&&c.append(t.submitter.name,t.submitter.value);const o={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(c,(e=>{const t=e[0],a=e[1];return!t.match(/^_/)&&{name:t,value:a}})).filter((e=>!1!==e)),formData:c};r({endpoint:`contact-forms/${e.wpcf7.id}/feedback`,method:"POST",body:c,wpcf7:{endpoint:"feedback",form:e,detail:o}}).then((t=>{const r=n(e,t.status);return o.status=t.status,o.apiResponse=t,["invalid","unaccepted","spam","aborted"].includes(r)?a(e,r,o):["sent","failed"].includes(r)&&a(e,`mail${r}`,o),a(e,"submit",o),t})).then((t=>{t.posted_data_hash&&(e.querySelector('input[name="_wpcf7_posted_data_hash"]').value=t.posted_data_hash),"mail_sent"===t.status&&(e.reset(),e.wpcf7.resetOnMailSent=!0),t.invalid_fields&&t.invalid_fields.forEach((t=>{s(e,t.field,t.message)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').insertAdjacentText("beforeend",t.message),e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=t.message}))})).catch((e=>console.error(e)))}r.use(((e,t)=>{if(e.wpcf7&&"feedback"===e.wpcf7.endpoint){const{form:t,detail:r}=e.wpcf7;d(t),a(t,"beforesubmit",r),n(t,"submitting")}return t(e)}));const d=e=>{e.querySelectorAll(".wpcf7-form-control-wrap").forEach((t=>{t.dataset.name&&i(e,t.dataset.name)})),e.wpcf7.parent.querySelector('.screen-reader-response [role="status"]').innerText="",e.querySelectorAll(".wpcf7-response-output").forEach((e=>{e.innerText=""}))};function f(e){const t=new FormData(e),c={contactFormId:e.wpcf7.id,pluginVersion:e.wpcf7.pluginVersion,contactFormLocale:e.wpcf7.locale,unitTag:e.wpcf7.unitTag,containerPostId:e.wpcf7.containerPost,status:e.wpcf7.status,inputs:Array.from(t,(e=>{const t=e[0],a=e[1];return!t.match(/^_/)&&{name:t,value:a}})).filter((e=>!1!==e)),formData:t};r({endpoint:`contact-forms/${e.wpcf7.id}/refill`,method:"GET",wpcf7:{endpoint:"refill",form:e,detail:c}}).then((t=>{e.wpcf7.resetOnMailSent?(delete e.wpcf7.resetOnMailSent,n(e,"mail_sent")):n(e,"init"),c.apiResponse=t,a(e,"reset",c)})).catch((e=>console.error(e)))}r.use(((e,t)=>{if(e.wpcf7&&"refill"===e.wpcf7.endpoint){const{form:t,detail:a}=e.wpcf7;d(t),n(t,"resetting")}return t(e)}));const u=(e,t)=>{for(const a in t){const n=t[a];e.querySelectorAll(`input[name="${a}"]`).forEach((e=>{e.value=""})),e.querySelectorAll(`img.wpcf7-captcha-${a.replaceAll(":","")}`).forEach((e=>{e.setAttribute("src",n)}));const r=/([0-9]+)\.(png|gif|jpeg)$/.exec(n);r&&e.querySelectorAll(`input[name="_wpcf7_captcha_challenge_${a}"]`).forEach((e=>{e.value=r[1]}))}},m=(e,t)=>{for(const a in t){const n=t[a][0],r=t[a][1];e.querySelectorAll(`.wpcf7-form-control-wrap[data-name="${a}"]`).forEach((e=>{e.querySelector(`input[name="${a}"]`).value="",e.querySelector(".wpcf7-quiz-label").textContent=n,e.querySelector(`input[name="_wpcf7_quiz_answer_${a}"]`).value=r}))}};function w(e){const a=new FormData(e);e.wpcf7={id:t(a.get("_wpcf7")),status:e.getAttribute("data-status"),pluginVersion:a.get("_wpcf7_version"),locale:a.get("_wpcf7_locale"),unitTag:a.get("_wpcf7_unit_tag"),containerPost:t(a.get("_wpcf7_container_post")),parent:e.closest(".wpcf7"),get schema(){return wpcf7.schemas.get(this.id)}},wpcf7.schemas.set(e.wpcf7.id,void 0),e.querySelectorAll(".has-spinner").forEach((e=>{e.insertAdjacentHTML("afterend",'<span class="wpcf7-spinner"></span>')})),(e=>{e.querySelectorAll(".wpcf7-exclusive-checkbox").forEach((t=>{t.addEventListener("change",(t=>{const a=t.target.getAttribute("name");e.querySelectorAll(`input[type="checkbox"][name="${a}"]`).forEach((e=>{e!==t.target&&(e.checked=!1)}))}))}))})(e),(e=>{e.querySelectorAll(".has-free-text").forEach((t=>{const a=t.querySelector("input.wpcf7-free-text"),n=t.querySelector('input[type="checkbox"], input[type="radio"]');a.disabled=!n.checked,e.addEventListener("change",(e=>{a.disabled=!n.checked,e.target===n&&n.checked&&a.focus()}))}))})(e),(e=>{e.querySelectorAll(".wpcf7-validates-as-url").forEach((e=>{e.addEventListener("change",(t=>{let a=e.value.trim();a&&!a.match(/^[a-z][a-z0-9.+-]*:/i)&&-1!==a.indexOf(".")&&(a=a.replace(/^\/+/,""),a="http://"+a),e.value=a}))}))})(e),(e=>{if(!e.querySelector(".wpcf7-acceptance")||e.classList.contains("wpcf7-acceptance-as-validation"))return;const t=()=>{let t=!0;e.querySelectorAll(".wpcf7-acceptance").forEach((e=>{if(!t||e.classList.contains("optional"))return;const a=e.querySelector('input[type="checkbox"]');(e.classList.contains("invert")&&a.checked||!e.classList.contains("invert")&&!a.checked)&&(t=!1)})),e.querySelectorAll(".wpcf7-submit").forEach((e=>{e.disabled=!t}))};t(),e.addEventListener("change",(e=>{t()})),e.addEventListener("wpcf7reset",(e=>{t()}))})(e),(e=>{const a=(e,a)=>{const n=t(e.getAttribute("data-starting-value")),r=t(e.getAttribute("data-maximum-value")),c=t(e.getAttribute("data-minimum-value")),o=e.classList.contains("down")?n-a.value.trim().length:a.value.trim().length;e.setAttribute("data-current-value",o),e.innerText=o,r&&r<a.value.length?e.classList.add("too-long"):e.classList.remove("too-long"),c&&a.value.length<c?e.classList.add("too-short"):e.classList.remove("too-short")},n=t=>{t={init:!1,...t},e.querySelectorAll(".wpcf7-character-count").forEach((n=>{const r=n.getAttribute("data-target-name"),c=e.querySelector(`[name="${r}"]`);c&&(c.value=c.defaultValue,a(n,c),t.init&&c.addEventListener("keyup",(e=>{a(n,c)})))}))};n({init:!0}),e.addEventListener("wpcf7reset",(e=>{n()}))})(e),window.addEventListener("load",(t=>{wpcf7.cached&&e.reset()})),e.addEventListener("reset",(t=>{wpcf7.reset(e)})),e.addEventListener("submit",(t=>{wpcf7.submit(e,{submitter:t.submitter}),t.preventDefault()})),e.addEventListener("wpcf7submit",(t=>{t.detail.apiResponse.captcha&&u(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&m(e,t.detail.apiResponse.quiz)})),e.addEventListener("wpcf7reset",(t=>{t.detail.apiResponse.captcha&&u(e,t.detail.apiResponse.captcha),t.detail.apiResponse.quiz&&m(e,t.detail.apiResponse.quiz)})),e.addEventListener("change",(t=>{t.target.closest(".wpcf7-form-control")&&wpcf7.validate(e,{target:t.target})})),e.addEventListener("wpcf7statuschanged",(t=>{const a=t.detail.status;e.querySelectorAll(".active-on-any").forEach((e=>{e.removeAttribute("inert"),e.classList.remove("active-on-any")})),e.querySelectorAll(`.inert-on-${a}`).forEach((e=>{e.setAttribute("inert","inert"),e.classList.add("active-on-any")}))}))}document.addEventListener("DOMContentLoaded",(t=>{var a;if("undefined"!=typeof wpcf7)if(void 0!==wpcf7.api)if("function"==typeof window.fetch)if("function"==typeof window.FormData)if("function"==typeof NodeList.prototype.forEach)if("function"==typeof String.prototype.replaceAll){wpcf7={init:w,submit:p,reset:f,validate:o,schemas:new Map,...null!==(a=wpcf7)&&void 0!==a?a:{}},document.querySelectorAll("form .wpcf7[data-wpcf7-id]").forEach((t=>{const a=document.createElement("p");a.setAttribute("class","wpcf7-form-in-wrong-place");const n=document.createElement("strong");n.append((0,e.__)("Error:","contact-form-7"));const r=(0,e.__)("This contact form is placed in the wrong place.","contact-form-7");a.append(n," ",r),t.replaceWith(a)})),document.querySelectorAll(".wpcf7 > form").forEach((e=>{wpcf7.init(e),e.closest(".wpcf7").classList.replace("no-js","js")}));for(const e of wpcf7.schemas.keys())r({endpoint:`contact-forms/${e}/feedback/schema`,method:"GET"}).then((t=>{wpcf7.schemas.set(e,t)}))}else console.error("Your browser does not support String.replaceAll().");else console.error("Your browser does not support NodeList.forEach().");else console.error("Your browser does not support window.FormData().");else console.error("Your browser does not support window.fetch().");else console.error("wpcf7.api is not defined.");else console.error("wpcf7 is not defined.")}))})();
function on_keydown_remove_from_cart(e){" "===e.key&&(e.preventDefault(),e.currentTarget.click())}function focus_populate_live_region(){var e=["woocommerce-message","woocommerce-error","wc-block-components-notice-banner"].map(function(e){return"."+e+'[role="alert"]'}).join(", "),o=document.querySelectorAll(e);if(0!==o.length){var t=o[0];t.setAttribute("tabindex","-1");var n=setTimeout(function(){t.focus(),clearTimeout(n)},500)}}function refresh_sorted_by_live_region(){var e=document.querySelector(".woocommerce-result-count"),o=document.querySelector('[data-wp-interactive="woocommerce/product-filters"]');if(e&&window.location.search&&!o){var t=e.innerHTML;e.setAttribute("role","alert"),e.setAttribute("aria-hidden","true");var n=setTimeout(function(){e.setAttribute("aria-hidden","false"),e.innerHTML="",e.innerHTML=t,clearTimeout(n)},2e3)}}function on_document_ready(){focus_populate_live_region(),refresh_sorted_by_live_region()}jQuery(function(e){e(".woocommerce-ordering").on("change","select.orderby",function(){e(this).closest("form").trigger("submit")}),e("input.qty:not(.product-quantity input.qty)").each(function(){var o=parseFloat(e(this).attr("min"));o>=0&&parseFloat(e(this).val())<o&&e(this).val(o)});var o="store_notice"+(e(".woocommerce-store-notice").data("noticeId")||"");if("hidden"===Cookies.get(o))e(".woocommerce-store-notice").hide();else{function t(o){["Enter"," "].includes(o.key)&&(o.preventDefault(),e(".woocommerce-store-notice__dismiss-link").click())}e(".woocommerce-store-notice").show(),e(".woocommerce-store-notice__dismiss-link").on("click",function n(r){Cookies.set(o,"hidden",{path:"/"}),e(".woocommerce-store-notice").hide(),r.preventDefault(),e(".woocommerce-store-notice__dismiss-link").off("click",n).off("keydown",t)}).on("keydown",t)}e(".woocommerce-input-wrapper span.description").length&&e(document.body).on("click",function(){e(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),e(".woocommerce-input-wrapper").on("click",function(e){e.stopPropagation()}),e(".woocommerce-input-wrapper :input").on("keydown",function(o){var t=e(this).parent().find("span.description");if(27===o.which&&t.length&&t.is(":visible"))return t.prop("aria-hidden",!0).slideUp(250),o.preventDefault(),!1}).on("click focus",function(){var o=e(this).parent(),t=o.find("span.description");o.addClass("currentTarget"),e(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),t.length&&t.is(":hidden")&&t.prop("aria-hidden",!1).slideDown(250),o.removeClass("currentTarget")}),e.scroll_to_notices=function(o){o.length&&e("html, body").animate({scrollTop:o.offset().top-100},1e3)},e('.woocommerce form .woocommerce-Input[type="password"]').wrap('<span class="password-input"></span>'),e(".woocommerce form input").filter(":password").parent("span").addClass("password-input"),e(".password-input").each(function(){const o=e(this).find("input").attr("id");e(this).append('<button type="button" class="show-password-input" aria-label="'+woocommerce_params.i18n_password_show+'" aria-describedBy="'+o+'"></button>')}),e(".show-password-input").on("click",function(o){o.preventDefault(),e(this).hasClass("display-password")?(e(this).removeClass("display-password"),e(this).attr("aria-label",woocommerce_params.i18n_password_show)):(e(this).addClass("display-password"),e(this).attr("aria-label",woocommerce_params.i18n_password_hide)),e(this).hasClass("display-password")?e(this).siblings(['input[type="password"]']).prop("type","text"):e(this).siblings('input[type="text"]').prop("type","password"),e(this).siblings("input").focus()}),e("a.coming-soon-footer-banner-dismiss").on("click",function(o){var t=e(o.target);e.ajax({type:"post",url:t.data("rest-url"),data:{woocommerce_meta:{coming_soon_banner_dismissed:"yes"}},beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",t.data("rest-nonce"))},complete:function(){e("#coming-soon-footer-banner").hide()}})}),"undefined"==typeof wc_add_to_cart_params&&e(document.body).on("keydown",".remove_from_cart_button",on_keydown_remove_from_cart),e(document.body).on("item_removed_from_classic_cart updated_wc_div",focus_populate_live_region)}),document.addEventListener("DOMContentLoaded",on_document_ready);
(function (){
'use strict';
function matchRule(qty, rules){
if(!rules||!rules.length) return null;
var best=null;
for (var i=0; i < rules.length; i++){
var rule=rules[i];
var ruleQty=parseInt(rule.qty, 10)||0;
var rulePrice=parseFloat(rule.price)||0;
if(qty >=ruleQty&&rulePrice > 0){
if(!best||ruleQty > (parseInt(best.qty, 10)||0)){
best=rule;
}}
}
return best;
}
function formatPrice(amount){
var d=(typeof wcbpData!=='undefined') ? wcbpData:{};
var sym=d.currency||'€';
var decimals=d.currencyDecimals!=null ? parseInt(d.currencyDecimals, 10):2;
var decSep=d.currencyDecSep||',';
var thousSep=d.currencyThSep||'.';
var pos=d.currencyPos||'left';
var fixed=Math.abs(amount).toFixed(decimals);
var parts=fixed.split('.');
var intPart=parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousSep);
var formatted=decimals > 0 ? intPart + decSep + parts[1]:intPart;
switch (pos){
case 'left':       return sym + formatted;
case 'left_space': return sym + '\u00A0' + formatted;
case 'right':      return formatted + sym;
case 'right_space':return formatted + '\u00A0' + sym;
default:           return sym + formatted;
}}
var nonceRefreshed=false;
function refreshAddonsNonce(){
if(nonceRefreshed) return;
nonceRefreshed=true;
var d=(typeof wcbpData!=='undefined') ? wcbpData:{};
if(!d.ajaxUrl||typeof window.fetch!=='function') return;
window.fetch(d.ajaxUrl + '?action=wcbp_refresh_addons_nonce', { credentials: 'same-origin' })
.then(function (r){ return r.json(); })
.then(function (res){
if(res&&res.success&&res.data&&res.data.nonce){
document.querySelectorAll('input[name="wcbp_addons_nonce"]').forEach(function (field){
field.value=res.data.nonce;
});
}})
.catch(function (){  });
}
function initAll(root){
root=root||document;
var nodes=[];
if(root.nodeType===1&&root.classList&&root.classList.contains('wcbp-selector')){
nodes.push(root);
}
if(root.querySelectorAll){
root.querySelectorAll('.wcbp-selector').forEach(function (el){
nodes.push(el);
});
}
nodes.forEach(function (selector){
if(selector.dataset.wcbpInit==='1') return;
selector.dataset.wcbpInit='1';
initSelector(selector);
});
}
function boot(){
initAll(document);
if(window.MutationObserver&&document.body){
new MutationObserver(function (mutations){
for (var i=0; i < mutations.length; i++){
var added=mutations[i].addedNodes;
for (var j=0; j < added.length; j++){
var node=added[j];
if(node.nodeType!==1) continue;
if((node.classList&&node.classList.contains('wcbp-selector')) ||
(node.querySelector&&node.querySelector('.wcbp-selector'))){
initAll(node);
}}
}}).observe(document.body, { childList: true, subtree: true });
}}
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', boot);
}else{
boot();
}
window.wcbpInit=initAll;
function initSelector(selector){
var cards=selector.querySelectorAll('.wcbp-card');
var form=selector.closest('form.cart')||selector.parentElement;
if(!cards.length) return;
var wcQtyInput=form ? form.querySelector('input.qty, input[name="quantity"]'):null;
var wcPriceEl=null;
var productEl=selector.closest('.product')||document.querySelector('.product');
if(productEl){
wcPriceEl=productEl.querySelector('.summary .price, .entry-summary .price, p.price, .woocommerce-Price-amount.amount');
}
function selectCard(card){
cards.forEach(function (c){
c.classList.remove('wcbp-card--active');
c.setAttribute('aria-checked', 'false');
var radio=c.querySelector('.wcbp-card__radio');
if(radio) radio.checked=false;
});
card.classList.add('wcbp-card--active');
card.setAttribute('aria-checked', 'true');
var radio=card.querySelector('.wcbp-card__radio');
if(radio){
radio.checked=true;
if(wcQtyInput){
wcQtyInput.value=radio.value;
wcQtyInput.dispatchEvent(new Event('change', { bubbles: true }));
}
updatePriceDisplay(card);
updateTotalSummary();
}}
function updatePriceDisplay(card){
if(!wcPriceEl) return;
var pricing=card.querySelector('.wcbp-card__price-wrap');
if(!pricing) return;
var priceEl=pricing.querySelector('.wcbp-card__price');
var compareEl=pricing.querySelector('.wcbp-card__compare-price');
if(priceEl){
var priceHtml=priceEl.innerHTML;
if(compareEl){
wcPriceEl.innerHTML=compareEl.innerHTML + ' ' + '<ins>' + priceHtml + '</ins>';
}else{
wcPriceEl.innerHTML=priceHtml;
}}
}
selector.setAttribute('role', 'radiogroup');
cards.forEach(function (card){
card.setAttribute('role', 'radio');
card.setAttribute('tabindex', '0');
card.setAttribute('aria-checked', card.classList.contains('wcbp-card--active') ? 'true':'false');
});
selector.addEventListener('click', function (e){
var card=e.target.closest('.wcbp-card');
if(card&&selector.contains(card)){
selectCard(card);
}});
selector.addEventListener('keydown', function (e){
var card=e.target.closest('.wcbp-card');
if(!card) return;
if(e.key==='Enter'||e.key===' '){
e.preventDefault();
selectCard(card);
}else if(e.key==='ArrowDown'||e.key==='ArrowRight'){
e.preventDefault();
var next=card.nextElementSibling;
if(next&&next.classList.contains('wcbp-card')){
next.focus();
selectCard(next);
}}else if(e.key==='ArrowUp'||e.key==='ArrowLeft'){
e.preventDefault();
var prev=card.previousElementSibling;
if(prev&&prev.classList.contains('wcbp-card')){
prev.focus();
selectCard(prev);
}}
});
var spinners=form ? form.querySelectorAll('.wcbp-custom-qty-wrapper'):document.querySelectorAll('.wcbp-custom-qty-wrapper');
spinners.forEach(function (spinner){
var card=spinner.closest('.wcbp-card')||spinner.closest('.wcbp-upsell');
var radio=card ? card.querySelector('.wcbp-card__radio, .wcbp-upsell-option__checkbox'):null;
if(!radio) return;
var input=spinner.querySelector('.wcbp-custom-qty__input');
var btnMinus=spinner.querySelector('.wcbp-custom-qty__btn--minus');
var btnPlus=spinner.querySelector('.wcbp-custom-qty__btn--plus');
var minQty=parseInt(input.getAttribute('min'), 10)||1;
var maxQty=parseInt(input.getAttribute('max'), 10)||Infinity;
var baseQty=parseInt(radio.getAttribute('data-base-qty'), 10)||minQty;
var basePrice=parseFloat(radio.getAttribute('data-price'))||0;
var baseCompare=parseFloat(radio.getAttribute('data-compare-price'))||0;
var unitPrice=basePrice / baseQty;
var unitCompare=baseCompare / baseQty;
var qtyTextEl=card.querySelector('.wcbp-card__qty-text');
var step=parseInt(input.getAttribute('step'), 10)||1;
function resizeInput(){
input.style.width=Math.max(1.2, input.value.length) + 0.8 + 'ch';
}
resizeInput();
function updateSpinnerLogic(){
var qty=parseInt(input.value, 10);
if(isNaN(qty)||qty < minQty){
qty=minQty;
input.value=qty;
}
if(qty > maxQty){
qty=maxQty;
input.value=qty;
}
resizeInput();
var matchedRule=null;
if(typeof wcbpData!=='undefined'&&wcbpData.rules){
var isAddon=radio.classList.contains('wcbp-upsell-option__checkbox');
var addonId=isAddon ? radio.getAttribute('data-addon-product-id'):null;
var rulesToMatch=wcbpData.rules;
if(isAddon&&wcbpData.addons){
for (var i=0; i < wcbpData.addons.length; i++){
if(wcbpData.addons[i].product_id==addonId){
rulesToMatch=wcbpData.addons[i].rules;
break;
}}
}
matchedRule=matchRule(qty, rulesToMatch);
}
if(matchedRule){
var rQty=parseInt(matchedRule.qty, 10)||1;
var rPrice=parseFloat(matchedRule.price)||0;
var rCompare=parseFloat(matchedRule.compare_price)||0;
unitPrice=rQty > 0 ? rPrice / rQty:rPrice;
unitCompare=rQty > 0 ? rCompare / rQty:rCompare;
}
var decimals=parseInt((typeof wcbpData!=='undefined'&&wcbpData.currencyDecimals!=null) ? wcbpData.currencyDecimals:2, 10);
var factor=Math.pow(10, decimals);
var newPrice=Math.round(unitPrice * qty * factor) / factor;
var newCompare=Math.round(unitCompare * qty * factor) / factor;
var newSavings=0;
var newSavingsPct=0;
if(newCompare > 0&&newCompare > newPrice){
newSavings=newCompare - newPrice;
newSavingsPct=Math.round((newSavings / newCompare) * 100);
}
radio.value=qty;
radio.setAttribute('data-price', newPrice);
radio.setAttribute('data-compare-price', newCompare);
radio.setAttribute('data-savings', newSavings);
radio.setAttribute('data-addon-qty', qty);
if(radio.classList.contains('wcbp-upsell-option__checkbox')&&radio.checked){
var addonCard=radio.closest('.wcbp-upsell');
if(addonCard){
var qtyAddonInput=addonCard.querySelector('.wcbp-addon__qty-input');
if(qtyAddonInput){
qtyAddonInput.value=qty;
}}
}
var priceEl=card.querySelector('.wcbp-card__price');
var compareWrapEl=card.querySelector('.wcbp-card__compare-price');
var compareEl=compareWrapEl ? compareWrapEl.querySelector('del'):null;
var savingsEl=card.querySelector('.wcbp-card__savings');
var hasCompare=newCompare > 0&&newCompare > newPrice;
if(priceEl) priceEl.innerHTML=formatPrice(newPrice);
if(compareEl) compareEl.innerHTML=formatPrice(newCompare);
if(compareWrapEl) compareWrapEl.style.display=hasCompare ? '':'none';
if(savingsEl){
savingsEl.style.display=hasCompare ? '':'none';
var label=(typeof wcbpData!=='undefined'&&wcbpData.i18n&&wcbpData.i18n.savingsLabel) ? wcbpData.i18n.savingsLabel:'SAVINGS';
savingsEl.textContent='';
savingsEl.appendChild(document.createTextNode(label + '\u00A0' + formatPrice(newSavings) + ' '));
var pctSpan=document.createElement('span');
pctSpan.className='wcbp-card__savings-pct';
pctSpan.textContent='-' + newSavingsPct + '%';
savingsEl.appendChild(pctSpan);
}
if(qtyTextEl&&typeof wcbpData!=='undefined'&&wcbpData.i18n &&
wcbpData.i18n.packageSingular&&wcbpData.i18n.packagePlural){
qtyTextEl.textContent=qty + ' ' + (qty > 1 ? wcbpData.i18n.packagePlural:wcbpData.i18n.packageSingular);
}
var isAddonCard=card.closest('.wcbp-upsell')!==null;
if(!isAddonCard&&card.classList.contains('wcbp-card--active')){
if(wcQtyInput){
wcQtyInput.value=qty;
wcQtyInput.dispatchEvent(new Event('change', { bubbles: true }));
}
updatePriceDisplay(card);
updateTotalSummary();
}}
btnMinus.addEventListener('click', function (e){
e.stopPropagation();
e.preventDefault();
var qty=parseInt(input.value, 10);
if(qty - step >=minQty){
input.value=qty - step;
updateSpinnerLogic();
}});
btnPlus.addEventListener('click', function (e){
e.stopPropagation();
e.preventDefault();
var newVal=parseInt(input.value, 10) + step;
if(newVal <=maxQty){
input.value=newVal;
updateSpinnerLogic();
}});
input.addEventListener('change', function (e){
updateSpinnerLogic();
});
input.addEventListener('input', function (e){
var qty=parseInt(input.value, 10);
if(!isNaN(qty)&&qty > maxQty){
input.value=maxQty;
updateSpinnerLogic();
}
resizeInput();
});
input.addEventListener('click', function(e){ e.stopPropagation(); });
});
var totalSummary=form ? form.querySelector('.wcbp-total-summary'):document.querySelector('.wcbp-total-summary');
var totalSummaryPrice=totalSummary ? totalSummary.querySelector('.wcbp-total-summary__price'):null;
var totalSummaryCompare=totalSummary ? totalSummary.querySelector('.wcbp-total-summary__compare'):null;
function updateTotalSummary(){
if(!totalSummary) return;
var totalPrice=0;
var totalCompare=0;
var hasCompare=false;
var activeCard=selector.querySelector('.wcbp-card--active .wcbp-card__radio');
if(activeCard){
var p=parseFloat(activeCard.getAttribute('data-price'))||0;
var cp=parseFloat(activeCard.getAttribute('data-compare-price'))||0;
totalPrice +=p;
if(cp > p){
totalCompare +=cp;
hasCompare=true;
}else{
totalCompare +=p;
}}
var selectedAddons=form ? form.querySelectorAll('.wcbp-upsell-option__checkbox:checked'):document.querySelectorAll('.wcbp-upsell-option__checkbox:checked');
selectedAddons.forEach(function(cb){
var ap=parseFloat(cb.getAttribute('data-price'))||0;
var acp=parseFloat(cb.getAttribute('data-compare-price'))||0;
totalPrice +=ap;
if(acp > ap){
totalCompare +=acp;
hasCompare=true;
}else{
totalCompare +=ap;
}});
if(totalPrice > 0){
totalSummary.style.display='';
totalSummaryPrice.innerHTML=formatPrice(totalPrice);
if(hasCompare&&totalCompare > totalPrice){
totalSummaryCompare.innerHTML=formatPrice(totalCompare);
totalSummaryCompare.style.display='';
}else{
totalSummaryCompare.style.display='none';
}}else{
totalSummary.style.display='none';
}}
var recommended=selector.querySelector('.wcbp-card--recommended');
var preselected=recommended||cards[0];
if(preselected){
selectCard(preselected);
}
var addons=form ? form.querySelectorAll('.wcbp-upsell'):document.querySelectorAll('.wcbp-upsell');
addons.forEach(function (addon){
var toggle=addon.querySelector('.wcbp-upsell__toggle');
var body=addon.querySelector('.wcbp-upsell__body');
if(!toggle||!body) return;
toggle.addEventListener('click', function (){
var expanded=toggle.getAttribute('aria-expanded')==='true';
toggle.setAttribute('aria-expanded', !expanded);
if(expanded){
body.style.display='none';
}else{
body.style.display='';
}});
toggle.addEventListener('keydown', function (e){
if(e.key==='Enter'||e.key===' '){
e.preventDefault();
toggle.click();
}});
var checkboxes=addon.querySelectorAll('.wcbp-upsell-option__checkbox');
var pidInput=addon.querySelector('.wcbp-addon__pid-input');
var qtyAddonInput=addon.querySelector('.wcbp-addon__qty-input');
checkboxes.forEach(function (cb){
cb.addEventListener('change', function (){
refreshAddonsNonce();
if(cb.checked){
checkboxes.forEach(function (other){
if(other!==cb){
other.checked=false;
var parentOption=other.closest('.wcbp-card');
if(parentOption) parentOption.classList.remove('wcbp-card--active');
}});
if(pidInput){
pidInput.value=cb.getAttribute('data-addon-product-id');
pidInput.disabled=false;
}
if(qtyAddonInput){
qtyAddonInput.value=cb.getAttribute('data-addon-qty');
qtyAddonInput.disabled=false;
}
var parentOption=cb.closest('.wcbp-card');
if(parentOption) parentOption.classList.add('wcbp-card--active');
addon.classList.add('wcbp-upsell--active');
}else{
if(pidInput){
pidInput.value='';
pidInput.disabled=true;
}
if(qtyAddonInput){
qtyAddonInput.value='';
qtyAddonInput.disabled=true;
}
var parentOption=cb.closest('.wcbp-card');
if(parentOption) parentOption.classList.remove('wcbp-card--active');
addon.classList.remove('wcbp-upsell--active');
}
updateTotalSummary();
});
var option=cb.closest('.wcbp-card');
if(option){
option.setAttribute('tabindex', '0');
option.addEventListener('keydown', function (e){
if(e.key==='Enter'||e.key===' '){
e.preventDefault();
cb.checked = !cb.checked;
cb.dispatchEvent(new Event('change'));
}});
}});
});
var isStickyEnabled=selector.getAttribute('data-sticky-cart')==='yes' &&
!document.querySelector('.wcbp-sticky-cart');
var stickyCartEl=null;
var stickyPriceEl=null;
if(isStickyEnabled){
stickyCartEl=document.createElement('div');
stickyCartEl.className='wcbp-sticky-cart';
var totalLabelText=(typeof wcbpData!=='undefined'&&wcbpData.i18n&&wcbpData.i18n.totalLabel) ? wcbpData.i18n.totalLabel:'Total';
var atcLabelText=(typeof wcbpData!=='undefined'&&wcbpData.i18n&&wcbpData.i18n.addToCartLabel) ? wcbpData.i18n.addToCartLabel:'Buy Now';
var infoEl=document.createElement('div');
infoEl.className='wcbp-sticky-cart__info';
var labelEl=document.createElement('span');
labelEl.className='wcbp-sticky-cart__total-label';
labelEl.textContent=totalLabelText;
var priceEl=document.createElement('span');
priceEl.className='wcbp-sticky-cart__total-price';
infoEl.appendChild(labelEl);
infoEl.appendChild(priceEl);
var btnEl=document.createElement('button');
btnEl.type='button';
btnEl.className='wcbp-sticky-cart__button';
btnEl.textContent=atcLabelText;
stickyCartEl.appendChild(infoEl);
stickyCartEl.appendChild(btnEl);
document.body.appendChild(stickyCartEl);
stickyPriceEl=stickyCartEl.querySelector('.wcbp-sticky-cart__total-price');
var btnAddToCart=form ? form.querySelector('.single_add_to_cart_button'):document.querySelector('.single_add_to_cart_button');
window.addEventListener('scroll', function(){
if(window.innerWidth > 768){
stickyCartEl.classList.remove('wcbp-sticky-cart--visible');
return;
}
var rect=selector.getBoundingClientRect();
var btnRect=btnAddToCart ? btnAddToCart.getBoundingClientRect():null;
var isVisible=rect.top < 0&&(!btnRect||btnRect.top > window.innerHeight||btnRect.bottom < 0);
if(isVisible){
stickyCartEl.classList.add('wcbp-sticky-cart--visible');
}else{
stickyCartEl.classList.remove('wcbp-sticky-cart--visible');
}}, { passive: true });
var stickyBtn=stickyCartEl.querySelector('.wcbp-sticky-cart__button');
stickyBtn.addEventListener('click', function(){
if(btnAddToCart){
btnAddToCart.scrollIntoView({ behavior: 'smooth', block: 'center' });
btnAddToCart.click();
}else{
selector.scrollIntoView({ behavior: 'smooth', block: 'start' });
}});
}
var originalUpdateTotalSummary=updateTotalSummary;
updateTotalSummary=function(){
originalUpdateTotalSummary();
if(stickyPriceEl&&totalSummaryPrice){
stickyPriceEl.innerHTML=totalSummaryPrice.innerHTML;
}};
updateTotalSummary();
}})();