var booked_load_calendar_date_booking_options,
booked_appt_form_options,
bookedNewAppointment;
;(function($, window, document, undefined){
var $win=$(window);
$.fn.spin.presets.booked={
lines: 10,
length: 7,
width: 5,
radius: 11,
corners: 1,
rotate: 0,
direction: 1,
color: '#555',
speed: 1,
trail: 60,
shadow: false,
hwaccel: false,
className: 'booked-spinner',
zIndex: 2e9,
top: '50%',
left: '50%'
}
$.fn.spin.presets.booked_top={
lines: 11,
length: 10,
width: 6,
radius: 15,
corners: 1,
rotate: 0,
scale: 0.5,
direction: 1,
color: '#aaaaaa',
speed: 1,
trail: 60,
shadow: false,
hwaccel: false,
className: 'booked-spinner booked-spinner-top',
zIndex: 2e9,
top: '15px',
left: '50%'
}
$.fn.spin.presets.booked_white={
lines: 13,
length: 11,
width: 5,
radius: 18,
scale: 1,
corners: 1,
rotate: 0,
direction: 1,
color: '#fff',
speed: 1,
trail: 60,
shadow: false,
hwaccel: false,
className: 'booked-spinner booked-white',
zIndex: 2e9,
top: '50%',
left: '50%'
}
$win.on('resize', function(){
adjust_calendar_boxes();
resize_booked_modal();
});
$win.on('load', function(){
BookedTabs.Init();
var ajaxRequests=[];
adjust_calendar_boxes();
$('.booked-calendar-wrap').each(function(){
var thisCalendar=$(this);
var calendar_month=thisCalendar.find('div.booked-calendar').attr('data-calendar-date');
thisCalendar.attr('data-default',calendar_month);
init_tooltips(thisCalendar);
});
$('.booked-list-view').each(function(){
var thisList=$(this);
var list_date=thisList.find('.booked-appt-list').attr('data-list-date');
thisList.attr('data-default',list_date);
});
bookedRemoveEmptyTRs();
init_appt_list_date_picker();
$('.booked_calendar_chooser').change(function(e){
e.preventDefault();
var $selector=$(this),
thisIsCalendar=$selector.parents('.booked-calendarSwitcher').hasClass('calendar');
if(!thisIsCalendar){
var thisCalendarWrap=$selector.parents('.booked-calendar-shortcode-wrap').find('.booked-list-view'),
thisDefaultDate=thisCalendarWrap.attr('data-default'),
thisIsCalendar=$selector.parents('.booked-calendarSwitcher').hasClass('calendar');
if(typeof thisDefaultDate=='undefined'){ thisDefaultDate=false; }
thisCalendarWrap.addClass('booked-loading');
var args={
'action':'booked_appointment_list_date',
'date':thisDefaultDate,
'calendar_id':$selector.val()
};
$(document).trigger("booked-before-loading-appointment-list-booking-options");
thisCalendarWrap.spin('booked_top');
$.ajax({
url: booked_js_vars.ajax_url,
type: 'post',
data: args,
success: function(html){
thisCalendarWrap.html(html);
init_appt_list_date_picker();
setTimeout(function(){
thisCalendarWrap.removeClass('booked-loading');
},1);
}});
}else{
var thisCalendarWrap=$selector.parents('.booked-calendar-shortcode-wrap').find('.booked-calendar-wrap'),
thisDefaultDate=thisCalendarWrap.attr('data-default');
if(typeof thisDefaultDate=='undefined'){ thisDefaultDate=false; }
var args={
'action':'booked_calendar_month',
'gotoMonth':thisDefaultDate,
'calendar_id':$selector.val()
};
savingState(true,thisCalendarWrap);
$.ajax({
url: booked_js_vars.ajax_url,
type: 'post',
data: args,
success: function(html){
thisCalendarWrap.html(html);
adjust_calendar_boxes();
bookedRemoveEmptyTRs();
init_tooltips(thisCalendarWrap);
$(window).trigger('booked-load-calendar', args, $selector);
}});
}
return false;
});
$('body').on('click', '.booked-calendar-wrap .page-right, .booked-calendar-wrap .page-left, .booked-calendar-wrap .monthName a', function(e){
e.preventDefault();
var $button=$(this),
gotoMonth=$button.attr('data-goto'),
thisCalendarWrap=$button.parents('.booked-calendar-wrap'),
thisCalendarDefault=thisCalendarWrap.attr('data-default'),
calendar_id=$button.parents('div.booked-calendar').attr('data-calendar-id');
if(typeof thisCalendarDefault=='undefined'){ thisCalendarDefault=false; }
var args={
'action':'booked_calendar_month',
'gotoMonth':gotoMonth,
'calendar_id':calendar_id,
'force_default':thisCalendarDefault
};
savingState(true,thisCalendarWrap);
$.ajax({
url: booked_js_vars.ajax_url,
type: 'post',
data: args,
success: function(html){
thisCalendarWrap.html(html);
adjust_calendar_boxes();
bookedRemoveEmptyTRs();
init_tooltips(thisCalendarWrap);
$(window).trigger('booked-load-calendar', args, $button);
}});
return false;
});
$('body').on('click', '.booked-calendar-wrap .bc-row.week .bc-col', function(e){
e.preventDefault();
var $thisDate=$(this),
booked_calendar_table=$thisDate.parents('div.booked-calendar'),
$thisRow=$thisDate.parent(),
date=$thisDate.attr('data-date'),
calendar_id=booked_calendar_table.attr('data-calendar-id'),
colspanSetting=$thisRow.find('.bc-col').length;
if(!calendar_id){ calendar_id=0; }
if($thisDate.hasClass('blur')||$thisDate.hasClass('booked')&&!booked_js_vars.publicAppointments||$thisDate.hasClass('prev-date')){
}else if($thisDate.hasClass('active')){
$thisDate.removeClass('active');
$('.bc-row.entryBlock').remove();
var calendarHeight=booked_calendar_table.height();
booked_calendar_table.parent().height(calendarHeight);
}else{
$('.bc-row.week .bc-col').removeClass('active');
$thisDate.addClass('active');
$('.bc-row.entryBlock').remove();
$thisRow.after('<div class="bc-row entryBlock booked-loading"><div class="bc-col"></div></div>');
$('.bc-row.entryBlock').find('.bc-col').spin('booked');
booked_load_calendar_date_booking_options={'action':'booked_calendar_date','date':date,'calendar_id':calendar_id};
$(document).trigger("booked-before-loading-calendar-booking-options");
var calendarHeight=booked_calendar_table.height();
booked_calendar_table.parent().height(calendarHeight);
$.ajax({
url: booked_js_vars.ajax_url,
type: 'post',
data: booked_load_calendar_date_booking_options,
success: function(html){
$('.bc-row.entryBlock').find('.bc-col').html(html);
$('.bc-row.entryBlock').removeClass('booked-loading');
$('.bc-row.entryBlock').find('.booked-appt-list').fadeIn(300);
$('.bc-row.entryBlock').find('.booked-appt-list').addClass('shown');
adjust_calendar_boxes();
}});
}
return;
});
$('body').on('click', '.booked-list-view .booked-list-view-date-prev, .booked-list-view .booked-list-view-date-next', function(e){
e.preventDefault();
var $thisLink=$(this),
date=$thisLink.attr('data-date'),
thisList=$thisLink.parents('.booked-list-view'),
defaultDate=thisList.attr('data-default'),
calendar_id=$thisLink.parents('.booked-list-view-nav').attr('data-calendar-id');
if(typeof defaultDate=='undefined'){ defaultDate=false; }
if(!calendar_id){ calendar_id=0; }
thisList.addClass('booked-loading');
var booked_load_list_view_date_booking_options={
'action':'booked_appointment_list_date',
'date':date,
'calendar_id':calendar_id,
'force_default':defaultDate
};
$(document).trigger("booked-before-loading-appointment-list-booking-options");
thisList.spin('booked_top');
$.ajax({
url: booked_js_vars.ajax_url,
type: 'post',
data: booked_load_list_view_date_booking_options,
success: function(html){
thisList.html(html);
init_appt_list_date_picker();
setTimeout(function(){
thisList.removeClass('booked-loading');
},1);
}});
return false;
});
bookedNewAppointment=function(e){
e.preventDefault();
var $button=$(this),
title=$button.attr('data-title'),
timeslot=$button.attr('data-timeslot'),
date=$button.attr('data-date'),
calendar_id=$button.attr('data-calendar-id'),
$thisTimeslot=$button.parents('.timeslot'),
is_list_view=$button.parents('.booked-calendar-wrap').hasClass('booked-list-view');
if(typeof is_list_view!='undefined'&&is_list_view){
var new_calendar_id=$button.parents('.booked-list-view').find('.booked-list-view-nav').attr('data-calendar-id');
}else{
var new_calendar_id=$button.parents('div.booked-calendar').attr('data-calendar-id');
}
calendar_id=new_calendar_id ? new_calendar_id:calendar_id;
booked_appt_form_options={'action':'booked_new_appointment_form','date':date,'timeslot':timeslot,'calendar_id':calendar_id,'title':title};
$(document).trigger("booked-before-loading-booking-form");
create_booked_modal();
setTimeout(function(){
$.ajax({
url: booked_js_vars.ajax_url,
type: 'post',
data: booked_appt_form_options,
success: function(html){
$('.bm-window').html(html);
var bookedModal=$('.booked-modal');
var bmWindow=bookedModal.find('.bm-window');
bmWindow.css({'visibility':'hidden'});
bookedModal.removeClass('bm-loading');
$(document).trigger("booked-on-new-app");
resize_booked_modal();
bmWindow.hide();
$('.booked-modal .bm-overlay').find('.booked-spinner').remove();
setTimeout(function(){
bmWindow.css({'visibility':'visible'});
bmWindow.show();
},50);
}});
},100);
return false;
}
$('body').on('click', '.booked-calendar-wrap button.new-appt', bookedNewAppointment);
var profileTabs=$('.booked-tabs');
if(!profileTabs.find('li.active').length){
profileTabs.find('li:first-child').addClass("active");
}
if(profileTabs.length){
$('.booked-tab-content').hide();
var activeTab=profileTabs.find('.active > a').attr('href');
activeTab=activeTab.split('#');
activeTab=activeTab[1];
$('#profile-'+activeTab).show();
profileTabs.find('li > a').on('click', function(e){
e.preventDefault();
$('.booked-tab-content').hide();
profileTabs.find('li').removeClass('active');
$(this).parent().addClass('active');
var activeTab=$(this).attr('href');
activeTab=activeTab.split('#');
activeTab=activeTab[1];
$('#profile-'+activeTab).show();
return false;
});
}
$('body').on('click', '.booked-profile-appt-list .booked-show-cf', function(e){
e.preventDefault();
var hiddenBlock=$(this).parent().find('.cf-meta-values-hidden');
if(hiddenBlock.is(':visible')){
hiddenBlock.hide();
$(this).removeClass('booked-cf-active');
}else{
hiddenBlock.show();
$(this).addClass('booked-cf-active');
}
return false;
});
if($('#loginform').length){
$('#loginform input[type="submit"]').on('click',function(e){
if($('#loginform input[name="log"]').val()&&$('#loginform input[name="pwd"]').val()){
$('#loginform .booked-custom-error').hide();
}else{
if($('#loginform').parents('.booked-form-wrap').length){
e.preventDefault();
$('#loginform').parents('.booked-form-wrap').find('.booked-custom-error').fadeOut(200).fadeIn(200);
}}
});
}
if($('#profile-forgot').length){
$('#profile-forgot input[type="submit"]').on('click',function(e){
if($('#profile-forgot input[name="user_login"]').val()){
$('#profile-forgot .booked-custom-error').hide();
}else{
e.preventDefault();
$('#profile-forgot').find('.booked-custom-error').fadeOut(200).fadeIn(200);
}});
}
if($('.booked-upload-wrap').length){
$('.booked-upload-wrap input[type=file]').on('change',function(){
var fileName=$(this).val();
$(this).parent().find('span').html(fileName);
$(this).parent().addClass('hasFile');
});
}
$('body').on('click', '.booked-profile-appt-list .appt-block .cancel', function(e){
e.preventDefault();
var $button=$(this),
$thisParent=$button.parents('.appt-block'),
appt_id=$thisParent.attr('data-appt-id');
confirm_delete=confirm(booked_js_vars.i18n_confirm_appt_delete);
if(confirm_delete==true){
var currentApptCount=parseInt($('.booked-profile-appt-list').find('h4').find('span.count').html());
currentApptCount=parseInt(currentApptCount - 1);
if(currentApptCount < 1){
$('.booked-profile-appt-list').find('h4').find('span.count').html('0');
$('.no-appts-message').slideDown('fast');
}else{
$('.booked-profile-appt-list').find('h4').find('span.count').html(currentApptCount);
}
$('.appt-block').animate({'opacity':0.4},0);
$thisParent.slideUp('fast',function(){
$(this).remove();
});
$.ajax({
'url':booked_js_vars.ajax_url,
'method':'post',
'data':{
'action':'booked_cancel_appt',
'appt_id':appt_id
},
success: function(data){
$('.appt-block').animate({'opacity':1},150);
}});
}
return false;
});
$('body').on('touchstart click','.bm-overlay, .bm-window .close, .booked-form .cancel',function(e){
e.preventDefault();
close_booked_modal();
return false;
});
$('body')
.on('focusin', '.booked-form input', function(){
if(this.title==this.value){
$(this).addClass('hasContent');
this.value='';
}}).on('focusout', '.booked-form input', function(){
if(this.value===''){
$(this).removeClass('hasContent');
this.value=this.title;
}});
$('body').on('change','.booked-form input',function(){
var condition=$(this).attr('data-condition'),
thisVal=$(this).val();
if(condition&&$('.condition-block').length){
$('.condition-block.'+condition).hide();
$('#condition-'+thisVal).fadeIn(200);
resize_booked_modal();
}});
$('body').on('submit','form#ajaxlogin', function(e){
e.preventDefault();
$('form#ajaxlogin p.status').show().html('<i class="fa-solid fa-circle-notch fa-spin"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_please_wait);
resize_booked_modal();
var $this=$(this),
date=$this.data('date'),
title=$this.data('title'),
timeslot=$this.data('timeslot'),
calendar_id=$this.data('calendar-id');
$.ajax({
type:'post',
url:booked_js_vars.ajax_url,
data:$('form#ajaxlogin').serialize(),
success:function(data){
if(data=='success'){
close_booked_modal();
var $button=$('<button data-title="' + title + '" data-timeslot="' + timeslot + '" data-date="' + date + '" data-calendar-id="' + calendar_id + '"></button>');
$button.on('click', window.bookedNewAppointment);
$button.triggerHandler('click');
$button.unbind('click', window.bookedNewAppointment);
$button.detach();
}else{
$('form#ajaxlogin p.status').show().html('<i class="fa-solid fa-triangle-exclamation" style="color:#E35656"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_wrong_username_pass);
resize_booked_modal();
}}
});
e.preventDefault();
});
$('body').on('click','.booked-forgot-password',function(e){
e.preventDefault();
$('#ajaxlogin').hide();
$('#ajaxforgot').show();
resize_booked_modal();
});
$('body').on('click','.booked-forgot-goback',function(e){
e.preventDefault();
$('#ajaxlogin').show();
$('#ajaxforgot').hide();
resize_booked_modal();
});
$('body').on('submit','form#ajaxforgot', function(e){
e.preventDefault();
$('form#ajaxforgot p.status').show().html('<i class="fa-solid fa-circle-notch fa-spin"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_please_wait);
resize_booked_modal();
var $this=$(this);
$.ajax({
type:'post',
url:booked_js_vars.ajax_url,
data:$('form#ajaxforgot').serialize(),
success:function(data){
if(data=='success'){
e.preventDefault();
$('#ajaxlogin').show();
$('#ajaxforgot').hide();
$('form#ajaxlogin p.status').show().html('<i class="fa-solid fa-check" style="color:#56c477"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_password_reset);
resize_booked_modal();
}else{
$('form#ajaxforgot p.status').show().html('<i class="fa-solid fa-triangle-exclamation" style="color:#E35656"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_password_reset_error);
resize_booked_modal();
}}
});
e.preventDefault();
});
$('body').on('click','.booked-form input#submit-request-appointment',function(e){
$('form#newAppointmentForm p.status').show().html('<i class="fa-solid fa-circle-notch fa-spin"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_please_wait);
resize_booked_modal();
e.preventDefault();
var customerType=$('#newAppointmentForm input[name=customer_type]').val(),
customerID=$('#newAppointmentForm input[name=user_id]').val(),
name=$('#newAppointmentForm input[name=booked_appt_name]').val(),
surname=$('#newAppointmentForm input[name=booked_appt_surname]').val(),
surnameActive=$('#newAppointmentForm input[name=booked_appt_surname]').length,
guest_name=$('#newAppointmentForm input[name=guest_name]').val(),
guest_surname=$('#newAppointmentForm input[name=guest_surname]').val(),
guest_surnameActive=$('#newAppointmentForm input[name=guest_surname]').length,
guest_email=$('#newAppointmentForm input[name=guest_email]').val(),
guest_emailActive=$('#newAppointmentForm input[name=guest_email]').length,
email=$('#newAppointmentForm input[name=booked_appt_email]').val(),
password=$('#newAppointmentForm input[name=booked_appt_password]').val(),
showRequiredError=false,
ajaxRequests=[];
$(this).parents('.booked-form').find('input,textarea,select').each(function(i,field){
var required=$(this).attr('required');
if(required&&$(field).attr('type')=='hidden'){
var fieldParts=$(field).attr('name');
fieldParts=fieldParts.split('---');
fieldName=fieldParts[0];
fieldNumber=fieldParts[1].split('___');
fieldNumber=fieldNumber[0];
if(fieldName=='radio-buttons-label'){
var radioValue=false;
$('input:radio[name="single-radio-button---'+fieldNumber+'[]"]:checked').each(function(){
if($(this).val()){
radioValue=$(this).val();
}});
if(!radioValue){
showRequiredError=true;
}}else if(fieldName=='checkboxes-label'){
var checkboxValue=false;
$('input:checkbox[name="single-checkbox---'+fieldNumber+'[]"]:checked').each(function(){
if($(this).val()){
checkboxValue=$(this).val();
}});
if(!checkboxValue){
showRequiredError=true;
}}
}else if(required&&$(field).attr('type')!='hidden'&&$(field).val()==''){
showRequiredError=true;
}});
if(showRequiredError){
$('form#newAppointmentForm p.status').show().html('<i class="fa-solid fa-triangle-exclamation" style="color:#E35656"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_fill_out_required_fields);
resize_booked_modal();
return false;
}
if(customerType=='new'&&!name||customerType=='new'&&surnameActive&&!surname||customerType=='new'&&!email||customerType=='new'&&!password){
$('form#newAppointmentForm p.status').show().html('<i class="fa-solid fa-triangle-exclamation" style="color:#E35656"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_appt_required_fields);
resize_booked_modal();
return false;
}
if(customerType=='guest'&&!guest_name||customerType=='guest'&&guest_emailActive&&!guest_email||customerType=='guest'&&guest_surnameActive&&!guest_surname){
$('form#newAppointmentForm p.status').show().html('<i class="fa-solid fa-triangle-exclamation" style="color:#E35656"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_appt_required_fields_guest);
resize_booked_modal();
return false;
}
if(customerType=='current'&&customerID ||
customerType=='guest'&&guest_name&&!guest_surnameActive&&!guest_emailActive ||
customerType=='guest'&&guest_name&&guest_surnameActive&&guest_surname&&!guest_emailActive ||
customerType=='guest'&&guest_name&&guest_emailActive&&guest_email&&!guest_surnameActive ||
customerType=='guest'&&guest_name&&guest_emailActive&&guest_email&&guest_surnameActive&&guest_surname){
SubmitRequestAppointment.currentUserOrGuest();
}
if(customerType=='new'&&name&&email&&password){
if(!surnameActive||surnameActive&&surname){
SubmitRequestAppointment.newUser();
}}
});
var SubmitRequestAppointment={
formSelector: '#newAppointmentForm',
formBtnRequestSelector: '.booked-form input#submit-request-appointment',
formStatusSelector: 'p.status',
formSubmitBtnSelector: '#submit-request-appointment',
apptContainerSelector: '.booked-appointment-details',
baseFields: 	[ 'guest_name','guest_surname','guest_email','action', 'customer_type', 'user_id' ],
apptFields: 	[ 'appoinment', 'calendar_id', 'title', 'date', 'timestamp', 'timeslot' ],
userFields: 	[ 'booked_appt_name','booked_appt_surname','booked_appt_email', 'booked_appt_password' ],
captchaFields: 	[ 'captcha_word', 'captcha_code' ],
currentApptIndex: false,
currentApptCounter: false,
hasAnyErrors: false,
currentUserOrGuest: function(){
var total_appts=SubmitRequestAppointment._totalAppts();
if(! total_appts){
return;
}
SubmitRequestAppointment._showLoadingMessage();
SubmitRequestAppointment._resetDefaultValues();
var data=SubmitRequestAppointment._getBaseData();
SubmitRequestAppointment.currentApptIndex=0;
SubmitRequestAppointment.currentApptCounter=1;
SubmitRequestAppointment._doRequestAppointment(data, total_appts);
},
newUser: function(){
var total_appts=SubmitRequestAppointment._totalAppts();
if(! total_appts){
return;
}
SubmitRequestAppointment._showLoadingMessage();
SubmitRequestAppointment._resetDefaultValues();
var data=SubmitRequestAppointment._getBaseData();
if(total_appts > 1){
var data_obj_with_no_reference=null;
data_obj_with_no_reference=$.extend(true, {}, data);
data_obj_with_no_reference=SubmitRequestAppointment._addUserRegistrationData(data_obj_with_no_reference);
SubmitRequestAppointment._requestUserRegistration(data_obj_with_no_reference);
data.customer_type='current';
}else{
data=SubmitRequestAppointment._addUserRegistrationData(data);
}
SubmitRequestAppointment.currentApptIndex=0;
SubmitRequestAppointment._doRequestAppointment(data, total_appts);
},
_doRequestAppointment: function(data, total_appts){
var appt_fields=SubmitRequestAppointment.apptFields;
if(SubmitRequestAppointment.currentApptIndex===0){
SubmitRequestAppointment._hideCancelBtn();
SubmitRequestAppointment._disableSubmitBtn();
SubmitRequestAppointment.hasAnyErrors=false;
}
var data_obj_with_no_reference=$.extend(true, {}, data);
for (var i=0; i < appt_fields.length; i++){
data_obj_with_no_reference[ appt_fields[i] ]=SubmitRequestAppointment._getFieldVal(appt_fields[i], SubmitRequestAppointment.currentApptIndex);
}
var calendar_id=SubmitRequestAppointment._getFieldVal('calendar_id', SubmitRequestAppointment.currentApptIndex);
data_obj_with_no_reference=SubmitRequestAppointment._addCustomFieldsData(data_obj_with_no_reference, calendar_id);
var $appt=SubmitRequestAppointment._getApptElement(SubmitRequestAppointment.currentApptIndex);
if(! $appt.hasClass('skip')){
$.ajax({
type:'post',
url:booked_js_vars.ajax_url,
data:data_obj_with_no_reference,
success:function(response){
SubmitRequestAppointment._requestAppointmentResponseHandler(response);
SubmitRequestAppointment.currentApptIndex++;
setTimeout(function(){
if(SubmitRequestAppointment.currentApptCounter===total_appts){
if(! SubmitRequestAppointment.hasAnyErrors){
SubmitRequestAppointment._onAfterRequestAppointment();
}else{
SubmitRequestAppointment._enableSubmitBtn();
SubmitRequestAppointment._showCancelBtn();
}}else{
SubmitRequestAppointment.currentApptCounter++;
SubmitRequestAppointment._doRequestAppointment(data, total_appts);
}}, 100);
}});
}else{
SubmitRequestAppointment.currentApptIndex++;
SubmitRequestAppointment.currentApptCounter++;
SubmitRequestAppointment._doRequestAppointment(data, total_appts, SubmitRequestAppointment.currentApptIndex);
}},
_totalAppts: function(){
return $(SubmitRequestAppointment.formSelector + ' input[name="appoinment[]"]').length;
},
_getBaseData: function(){
var data={},
fields=SubmitRequestAppointment.baseFields;
for(var i=0; i < fields.length; i++){
data[ fields[i] ]=SubmitRequestAppointment._getFieldVal(fields[i]);
}
data['is_fe_form']=true;
data['total_appts']=SubmitRequestAppointment._totalAppts();
return data;
},
_getFieldVal: function(field_name, field_index){
var field_name=typeof field_name==='undefined' ? '':field_name,
field_index=typeof field_index==='undefined' ? false:field_index,
selector=SubmitRequestAppointment.formSelector + ' ';
if(field_index===false){
selector +=' [name=' + field_name + ']';
return $(selector).val();
}
selector +=' [name="' + field_name + '[]"]';
return $(selector).eq(field_index).val();
},
_resetDefaultValues: function(){
$('.booked-form input').each(function(){
var thisVal=$(this).val(),
thisDefault=$(this).attr('title');
if(thisDefault==thisVal){
$(this).val('');
}});
},
_resetToDefaultValues: function(){
$('.booked-form input').each(function(){
var thisVal=$(this).val(),
thisDefault=$(this).attr('title');
if(! thisVal){
$(this).val(thisDefault);
}});
},
_addUserRegistrationData: function(data){
$.each(SubmitRequestAppointment.userFields, function(index, field_name){
data[ field_name ]=SubmitRequestAppointment._getFieldVal(field_name);
});
$.each(SubmitRequestAppointment.captchaFields, function(index, field_name){
var field_value=SubmitRequestAppointment._getFieldVal(field_name);
if(! field_value){
return;
}
data[ field_name ]=field_value;
});
return data;
},
_addCustomFieldsData: function(data, calendar_id){
var custom_fields_data=$('.cf-block [name]')
.filter(function(index){
var $this=$(this);
return parseInt($this.data('calendar-id'))===parseInt(calendar_id)&&$this.attr('name').match(/---\d+/g);
})
.each(function(index){
var $this=$(this),
name=$this.attr('name'),
value=$this.val(),
type=$this.attr('type');
if(! value){
return;
}
if(! name.match(/checkbox|radio+/g)){
data[ name ]=value;
return;
}
if(name.match(/radio+/g)&&$this.is(':checked')){
data[ name ]=value;
return;
}
if(! name.match(/radio+/g)&&typeof data[ name ]==='undefined'||! name.match(/radio+/g)&&data[ name ].constructor!==Array){
data[ name ]=[];
}
if(! $this.is(':checked')){
return;
}
data[ name ].push(value);
});
return data;
},
_requestUserRegistration: function(base_data, appt_index){
$.ajax({
type:'post',
url:booked_js_vars.ajax_url,
data:base_data,
async:false,
success:function(response){
SubmitRequestAppointment._requestUserRegistrationResponseHandler(response);
}});
},
_requestUserRegistrationResponseHandler: function(response){
var response_parts=response.split('###'),
data_result=response_parts[0].substr(response_parts[0].length - 5);
if(data_result==='error'){
return;
}},
_requestAppointment: function(response){
SubmitRequestAppointment._requestAppointmentResponseHandler(response);
},
_requestAppointmentResponseHandler: function(response){
var response_parts=response.split('###'),
data_result=response_parts[0].substr(response_parts[0].length - 5);
if(data_result==='error'){
SubmitRequestAppointment._requestAppointmentOnError(response_parts);
return;
}
SubmitRequestAppointment._requestAppointmentOnSuccess(response_parts);
},
_requestAppointmentOnError: function(response_parts){
var $apptEl=SubmitRequestAppointment._getApptElement();
$(document).trigger("booked-on-requested-appt-error",[$apptEl]);
SubmitRequestAppointment._highlightAppt();
SubmitRequestAppointment._setStatusMsg(response_parts[1]);
SubmitRequestAppointment.hasAnyErrors=true;
resize_booked_modal();
},
_requestAppointmentOnSuccess: function(response_parts){
var $apptEl=SubmitRequestAppointment._getApptElement();
$(document).trigger("booked-on-requested-appt-success",[$apptEl]);
SubmitRequestAppointment._unhighlightAppt();
},
_onAfterRequestAppointment: function(){
var redirectObj={ redirect:false };
var redirect=$(document).trigger("booked-on-requested-appointment",[redirectObj]);
if(redirectObj.redirect){
return;
}
if(booked_js_vars.profilePage){
window.location=booked_js_vars.profilePage;
return;
}
SubmitRequestAppointment._reloadApptsList();
SubmitRequestAppointment._reloadCalendarTable();
},
_setStatusMsg: function(msg){
var form_status_selector=SubmitRequestAppointment.formSelector + ' ' + SubmitRequestAppointment.formStatusSelector;
$(form_status_selector).show().html('<i class="fa-solid fa-triangle-exclamation" style="color:#E35656"></i>&nbsp;&nbsp;&nbsp;' + msg);
},
_getApptElement: function(appt_index){
var appt_index=typeof appt_index==='undefined' ? SubmitRequestAppointment.currentApptIndex:appt_index,
appt_cnt_selector=SubmitRequestAppointment.formSelector + ' ' + SubmitRequestAppointment.apptContainerSelector;
return $(appt_cnt_selector).eq(appt_index);
},
_highlightAppt: function(msg){
var $apptEl=SubmitRequestAppointment._getApptElement();
if(! $apptEl.length){
return;
}
$apptEl.addClass('has-error');
},
_unhighlightAppt: function(msg){
var $apptEl=SubmitRequestAppointment._getApptElement();
if(! $apptEl.length){
return;
}
$apptEl.removeClass('has-error').addClass('skip');
},
_enableSubmitBtn: function(){
var btn_selector=SubmitRequestAppointment.formSelector + ' ' + SubmitRequestAppointment.formSubmitBtnSelector;
$(btn_selector).attr('disabled', false);
},
_disableSubmitBtn: function(){
var btn_selector=SubmitRequestAppointment.formSelector + ' ' + SubmitRequestAppointment.formSubmitBtnSelector;
$(btn_selector).attr('disabled', true);
},
_showCancelBtn: function(){
$(SubmitRequestAppointment.formSelector).find('button.cancel').show();
},
_hideCancelBtn: function(){
$(SubmitRequestAppointment.formSelector).find('button.cancel').hide();
},
_showLoadingMessage: function(){
$('form#newAppointmentForm p.status').show().html('<i class="fa-solid fa-circle-notch fa-spin"></i>&nbsp;&nbsp;&nbsp;' + booked_js_vars.i18n_please_wait);
},
_reloadApptsList: function(){
if(! $('.booked-appt-list').length){
return;
}
$('.booked-appt-list').each(function(){
var $thisApptList=$(this),
date=$thisApptList.attr('data-list-date'),
thisList=$thisApptList.parents('.booked-list-view'),
defaultDate=thisList.attr('data-default'),
calendar_id=parseInt($thisApptList.find('.booked-list-view-nav').attr('data-calendar-id'))||0;
defaultDate=typeof defaultDate==='undefined' ? false:defaultDate;
calendar_id=calendar_id ? calendar_id:0;
thisList.addClass('booked-loading');
var booked_load_list_view_date_booking_options={
'action':'booked_appointment_list_date',
'date':date,
'calendar_id':calendar_id,
'force_default':defaultDate
};
$(document).trigger("booked-before-loading-appointment-list-booking-options");
thisList.spin('booked_top');
$.ajax({
url: booked_js_vars.ajax_url,
type: 'post',
data: booked_load_list_view_date_booking_options,
success: function(html){
thisList.html(html);
close_booked_modal();
init_appt_list_date_picker();
setTimeout(function(){
thisList.removeClass('booked-loading');
},1);
}});
});
},
_reloadCalendarTable: function(){
if(! $('.bc-col.active').length){
return;
}
var $activeTD=$('.bc-col.active'),
activeDate=$activeTD.attr('data-date'),
calendar_id=parseInt($activeTD.parents('table').data('calendar-id'))||0;
booked_load_calendar_date_booking_options={ 'action':'booked_calendar_date', 'date':activeDate, 'calendar_id':calendar_id };
$(document).trigger("booked-before-loading-calendar-booking-options");
$.ajax({
url: booked_js_vars.ajax_url,
type: 'post',
data: booked_load_calendar_date_booking_options,
success: function(html){
$('.bc-row.entryBlock').find('.bc-col').html(html);
close_booked_modal();
$('.bc-row.entryBlock').removeClass('booked-loading');
$('.bc-row.entryBlock').find('.booked-appt-list').hide().fadeIn(300);
$('.bc-row.entryBlock').find('.booked-appt-list').addClass('shown');
adjust_calendar_boxes();
}});
}}
});
function bookedRemoveEmptyTRs(){
$('div.booked-calendar').find('.bc-row.week').each(function(){
if($(this).children().length==0){
$(this).remove();
}});
}
function savingState(show,limit_to){
show=typeof show!=='undefined' ? show:true;
limit_to=typeof limit_to!=='undefined' ? limit_to:false;
if(limit_to){
var $savingStateDIV=limit_to.find('li.active .savingState, .topSavingState.savingState, .calendarSavingState');
var $stuffToHide=limit_to.find('.monthName');
var $stuffToTransparent=limit_to.find('div.booked-calendar .bc-body');
}else{
var $savingStateDIV=$('li.active .savingState, .topSavingState.savingState, .calendarSavingState');
var $stuffToHide=$('.monthName');
var $stuffToTransparent=$('div.booked-calendar .bc-body');
}
if(show){
$savingStateDIV.fadeIn(200);
$stuffToHide.hide();
$stuffToTransparent.animate({'opacity':0.2},100);
}else{
$savingStateDIV.hide();
$stuffToHide.show();
$stuffToTransparent.animate({'opacity':1},0);
}}
$(document).ajaxStop(function(){
savingState(false);
});
function init_appt_list_date_picker(){
$('.booked_list_date_picker').each(function(){
var thisDatePicker=$(this);
var minDateVal=thisDatePicker.parents('.booked-appt-list').attr('data-min-date');
var maxDateVal=thisDatePicker.parents('.booked-appt-list').attr('data-max-date');
if(typeof minDateVal=='undefined'){ var minDateVal=thisDatePicker.attr('data-min-date'); }
thisDatePicker.datepicker({
dateFormat: 'yy-mm-dd',
minDate: minDateVal,
maxDate: maxDateVal,
showAnim: false,
beforeShow: function(input, inst){
$('#ui-datepicker-div').removeClass();
$('#ui-datepicker-div').addClass('booked_custom_date_picker');
},
onClose: function(dateText){
$('.booked_list_date_picker_trigger').removeClass('booked-dp-active');
},
onSelect: function(dateText){
var thisInput=$(this),
date=dateText,
thisList=thisInput.parents('.booked-list-view'),
defaultDate=thisList.attr('data-default'),
calendar_id=thisInput.parents('.booked-list-view-nav').attr('data-calendar-id');
if(typeof defaultDate=='undefined'){ defaultDate=false; }
if(!calendar_id){ calendar_id=0; }
thisList.addClass('booked-loading');
var booked_load_list_view_date_booking_options={
'action':'booked_appointment_list_date',
'date':date,
'calendar_id':calendar_id,
'force_default':defaultDate
};
$(document).trigger("booked-before-loading-appointment-list-booking-options");
thisList.spin('booked_top');
$.ajax({
url: booked_js_vars.ajax_url,
type: 'post',
data: booked_load_list_view_date_booking_options,
success: function(html){
thisList.html(html);
init_appt_list_date_picker();
setTimeout(function(){
thisList.removeClass('booked-loading');
},1);
}});
return false;
}});
});
$('body').on('click','.booked_list_date_picker_trigger',function(e){
e.preventDefault();
if(!$(this).hasClass('booked-dp-active')){
$(this).addClass('booked-dp-active');
$(this).parents('.booked-appt-list').find('.booked_list_date_picker').datepicker('show');
}});
}
var BookedTabs={
bookingModalSelector: '.booked-modal',
tabSelector: '.booked-tabs',
tabNavSelector: '.booked-tabs-nav span',
tabCntSelector: '.booked-tabs-cnt',
Init: function(){
$(document).on('click', this.tabNavSelector, this.tabsNav);
},
tabsNav: function(event){
event.preventDefault();
BookedTabs.switchToTab($(this));
BookedTabs.maybeResizeBookingModal();
},
switchToTab: function(tab_nav_item){
var $nav_item=tab_nav_item,
tab_cnt_class='.' + $nav_item.data('tab-cnt'),
$tabs_container=$nav_item.parents(BookedTabs.tabSelector);
$nav_item
.addClass('active')
.siblings()
.removeClass('active')
$tabs_container
.find(BookedTabs.tabCntSelector + ' ' + tab_cnt_class)
.addClass('active')
.siblings()
.removeClass('active');
},
maybeResizeBookingModal: function(){
if(! $(BookedTabs.bookingModalSelector).length){
return;
}
resize_booked_modal();
}}
})(jQuery, window, document);
function create_booked_modal(){
var windowHeight=jQuery(window).height();
var windowWidth=jQuery(window).width();
if(windowWidth > 720){
var maxModalHeight=windowHeight - 295;
}else{
var maxModalHeight=windowHeight;
}
jQuery('body input, body textarea, body select').blur();
jQuery('body').addClass('booked-noScroll');
jQuery('<div class="booked-modal bm-loading"><div class="bm-overlay"></div><div class="bm-window"><div style="height:100px"></div></div></div>').appendTo('body');
jQuery('.booked-modal .bm-overlay').spin('booked_white');
jQuery('.booked-modal .bm-window').css({'max-height':maxModalHeight+'px'});
}
var previousRealModalHeight=100;
function resize_booked_modal(){
var windowHeight=jQuery(window).height();
var windowWidth=jQuery(window).width();
var common43=43;
if(jQuery('.booked-modal .bm-window .booked-scrollable').length){
var realModalHeight=jQuery('.booked-modal .bm-window .booked-scrollable')[0].scrollHeight;
if(realModalHeight < 100){
realModalHeight=previousRealModalHeight;
}else{
previousRealModalHeight=realModalHeight;
}}else{
var realModalHeight=0;
}
var minimumWindowHeight=realModalHeight + common43 + common43;
var modalScrollableHeight=realModalHeight - common43;
var maxModalHeight;
var maxFormHeight;
if(windowHeight < minimumWindowHeight){
modalScrollableHeight=windowHeight - common43 - common43;
}else{
modalScrollableHeight=realModalHeight;
}
if(windowWidth > 720){
maxModalHeight=modalScrollableHeight - 25;
maxFormHeight=maxModalHeight - 15;
var modalNegMargin=(maxModalHeight + 78) / 2;
}else{
maxModalHeight=windowHeight - common43;
maxFormHeight=maxModalHeight - 60;
var modalNegMargin=(maxModalHeight) / 2;
}
jQuery('.booked-modal').css({'margin-top':'-'+modalNegMargin+'px'});
jQuery('.booked-modal .bm-window').css({'max-height':maxModalHeight+'px'});
jQuery('.booked-modal .bm-window .booked-scrollable').css({'max-height':maxFormHeight+'px'});
}
function close_booked_modal(){
var modal=jQuery('.booked-modal');
modal.fadeOut(200);
modal.addClass('bm-closing');
jQuery('body').removeClass('booked-noScroll');
setTimeout(function(){
modal.remove();
},300);
}
function init_tooltips(container){
jQuery('.tooltipster').tooltipster({
theme: 		'tooltipster-light',
animation:	'grow',
speed:		200,
delay: 		50,
offsetY:	-15
});
}
function adjust_calendar_boxes(){
jQuery('div.booked-calendar').each(function(){
var windowWidth=jQuery(window).width();
var smallCalendar=jQuery(this).parents('.booked-calendar-wrap').hasClass('small');
var boxesWidth=jQuery(this).find('.bc-body .bc-row.week .bc-col').width();
var calendarHeight=jQuery(this).height();
boxesHeight=boxesWidth * 1;
jQuery(this).find('.bc-body .bc-row.week .bc-col').height(boxesHeight);
jQuery(this).find('.bc-body .bc-row.week .bc-col .date').css('line-height',boxesHeight+'px');
jQuery(this).find('.bc-body .bc-row.week .bc-col .date .number').css('line-height',boxesHeight+'px');
if(smallCalendar||windowWidth < 720){
jQuery(this).find('.bc-body .bc-row.week .bc-col .date .number').css('line-height',boxesHeight+'px');
}else{
jQuery(this).find('.bc-body .bc-row.week .bc-col .date .number').css('line-height','');
}
var calendarHeight=jQuery(this).height();
jQuery(this).parent().height(calendarHeight);
});
};
(()=>{"use strict";var t={d:(e,s)=>{for(var i in s)t.o(s,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:s[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function s(t){if(this.formData={},this.tree={},!(t instanceof FormData))return this;this.formData=t;const e=()=>{const t=new Map;return t.largestIndex=0,t.set=function(e,s){""===e?e=t.largestIndex++:/^[0-9]+$/.test(e)&&(e=parseInt(e),t.largestIndex<=e&&(t.largestIndex=e+1)),Map.prototype.set.call(t,e,s)},t};this.tree=e();const s=/^(?<name>[a-z][-a-z0-9_:]*)(?<array>(?:\[(?:[a-z][-a-z0-9_:]*|[0-9]*)\])*)/i;for(const[t,i]of this.formData){const o=t.match(s);if(o)if(""===o.groups.array)this.tree.set(o.groups.name,i);else{const t=[...o.groups.array.matchAll(/\[([a-z][-a-z0-9_:]*|[0-9]*)\]/gi)].map((([t,e])=>e));t.unshift(o.groups.name);const s=t.pop();t.reduce(((t,s)=>{if(/^[0-9]+$/.test(s)&&(s=parseInt(s)),t.get(s)instanceof Map)return t.get(s);const i=e();return t.set(s,i),i}),this.tree).set(s,i)}}}t.r(e),t.d(e,{date:()=>d,email:()=>r,enum:()=>f,file:()=>m,maxdate:()=>b,maxfilesize:()=>z,maxitems:()=>u,maxlength:()=>v,maxnumber:()=>x,mindate:()=>y,minfilesize:()=>A,minitems:()=>h,minlength:()=>g,minnumber:()=>w,number:()=>c,required:()=>n,requiredfile:()=>a,tel:()=>l,url:()=>p}),s.prototype.entries=function(){return this.tree.entries()},s.prototype.get=function(t){return this.tree.get(t)},s.prototype.getAll=function(t){if(!this.has(t))return[];const e=t=>{const s=[];if(t instanceof Map)for(const[i,o]of t)s.push(...e(o));else""!==t&&s.push(t);return s};return e(this.get(t))},s.prototype.has=function(t){return this.tree.has(t)},s.prototype.keys=function(){return this.tree.keys()},s.prototype.values=function(){return this.tree.values()};const i=s;function o({rule:t,field:e,error:s,...i}){this.rule=t,this.field=e,this.error=s,this.properties=i}const n=function(t){if(0===t.getAll(this.field).length)throw new o(this)},a=function(t){if(0===t.getAll(this.field).length)throw new o(this)},r=function(t){if(!t.getAll(this.field).every((t=>{if((t=t.trim()).length<6)return!1;if(-1===t.indexOf("@",1))return!1;if(t.indexOf("@")!==t.lastIndexOf("@"))return!1;const[e,s]=t.split("@",2);if(!/^[a-zA-Z0-9!#$%&\'*+\/=?^_`{|}~\.-]+$/.test(e))return!1;if(/\.{2,}/.test(s))return!1;if(/(?:^[ \t\n\r\0\x0B.]|[ \t\n\r\0\x0B.]$)/.test(s))return!1;const i=s.split(".");if(i.length<2)return!1;for(const t of i){if(/(?:^[ \t\n\r\0\x0B-]|[ \t\n\r\0\x0B-]$)/.test(t))return!1;if(!/^[a-z0-9-]+$/i.test(t))return!1}return!0})))throw new o(this)},p=function(t){const e=t.getAll(this.field);if(!e.every((t=>{if(""===(t=t.trim()))return!1;try{return(t=>-1!==["http","https","ftp","ftps","mailto","news","irc","irc6","ircs","gopher","nntp","feed","telnet","mms","rtsp","sms","svn","tel","fax","xmpp","webcal","urn"].indexOf(t))(new URL(t).protocol.replace(/:$/,""))}catch{return!1}})))throw new o(this)},l=function(t){if(!t.getAll(this.field).every((t=>(t=(t=t.trim()).replaceAll(/[()/.*#\s-]+/g,""),/^[+]?[0-9]+$/.test(t)))))throw new o(this)},c=function(t){if(!t.getAll(this.field).every((t=>(t=t.trim(),!!/^[-]?[0-9]+(?:[eE][+-]?[0-9]+)?$/.test(t)||!!/^[-]?(?:[0-9]+)?[.][0-9]+(?:[eE][+-]?[0-9]+)?$/.test(t)))))throw new o(this)},d=function(t){if(!t.getAll(this.field).every((t=>/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(t.trim()))))throw new o(this)},m=function(t){if(!t.getAll(this.field).every((t=>t instanceof File&&this.accept?.some((e=>/^\.[a-z0-9]+$/i.test(e)?t.name.toLowerCase().endsWith(e.toLowerCase()):(t=>{const e=[],s=t.match(/^(?<toplevel>[a-z]+)\/(?<sub>[*]|[a-z0-9.+-]+)$/i);if(s){const t=s.groups.toplevel.toLowerCase(),i=s.groups.sub.toLowerCase();for(const[o,n]of(()=>{const t=new Map;return t.set("jpg|jpeg|jpe","image/jpeg"),t.set("gif","image/gif"),t.set("png","image/png"),t.set("bmp","image/bmp"),t.set("tiff|tif","image/tiff"),t.set("webp","image/webp"),t.set("ico","image/x-icon"),t.set("heic","image/heic"),t.set("asf|asx","video/x-ms-asf"),t.set("wmv","video/x-ms-wmv"),t.set("wmx","video/x-ms-wmx"),t.set("wm","video/x-ms-wm"),t.set("avi","video/avi"),t.set("divx","video/divx"),t.set("flv","video/x-flv"),t.set("mov|qt","video/quicktime"),t.set("mpeg|mpg|mpe","video/mpeg"),t.set("mp4|m4v","video/mp4"),t.set("ogv","video/ogg"),t.set("webm","video/webm"),t.set("mkv","video/x-matroska"),t.set("3gp|3gpp","video/3gpp"),t.set("3g2|3gp2","video/3gpp2"),t.set("txt|asc|c|cc|h|srt","text/plain"),t.set("csv","text/csv"),t.set("tsv","text/tab-separated-values"),t.set("ics","text/calendar"),t.set("rtx","text/richtext"),t.set("css","text/css"),t.set("htm|html","text/html"),t.set("vtt","text/vtt"),t.set("dfxp","application/ttaf+xml"),t.set("mp3|m4a|m4b","audio/mpeg"),t.set("aac","audio/aac"),t.set("ra|ram","audio/x-realaudio"),t.set("wav","audio/wav"),t.set("ogg|oga","audio/ogg"),t.set("flac","audio/flac"),t.set("mid|midi","audio/midi"),t.set("wma","audio/x-ms-wma"),t.set("wax","audio/x-ms-wax"),t.set("mka","audio/x-matroska"),t.set("rtf","application/rtf"),t.set("js","application/javascript"),t.set("pdf","application/pdf"),t.set("swf","application/x-shockwave-flash"),t.set("class","application/java"),t.set("tar","application/x-tar"),t.set("zip","application/zip"),t.set("gz|gzip","application/x-gzip"),t.set("rar","application/rar"),t.set("7z","application/x-7z-compressed"),t.set("exe","application/x-msdownload"),t.set("psd","application/octet-stream"),t.set("xcf","application/octet-stream"),t.set("doc","application/msword"),t.set("pot|pps|ppt","application/vnd.ms-powerpoint"),t.set("wri","application/vnd.ms-write"),t.set("xla|xls|xlt|xlw","application/vnd.ms-excel"),t.set("mdb","application/vnd.ms-access"),t.set("mpp","application/vnd.ms-project"),t.set("docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"),t.set("docm","application/vnd.ms-word.document.macroEnabled.12"),t.set("dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"),t.set("dotm","application/vnd.ms-word.template.macroEnabled.12"),t.set("xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"),t.set("xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"),t.set("xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"),t.set("xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"),t.set("xltm","application/vnd.ms-excel.template.macroEnabled.12"),t.set("xlam","application/vnd.ms-excel.addin.macroEnabled.12"),t.set("pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"),t.set("pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"),t.set("ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"),t.set("ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"),t.set("potx","application/vnd.openxmlformats-officedocument.presentationml.template"),t.set("potm","application/vnd.ms-powerpoint.template.macroEnabled.12"),t.set("ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"),t.set("sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"),t.set("sldm","application/vnd.ms-powerpoint.slide.macroEnabled.12"),t.set("onetoc|onetoc2|onetmp|onepkg","application/onenote"),t.set("oxps","application/oxps"),t.set("xps","application/vnd.ms-xpsdocument"),t.set("odt","application/vnd.oasis.opendocument.text"),t.set("odp","application/vnd.oasis.opendocument.presentation"),t.set("ods","application/vnd.oasis.opendocument.spreadsheet"),t.set("odg","application/vnd.oasis.opendocument.graphics"),t.set("odc","application/vnd.oasis.opendocument.chart"),t.set("odb","application/vnd.oasis.opendocument.database"),t.set("odf","application/vnd.oasis.opendocument.formula"),t.set("wp|wpd","application/wordperfect"),t.set("key","application/vnd.apple.keynote"),t.set("numbers","application/vnd.apple.numbers"),t.set("pages","application/vnd.apple.pages"),t})())("*"===i&&n.startsWith(t+"/")||n===s[0])&&e.push(...o.split("|"))}return e})(e).some((e=>(e="."+e.trim(),t.name.toLowerCase().endsWith(e.toLowerCase())))))))))throw new o(this)},f=function(t){if(!t.getAll(this.field).every((t=>this.accept?.some((e=>t===String(e))))))throw new o(this)},h=function(t){if(t.getAll(this.field).length<parseInt(this.threshold))throw new o(this)},u=function(t){const e=t.getAll(this.field);if(parseInt(this.threshold)<e.length)throw new o(this)},g=function(t){const e=t.getAll(this.field);let s=0;if(e.forEach((t=>{"string"==typeof t&&(s+=t.length)})),0!==s&&s<parseInt(this.threshold))throw new o(this)},v=function(t){const e=t.getAll(this.field);let s=0;if(e.forEach((t=>{"string"==typeof t&&(s+=t.length)})),parseInt(this.threshold)<s)throw new o(this)},w=function(t){if(!t.getAll(this.field).every((t=>!(parseFloat(t)<parseFloat(this.threshold)))))throw new o(this)},x=function(t){if(!t.getAll(this.field).every((t=>!(parseFloat(this.threshold)<parseFloat(t)))))throw new o(this)},y=function(t){if(!t.getAll(this.field).every((t=>(t=t.trim(),!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(t)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&t<this.threshold)))))throw new o(this)},b=function(t){if(!t.getAll(this.field).every((t=>(t=t.trim(),!(/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(t)&&/^[0-9]{4,}-[0-9]{2}-[0-9]{2}$/.test(this.threshold)&&this.threshold<t)))))throw new o(this)},A=function(t){const e=t.getAll(this.field);let s=0;if(e.forEach((t=>{t instanceof File&&(s+=t.size)})),s<parseInt(this.threshold))throw new o(this)},z=function(t){const e=t.getAll(this.field);let s=0;if(e.forEach((t=>{t instanceof File&&(s+=t.size)})),parseInt(this.threshold)<s)throw new o(this)};var $;window.swv={validators:e,validate:(t,s,n={})=>{const a=(t.rules??[]).filter((({rule:t,...s})=>"function"==typeof e[t]&&("function"!=typeof e[t].matches||e[t].matches(s,n))));if(!a.length)return new Map;const r=new i(s),p=a.reduce(((t,s)=>{const{rule:i,...n}=s;if(t.get(n.field)?.error)return t;try{e[i].call({rule:i,...n},r)}catch(e){if(e instanceof o)return t.set(n.field,e)}return t}),new Map);for(const t of r.keys())p.has(t)||p.set(t,{validInputs:r.getAll(t)});return p},...null!==($=window.swv)&&void 0!==$?$:{}}})();