!function(){"use strict";var t,e={640:function(t,e,r){var a=window.jQuery,n=r.n(a),o=window.wp.apiFetch,c=r.n(o),i=window.wp.i18n;function d(){const t=n()("#warranty-selector");let e=0;const r=[],a=n()('input[name="main_warranty"]:checked',t);if(a.length){const t=parseFloat(a.closest(".product-card, .product-item").data("price"));isNaN(t)||(e+=t,r.push({name:a.closest(".product-card, .product-item").find("h4").text(),price:t,type:"warranty"}))}n()('input[name="services[]"]:checked',t).each(function(){const t=parseFloat(n()(this).closest(".product-card, .product-item").data("price"));isNaN(t)||(e+=t,r.push({name:n()(this).closest(".product-card, .product-item").find("h4").text(),price:t,type:"service"}))}),n()(".total-amount",t).text(`€${e.toFixed(2)}`);const o=n()("#selected-items-list",t);o.empty(),r.forEach(t=>{const e="warranty"===t.type?"":"+ ";o.append(`<li>${e}${t.name} (${t.price.toFixed(2)}€)</li>`)}),r.length>0?n()(".selected-items",t).show():n()(".selected-items",t).hide(),n()("#add-to-cart-btn").prop("disabled",0===e)}async function s(t){t.preventDefault();const e=n()("#warranty-selector"),r=n()('input[name="main_warranty"]:checked',e).val();if(!r)return void(void 0!==window.wc_add_notice?window.wc_add_notice((0,i.__)("Please select a main warranty.","warranty-cart"),"error"):console.error((0,i.__)("Please select a main warranty.","warranty-cart")));const a=n()(t.target);if(a.hasClass("loading"))return;a.prop("disabled",!0).addClass("loading").text((0,i.__)("Adding to Cart…","warranty-cart"));const o=n()('input[name="services[]"]:checked',e).map((t,e)=>parseInt(e.value)).get();try{const t=await c()({path:"warranty-cart/v1/cart/add",method:"POST",data:{main:parseInt(r),services:o}});if(!t.success||!t.data?.redirect_url)throw new Error(t.data?.message||t.message||(0,i.__)("Failed to add items to cart.","warranty-cart"));a.removeClass("loading").text((0,i.__)("Redirecting to Checkout…","warranty-cart")),setTimeout(()=>{window.location.href=t.data.redirect_url},500)}catch(t){console.error("Warranty cart error:",t);let e=(0,i.__)("An error occurred. Please try again.","warranty-cart");t.message?e=t.message:"rest_forbidden"===t.code?e=(0,i.__)("You do not have permission to perform this action.","warranty-cart"):"invalid_product_ids"===t.code&&(e=(0,i.__)("Some selected products are no longer available.","warranty-cart")),void 0!==window.wc_add_notice?window.wc_add_notice(e,"error"):console.error(e),a.prop("disabled",!1).removeClass("loading").text((0,i.__)("Add to Cart & Checkout","warranty-cart"))}}document.addEventListener("DOMContentLoaded",()=>{document.getElementById("warranty-selector")&&function(){const t=n()("#warranty-selector");t.length&&(t.on("change",'input[name="main_warranty"], input[name="services[]"]',d),n()("#add-to-cart-btn").on("click",s),d())}()})}},r={};function a(t){var n=r[t];if(void 0!==n)return n.exports;var o=r[t]={exports:{}};return e[t](o,o.exports,a),o.exports}a.m=e,t=[],a.O=function(e,r,n,o){if(!r){var c=1/0;for(u=0;u<t.length;u++){r=t[u][0],n=t[u][1],o=t[u][2];for(var i=!0,d=0;d<r.length;d++)(!1&o||c>=o)&&Object.keys(a.O).every(function(t){return a.O[t](r[d])})?r.splice(d--,1):(i=!1,o<c&&(c=o));if(i){t.splice(u--,1);var s=n();void 0!==s&&(e=s)}}return e}o=o||0;for(var u=t.length;u>0&&t[u-1][2]>o;u--)t[u]=t[u-1];t[u]=[r,n,o]},a.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return a.d(e,{a:e}),e},a.d=function(t,e){for(var r in e)a.o(e,r)&&!a.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},a.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},function(){var t={343:0,834:0};a.O.j=function(e){return 0===t[e]};var e=function(e,r){var n,o,c=r[0],i=r[1],d=r[2],s=0;if(c.some(function(e){return 0!==t[e]})){for(n in i)a.o(i,n)&&(a.m[n]=i[n]);if(d)var u=d(a)}for(e&&e(r);s<c.length;s++)o=c[s],a.o(t,o)&&t[o]&&t[o][0](),t[o]=0;return a.O(u)},r=self.webpackChunkwarranty_cart=self.webpackChunkwarranty_cart||[];r.forEach(e.bind(null,0)),r.push=e.bind(null,r.push.bind(r))}();var n=a.O(void 0,[834],function(){return a(640)});n=a.O(n)}();