jQuery(function(m){var g=function(t){var a={};return m.each(t,function(t,i){var e;a[(e=t)&&e.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g).map(function(t){return t.toLowerCase()}).join("-")]=i}),a};m.fn.yith_bundle_form=function(){m(this).each(function(){var n=m(this),r=n.data("product-id"),d=(n.data("per-item-pricing"),n.data("ajax-update-price")),t=n.find(".yith-wcpb-product-bundled-items .price"),i=n.closest(yith_wcpb_params.price_handler_parent).find(yith_wcpb_params.price_handler)||n.closest(yith_wcpb_params.price_handler_parent_alt).find(yith_wcpb_params.price_handler_alt),c=1==yith_wcpb_params.price_handler_only_first?i.not(t).first():i.not(t),a=n.closest("form").find("button[type=submit]"),_=n.closest(".product").find(".add-request-quote-button"),l=n.find(".bundled_item_cart_content"),s=n.find("input.yith-wcpb-bundled-quantity"),p=n.find(".yith-wcpb-bundled-optional"),u=n.find(".variation_id"),h=null,f={message:null,overlayCSS:{background:"#fff",opacity:.6},ignoreIfBlocked:!0},e=function(t){m(this).is(".disabled")&&(t.preventDefault(),m(this).is(".yith-wcpb-out-of-stock-item-selected")?window.alert(yith_wcpb_params.i18n.out_of_stock_item_selected):m(this).is(".yith-wcpb-variation-selection-needed")&&window.alert(yith_wcpb_params.i18n.variation_selection_needed))};a.on("click",e),_.on("click",e),n.on("yith_wcpb_update_price",function(){var t,o,i,e;o=t=!1,e=[i="disabled","yith-wcpb-variation-selection-needed","yith-wcpb-out-of-stock-item-selected"].join(" "),l.each(function(){var t=m(this),i=t.closest(".yith-wcpb-product-bundled-item"),e=i.find(".yith-wcpb-bundled-optional").first(),a=i.find(".yith-wcpb-bundled-quantity").first(),n=t.find("select.yith-wcpb-select-for-variables"),r=e.length,d=r&&e.is(":checked"),c=a.length&&0===parseInt(a.val(),10);r&&!d||c?r&&(t.find(".quantity input.qty").removeAttr("max"),t.find(".single_variation_wrap").slideUp("fast"),t.find(".variations").slideUp("fast")):(n.each(function(){m(this).val()||0}),t.find(".variations").slideDown("fast"),t.find(".single_variation_wrap").slideDown("fast"),t.find(".out-of-stock").length&&(o=!0))}),o&&(i+=" yith-wcpb-out-of-stock-item-selected"),s.filter(function(){return!this.checkValidity()}).length&&(t=!0),t?a.addClass(i):a.removeClass(e),_.length&&(t?_.addClass(i):_.removeClass(e)),function(){if(h&&h.abort(),1==d){c.block(f);var t=[],i=[],e=[];s.each(function(){t[m(this).data("item-id")-1]=m(this).val()}),p.each(function(){i[m(this).data("item-id")-1]=m(this).is(":checked")?1:0}),u.each(function(){e[m(this).data("item-id")-1]=m(this).val()});var a=m.extend({},g(n.data()),{bundle_id:r,array_qty:t,array_opt:i,array_var:e,context:"frontend",action:"yith_wcpb_get_bundle_total_price",security:yith_wcpb_params.nonces.getBundleTotal});h=m.ajax({type:"POST",data:a,url:yith_wcpb_params.ajaxurl,success:function(t){var i=c.find("ins .amount");i.length<1&&(i=c.find(".amount")),i.length<1&&(i=c),(i=i.first()).html(t.price_html),c.html(t.price_html),m(document).trigger("yith_wcpb_ajax_update_price_request",t),c.unblock()}})}}()}),"yes"===yith_wcpb_params.update_price_on_load&&n.trigger("yith_wcpb_update_price"),s.on("change",function(){m(this).parents(".bundled_item_cart_content").length||n.trigger("yith_wcpb_update_price")}),p.on("click",function(){m(this).parents(".bundled_item_cart_content").length||n.trigger("yith_wcpb_update_price")}),l.on("change",function(){n.trigger("yith_wcpb_update_price")}),l.on("found_variation",function(t,i){var e=m(this).closest(".product"),a=e.find(".yith-wcpb-product-bundled-item-data__price .price").first(),n=a.find("ins"),r=a.find("del"),d=e.find(".yith-wcpb-product-bundled-item-image img").first(),c=e.data("min-quantity"),o=e.data("max-quantity"),_=e.find(".yith-wcpb-bundled-quantity");if("undefined"!=typeof i.max_qty&&i.max_qty&&(o=Math.min(o,i.max_qty)),_.length){_.attr("min",c),e.find(".yith-wcpb-bundled-quantity__invalid-notice__min-qty").html(c),_.attr("max",o),e.find(".yith-wcpb-bundled-quantity__invalid-notice__max-qty").html(o);var l=Math.min(Math.max(_.val(),c),o);_.val(l)}"undefined"!=typeof i.image&&("undefined"!=typeof i.image.srcset&&i.image.srcset?d.attr("srcset",i.image.srcset):"undefined"!=typeof i.image.thumb_src&&i.image.thumb_src&&(d.removeAttr("srcset"),d.attr("src",i.image.thumb_src)),"undefined"!=typeof i.image.full_src&&"undefined"!=typeof i.image.full_src_h&&"undefined"!=typeof i.image.full_src_w&&(d.attr("data-large_image",i.image.full_src),d.attr("data-large_image_width",i.image.full_src_w),d.attr("data-large_image_height",i.image.full_src_h))),n.html(i.price_html.replace("price","amount")),r.html(i.display_regular_price_html),m(document).trigger("yith_wcpb_found_variation_after",[m(this),i])}).on("reset_data",function(){var t=m(this).closest(".product"),i=t.find(".yith-wcpb-product-bundled-item-data__price .price").first(),e=i.find("ins"),a=i.data("default-ins"),n=i.find("del"),r=i.data("default-del"),d=t.find(".yith-wcpb-product-bundled-item-image img").first(),c=d.attr("src");void 0!==c&&0<c.length&&d.attr("srcset",c),e.html(a),n.html(r)}),l.trigger("check_variations"),l.trigger("update_variation_values")})},m(document).on("yith_wcpb_add_to_cart_init",function(){m(".yith-wcpb-bundle-form").yith_bundle_form()}).trigger("yith_wcpb_add_to_cart_init"),m(document).on("qv_loader_stop",function(){m(document).trigger("yith_wcpb_add_to_cart_init")}),m(document).on("mfpOpen",function(){m(".variations_form").each(function(){m(this).wc_variation_form()}),m(document).trigger("yith_wcpb_add_to_cart_init")});var r={enabled:"undefined"!=typeof PhotoSwipe&&"undefined"!=typeof PhotoSwipeUI_Default&&"undefined"!=typeof wc_single_product_params&&"yes"===yith_wcpb_params.photoswipe_enabled,init:function(){m(document).on("click",".yith-wcpb-product-bundled-item-image .woocommerce-product-gallery__image a",this.openPhotoswipe),this.indexGallery()},getImages:function(){return m(".yith-wcpb-product-bundled-item-image .woocommerce-product-gallery__image")},indexGallery:function(){var t=this.getImages(),i=0;t.each(function(){m(this).data("bundled-image-index",i),i++})},getGalleryItems:function(){var t=this.getImages(),n=[];return 0<t.length&&t.each(function(t,i){var e=m(i).find("img");if(e.length){var a={src:e.attr("data-large_image"),w:e.attr("data-large_image_width"),h:e.attr("data-large_image_height"),title:e.attr("data-caption")?e.attr("data-caption"):e.attr("title")};n.push(a)}}),n},openPhotoswipe:function(t){if(t.preventDefault(),r.enabled){var i=m(".pswp")[0],e=r.getGalleryItems(),a=m(t.target).closest(".woocommerce-product-gallery__image"),n=m.extend({index:m(a).data("bundled-image-index")},wc_single_product_params.photoswipe_options);new PhotoSwipe(i,PhotoSwipeUI_Default,e,n).init()}}};r.init()});