!function(f,a){const t=PaoValidation;function e(a){return this instanceof e?!!a.length&&(this.$el=a,this.$addons=this.$el.find(".wc-pao-addon-field"),this.$addons.length?(this.is_rtl="rtl"===document.documentElement.dir,this.validation=new t(this),this.totals=new o(this),this.show_incomplete_subtotals=this.totals.showIncompleteSubtotals(),this.contains_required=this.containsRequired(),this.setupEvents(),this.validation.validate(),this.updateTotals(),f(".wc-pao-addon-image-swatch").tipTip({delay:200}),void WC_PAO.initialized_forms.push(this)):this.$addons=!1):new e(a)}function o(a){return this instanceof o?!f.isEmptyObject(a)&&(this.$form=a.$el,this.$addons=a.$addons,this.$variation_input=!!this.$form.hasClass("variations_form")&&this.$form.find('input[name="variation_id"], input.variation_id'),this.is_variable=this.$variation_input&&0<this.$variation_input.length,this.$totals=this.$form.find("#product-addons-total"),this.product_id=this.is_variable?this.$variation_input.val():this.$totals.data("product-id"),!!this.product_id)&&(this.base_price=this.$totals.data("price"),this.raw_price=this.$totals.data("raw-price"),this.product_type=this.$totals.data("type"),this.qty=parseFloat(this.$form.find("input.qty").val()),this.addons_price_data=[],this.$subscription_plans=this.$form.find(".wcsatt-options-product"),this.has_subscription_plans=0<this.$subscription_plans.length,this.is_rtl=a.is_rtl,this.total=0,this.total_raw=0,this.show_subtotal_panel=!0,void(this.price_request=null)):new o(a)}(WC_PAO=a.WC_PAO||{}).initialized_forms=[],WC_PAO.Helper={escapeHtml:function(a){return document.createElement("div").appendChild(document.createTextNode(a)).parentNode.innerHTML},isGroupedSubsSelected:function(){var a=f(".product-type-grouped"),t=!1;return a.length&&a.find(".group_table tr.product").each(function(){if(0<f(this).find(".input-text.qty").val()&&f(this).find(".entry-summary .subscription-details").length)return!(t=!0)}),t},addMinutes:function(a,t){return new Date(a.getTime()+6e4*t)},isGroupedMixedProductType:function(){var a=f(".product-type-grouped"),t=0,e=0;return!!(a.length&&(a.find(".group_table tr.product").each(function(){0<f(this).find(".input-text.qty").val()&&(f(this).find(".entry-summary .subscription-details").length?t++:e++)}),0<t)&&0<e)},delay:function(a,t){clearTimeout(0),setTimeout(a,t)}},WC_PAO.Form=(e.prototype.setupEvents=function(){var t,n=this;n.$el.find('button[type="submit"]').on("click",function(){var a,t;return!!n.validation.validate(!0)||((a=n.$el.find(".wc-pao-validation-notice")).length&&(t=n.$el.find(a[0].closest(".wc-pao-addon-container"))).length&&(t=t.find(".wc-pao-addon-field").first()).length&&(t.is(":hidden")?f(a[0]):t).focus(),!1)}),n.$el.on("blur change",".wc-pao-addon input:not(.wc-pao-addon-file-upload), .wc-pao-addon textarea, .wc-pao-addon select, .wc-pao-addon-custom-text",function(a){if(f(this).is(".wc-pao-addon-checkbox")){var t=f(this).closest(".wc-pao-fieldset"),a=f(a.relatedTarget).closest(".wc-pao-fieldset");if(t.is(a))return}n.validation.validateAddon(f(this),!0),n.updateTotals()}),n.$el.on("change",".wc-pao-addon input.wc-pao-addon-file-upload",function(){const a=f(this);var t=a.closest(".wc-pao-addon-container"),e=t.find(".reset_file"),t=t.find(".wc-pao-addon-file-name");e.length&&e.addClass("active"),t.length&&t.hide(250,function(){f(this).remove(),a.data("value","")}),n.validation.validateAddon(a,!0),n.updateTotals()}),n.$el.on("input",".wc-pao-addon input:not(.wc-pao-addon-checkbox), .wc-pao-addon textarea, .wc-pao-addon-custom-text",function(){var a=f(this);WC_PAO.Helper.delay(function(){n.validation.validateAddon(a,!0),n.updateTotals()},300)}),n.$el.on("change","input.qty",function(){n.updateTotals()}),n.$el.on("touchstart",".wc-pao-addon-image-swatch",function(a){t=new Date}),n.$el.on("click touchend",".wc-pao-addon-image-swatch",function(a){if((a.preventDefault(),"touchend"===a.type&&t)&&100<new Date-t)return;n.updateImageSwatch(f(this))}),n.$el.on("keydown",".wc-pao-addon-image-swatch",function(a){var t=f(this),e=t.parents(".wc-pao-addon-wrap").find(".wc-pao-addon-image-swatch"),o=e.index(t),i=!1;if("ArrowRight"===a.key||"ArrowDown"===a.key)o=(o+1)%e.length,i=!0;else if("ArrowLeft"===a.key||"ArrowUp"===a.key)o=(o-1+e.length)%e.length,i=!0;else if(" "===a.key||"Enter"===a.key)return void n.updateImageSwatch(t);i&&(a.preventDefault(),(t=e.eq(o)).focus(),n.updateImageSwatch(t))}),n.$el.on("click",".reset_variations",function(){n.totals.reset()}),n.$el.on("wc_variation_form",function(){n.validation.validate(),n.updateTotals()}),n.$el.on("found_variation",function(a,t){n.totals.updateVariation(t),n.validation.validate(),n.updateTotals()}),n.$el.on("hide_variation",function(a){n.updateTotals()}),n.$el.on("woocommerce-product-addons-update",function(){n.validation.validate(),n.updateTotals()}),n.$el.find(".datepicker").each(function(){var e=f(this),a=e.parent(),o=a.find(".reset_date"),i=a.find('input[name="'+e.attr("name")+'-wc-pao-date"]'),t=a.find('input[name="'+e.attr("name")+'-wc-pao-date-gmt-offset"]'),a=(t.length||((t=f("<input/>")).attr("type","hidden"),t.attr("name",e.attr("name")+"-wc-pao-date-gmt-offset"),a.append(t)),new Date),n=parseFloat(woocommerce_addons_params.gmt_offset,10),s=a.getTimezoneOffset()/60,t=("default"===woocommerce_addons_params.date_input_timezone_reference?t.val(s):"store"===woocommerce_addons_params.date_input_timezone_reference&&(a.getHours(),a.getMinutes(),t.val(n)),e.datepicker({beforeShow:function(a,t){woocommerce_addons_params.datepicker_class&&(f("#ui-datepicker-div").removeClass(woocommerce_addons_params.datepicker_class),f("#ui-datepicker-div").addClass(woocommerce_addons_params.datepicker_class))},dateFormat:woocommerce_addons_params.datepicker_date_format,changeMonth:!0,changeYear:!0,yearRange:"c-100:c+10"}),e.datepicker("getDate"));null!==t&&"function"==typeof t.getTime&&(t.setHours(a.getHours(),a.getMinutes()),"store"===woocommerce_addons_params.date_input_timezone_reference&&(t=WC_PAO.Helper.addMinutes(t,-1*s*60),t=WC_PAO.Helper.addMinutes(t,60*n)),i.val(t.getTime()/1e3),o.show()),e.on("change",function(){var a,t=e.datepicker("getDate");null!==t&&"function"==typeof t.getTime?(a=new Date,t.setHours(a.getHours(),a.getMinutes()),"store"===woocommerce_addons_params.date_input_timezone_reference&&(t=WC_PAO.Helper.addMinutes(t,-1*s*60),t=WC_PAO.Helper.addMinutes(t,60*n)),i.val(t.getTime()/1e3),o.show()):(o.hide(),i.val(""))}),o.on("click",function(a){a.preventDefault(),i.val(""),e.val("").trigger("change")})}),n.$el.on("click",".reset_file",function(a){a.preventDefault();var a=f(this).closest(".wc-pao-addon-container"),t=a.find("input.wc-pao-addon-field"),a=a.find(".wc-pao-addon-file-name");a.length&&a.hide(250,function(){f(this).remove()}),f(this).removeClass("active").addClass("inactive"),t.data("value",""),t.val(""),n.validation.validateAddon(t,!0),n.updateTotals()}),f("#credit_called").on("keyup",function(){n.validation.validate(),n.updateTotals()})},e.prototype.updateImageSwatch=function(a){var t=a.data("value"),e=a.parents(".wc-pao-addon-wrap"),o=f.parseHTML(a.data("price")),i=e.find(".wc-pao-addon-image-swatch-selected-swatch");i.html(""),e.find(".wc-pao-addon-image-swatch").removeClass("selected").attr("aria-checked","false").attr("tabindex","-1"),a.addClass("selected").attr("aria-checked","true").attr("tabindex","0"),e.find(".wc-pao-addon-image-swatch-select").val(t),i.html(o),this.validation.validateAddon(e.find("select.wc-pao-addon-field"),!0),this.updateTotals()},e.prototype.updateTotals=function(){this.totals.calculate(),(this.show_incomplete_subtotals||this.isValid())&&(this.contains_required||this.totals.$totals.data("price_data").length)?this.totals.render():this.totals.reset()},e.prototype.isValid=function(){var a=!0;return this.$el.find("button.single_add_to_cart_button").is(".disabled")?a=!1:(f.each(this.validation.getValidationState(),function(){if(!this.validity)return a=!1}),a)},e.prototype.containsRequired=function(){var t=!1;return this.$addons.each(function(){var a=f(this).data("restrictions");if(!f.isEmptyObject(a)&&"required"in a&&"yes"===a.required)return t=!0}),t},o.prototype.showIncompleteSubtotals=function(){return 1===this.$totals.data("show-incomplete-sub-total")},o.prototype.updateVariation=function(a){this.$variation_input=!!this.$form.hasClass("variations_form")&&this.$form.find('input[name="variation_id"], input.variation_id'),this.product_id=a.variation_id,this.$totals.data("product-id",this.product_id),void 0!==a.display_price?this.base_price=a.display_price:f(a.price_html).find(".amount").last().length&&(this.base_price=f(a.price_html).find(".amount").last().text(),this.base_price=this.base_price.replace(woocommerce_addons_params.currency_format_symbol,""),this.base_price=this.base_price.replace(woocommerce_addons_params.currency_format_thousand_sep,""),this.base_price=this.base_price.replace(woocommerce_addons_params.currency_format_decimal_sep,"."),this.base_price=this.base_price.replace(/[^0-9\.]/g,""),this.base_price=parseFloat(this.base_price)),this.$totals.data("price",this.base_price)},o.prototype.calculate=function(){var m=this;m.qty=parseFloat(m.$form.find("input.qty").val()),m.addons_price_data=[],m.total=0,m.total_raw=0,m.base_price=m.$totals.data("price"),m.raw_price=m.$totals.data("raw-price"),m.product_id=m.is_variable?m.$variation_input.val():m.$totals.data("product-id"),""===m.base_price&&"undefined"!=typeof custom_gift_card_amount&&custom_gift_card_amount.length&&0<custom_gift_card_amount.val()&&(m.base_price=custom_gift_card_amount.val()),woocommerce_addons_params.is_bookings&&f(".wc-bookings-booking-cost").length&&(m.base_price=parseFloat(f(".wc-bookings-booking-cost").attr("data-raw-price"))),this.$addons.each(function(){var a=f(this),t=a.parents(".wc-pao-addon");if((!a.is(".wc-pao-addon-file-upload")||!t.find(".wc-pao-addon-file-name input").length||t.find(".wc-pao-addon-file-name input").val())&&(a.is(".wc-pao-addon-file-upload")&&t.find(".wc-pao-addon-file-name input").length||a.val())){var e,o,i,n=t.find(".wc-pao-addon-name").length?t.find(".wc-pao-addon-name").data("addon-name"):"",s="",d=0,r=0,c=a.data("price-type"),p=!1,l={},_=!!t.find(".wc-pao-addon-name").length&&t.find(".wc-pao-addon-name").data("has-per-person-pricing"),u=!!t.find(".wc-pao-addon-name").length&&t.find(".wc-pao-addon-name").data("has-per-block-pricing");if(a.is(".wc-pao-addon-custom-price"))p=!0,d=a.val(),r=a.val(),c="quantity_based","."!==woocommerce_addons_params.currency_format_decimal_sep&&(d=d.replace(woocommerce_addons_params.currency_format_decimal_sep,"."),r=r.replace(woocommerce_addons_params.currency_format_decimal_sep,"."));else if(a.is(".wc-pao-addon-input-multiplier"))""!==a.val()&&(a.val(Math.ceil(a.val())),d=a.data("price")*a.val(),r=a.data("raw-price")*a.val());else if(a.is(".wc-pao-addon-checkbox, .wc-pao-addon-radio")){if(!a.is(":checked"))return;s=a.data("label"),d=a.data("price"),r=a.data("raw-price")}else if(a.is(".wc-pao-addon-image-swatch-select, .wc-pao-addon-select")){if(!a.find("option:selected")||""===a.find("option:selected").val())return;c=a.find("option:selected").data("price-type"),s=a.find("option:selected").data("label"),d=a.find("option:selected").data("price"),r=a.find("option:selected").data("raw-price")}else{if(!a.is(".wc-pao-addon-file-upload")&&!a.val())return;d=a.data("price"),r=a.data("raw-price")}switch(d=d||0,r=r||0,"booking"!==m.product_type&&"accommodation-booking"!==m.product_type||!woocommerce_addons_params.is_bookings||(void(e=m.qty=0)!==f("#wc_bookings_field_duration")&&0<f("#wc_bookings_field_duration").val()&&(e=f("#wc_bookings_field_duration").val()),void 0!==f("#wc-bookings-form-end-time")&&0<f("#wc-bookings-form-end-time").val()&&(e=f("#wc-bookings-form-end-time").val()),i=f("#wc_bookings_field_persons"),o=0,1===i.length?o=parseInt(o,10)+parseInt(i.val(),10):f(".wc-bookings-booking-form").find("input").each(function(){var a=this.id.match(/wc_bookings_field_persons_(\d+)/);null!=a&&f("#"+a[0]).length&&(o=parseInt(o,10)+parseInt(f("#"+a[0]).val(),10))}),0===m.qty&&f(".wc-bookings-booking-cost").length&&(m.qty=1),_&&o&&(m.qty*=o),u&&e&&(m.qty*=e)),c){case"flat_fee":l.cost=parseFloat(d),l.cost_raw=parseFloat(r);break;case"quantity_based":l.cost_pu=parseFloat(d),l.cost_raw_pu=parseFloat(r),l.cost=l.cost_pu*m.qty,l.cost_raw=l.cost_raw_pu*m.qty;break;case"percentage_based":l.cost_pct=parseFloat(d)/100,l.cost_raw_pct=parseFloat(r)/100,l.cost=parseFloat(m.base_price)*l.cost_pct*m.qty,l.cost_raw=parseFloat(m.raw_price)*l.cost_raw_pct*m.qty}m.total+=l.cost||0,m.total_raw+=l.cost_raw||0,void 0!==s&&("number"==typeof s||s.length?(l.name=n+(s?" - "+s:""),l.nameFormattedHTML='<span class="wc-pao-addon-name">'+n+"</span>"+(s?' - <span class="wc-pao-addon-value">'+s+"</span>":"")):(i=a.val(),_=parseInt(woocommerce_addons_params.trim_user_input_characters,10),a.is(".wc-pao-addon-file-upload")?i=(i=t.find(".wc-pao-addon-file-name").length?t.find(".wc-pao-addon-file-name").data("value"):i).replace(/^.*[\\\/]/,""):a.is(".wc-pao-addon-custom-price")&&("."!==woocommerce_addons_params.currency_format_decimal_sep&&(i=i.replace(woocommerce_addons_params.currency_format_decimal_sep,".")),i=accounting.formatNumber(i,{symbol:"",decimal:woocommerce_addons_params.currency_format_decimal_sep,precision:parseFloat(i)%1==0?0:i.toString().split(".")[1].length})),_<i.length&&(i=i.slice(0,_)+"..."),l.name=n+" - "+WC_PAO.Helper.escapeHtml(i),l.nameFormattedHTML='<span class="wc-pao-addon-name">'+n+'</span> - <span class="wc-pao-addon-value">'+WC_PAO.Helper.escapeHtml(i)+"</span>"),l.is_custom_price=p,l.price_type=c,m.addons_price_data.push(l))}}),m.$totals.data("price_data",m.addons_price_data),m.$form.trigger("updated_addons")},o.prototype.render=function(){var a,e,o,t,i,n,s,d,r,c=this;c.$totals.data("show-sub-total")&&c.qty&&(c.formatMoney(c.total),o=!1,void 0!==c.base_price&&c.product_id&&(a=f(".wc-bookings-booking-form").length?isNaN(c.base_price)?0:parseFloat(c.base_price):parseFloat(c.base_price*c.qty),e=c.formatMoney(a+c.total)),c.has_subscription_plans?(t=c.$form.data("satt_script"))&&t.schemes_model.get_active_scheme_key()&&(t=c.$subscription_plans.find("input:checked")).val()&&(i=t.parent().find(".subscription-details")):c.$form.parent().find(".subscription-details").length&&!c.$form.hasClass("bundle_data")&&(i=c.$form.parent().find(".subscription-details"),c.$variation_input)&&0<c.$variation_input.length&&(i=c.$form.parent().find(".woocommerce-variation .subscription-details")),i&&0<i.length&&(n=" "+i.clone().wrap("<p>").parent().html()),"grouped"===c.product_type?n&&!WC_PAO.Helper.isGroupedMixedProductType()&&WC_PAO.Helper.isGroupedSubsSelected()&&e&&(e+=n):n&&e&&(e+=n),e)?(t=c.$form.find(".wc-pao-addon-container").data("product-name"),i=c.formatMoney(a),n=c.$form.find(".wc-pao-addon-container").data("product-tax-status"),s=f(".wc-bookings-booking-form").length?'<div class="product-addon-totals"><ul><li><div class="wc-pao-col1"><strong>'+t+'</strong></div><div class="wc-pao-col2"><strong><span class="amount">'+i+"</span></strong></div></li>":'<div class="product-addon-totals"><ul><li><div class="wc-pao-col1"><strong><span>'+(c.is_rtl?woocommerce_addons_params.quantity_symbol+c.qty:c.qty+woocommerce_addons_params.quantity_symbol)+"</span> "+t+'</strong></div><div class="wc-pao-col2"><strong><span class="amount">'+i+"</span></strong></div></li>",c.addons_price_data.length&&f.each(c.addons_price_data,function(a,t){var e=t.cost,e=0===e?"-":0<e?c.formatMoney(e):"-"+c.formatMoney(Math.abs(e));s=s+'<li><div class="wc-pao-col1"><strong>'+t.nameFormattedHTML+'</strong></div><div class="wc-pao-col2"><span class="amount">'+e+"</span></div></li>",woocommerce_addons_params.tax_enabled&&t.is_custom_price&&(o=!0)}),d="",r=void 0===c.$totals.data("i18n_sub_total")?woocommerce_addons_params.i18n_sub_total:c.$totals.data("i18n_sub_total"),o||woocommerce_addons_params.price_display_suffix&&woocommerce_addons_params.tax_enabled?"taxable"!==n||o||!1!=-1<woocommerce_addons_params.price_display_suffix.indexOf("{price_including_tax}")||!1!=-1<woocommerce_addons_params.price_display_suffix.indexOf("{price_excluding_tax}")?c.price_request=f.ajax({type:"POST",url:woocommerce_addons_params.ajax_url,data:{action:"wc_product_addons_calculate_tax",product_id:c.product_id,add_on_total:c.total,add_on_total_raw:c.total_raw,qty:c.qty},beforeSend:function(){null!=c.price_request&&c.price_request.abort()},complete:function(){c.price_request=null},success:function(a){var t;s="SUCCESS"==a.result?(d='<small class="woocommerce-price-suffix">'+woocommerce_addons_params.price_display_suffix+"</small>",t=c.formatMoney(a.price_including_tax),a=c.formatMoney(a.price_excluding_tax),d=(d=d.replace("{price_including_tax}",'<span class="amount">'+t+"</span>")).replace("{price_excluding_tax}",'<span class="amount">'+a+"</span>"),t=woocommerce_addons_params.display_include_tax?t:a,s+'<li class="wc-pao-subtotal-line"><p class="price">'+r+' <span class="amount">'+t+"</span> "+d+" </p></li></ul></div>"):s+'<li class="wc-pao-subtotal-line"><p class="price">'+r+' <span class="amount">'+e+"</span></p></li></ul></div>",c.show_subtotal_panel?c.$totals.html(s):c.$totals.html(""),c.$form.trigger("updated_addons")},error:function(){s=s+'<li class="wc-pao-subtotal-line"><p class="price">'+r+' <span class="amount">'+e+"</span></p></li></ul></div>",c.show_subtotal_panel?c.$totals.html(s):c.$totals.html(""),c.$form.trigger("updated_addons")}}):(s=s+'<li class="wc-pao-subtotal-line"><strong>'+r+' <span class="amount">'+e+"</span> "+woocommerce_addons_params.price_display_suffix+"</strong></li></ul></div>",c.show_subtotal_panel?c.$totals.html(s):c.$totals.html(""),c.$form.trigger("updated_addons")):(s=s+'<li class="wc-pao-subtotal-line"><p class="price">'+r+' <span class="amount">'+e+"</span></p></li></ul></div>",c.show_subtotal_panel?c.$totals.html(s):c.$totals.html(""),c.$form.trigger("updated_addons"))):(c.$totals.empty(),c.$form.trigger("updated_addons"))},o.prototype.reset=function(){this.$totals.empty(),this.$totals.html(""),this.$form.trigger("updated_addons")},o.prototype.formatMoney=function(a){let t=woocommerce_addons_params.currency_format_num_decimals;var e;return woocommerce_addons_params.trim_trailing_zeros&&(e=parseFloat(a)%1==0,a=parseFloat(a),t=e?0:a.toString().split(".")[1].length),accounting.formatMoney(a,{symbol:woocommerce_addons_params.currency_format_symbol,decimal:woocommerce_addons_params.currency_format_decimal_sep,thousand:woocommerce_addons_params.currency_format_thousand_sep,precision:t,format:woocommerce_addons_params.currency_format})},e),f(function(){f("body").on("quick-view-displayed",function(){f(this).find(".cart:not(.cart_group)").each(function(){new WC_PAO.Form(f(this))})}),f("body").find(".cart:not(.cart_group)").each(function(){new WC_PAO.Form(f(this))})})}(jQuery,window);