var EC={initialized:!1,lock_add_cart_prod:{},initialize:function(){$(document).on("calendar_on_day_selected",function(e,t){var a=$(".pf_cal #template_calendar"+t.calendar_id).closest(".pf_cal").attr("data-pf");if(void 0!=a&&0==$("#pf_"+a+"_sf").length){var s="calendar_date="+$("#pf_"+a+"_cal .template_calendar").attr("data-sel-date");s+="&ref_id="+$("#pf_"+a+"_cal").attr("data-ref-id"),s+="&ref_type="+$("#pf_"+a+"_cal").attr("data-ref-type"),EC.start_search(a,s)}}),$(document).on("calendar_on_interval_selected",function(e,t){var a=$(".pf_cal #template_calendar"+t.calendar_id).closest(".pf_cal").attr("data-pf");if(void 0!=a&&0==$("#pf_"+a+"_sf").length){$("#pf_"+a+"_cal .template_calendar").attr("data-sel-date");var s="calendar_date_1="+t.date_1;s+="&calendar_date_2="+t.date_2,s+="&ref_id="+$("#pf_"+a+"_cal").attr("data-ref-id"),s+="&ref_type="+$("#pf_"+a+"_cal").attr("data-ref-type"),EC.start_search(a,s)}}),$('.pf_sf form input[type="submit"]').on("click",function(e){var t=$(this).closest(".pf_sf").attr("data-pf"),a=$(this).closest("form");$(a).find(".form_messages").html(""),$(a).closest("form").validate({submitHandler:function(e){var s=!1,r=null;if($("#pf_"+t+"_cal")&&1==$("#pf_"+t+"_cal").attr("data-required")){if($("#pf_"+t+"_cal .template_calendar").hasClass("interval_selection")){var i=$("#pf_"+t+"_cal .template_calendar").attr("data-id"),o=TC.date_interval?TC.date_interval[i+"_date_1"]:null,c=TC.date_interval?TC.date_interval[i+"_date_2"]:null;c||(c=F.date_from_slash_to_dash($("#pf_"+t+"_cal").find(".date_2_text").text())),o&&c?r="&calendar_date_1="+o+"&calendar_date_2="+c:(s=!0,$(a).find(".form_messages").append('<div class="message error">'+ZJS.strings.string_searchform_select_calendar_date+"</div>"))}else{var l=$("#pf_"+t+"_cal .template_calendar").attr("data-sel-date");l?r="&calendar_date="+l:(s=!0,$(a).find(".form_messages").append('<div class="message error">'+ZJS.strings.string_searchform_select_calendar_date+"</div>"))}}if(!s){var n=$(a).serialize();r&&(n+=r);var d=a.find(".disparity_code").val();d&&(n+="&disparity_code="+d),n+="&ref_id="+$("#pf_"+t+"_sf").attr("data-ref-id"),n+="&ref_type="+$("#pf_"+t+"_sf").attr("data-ref-type"),EC.start_search(t,n)}}})}),$.each($(".purchase_flow_step"),function(){EC.on_step_shown($(this).attr("data-pf-id"),$(this).attr("data-step-id"))}),$.each($('.purchase_flow_steps[data-date-type="0"]'),function(){var e=$(this).attr("data-pf");if(0==$('.pf_sf[data-pf="'+e+'"]').length){var t="ref_id="+$(this).attr("data-ref-id");t+="&ref_type="+$(this).attr("data-ref-type"),EC.start_search(e,t)}}),EC.products_selection_behaviors(),EC.pf_breadcrumbs_behaviors(),EC.cart_behaviors(),EC.coupon_behaviors(),EC.shipping_behaviors(),EC.payments_behaviors(),EC.initialized=!0,F.register_event("ecommerce_js_loaded")},start_search:function(e,t){F.register_event("pf_on_starting_search",{purchase_flow_id:e}),ZF.postquery(base_url+"bootstrap/purchase_flow_save_search/"+e,void 0!=t?{data:t}:"",function(t){if(void 0!=t){if(t.ret){void 0!=t.search_summary&&EC.show_search_summary(t.search_summary,e);var a=void 0!=t.step;t.jump?void 0!=t.noresult_message&&(a=!1,F.show_message(t.noresult_message),$("#purchase_flow_"+e+"_steps").html(""),F.register_event("pf_on_step_shown",{purchase_flow_id:e,step_id:1})):a||ZF.redirect(t.link),a&&(F.register_event("pf_on_step_showing",{purchase_flow_id:e}),$("#purchase_flow_"+e+"_steps").html(t.step),EC.on_step_shown(e,t.step_id))}else F.register_event("pf_on_search_error",{purchase_flow_id:e}),void 0!=t.error_message&&F.show_message(t.error_message)}},"json",!0)},on_step_shown:function(e,t){$(".purchase_flow_"+e+"_step .pf_step_button").off("click").on("click",function(){var t=$(this);if(t.hasClass("clicked")||t.hasClass("disabled"))return!1;t.addClass("clicked");var a=$('.purchase_flow_step[data-pf-id="'+$(this).attr("data-pf-id")+'"][data-step-id="'+$(this).attr("data-step-id")+'"]'),s=a.attr("data-step-id"),r=parseInt(a.attr("data-min-sel")),i=a.attr("data-search-id"),o=a.attr("data-real-time"),c=0;if($.each(a.find(".product_selection").not(a.find(".kit_details .product_selection")),function(){c+=parseInt($(this).val())}),c>=r){var l=!1,n=!1;if(a.find(".kit_selection_wrap").length&&$.each(a.find(".kit_selection_wrap"),function(){if(parseInt($(this).find(".product_selection.kit_selection").val())>0&&($.each($(this).closest(".elem").find(".kit_details_wrap"),function(){var e=$(this).attr("data-prod-max"),t=$(this).attr("data-prod-min"),a=0;if($.each($(this).find(".product_selection"),function(){a+=parseInt($(this).val())}),a<t?l=ZJS.strings.string_select_kits_products_min_warning:a<e&&(l=ZJS.strings.string_select_kits_products_warning,n=!0),l)return}),l))return}),l)F.show_message(l+(n?'<div class="buttons_wrapper select_prod_error"><input type="button" class="back_btn button" value="'+ZJS.strings.string_back+'" /><input type="button" class="continue_btn button" value="'+ZJS.strings.string_continue+'" /></div>':"")),$(".select_prod_error .continue_btn").one("click",function(){if(0==o){var t=a.find(".product_selection").not('[value="0"]').serialize();EC.add_cart_products(e,s,i,t,!0)}else EC.go_to_next_step(e,s,i);$("#page_error").hide()}),$(".select_prod_error .back_btn").one("click",function(){$("#page_error").hide()}),F.register_event("pf_on_message_shown"),t.removeClass("clicked");else if(0==o){var d=a.find(".product_selection").not('[value="0"]').serialize();EC.add_cart_products(e,s,i,d,!0)}else EC.go_to_next_step(e,s,i)}else t.removeClass("clicked"),F.show_message(ZJS.strings.string_select_products_error),F.register_event("pf_on_message_shown")}),EC.refresh_cart_on_the_fly(!0),F.register_event("pf_on_step_shown",{purchase_flow_id:e,step_id:t})},pf_breadcrumbs_behaviors:function(){$(document).on("pf_on_step_shown",function(e,t){let a=document.querySelector('#pf_breadcrumbs[data-pf="'+t.purchase_flow_id+'"]');if(a){let s=!1;a.querySelectorAll(".breadcrumb")?.forEach(e=>{let a=e.getAttribute("data-id");a=="step_"+t.step_id?(s=!0,e.classList.add("active"),e.classList.remove("before"),e.classList.remove("after")):(e.classList.remove("active"),s?(e.classList.remove("before"),e.classList.add("after")):(e.classList.add("before"),e.classList.remove("after")))})}})},products_selection_behaviors:function(){$(document).on("click",".product_selection_wrap .prod_sel_rem",function(){if($(this).hasClass("disabled"))return;if($("#cart_template_wrapper").length>0&&$("#cart_template_wrapper").hasClass("one_time_stop")){$("#cart_template_wrapper").removeClass("one_time_stop");return}var e=$(this).closest(".purchase_flow_step"),t=$(this).closest(".product_selection_wrap"),a=$(this).closest(".selector_wrapper"),s=$(this).closest("#cart_template_wrapper").length>0,r=t.attr("data-content-id"),i=e.attr("data-pf-id"),o=e.attr("data-step-id"),c=e.attr("data-real-time"),l=e.attr("data-max-sel"),n=e.attr("data-min-sel"),d=parseInt(t.attr("data-prod-min"));parseInt(a.attr("data-av"));var p=$(this).closest(".selection_per_day_wrap").length>0;let u=0;$.each(t.find(".product_selection").not(a.find(".product_selection")),function(){u+=parseInt($(this).val())}),d>0&&(d-=u,d=d>0?d:-1),p&&(d=0);let f=parseInt(a.attr("data-uprd-min"));if(isNaN(f)){let h=parseInt(t.attr("data-upr-min"));!isNaN(h)&&(h-=u,(h=h>0?h:0)>d&&(d=h))}else f>d&&(d=f);var m=parseInt(a.find(".product_selection").val()),v=m-1;if(v>=d&&(!s&&v>=0||s&&(v>0||v>=0&&p))){let g=!1;if(void 0!=t.attr("data-fixedNumber")&&(v=0,g=!0),p&&g&&1!=t.attr("data-wholestay")){let y=$(this).closest(".selector_wrapper").attr("data-date");$(this).closest(".box").find('.multiple_days[data-fixednumber] .selector_wrapper[data-date="'+y+'"]').each(function(){$(this).find(".prod_sel_content").html(v),$(this).find(".product_selection").val(v)})}else p&&1==t.attr("data-wholestay")?g?$(this).closest(".box").find(".multiple_days[data-fixednumber] .selector_wrapper").each(function(){$(this).find(".prod_sel_content").html(v),$(this).find(".product_selection").val(v)}):$(this).closest(".multiple_days").find(".selector_wrapper").each(function(){$(this).find(".prod_sel_content").html(v),$(this).find(".product_selection").val(v)}):t.attr("data-crossBooking")?($("[data-crossBooking].cb_active .prod_sel_content").html(v),$("[data-crossBooking].cb_active .product_selection").val(v)):(a.find(".prod_sel_content").html(v),a.find(".product_selection").val(v));if(F.register_event("pf_on_product_num_decreased",{purchase_flow_id:i,step_id:o,content_id:r,num:v}),1==c){var b=e.attr("data-search-id");products=p&&1==t.attr("data-wholestay")?$(this).closest(".multiple_days").find(".selector_wrapper .product_selection").serialize():t.attr("data-crossBooking")?$("[data-crossBooking].cb_active .product_selection").serialize():a.find(".product_selection").serialize(),EC.add_cart_products(i,o,b,products,l==n&&1==n,!0,!1,function(){})}if(!p){0==v&&$(this).closest(".elem").removeClass("selected");var w=(parseFloat($(this).parent().find(".product_price").val())*v).toFixed(2).split(".");$(this).closest(".elem").find(".zlabeltotalprice .number").text(w[0]),$(this).closest(".elem").find(".zlabeltotalprice .decimal").text(w[1])}if(0==v&&a.find(".product_selection").hasClass("kit_selection")&&$(this).closest(".elem").find(".kit_details").hide(),$(this).closest(".selection_date_fields").length>0){var k=$(this).closest(".selection_date_fields"),C=(parseFloat(k.find(".ppd").val())*parseFloat(k.find(".product_selection").val())).toFixed(2).split(".");k.find(".price_subtotal .number").text(C[0]),k.find(".price_subtotal .decimal").text(C[1])}$(this).hasClass("prod_sel_rem_kit_detail")&&!s&&EC.calculate_kit_price($(this).closest(".kit_details").closest(".elem")),1!=c&&(s?v<m&&EC.save_cart_page_data(r):EC.refresh_cart_on_the_fly())}}),$(document).on("click",".product_selection_wrap .prod_sel_add",function(){if($(this).hasClass("disabled"))return;if($("#cart_template_wrapper").length>0&&$("#cart_template_wrapper").hasClass("one_time_stop")){$("#cart_template_wrapper").removeClass("one_time_stop");return}var e=$(this).closest(".product_selection_wrap");if(e.hasClass("selection_locked"))return;let t=$(this).closest(".kits").length>0;var a=$(this).closest(".purchase_flow_step"),s=$(this).closest(".selector_wrapper"),r=t?$(this).closest(".kits").closest(".elem"):$(this).closest(".elem"),i=e.attr("data-content-id"),o=a.attr("data-pf-id"),c=a.attr("data-step-id"),l=a.attr("data-real-time"),n=a.attr("data-max-sel"),d=a.attr("data-max-units"),p=a.attr("data-min-sel"),u=parseInt(e.attr("data-prod-max")),f=parseInt(s.attr("data-av")),h=$(this).closest(".selection_per_day_wrap").length>0;let m=0;$.each(a.find(".product_selection").not(s.find(".product_selection")),function(){m+=parseInt($(this).val())});let v=0;$.each(e.find(".product_selection").not(s.find(".product_selection")),function(){v+=parseInt($(this).val())});let g=0;t&&$.each(a.find(".kit_selection").not(s.find(".kit_selection")),function(){g+=parseInt($(this).val())}),u>0&&(u-=v,u=u>0?u:-1);var y=s.attr("data-dm");void 0!=y&&y.length&&(-1==u||0==u||y<u)&&(u=y);let b=parseInt(s.attr("data-uprd-max"));if(isNaN(b)){let w=parseInt(e.attr("data-upr-max"));if(!isNaN(w)){if(w>0&&(w-=v+g,w=w>0?w:-1),-1==w)return;w>0&&(0==u||w<u)&&(u=w)}}else{if(-1==b)return;b>0&&(0==u||b<u)&&(u=b)}var k=0;if(s.hasClass("inherited_availability")){var C=s.attr("data-fcid"),q=s.attr("data-date"),x=a.find('.selector_wrapper[data-fcid="'+C+'"]'+(h?'[data-date="'+q+'"]':""));$.each(x,function(){$(this).is(s)||(k+=parseInt($(this).find(".product_selection").val()))})}var _=0;if(r.hasClass("shared_availability")){var S=r.attr("data-shared_id"),q=s.attr("data-date"),x=a.find('.elem[data-shared_id="'+S+'"] .selector_wrapper'+(h?'[data-date="'+q+'"]':""));$.each(x,function(){$(this).is(s)||(_+=parseInt($(this).find(".product_selection").val()))})}k+=_;var E=parseInt(s.find(".product_selection").val()),L=E+1;if(1==a.attr("data-max-sel")&&(a.find(".product_selection_wrap .prod_sel_content").html(0),a.find(".product_selection_wrap .product_selection").val(0)),(isNaN(f)||L<=f-k)&&(L<=u||0==u||isNaN(u))&&(void 0==d||0==d||m+L<=d)){let A=!1;if(void 0!=e.attr("data-fixedNumber")&&(L=e.attr("data-fixedNumber"),A=!0),h&&A&&1!=e.attr("data-wholestay")){let z=$(this).closest(".selector_wrapper").attr("data-date");$(this).closest(".box").find('.multiple_days[data-fixednumber] .selector_wrapper[data-date="'+z+'"]').each(function(){let e=$(this).closest(".multiple_days").attr("data-fixednumber");$(this).find(".prod_sel_content").html(e),$(this).find(".product_selection").val(e)})}else h&&1==e.attr("data-wholestay")?A?$(this).closest(".box").find(".multiple_days[data-fixednumber] .selector_wrapper").each(function(){let e=$(this).closest(".multiple_days").attr("data-fixednumber");$(this).find(".prod_sel_content").html(e),$(this).find(".product_selection").val(e)}):$(this).closest(".multiple_days").find(".selector_wrapper").each(function(){$(this).find(".prod_sel_content").html(L),$(this).find(".product_selection").val(L)}):e.attr("data-crossBooking")?($("[data-crossBooking].cb_active .prod_sel_content").html(L),$("[data-crossBooking].cb_active .product_selection").val(L)):(s.find(".prod_sel_content").html(L),s.find(".product_selection").val(L));if(F.register_event("pf_on_product_num_increased",{purchase_flow_id:o,step_id:c,content_id:i,num:L}),1==l){var j=a.attr("data-search-id"),T="";T=h&&1==e.attr("data-wholestay")?$(this).closest(".multiple_days").find(".selector_wrapper .product_selection").serialize():e.attr("data-crossBooking")?$("[data-crossBooking].cb_active .product_selection").serialize():s.find(".product_selection").serialize(),EC.add_cart_products(o,c,j,T,n==p&&1==p,!0,!1,function(){})}if(0==$(this).closest(".selection_per_day_wrap").length){L>0&&$(this).closest(".elem").addClass("selected");var H=(parseFloat($(this).parent().find(".product_price").val())*L).toFixed(2).split(".");$(this).closest(".elem").find(".zlabeltotalprice .number").text(H[0]),$(this).closest(".elem").find(".zlabeltotalprice .decimal").text(H[1])}if(s.find(".product_selection").hasClass("kit_selection")&&$(this).closest(".elem").find(".kit_details").show(),$(this).closest(".selection_date_fields").length>0){var B=$(this).closest(".selection_date_fields"),M=(parseFloat(B.find(".ppd").val())*parseFloat(B.find(".product_selection").val())).toFixed(2).split(".");B.find(".price_subtotal .number").text(M[0]),B.find(".price_subtotal .decimal").text(M[1])}$(this).hasClass("prod_sel_add_kit_detail")&&!$(this).closest("#cart_template_wrapper").length&&EC.calculate_kit_price($(this).closest(".kit_details").closest(".elem")),1!=l&&($(this).closest("#cart_template_wrapper").length>0?L>E&&EC.save_cart_page_data(i):EC.refresh_cart_on_the_fly())}else F.register_event("pf_on_product_not_added",{})}),$(document).on("click",'.product_selection_wrap .zselection[type="button"]',function(){if(!$(this).hasClass("disabled")){var e=$(this).closest(".product_selection_wrap"),t=$(this).closest(".selector_wrapper"),a=$(this).closest(".kits").length?$(this).closest(".kits").closest(".elem"):$(this).closest(".elem"),s=$(this),r=$(this).closest(".purchase_flow_step"),i=r.attr("data-pf-id"),o=r.attr("data-step-id"),c=r.attr("data-real-time"),l=r.attr("data-max-sel"),n=r.attr("data-min-sel"),d=e.attr("data-content-id"),p=parseInt(t.find(".product_selection").val()),u=parseInt(e.attr("data-prod-max")),f=parseInt(e.attr("data-prod-min")),h=parseInt(t.attr("data-av"));if(1==c&&(p=0),t.hasClass("inherited_availability")){var m=t.attr("data-fcid");$.each(r.find('.selector_wrapper[data-fcid="'+m+'"]'),function(){$(this).is(t)||(h-=parseInt($(this).find(".product_selection").val()))})}if(a.hasClass("shared_availability")){var v=a.attr("data-shared_id");$.each(r.find('.elem[data-shared_id="'+v+'"] .selector_wrapper'),function(){$(this).is(t)||(h-=parseInt($(this).find(".product_selection").val()))})}if(f>0&&($.each(e.find(".product_selection").not(t.find(".product_selection")),function(){f-=parseInt($(this).val())}),f=f>0?f:-1),1==l&&(r.find(".product_selection_wrap .product_selection").val(0),r.find(".product_selection_wrap .prod_sel_content").text(0),r.find(".product_selection_wrap .zselection, .product_selection_wrap .zkitselection").removeClass("selected"),r.find(".purchase_flow_step .elem").removeClass("selected"),r.find(".kit_details").hide()),1==u&&(a.find(".product_selection_wrap").not(".kit_details_wrap").find(".product_selection").val(0),a.find(".product_selection_wrap").not(".kit_details_wrap").find(".prod_sel_content").text(0),a.find(".product_selection_wrap").not(".kit_details_wrap").find(".zselection, .zkitselection").removeClass("selected"),a.find(".product_selection_wrap").not(".kit_details_wrap").find(".zselection").closest(".elem").removeClass("selected"),a.find(".kit_details").hide()),(0==u||p<u)&&(isNaN(h)||h>0)?p++:(1==u&&1==p||0==h)&&(-1==f||p>f)&&(p=0),t.find(".product_selection").val(p),0==$(this).closest(".selection_per_day_wrap").length){var g=(parseFloat($(this).parent().find(".product_price").val())*p).toFixed(2).split(".");$(this).closest(".elem").find(".zlabeltotalprice .number").text(g[0]),$(this).closest(".elem").find(".zlabeltotalprice .decimal").text(g[1])}if(p>0){if($(this).addClass("selected"),$(this).closest(".elem").addClass("selected"),$(this).hasClass("zkitselection")&&$(this).closest(".elem").find(".kit_details").show(),F.register_event("pf_on_product_num_increased",{purchase_flow_id:i,step_id:o,content_id:d,num:p}),1==c){s.prop("disabled",!0);var y=r.attr("data-search-id"),b=t.find(".product_selection").serialize(),w=l==n&&1==n;EC.add_cart_products(i,o,y,b,w,!1,!1,function(e){s.prop("disabled",!1),w||(t.attr("data-av",h-1),t.append('<span class="icon_added_to_cart glyphicons glyphicons-ok-circle"></span>'),setTimeout(function(){t.find(".icon_added_to_cart").fadeOut(function(){t.find(".icon_added_to_cart").remove()})},3e3)),e.disable_all_similar_items?$('div[data-occupancy-code="'+e.disable_all_similar_items+'"]').find('.zselection[type="button"]').prop("disabled",!0):e.enable_all_similar_items&&$('div[data-occupancy-code="'+e.enable_all_similar_items+'"]').find('.zselection[type="button"]').prop("disabled",!1)})}}else $(this).removeClass("selected"),$(this).closest(".elem").removeClass("selected"),F.register_event("pf_on_product_num_decreased",{purchase_flow_id:i,step_id:o,content_id:d,num:p});1!=c&&EC.refresh_cart_on_the_fly()}}),$(document).on("keypress",".product_selection_wrap .prod_sel_content, #cart_template_wrapper .prod_sel_content",function(e){isNaN(String.fromCharCode(e.which))&&e.preventDefault()}),$(document).on("keydown",".product_selection_wrap .prod_sel_content, #cart_template_wrapper .prod_sel_content",function(e){13==e.which&&$(this).blur()}),$(document).on("blur",".product_selection_wrap .prod_sel_content",function(e){var t=$(this).closest(".purchase_flow_step"),a=t.attr("data-free-sel"),s=$(this).closest(".selector_wrapper");if(a){var r=$(this).closest(".product_selection_wrap"),i=parseInt($(this).text()),o=parseInt(s.find(".product_selection").val());isNaN(i)&&(i=0);var c=r.attr("data-av"),l=t.attr("data-max-units");if(l>0){var n=0;$.each(t.find(".product_selection").not(s.find(".product_selection")),function(){n+=parseInt($(this).val())}),n+i>l&&(i=l-n)}if(c>0){var d=0;$.each(r.find(".product_selection").not(s.find(".product_selection")),function(){d+=parseInt($(this).val())}),i+d>c&&(i=c-d)}i.toString()!=$(this).text()&&$(this).text(i),i!=o&&(s.find(".product_selection").val(i),EC.refresh_cart_on_the_fly())}}),$(document).on("blur","#cart_template_wrapper .prod_sel_content",function(e){var t=$(this).closest(".selector_wrapper"),a=$(this).closest(".product_selection_wrap");if(a.attr("data-free-sel")){var s=parseInt($(this).text()),r=parseInt(t.find(".product_selection").val()),i=parseInt(a.attr("data-pf-id")),o=parseInt(a.attr("data-content-id")),c=parseInt(a.attr("data-step-id"));isNaN(s)&&(s=0);var l=a.attr("data-av"),n=a.attr("data-max-units");if(n>0){var d=0;$.each($('#cart_template_wrapper .product_selection_wrap[data-pf-id="'+i+'"][data-step-id="'+c+'"] .product_selection').not(t.find(".product_selection")),function(){d+=parseInt($(this).val())}),d+s>n&&(s=n-d)}if(l>0){var p=0;$.each(a.find(".product_selection").not(t.find(".product_selection")),function(){p+=parseInt($(this).val())}),s+p>l&&(s=l-p)}s.toString()!=$(this).text()&&$(this).text(s),s!=r&&(t.find(".product_selection").val(s),EC.save_cart_page_data(o))}});let e=function(e){if(e){let t=e.querySelector("option:checked");if(t){let a=e.value,s=t.getAttribute("avail"),r=e.closest(".selector_wrapper");if(r&&!isNaN(parseInt(s))){r.setAttribute("data-av",s);let i=r.querySelector(".product_selection");if(i){let o,c=i.getAttribute("name").match(/^(product\[\d+\])(\[[^\]]+\])$/);if(c){let l=c[1],n=c[2],d=(n=n.replace("[","").replace("]","")).split(" ")[0];n.split(" ")[1],i.setAttribute("name",l+"["+d+" "+a+"]")}}}}}};document.querySelectorAll(".selection_time select").forEach(t=>{e(t),t.addEventListener("change",function(a){e(this);let s=this.closest(".purchase_flow_step"),r=s.getAttribute("data-real-time"),i=t.closest(".selector_wrapper");if(i){let o=i.querySelector(".product_selection");if(o){let c=i.getAttribute("data-av");o.value>c&&(o.value=1,o.closest(".fieldvalue").querySelector(".prod_sel_rem").click())}}1!=r&&EC.refresh_cart_on_the_fly()})})},save_cart_page_data:function(e){var t=$('#cart_template_wrapper .product_selection_wrap[data-content-id="'+e+'"]'),a=t.attr("data-pf-id"),s=t.attr("data-step-id"),r=t.attr("data-search-id"),i={};i=t.hasClass("kit_details_wrap")?selector.closest(".kit_details").closest(".elem").find(".kit_selection_wrap .product_selection").serialize():t.find(".product_selection").serialize(),EC.add_cart_products(a,s,r,i,!1,!0)},add_cart_products:function(e,t,a,s,r,i,o,c){if(!EC.lock_add_cart_prod[e]){EC.lock_add_cart_prod[e]=!0,$(".prod_sel_add").addClass("disabled"),$(".prod_sel_rem").addClass("disabled"),F.register_event("pf_on_adding_product_to_cart",{purchase_flow_id:e,step_id:t}),$("#cart_template_wrapper").length>0&&$("#cart_template_wrapper .template_loading").show();var l={products:s,cart_page:$("#cart_template_wrapper").length>0?1:0,purchase_flow_id:e,step_id:t,search_id:a,clear_quantity:i?1:0,clear_cart:o?1:0,products_on_the_fly:EC.prepare_on_the_fly_products()};$(".product_kit_data").length&&(l.kits_data=$(".product_kit_data").serialize(),l.kits_details=$(".kit_detail_selection").serialize(),l.kits_details_dates=$(".kit_detail_date_selection").serialize()),ZF.postquery(base_url+"bootstrap/add_cart_products",l,function(s){EC.lock_add_cart_prod[e]=!1,$(".prod_sel_add:not(.max_occ)").removeClass("disabled"),$(".prod_sel_rem:not(.max_occ)").removeClass("disabled");var i=s;1==s.error?(i=!1,s.error_message?F.show_message(s.error_message):F.show_message(ZJS.strings.string_add_cart_product_error),$('.pf_step_button[data-pf-id="'+e+'"]').removeClass("clicked")):r&&($("#pf_"+e+"_step_"+t).addClass("products_added_to_cart"),F.register_event("pf_on_product_added_to_cart",s.products),$("#pf_"+e+"_step_"+t).hasClass("blocking_next_step")||EC.go_to_next_step(e,t,a)),s.disable_all_similar_items?($('div[data-occupancy-code="'+s.disable_all_similar_items+'"]').find(".prod_sel_add").addClass("disabled").addClass("max_occ"),$('div[data-occupancy-code="'+s.disable_all_similar_items+'"]').each(function(){0==$(this).find(".product_selection").val()&&$(this).find(".prod_sel_rem").addClass("disabled").addClass("max_occ")})):s.enable_all_similar_items&&($('div[data-occupancy-code="'+s.enable_all_similar_items+'"]').find(".prod_sel_add").removeClass("disabled").removeClass("max_occ"),$('div[data-occupancy-code="'+s.enable_all_similar_items+'"]').find(".prod_sel_rem").removeClass("disabled").removeClass("max_occ")),F.register_event("pf_on_add_cart_products_complete",s),i&&(s.cart_template?EC.refresh_cart_page_html(s):EC.process_cart_detail_data(s.cart_variable_data)),void 0!=c&&c(i)},"json",!0)}},go_to_next_step:function(e,t,a){ZF.getquery(base_url+"bootstrap/get_next_step/"+e+"/"+t+"/"+a,null,"json",!0,function(t){void 0!=t&&t.ret&&(void 0!=t.step?(F.register_event("pf_on_step_showing",{purchase_flow_id:e}),$("#purchase_flow_"+e+"_steps").html(t.step),EC.on_step_shown(e,t.step_id)):ZF.redirect(t.link))})},remove_cart_product:function(e,t,a,s){$("#cart_template_wrapper").length>0&&$("#cart_template_wrapper .template_loading").show(),document.querySelector('#cart_detail .remove_product[data-cid="'+e+'"][data-pf-id="'+t+'"][data-step-id="'+a+'"]')?.classList.add("removing");var r={product:{}};r.product[e]=-1;var i={products:$.param(r),cart_page:$("#cart_template_wrapper").length>0?1:0,purchase_flow_id:t,step_id:a,search_id:s};ZF.postquery(base_url+"bootstrap/add_cart_products",i,function(e){$.each(e.products,function(e,t){return F.register_event("pf_on_product_removed_to_cart",t),!1}),e.disable_all_similar_items?$('div[data-occupancy-code="'+e.disable_all_similar_items+'"]').find('.zselection[type="button"]').prop("disabled",!0):e.enable_all_similar_items&&$('div[data-occupancy-code="'+e.enable_all_similar_items+'"]').find('.zselection[type="button"]').prop("disabled",!1),e.cart_template?EC.refresh_cart_page_html(e):EC.refresh_cart_on_the_fly()},"json",!0)},clear_cart:function(){ZF.getquery(base_url+"bootstrap/clear_cart",null,"json",!1,function(e){})},get_cart:function(e){ZF.getquery(base_url+"bootstrap/get_cart/echo",null,"json",!0,function(t){void 0!=e&&e(t.cart)})},process_cart_detail_data:function(e){var t=$("#cart_detail").is(":visible");if(void 0!=e.ret&&$("#cart").length>0&&($("#cart").replaceWith(e.ret),t&&($("#cart").addClass("opened"),$("#cart_detail").show())),void 0!=e.ret_summary&&$("#cart_summary_wrapper").length>0&&$("#cart_summary_wrapper").replaceWith(e.ret_summary),void 0!=e.total_amount&&$("#total_amount").length>0){let a=$("<div></div>").html(e.total_amount);$("#total_amount .value").replaceWith(a.find(".value")),$('#total_amount input[type="hidden"]').replaceWith(a.find('input[type="hidden"]')),a.find(".paypal_message_scripts").length>0?0==$("body .paypal_message_scripts").length&&$("body").append(a.find(".paypal_message_scripts")):$("body .paypal_message_scripts").remove()}e.activated_products&&(Object.keys(e.activated_products).forEach(t=>{document.querySelectorAll('.purchase_flow_step .product_selection_wrap[data-content-id="'+t+'"]').forEach(a=>{let s=a.closest(".elem");if(e.activated_products[t].activated){a.classList.remove("selection_locked"),s.classList.contains("starting_hidden")&&a.closest(".elem").classList.remove("hidden_product");let r=e.activated_products[t].min_activated;if(!1!==r){let i=parseInt(a.getAttribute("data-prod-min"));r<i&&(r=i),a.setAttribute("data-upr-min",r),r>0&&a.querySelector(".product_selection").value<r&&(a.querySelector(".product_selection").value=r,a.querySelector(".prod_sel_content").innerText=r)}else a.removeAttribute("data-upr-min");let o=e.activated_products[t].max_activated;if(!1!==r){let c=parseInt(a.getAttribute("data-prod-max"));o>c&&c>0&&(o=c),a.setAttribute("data-upr-max",o),o>0&&a.querySelector(".product_selection").value>o&&(a.querySelector(".product_selection").value=o,a.querySelector(".prod_sel_content").innerText=o),-1==o&&s.classList.contains("starting_hidden")&&s.classList.add("hidden_product")}else a.removeAttribute("data-upr-max");let l=e.activated_products[t].daily_min_activated,n=e.activated_products[t].daily_max_activated;(void 0!==l||void 0!==n)&&a.querySelectorAll(".selector_wrapper").forEach(e=>{let t=e.getAttribute("data-date");void 0!==l&&void 0!==l[t]?(e.setAttribute("data-uprd-min",l[t]),l[t]>0&&e.querySelector(".product_selection").value<l[t]&&(e.querySelector(".product_selection").value=l[t],e.querySelector(".prod_sel_content").innerText=l[t])):e.removeAttribute("data-uprd-min"),void 0!==n&&void 0!==n[t]?(e.setAttribute("data-uprd-max",n[t]),n[t]>0&&e.querySelector(".product_selection").value>n[t]&&(e.querySelector(".product_selection").value=n[t],e.querySelector(".prod_sel_content").innerText=n[t]),-1==n[t]&&s.classList.contains("starting_hidden")&&(e.classList.add("hidden_spec_date_product"),0==a.querySelectorAll(".selector_wrapper:not(.hidden_spec_date_product)").length&&s.classList.add("hidden_product"))):e.removeAttribute("data-uprd-max")})}else a.classList.add("selection_locked"),s.classList.contains("starting_hidden")&&s.classList.add("hidden_product"),a.querySelector(".product_selection").value=0,a.querySelector(".prod_sel_content").innerText=0})}),F.register_event("on_products_activated",{activated_products:e.activated_products})),F.register_event("on_cart_detail_refreshed")},show_search_summary:function(e,t=null){e.length>0?($("#last_search_summary .search_summary_wrapper").html(e),$("#last_search_summary").removeClass("empty")):$("#last_search_summary").addClass("empty"),F.register_event("pf_on_search_summary_shown",{purchase_flow_id:t})},prepare_on_the_fly_products:function(){var e=[];return $.each($(".purchase_flow_step[data-real-time=\"0\"] .product_selection"),function(){var t=$(this).closest(".purchase_flow_step"),a=0;a=$(this).closest(".multiple_days").length>0?parseFloat($(this).closest(".selection_per_day_wrap").find(".ppd").val()):$(this).closest(".multiple_combinations").length>0?parseFloat($(this).closest(".selection_per_combination_wrap").find(".ppc").val()):parseFloat($(this).closest(".selector_wrapper").find(".product_price").val());let s={purchase_flow_id:t.attr("data-pf-id"),step_id:t.attr("data-step-id"),search_id:t.attr("data-search-id"),reinitialize_cart:t.hasClass("pf_reinitialize_cart")?1:0,content_id:$(this).attr("data-prod"),quantity:parseInt($(this).val()),amount:a};$(this).closest(".multiple_days").length>0&&(s.date=$(this).closest(".selector_wrapper").attr("data-date")),$(this).closest(".multiple_combinations").length>0&&(s.combination=$(this).closest(".selector_wrapper").attr("data-comb"));let r=$(this).closest(".selector_wrapper").find(".selection_time select");if(r){let i=r.val();s.time=i}e.push(s)}),e},refresh_cart_on_the_fly:function(e=!1){e&&document.querySelector(".pf_step_button")?.classList.add("disabled"),ZF.postquery(base_url+"bootstrap/generate_cart_variable/echo/0",{products_on_the_fly:EC.prepare_on_the_fly_products()},function(t){EC.process_cart_detail_data(t),e&&document.querySelector(".pf_step_button")?.classList.remove("disabled")},"json",!0)},refresh_cart_page:function(){$("#cart_template_wrapper .template_loading").show(),ZF.getquery(base_url+"bootstrap/generate_cart_page/echo",null,"json",!0,function(e){EC.refresh_cart_page_html(e)})},refresh_cart_page_html:function(e){if(e.cart_empty)ZF.refresh();else{$("#cart_template_wrapper").replaceWith(e.cart_template);let t=$("<div></div>").html(e.total_amount);$("#total_amount .value").replaceWith(t.find(".value")),$('#total_amount input[type="hidden"]').replaceWith(t.find('input[type="hidden"]')),t.find(".paypal_message_scripts").length>0?0==$("body .paypal_message_scripts").length&&$("body").append(t.find(".paypal_message_scripts")):$("body .paypal_message_scripts").remove(),F.register_event("pf_on_cart_page_refreshed"),$("#cart_template_wrapper .template_loading").hide()}},cart_behaviors:function(){$(document).on("click","#cart_detail .remove_product",function(){if($("#cart_detail").hasClass("one_time_stop")){$("#cart_detail").removeClass("one_time_stop");return}var e=$(this).attr("data-cid"),t=$(this).attr("data-pf-id"),a=$(this).attr("data-step-id"),s=$(this).attr("data-search-id");EC.remove_cart_product(e,t,a,s)}),$(document).on("click",".cart_remove_product",function(){if($("#cart_template_wrapper").hasClass("one_time_stop")){$("#cart_template_wrapper").removeClass("one_time_stop");return}var e=$(this).attr("data-cid"),t=$(this).attr("data-pf-id"),a=$(this).attr("data-step-id"),s=$(this).attr("data-search-id");EC.remove_cart_product(e,t,a,s)}),$(document).on("mouseenter","#cart",function(){$("#cart_detail").length>0&&($(this).addClass("opened"),$("#cart_detail").show())}),$(document).on("mouseleave","#cart",function(){$("#cart_detail").length>0&&($(this).removeClass("opened"),$("#cart_detail").hide())})},coupon_behaviors:function(){$(document).on("click","#coupon_button",function(){var e=$("#coupon_text").val(),t={coupon:e};$("#coupon_text").hasClass("active")&&(t.invalidate=1),e.length>0?ZF.postquery(base_url+"bootstrap/validate_coupon",t,function(e){e.ret||1===t.invalidate?ZF.refresh():F.show_message(ZJS.strings.string_unusable_coupon)},"json",!0):$("#coupon_text").focus()})},shipping_behaviors:function(){$(document).on("change",".shipping_methods",function(){1==$(this).find("option:selected").attr("data-skip_form")?($(".shipping_form_wrapper").hide(),$(".shipping_form_wrapper .required").removeAttr("required")):($(".shipping_form_wrapper").show(),$(".shipping_form_wrapper .required").attr("required","required"))})},payments_behaviors:function(){$(document).on("click","#paypal_payment",function(){EC.check_conditions()&&($(".paypal_loading").show(),ZF.postquery(base_url+"bootstrap/paypal_request_payment",{order_id:$(this).closest(".paypal_payment").find('[name="order_id"]').val()},function(e){e.redirect_url?window.location.href=e.redirect_url:($(".paypal_loading").hide(),F.show_message(ZJS.strings.string_paypal_error))},"json",!0))}),$(document).on("click","#setefi_payment",function(){EC.check_conditions()&&($(".setefi_loading").show(),ZF.postquery(base_url+"bootstrap/setefi_request_payment",{order_id:$(this).closest(".setefi_payment").find('[name="order_id"]').val()},function(e){e.redirect_url?window.location.href=e.redirect_url:($(".setefi_loading").hide(),F.show_message(ZJS.strings.string_setefi_error))},"json",!0))}),$(document).on("click","#stripe_payment",function(){EC.check_conditions()&&ZF.postquery(base_url+"bootstrap/stripe_request_payment",{order_id:$(this).closest(".stripe_payment").find('[name="order_id"]').val()},function(e){e.redirect_url?window.top.location.href=e.redirect_url:e.error_message?F.show_message(e.error_message):F.show_message(ZJS.strings.string_payment_error)},"json",!0)}),$(document).on("click","#scalapay_payment",function(){EC.check_conditions()&&($(".scalapay_loading").show(),ZF.postquery(base_url+"bootstrap/scalapay_request_payment",{order_id:$(this).closest(".scalapay_payment").find('[name="order_id"]').val()},function(e){e.redirect_url?window.location.href=e.redirect_url:($(".scalapay_loading").hide(),F.show_message(ZJS.strings.string_scalapay_error))},"json",!0))}),$(document).on("click","#syspay_payment",function(){EC.check_conditions()&&($(".syspay_loading").show(),ZF.postquery(base_url+"bootstrap/syspay_request_payment",{order_id:$(this).closest(".syspay_payment").find('[name="order_id"]').val()},function(e){e.redirect_url?window.location.href=e.redirect_url:(e.error_message&&console.log(e.error_message),$(".syspay_loading").hide(),F.show_message(ZJS.strings.string_payment_error))},"json",!0))}),$(document).on("click","#worldline_payment",function(){EC.check_conditions()&&($(".worldline_loading").show(),ZF.postquery(base_url+"bootstrap/worldline_request_payment",{order_id:$(this).closest(".worldline_payment").find('[name="order_id"]').val()},function(e){switch(e.action){case"show_error":$(".worldline_loading").hide(),F.show_message(e.error_message);break;case"redirect":window.location.href=e.redirect_url;break;case"load_sdk":window.axeptaClient||(window.axeptaClient=new AxeptaSDKClient(e.sdk_url,e.license_key)),window.axeptaClient.proceedToPayment(e.payment_id)}},"json",!0))}),$(document).on("click","#worldline_payment_btn",function(){EC.check_conditions()&&($(".worldline_loading").show(),ZF.postquery(base_url+"bootstrap/check_expired_order",{order_id:$(this).attr("data-order_id")},function(e){$(".worldline_loading").hide(),!0==e.expired?window.location.href=e.redirect_url:axeptaClient.submit()},"json",!0))}),$(document).on("click","#planet_payment",function(){EC.check_conditions()&&($(".planet_loading").show(),ZF.postquery(base_url+"bootstrap/planet_request_payment",{order_id:$(this).closest(".planet_payment").find('[name="order_id"]').val()},function(e){e.ipg_session?($("#planet_form input[name=ajax_token]").remove(),$("#planet_form input[name=XXX_IPGSESSION_XXX]").val(e.ipg_session),$("#planet_form").submit()):e.redirect_url?window.location.href=e.redirect_url:(e.error_message&&console.log(e.error_message),$(".planet_loading").hide(),F.show_message(ZJS.strings.string_payment_error))},"json",!0))}),$("iframe#evo_iframe").length,$(document).on("click","#bank_transfer_payment, #cash_on_delivery_payment",function(e){EC.check_conditions()||e.preventDefault()}),$(document).on("click","#goto_thankyou_page",function(){EC.check_conditions()&&ZF.redirect($(this).attr("data-href"))}),void 0!=ZJS.order_expiration_time&&setTimeout(function(){ZF.refresh()},1e3*ZJS.order_expiration_time)},check_conditions:function(e){var t=!0;if($("#showprivacy.ecommerce_privacy").length){var a=$("#showprivacy.ecommerce_privacy").attr("data-order-id");if($.each($('#showprivacy.ecommerce_privacy .privacy_field input[type="checkbox"]'),function(){if($(this).prop("required")&&!$(this).is(":checked"))return t=!1,!1}),$.each($('#showprivacy.ecommerce_privacy .privacy_field input[type="radio"][value="1"]'),function(){if(1==$(this).attr("data-req")){if(!$(this).is(":checked"))return t=!1,!1}else if(0==$('[name="'+$(this).attr("name")+'"]:checked').length)return t=!1,!1}),!0===e)return t;t?(EC.send_to_iubenda_cons(),ZF.postquery(base_url+"bootstrap/save_payment_conditions",{order_id:a,privacy_fields:$("#showprivacy.ecommerce_privacy .privacy_field input").serialize()},function(e){},"json")):F.show_message(ZJS.strings.string_accept_payment_conditions)}return t},calculate_kit_price:function(e){var t=parseFloat(e.find(".kit_selection_wrap").attr("data-bp")),a=parseFloat(e.find(".kit_selection_wrap").attr("data-min-price"));$.each(e.find(".kit_details .kit_details_wrap"),function(){var e=0,a=0,s=parseFloat($(this).attr("data-mp")),r=parseInt($(this).attr("data-initial-qty"));$.each($(this).find(".selector_wrapper"),function(){var t=parseInt($(this).find(".product_selection").val()),s=parseFloat($(this).find(".vppd").val())*t;e+=t,a+=s}),r>e&&(a+=(r-e)*s),t+=a}),t<a&&(t=a),t=t.toFixed(2),e.find(".product_price").val(t);var s=t.split("."),r=e.find(".zlabelprice");r.find(".number").text(s[0]),r.find(".decimal").text(s[1])},calculate_total_price:function(){var e=$("#total_amount");if(e.length){var t=parseFloat($("#total_amount_value").val());isNaN(t)&&(t=0),$.each($(".purchase_flow_step"),function(){if($(this).hasClass("pf_reinitialize_cart"))return t=0,!1}),$.each($(".purchase_flow_step .product_price"),function(){var e=$(this).attr("data-prod"),a=parseFloat($(this).val()),s=parseFloat($(this).closest(".purchase_flow_step").find('.product_selection[name="product['+e+']"]').val());t+=a*s}),$.each($(".purchase_flow_step .selection_per_day_wrap .product_selection").not(".kit_detail_selection"),function(){$(this).attr("data-prod");var e=parseFloat($(this).parent().find(".ppd").val()),a=parseFloat($(this).val());t+=e*a});var a=t.toFixed(2).split(".");e.find(".number").text(a[0]),e.find(".decimal").text(a[1]),$("#total_amount").show(),F.register_event("on_total_amount_updated",{total_amount:t})}},send_to_iubenda_cons:function(){if(!EC.iubenda_cons_called&&(EC.iubenda_cons_called=!0,"undefined"!=typeof _iub&&_iub.cons_instructions))try{var e={};$("#showprivacy.ecommerce_privacy [data-cons-subject]").each(function(){e[$(this).attr("data-cons-subject")]=$(this).val()});var t={},a=[];$("#showprivacy.ecommerce_privacy input").each(function(){var e=$(this).attr("data-cons-preference");e&&("radio"==$(this).attr("type")&&1==$(this).val()?t[e]=!0==$(this).prop("checked"):"checkbox"==$(this).attr("type")&&(t[e]=!0==$(this).prop("checked")));var s=$(this).attr("legal-notice-id");s&&(a[s]={identifier:s})});var s=[];for(var r in a)s.push(a[r]);var i=[];i.push({});var o=$("#showprivacy.ecommerce_privacy input").serializeArray(),c={};$.map(o,function(e,t){c[e.name]=e.value});var l=JSON.stringify(c);i[0].content=l,i[0].form=$("#showprivacy.ecommerce_privacy").clone().wrap("<p/>").parent().html(),_iub.cons_instructions.push(["submit",{writeOnLocalStorage:!0,consent:{subject:e,preferences:t,legal_notices:s,proofs:i}},{success:function(e){window.localStorage.removeItem("IUB_DATA")},error:function(e){}}])}catch(n){console.log(n)}},ibe_behaviors:function(){let e=function(){let e=0;document.querySelectorAll("[data-crossbooking].cb_active .product_price").forEach(t=>{e+=parseFloat(t.value)});let t=e.toLocaleString("it-IT",{minimumFractionDigits:0,maximumFractionDigits:0,useGrouping:!0}),a=e.toLocaleString("it-IT",{minimumFractionDigits:0,maximumFractionDigits:2}).toString();1==(a=-1==a.indexOf(",")?"00":a.split(",")[1]).length&&(a+="0"),document.querySelector(".crossbooking_total span").innerHTML=`<span class="number">${t}</span><span class="comma">,</span><span class="decimal">${a}</span>`},t=document.querySelectorAll("[data-crossbooking]"),a=null;if(t.length>0){document.querySelector(".purchase_flow_step")?.classList.add("crossbooking_step");let s=[];t.forEach(e=>{let t=e.getAttribute("data-crossb_block"),r=e.closest(".subcontents")?.closest(".elem");if(s[t]||(s[t]={block_id:t,date_1:e.getAttribute("data-crossb_d1"),date_2:e.getAttribute("data-crossb_d2"),rooms:[]}),s[t].rooms.push(r),null==a&&(a=r),r){let i=r.querySelector(".subcontents .ztemplate");i&&(i.style.display="none")}});let r=t[0].closest(".subcontents")?.closest(".box"),i=r.appendChild(Object.assign(document.createElement("div"),{className:"crossbooking"})),o="";a.querySelector(".subcontents .elem")?.classList.forEach(e=>{e.indexOf("treatment-")>-1&&(o=e)});let c=a.querySelector(".subcontents .elem .title")?.outerHTML,l=a.querySelector(".subcontents .elem .rate_arrangement")?.outerHTML,n=a.querySelector(".canc_policy")?.closest(".zlabel")?.outerHTML;i.innerHTML=`<div class="crossbooking_header">
					<div class="info_title">${ZJS.strings.ibe_cross_booking_info_1}</div>
					<div class="info_subtitle">${ZJS.strings.ibe_cross_booking_info_2}</div>
				</div>
				<div class="crossbooking_elements"></div>
				<div class="crossbooking_footer">
					<div class="rate-group">
						<div class="rate-group-header open">
							<div class="rate-group-title"><p>${a.querySelector(".rate-group-title")?.textContent}</p></div>
							<div class="rate-group-cond"><p>${ZJS.strings.order_preview_payment_conditions}</p></div>
							<div class="rate-group-price"><p>${ZJS.strings.total_stay_price}</p></div>
							<div class="rate-group-rooms"><p>${ZJS.strings.payment_booking_expert_book}</p></div>
						</div>
						<div class="rate-group-content">
							<div class="rate-group-title-value ${o}">${c} ${l}</div>
							<div class="rate-group-cond-value">${n}</div>
							<div class="rate-group-price-value">
								<div class="crossbooking_total">€ <span></span></div>
							</div>
							<div class="rate-group-rooms-value">
								<div class="zselection cross_selection_wrap selector_wrapper">
									<span class="prod_sel_rem"></span>
									<div class="prod_sel_content">0</div>
									<span class="prod_sel_add"></span>
								</div>
							</div>
						</div>
					</div>
				</div>`,s.forEach(e=>{let t="";e.rooms.length>1&&(t=`
						<div class="crossbooking_select">
							<form>
								<div class="form field select_wrap select">
									<div class="form_element_title">${ZJS.strings.ibe_cross_booking_change_room}</div>
									<select class="hidden_form_element"></select>
									<div class="form_select html_select">
										<div class="current_value"></div>
										<div class="elements_list none" style="display: none;"></div>
									</div>
								</div>
							</form>
						</div>`);let a=Object.assign(document.createElement("div"),{className:`crossbooking_block block_${e.block_id}`}),s=ZJS.strings.ibe_cross_booking_dates.replace("{0}",F.date_from_dash_to_slash(e.date_1)).replace("{1}",F.date_from_dash_to_slash(e.date_2));a.innerHTML=`
					<div class="crossbooking_block_header"><div class="crossbooking_dates">${s}</div>${t}</div>
					<div class="crossbooking_block_rooms"></div>`;let r=!0;e.rooms.forEach(e=>{let t=e.querySelector(".title")?.textContent,s=e.getAttribute("data-cid");if(a.querySelector(".crossbooking_select .hidden_form_element")?.insertAdjacentHTML("beforeend",`<option value="${s}">${t}</option>`),a.querySelector(".crossbooking_select .elements_list")?.insertAdjacentHTML("beforeend",`<div class="option" data-opt-id="${s}">${t}</div>`),r){r=!1,e.querySelector("[data-crossbooking]").classList.add("cb_active");let i=a.querySelector(".crossbooking_select .current_value");i&&(i.textContent=t)}else e.classList.add("cross_booking_hide");a.querySelector(".crossbooking_block_rooms").appendChild(e)}),i.querySelector(".crossbooking_elements").appendChild(a)}),e(),document.querySelector(".cross_selection_wrap .prod_sel_add").addEventListener("click",function(){document.querySelector("[data-crossbooking].cb_active .prod_sel_add").classList.contains("disabled")||(this.classList.add("disabled"),this.classList.add("max_occ"),document.querySelector("[data-crossbooking].cb_active .prod_sel_add").click(),document.querySelector(".cross_selection_wrap .prod_sel_content").textContent="1")}),document.querySelector(".cross_selection_wrap .prod_sel_rem").addEventListener("click",function(){document.querySelector(".cross_selection_wrap .prod_sel_add").classList.remove("disabled"),document.querySelector(".cross_selection_wrap .prod_sel_add").classList.remove("max_occ"),document.querySelector("[data-crossbooking].cb_active .prod_sel_rem").click(),document.querySelector(".cross_selection_wrap .prod_sel_content").textContent="0"}),$(".crossbooking_select select").on("change",function(){document.querySelector("[data-crossbooking].cb_active .prod_sel_rem").click();let t=this.value;this.closest(".crossbooking_block").querySelectorAll(".crossbooking_block_rooms > .elem").forEach(function(e){let a=e.getAttribute("data-cid");a==t?(e.classList.remove("cross_booking_hide"),e.querySelector("[data-crossbooking]").classList.add("cb_active")):(e.classList.add("cross_booking_hide"),e.querySelector("[data-crossbooking]").classList.remove("cb_active"))}),e()})}function d(e){let t=null,a=null;if(document.querySelectorAll(".engagement_info").forEach(e=>{let s=e.querySelector(".accomodation_id").textContent,r=document.querySelector(`.accomodation_info[ac_id="${s}"]`),i=document.querySelectorAll(`.selector_wrapper[data-occupancy-code="${s}"] .product_selection`);a||(a=r);let o=null;if(i.forEach(function(e){!isNaN(parseInt(e.value))&&parseInt(e.value)>0&&(o=e)}),o){let c="";o.closest(".elem")?.classList.forEach(e=>{-1!==e.indexOf("treatment")&&(c=e)}),r.querySelector(".selected_rate_ctn").setAttribute("treatment",c);let l=o.closest(".subcontents")?.closest(".elem")?.querySelector(".title")?.textContent;r.querySelector(".selected_room_name").textContent=l;let n=o.closest(".elem")?.querySelector(".zlabelprice .fieldvalue")?.innerHTML;r.querySelector(".selected_room_price").innerHTML=n,r.querySelector(".selected_rate_ctn").innerHTML=o.closest(".elem").innerHTML,r.classList.add("selected"),r.querySelector(".selected_rate_ctn .selector_wrapper").remove(),r.querySelector(".selected_option_info").setAttribute("rate_id",o.getAttribute("data-prod")),r.classList.remove("logical_hide"),r.querySelector(".selected_option_info").classList.remove("logical_hide"),r.querySelector(".info_msg").classList.add("logical_hide"),i.forEach(function(e){e.closest(".subcontents").closest(".elem").classList.add("logical_hide")})}else null==t?(t=s,r.querySelector(".selected_room_name").textContent="",r.querySelector(".selected_room_price").textContent="",r.querySelector(".selected_rate_ctn").innerHTML="",r.querySelector(".selected_rate_ctn").removeAttribute("treatment"),r.classList.remove("selected"),r.querySelector(".selected_option_info").removeAttribute("rate_id"),r.classList.remove("logical_hide"),r.querySelector(".selected_option_info").classList.add("logical_hide"),r.querySelector(".info_msg").classList.remove("logical_hide"),i.forEach(function(e){e.closest(".subcontents").closest(".elem").classList.remove("logical_hide")})):(r.querySelector(".selected_room_name").textContent="",r.querySelector(".selected_room_price").textContent="",r.querySelector(".selected_rate_ctn").innerHTML="",r.querySelector(".selected_rate_ctn").removeAttribute("treatment"),r.classList.remove("selected"),r.querySelector(".selected_option_info").removeAttribute("rate_id"),r.classList.add("logical_hide"),i.forEach(function(e){e.closest(".subcontents").closest(".elem").classList.add("logical_hide")}))}),!e&&a){let s=a.getBoundingClientRect().top+window.pageYOffset-350;"scrollBehavior"in document.documentElement.style&&window.scroll({top:s,behavior:"smooth"})}$.fn.slick&&$(".slick-slider").slick("refresh")}document.querySelector(".engagement_infos")&&(window.accomodations_list=[],document.querySelectorAll(".engagement_info").forEach(e=>{let t=e.querySelector(".accomodation_id").textContent,a=e.querySelector(".accomodation_msg").innerHTML;accomodations_list.push(t);let s=document.querySelector('[data-occupancy-code="'+t+'"]')?.closest(".subcontents")?.closest(".elem");if(s){let r=document.createElement("div");r.classList.add("accomodation_info"),r.setAttribute("ac_id",t),r.innerHTML=`
						<div class="info_msg">${a}</div>
						<div class="selected_option_info">
							<div class="remove_eng_selection">${ZJS.strings.string_cancel}</div>
							<div class="selected_room_name"></div>
							<div class="selected_room_price"></div>
							<div class="toggle_open">${ZJS.strings.string_details}</div>
							<div class="selected_rate_ctn toggle_target"></div>
						</div>`,s.insertAdjacentElement("beforebegin",r)}}),d(!0)),document.addEventListener("click",function(e){let t=e.target.closest(".remove_eng_selection");if(t){let a=t.closest(".accomodation_info").querySelector(".selected_option_info").getAttribute("rate_id");a&&document.querySelector('.selector_wrapper[data-content-id="'+a+'"] .prod_sel_rem').click()}});let p=!0;$(document).on("on_cart_detail_refreshed",function(e,t){if(document.querySelector(".engagement_infos")){let a=0;document.querySelectorAll(".product_selection").forEach(function(e){a+=isNaN(parseInt(e.value))?0:parseInt(e.value)}),a==accomodations_list.length?document.querySelector(".pf_step_button").classList.remove("logical_hide"):document.querySelector(".pf_step_button").classList.add("logical_hide"),p?p=!1:d(!1)}});let u=document.querySelector(".refuse_offer_btn");u&&u.addEventListener("click",function(e){F.show_message(ZJS.strings.ibe_refuse_offer_confirm,{buttons:[{text:ZJS.strings.string_confirm,class:"ok_btn",callback:function(){$(".data_loading").show(),ZF.postquery(base_url+"bootstrap/ibe_refuse_offer",{reservation_id:window.reservation_id,user_email:localStorage.getItem("eng_email|"+window.reservation_id),msg:document.getElementById("refuse_offer_reason").value},function(e){$(".data_loading").hide(),!0==e.ret?(localStorage.removeItem("eng_email|"+window.reservation_id),window.location.href=ZJS.base_url):F.show_message(ZJS.strings.string_error)},"json",!0)}},{text:ZJS.strings.string_cancel,class:"cancel_btn"}]})});let f=document.getElementById("unlock_offer_form");if(f){window.reservation_id=f.getAttribute("reservation_id");let h=localStorage.getItem("eng_email|"+window.reservation_id),m=!1;if(!h){let v=f.getAttribute("unlock_email");v&&""!==v.trim()&&v.includes("@")&&(h=v,m=!0)}function g(e){ZF.postquery(base_url+"bootstrap/ibe_unlock_offer",{input_email:e,reservation_id:window.reservation_id},function(t){!0==t.ret?(localStorage.setItem("eng_email|"+window.reservation_id,e),document.querySelector(".refuse_offer")?.classList.remove("logical_hide"),document.querySelector(".ibe_offers_wrapper")?.classList.remove("logical_hide"),document.querySelector(".unlock_offer")?.classList.add("logical_hide"),document.querySelectorAll(".view_offer_link").forEach(function(t){let a=t.getAttribute("href");if(-1==a.indexOf("user_email")){let s=-1==a.indexOf("?")?"?":"&";a+=s+"user_email="+encodeURIComponent(e),t.setAttribute("href",a)}})):F.show_message(t.error_msg)},"json",!0)}h?(document.querySelector(".unlock_offer")?.classList.add("logical_hide"),document.querySelector(".ibe_offers_wrapper")?.classList.remove("logical_hide"),document.querySelectorAll(".view_offer_link").forEach(function(e){let t=e.getAttribute("href");if(-1==t.indexOf("user_email")){let a=-1==t.indexOf("?")?"?":"&";t+=a+"user_email="+encodeURIComponent(h),e.setAttribute("href",t)}})):(document.querySelector(".refuse_offer")?.classList.add("logical_hide"),document.querySelector(".ibe_offers_wrapper")?.classList.add("logical_hide")),f.addEventListener("submit",function(e){e.preventDefault();g(document.getElementById("unlock_offer_email").value)}),m&&(console.log("unlock automatico"),g(h))}}};$(function(){$(document).ready(function(){F.cookieless_widget()?console.log("ecommerce wait for widget"):EC.initialize()})});