$j(document).ready(function(){$j("body").on("bookacti_calendar_init_data",".bookacti-booking-system",function(b,a){b=$j(this);var c=b.attr("id");"undefined"!==typeof bookacti.booking_system[c]&&"undefined"!==typeof bookacti.booking_system[c].display_data&&(c=bookacti.booking_system[c].display_data,bookacti_localized.no_events&&(a.noEventsContent=bookacti_localized.no_events),badp_update_calendar_settings(a,c,b))});$j("body").on("bookacti_calendar_editor_init_data","#bookacti-template-calendar",function(b,
a){b=$j(this);var c=b.attr("id");if("undefined"!==typeof bookacti.booking_system[c]&&"undefined"!==typeof bookacti.booking_system[c].template_data&&"undefined"!==typeof bookacti.booking_system[c].template_data.settings){var d="slotDuration slotEventOverlap hiddenDays initialView availableViews flexibleViewsDayCount multipleMonthsViewsDuration multiMonthMinWidth showNonCurrentDates".split(" "),e={};$j.each(bookacti.booking_system[c].template_data.settings,function(h,g){0<=$j.inArray(h,d)&&(e[h]=g)});
bookacti_localized.no_events&&(a.noEventsContent=bookacti_localized.no_events);badp_update_calendar_settings(a,e,b)}});$j("body").on("bookacti_calendar_editor_view_class_names bookacti_calendar_view_class_names","#bookacti-template-calendar, .bookacti-booking-system",function(b,a,c){b=$j(this).attr("id");-1<c.view.type.indexOf("timeGrid")&&bookacti.fc_calendar[b].getOption("slotEventOverlap")&&a.class_names.push("bookacti-events-overlap")});$j("body").on("bookacti_calendar_event_did_mount bookacti_calendar_editor_event_did_mount",
".bookacti-booking-system, #bookacti-template-calendar",function(b,a){var c=$j(this).attr("id"),d=bookacti.booking_system[c]?.events_data?.[a.event.groupId]?.activity_id;b=bookacti.booking_system[c]?.activities_data?.[d]?.settings?.text_color;c=bookacti.booking_system[c]?.activities_data?.[d]?.settings?.background_image;b&&"#fff"!==b&&"#ffffff"!==b&&$j(a.el).css("color",b);c&&($j(a.el).css("background-image","url("+c+")"),$j(a.el).addClass("badp-has-background-image"))});$j("body").on("bookacti_fc_events",
".bookacti-booking-system, .bookacti-booking-system-editor",function(b,a){var c=$j(this).attr("id");$j.each(a.events,function(d,e){e=e.activity_id||bookacti.booking_system[c]?.events_data?.[e.groupId]?.activity_id;(e=bookacti.booking_system[c]?.activities_data?.[e]?.settings?.text_color)&&"#fff"!==e&&"#ffffff"!==e&&(a.events[d].textColor=e)})});$j("body").on("bookacti_refresh_picked_events_on_calendar","#bookacti-template-calendar, .bookacti-booking-system",function(b){$j(this).find(".bookacti-events-overlap .bookacti-picked-event").closest(".fc-timegrid-event-harness").addClass("bookacti-picked-event-container")});
$j("body").on("bookacti_unpick_all_events_on_calendar","#bookacti-template-calendar, .bookacti-booking-system",function(b){$j(this).find(".bookacti-picked-event-container").removeClass("bookacti-picked-event-container")});$j("body").on("bookacti_calendar_event_content bookacti_calendar_editor_event_content",".bookacti-booking-system, #bookacti-template-calendar",function(b,a,c){"list"===c.view.type.substr(0,4)&&(a.domNodes=a.domNodes.filter(function(d){return d.classList.contains("fc-event-time")?
!1:!0}))});$j("body").on("bookacti_calendar_event_did_mount bookacti_calendar_editor_event_did_mount",".bookacti-booking-system, #bookacti-template-calendar",function(b,a){"list"!==a.view.type.substr(0,4)||a.isEnd||(b="LT","wp_settings"===bookacti_localized.calendar_localization&&(b=bookacti_convert_php_datetime_format_to_moment_js(bookacti_localized.wp_time_format)),$j(a.el).children(":first-child").html('<span class="bookacti-event-time-start">'+moment.utc(a.event.start).clone().locale("en").format(b)+
'</span><span class="bookacti-event-time-separator">'+bookacti_localized.dates_separator+'</span><span class="bookacti-event-time-end">'+moment.utc(a.event.end).clone().locale("en").formatPHP(bookacti_localized.date_format)+"</span>"))});$j("body").on("bookacti_calendar_event_class_names bookacti_calendar_editor_event_class_names",".bookacti-booking-system, #bookacti-template-calendar",function(b,a,c){"list"===c.view.type.substr(0,4)&&(c.isStart||a.class_names.push("bookacti-event-hidden"))});$j("body").on("bookacti_calendar_view_render bookacti_calendar_editor_view_render bookacti_booking_system_reloaded bookacti_booking_system_interval_data_loaded bookacti_calendar_editor_interval_data_loaded",
".bookacti-booking-system, #bookacti-template-calendar",function(){$j(this).find(".fc-list-table tr.fc-list-day").each(function(){$j(this).nextUntil(".fc-list-day",".fc-list-event:visible").length||$j(this).addClass("badp-empty-list-day")})});$j("body").on("bookacti_refresh_selected_events","#bookacti-template-calendar",function(){var b=$j(this);b.find(".fc-list-event").length&&($j(".fc-list-event").removeClass("bookacti-picked-event"),$j.each(bookacti.booking_system["bookacti-template-calendar"].picked_events,
function(a,c){a=moment.utc(c.start).clone().locale("en").format("YYYY-MM-DD HH:mm:ss");b.find('.fc-list-event[data-event-id="'+c.id+'"][data-event-start="'+a+'"]').addClass("bookacti-picked-event")}),$j(".fc-list-event").removeClass("bookacti-selected-event"),$j(".fc-list-event .bookacti-event-action-select-checkbox").prop("checked",!1),$j.each(bookacti.booking_system["bookacti-template-calendar"].selected_events,function(a,c){a=moment.utc(c.start).clone().locale("en").format("YYYY-MM-DD HH:mm:ss");
c=$j('.fc-list-event[data-event-id="'+c.id+'"][data-event-start="'+a+'"]');c.addClass("bookacti-selected-event");c.find(".bookacti-event-action-select-checkbox").prop("checked",!0)}))});$j("body").on("bookacti_select_event","#bookacti-template-calendar",function(b,a){$j(this).find(".fc-list-event").length&&(b=moment.utc(a.start).clone().locale("en").format("YYYY-MM-DD HH:mm:ss"),a=$j('.fc-list-event[data-event-id="'+a.id+'"][data-event-start="'+b+'"]'),a.addClass("bookacti-selected-event"),a.find(".bookacti-event-action-select-checkbox").prop("checked",
!0))});$j("body").on("bookacti_unselect_event","#bookacti-template-calendar",function(b,a,c){$j(this).find(".fc-list-event").length&&(b=$j('.fc-list-event[data-event-id="'+a.id+'"]'),!c&&a.start&&(c=moment.utc(a.start).clone().locale("en").format("YYYY-MM-DD HH:mm:ss"),b=$j('.fc-list-event[data-event-id="'+a.id+'"][data-event-start="'+c+'"]')),b.removeClass("bookacti-selected-event"),b.find(".bookacti-event-action-select-checkbox").prop("checked",!1))});$j("body").on("bookacti_pick_event",".bookacti-booking-system, #bookacti-template-calendar",
function(b,a,c,d){b=$j(this);b.find(".fc-list-event").length&&(c="undefined"!==typeof a.groupId?parseInt(a.groupId):parseInt(a.id),a=moment.utc(a.start).clone().locale("en").format("YYYY-MM-DD HH:mm:ss"),b.find('.fc-list-event[data-event-id="'+c+'"][data-event-start="'+a+'"]').addClass("bookacti-picked-event"))});$j("body").on("bookacti_refresh_picked_events_on_calendar",".bookacti-booking-system",function(){var b=$j(this);if(b.find(".fc-list-event").length){var a=b.attr("id");$j.each(bookacti.booking_system[a].picked_events,
function(c,d){c=moment.utc(d.start).clone().locale("en").format("YYYY-MM-DD HH:mm:ss");b.find('.fc-list-event[data-event-id="'+d.id+'"][data-event-start="'+c+'"]').addClass("bookacti-picked-event")})}});$j("body").on("bookacti_start_loading",".bookacti-booking-system",function(b,a){b=$j(this);"calendar"===a&&b.find(".fc-list.fc-view").length&&b.find(".fc-scroller").css("min-height","200px")});$j("body").on("bookacti_exit_loading_state",".bookacti-booking-system",function(b,a,c){b=$j(this);"calendar"===
a&&b.find(".fc-list.fc-view").length&&b.find(".fc-scroller").css("min-height","auto")})});
function badp_update_calendar_settings(b,a,c){var d=c.attr("id"),e="undefined"!==typeof a.flexibleViewsDayCount?parseInt(a.flexibleViewsDayCount):3,h="undefined"!==typeof a.flexibleViewsIncrement?parseInt(a.flexibleViewsIncrement):e,g="undefined"!==typeof a.multipleMonthsViewsDuration?parseInt(a.multipleMonthsViewsDuration):2,n="undefined"!==typeof a.multiMonthMinWidth?parseInt(a.multiMonthMinWidth):0,p=0<n?"multiMonth":"dayGrid",q=0<n?99:1;"undefined"!==typeof a.height&&(b.height=$j.isNumeric(a.height)?
parseInt(a.height):a.height?a.height:"auto");"undefined"!==typeof a.contentHeight&&(b.contentHeight=$j.isNumeric(a.contentHeight)?parseInt(a.contentHeight):a.contentHeight?a.contentHeight:"auto");"undefined"!==typeof a.aspectRatio&&(b.aspectRatio=$j.isNumeric(a.aspectRatio)?parseFloat(a.aspectRatio):a.aspectRatio?a.aspectRatio:"auto");"auto"===b?.height&&delete b.height;"auto"===b?.contentHeight&&delete b.contentHeight;"auto"===b?.aspectRatio&&delete b.aspectRatio;b?.height||b?.contentHeight||b?.aspectRatio||
(b.height="auto",b.contentHeight="auto");a.handleWindowResize&&(b.handleWindowResize=parseInt(a.handleWindowResize)?!0:!1);if(a.initialView){var k="";"string"===typeof a.initialView?k=a.initialView:$j.each(a.initialView,function(l,m){k=m;if(c.width()<=l)return!1});k&&(b.initialView=k)}if("undefined"!==typeof a.availableViews){if(!$j.isArray(a.availableViews)){var f="string"==typeof a.availableViews&&""!==a.availableViews?a.availableViews:"";a.availableViews=[];""!==f&&a.availableViews.push(f)}-1<
$j.inArray(d,["bookacti-template-calendar","bookacti-booking-system-bookings-page"])&&-1===$j.inArray("timeGridWeek",a.availableViews)&&a.availableViews.push("timeGridWeek");d="listYear listMonthMultiple dayGridMonthMultiple dayGridYear listMonth dayGridMonth listWeek timeGridWeek dayGridWeek listFlexible timeGridFlexible dayGridFlexible listDay timeGridDay dayGridDay".split(" ");7<e&&(d="listYear listMonthMultiple dayGridMonthMultiple dayGridYear listMonth dayGridMonth listFlexible timeGridFlexible dayGridFlexible listWeek timeGridWeek dayGridWeek listDay timeGridDay dayGridDay".split(" "));
d=d.filter(l=>a.availableViews.includes(l));b.headerToolbar.end=d.join(",")}"undefined"!==typeof a.weekNumbers&&(b.weekNumbers=parseInt(a.weekNumbers)?!0:!1);"undefined"!==typeof a.navLinks&&(b.navLinks=parseInt(a.navLinks));a.slotDuration&&(b.slotDuration=a.slotDuration);a.scrollTime&&(b.scrollTime=a.scrollTime);"undefined"!==typeof a.nowIndicator&&(b.nowIndicator=parseInt(a.nowIndicator));"undefined"!==typeof a.slotEventOverlap&&(b.slotEventOverlap=parseInt(a.slotEventOverlap));a.moreLinkClick&&
(b.moreLinkClick=a.moreLinkClick);"undefined"!==typeof a.showNonCurrentDates&&(b.showNonCurrentDates=parseInt(a.showNonCurrentDates));"undefined"!==typeof a.hiddenDays&&$j.isArray(a.hiddenDays)&&(b.hiddenDays=[],a.hiddenDays.length&&$j.each(a.hiddenDays,function(l,m){isNaN(parseInt(m))||b.hiddenDays.push(parseInt(m))}));d=!1;"undefined"!==typeof a.dayMaxEvents&&($j.isNumeric(a.dayMaxEvents)?(0===parseInt(a.dayMaxEvents)&&(d=!1),0<parseInt(a.dayMaxEvents)&&(d=parseInt(a.dayMaxEvents))):d=!0);f={weekday:"long",
month:"long",year:"numeric",day:"numeric"};b.views={dayGridMonth:{dayMaxEvents:d},dayGridYear:{dayMaxEvents:d},listDay:{buttonText:bookacti_localized.calendar_button_list_day,listDayFormat:f,listDaySideFormat:!1},listWeek:{buttonText:bookacti_localized.calendar_button_list_week,listDayFormat:f,listDaySideFormat:!1},listMonth:{buttonText:bookacti_localized.calendar_button_list_month,listDayFormat:f,listDaySideFormat:!1},listYear:{buttonText:bookacti_localized.calendar_button_list_year,listDayFormat:f,
listDaySideFormat:!1},timeGridFlexible:{type:"timeGrid",dayCount:e,dateIncrement:{days:h},buttonText:bookacti_localized.calendar_button_flexible.replace("{days}",e)},dayGridFlexible:{type:"dayGrid",dayCount:e,dateIncrement:{days:h},buttonText:bookacti_localized.calendar_button_flexible.replace("{days}",e)},listFlexible:{type:"list",duration:{days:e},listDayFormat:f,listDaySideFormat:!1,buttonText:bookacti_localized.calendar_button_flexible.replace("{days}",e)},dayGridMonthMultiple:{type:p,duration:{months:g},
fixedWeekCount:!1,multiMonthMaxColumns:q,multiMonthMinWidth:n,dayMaxEvents:d,buttonText:bookacti_localized.calendar_button_multiple_months.replace("{months}",g)},listMonthMultiple:{type:"list",duration:{months:g},fixedWeekCount:!1,listDayFormat:f,listDaySideFormat:!1,buttonText:bookacti_localized.calendar_button_multiple_months.replace("{months}",g)}};return b};
