/*! Simple Calendar - 3.1.36
 * https://simplecalendar.io
 * Copyright (c) Moonstone Media 2021
 * Licensed GPLv2+ */

!function(a,b,c){"use strict";jQuery(function(c){function d(a,b,d,e){a.each(function(a,f){var g=c(f),h=new Date(1e3*b);g.hasClass("simcal-prev")?(h=new Date(h.setMonth(h.getMonth(),1)),h.setDate(0),h.getTime()/1e3<=d?g.attr("disabled","disabled"):g.removeAttr("disabled")):(h=new Date(h.setMonth(h.getMonth()+1,1)),h.setDate(0),h.setHours(23),h.setMinutes(59),h.setSeconds(59),h.getTime()/1e3>=e?g.attr("disabled","disabled"):g.removeAttr("disabled"))})}function e(a,b,d,e,f,g){var h=b.find(".simcal-events-list-container"),i=h.data("prev"),j=h.data("next"),k=h.find("li.simcal-event:last").data("start");a.each(function(a,b){var h=c(b);f?h.hasClass("simcal-prev")?"prev"==f?i<=d&&g<=d&&h.attr("disabled","disabled"):h.removeAttr("disabled"):h.hasClass("simcal-next")&&("next"==f?(j>=e&&g>=e||k>=e)&&h.attr("disabled","disabled"):h.removeAttr("disabled")):h.hasClass("simcal-prev")?i<=d&&g<=d&&h.attr("disabled","disabled"):h.hasClass("simcal-next")&&(j>=e&&g>=e||k>=e)&&h.attr("disabled","disabled")})}function f(a){var b=c(a).find(".simcal-current"),d=c(a).find(".simcal-events-list-container"),e=d.data("heading-small"),f=d.data("heading-large"),g=c("<h3 />");a.width()<400?g.text(e):g.text(f),b.html(g)}function g(b){var d=c(b).find("> table"),e=d.find("thead"),f=e.find("th.simcal-week-day"),g=d.find("td.simcal-day > div"),h=d.find("ul.simcal-events"),i=h.find("> li > .simcal-event-title"),j=d.find(".simcal-events-toggle"),k=d.find("span.simcal-events-dots"),l=d.find(".simcal-tooltip-content"),m=d.find(".simcal-event-toggled"),n=d.data("event-bubble-trigger"),o=g.first().width();if(o<60){f.each(function(a,b){c(b).text(c(b).data("screen-small"))}),h.hide(),i.hide(),"undefined"!=j&&(j.hide(),"undefined"!=m&&m.show()),k.show(),n="click";var p=o-10+"px";g.css("min-height",p),d.find("span.simcal-events-dots:not(:empty)").css("min-height",p)}else o<=240?f.each(function(a,b){c(b).text(c(b).data("screen-medium"))}):f.each(function(a,b){c(b).text(c(b).data("screen-large"))}),h.show(),i.show(),"undefined"!=j&&(j.show(),"undefined"!=m&&m.hide()),k.hide(),g.css("min-height",o+"px");g.each(function(b,d){var e,f,g=c(d).find("span.simcal-events-dots"),h=c(d).find(".simcal-tooltip");o<60?(l.show(),e=g):(l.hide(),e=h),e.each(function(b,e){c(e).qtip({content:o<60?c(d).find("ul.simcal-events"):c(e).find("> .simcal-tooltip-content"),position:{my:"top center",at:"bottom center",target:c(e),viewport:!(o<60)||c(a),adjust:{method:"shift",scroll:!1}},style:{def:!1,classes:"simcal-default-calendar simcal-event-bubble"},show:{solo:!0,effect:!1,event:"hover"==n?"mouseenter":"click"},hide:{fixed:!0,effect:!1,event:"click"==n?"unfocus":"mouseleave",delay:100},events:{show:function(a,b){f&&f.id&&f.id!=b.id&&f.hide(),f=b}},overwrite:!1})})})}function h(){c(".simcal-events-toggle").each(function(a,b){var d=c(b).prev(".simcal-events"),e=d.find(".simcal-event-toggled"),f=c(b).find("i");c(b).on("click",function(){f.toggleClass("simcal-icon-rotate-180"),e.slideToggle()})})}c(".simcal-default-calendar").each(function(a,i){var j,k,l=c(i),m=l.data("calendar-id"),n=l.data("offset"),o=l.data("events-first"),p=l.data("calendar-end"),q=l.find(".simcal-calendar-head"),r=q.find(".simcal-nav-button"),s=l.find(".simcal-ajax-loader"),t=q.find(".simcal-current"),u=t.data("calendar-current"),v=t.find("span.simcal-current-month"),w=t.find("span.simcal-current-year"),x=b.tz(1e3*u,l.data("timezone"));l.hasClass("simcal-default-calendar-grid")?(k="simcal_default_calendar_draw_grid",j=new Date(x.year(),x.month()),d(r,j.getTime()/1e3,o,p)):(k="simcal_default_calendar_draw_list",e(r,l,o,p,!1,u),f(l)),r.on("click",function(){var a=c(this).hasClass("simcal-next")?"next":"prev";if("simcal_default_calendar_draw_grid"==k){var b,i,q,u=l.find(".simcal-month");"prev"==a?b=new Date(j.setMonth(j.getMonth()-1,1)):(b=new Date(j.setMonth(j.getMonth()+2,1)),b.setDate(0),b.setHours(23),b.setMinutes(59),b.setSeconds(59)),i=b.getMonth(),q=b.getFullYear(),c.ajax({url:simcal_default_calendar.ajax_url,type:"POST",dataType:"json",cache:!1,data:{action:k,month:i+1,year:q,id:m},beforeSend:function(){s.fadeToggle()},success:function(a){v.text(simcal_default_calendar.months.full[i]),w.text(q),t.attr("data-calendar-current",b.getTime()/1e3+n+1),d(r,b.getTime()/1e3,o,p),s.fadeToggle(),j=b,u.replaceWith(a.data),g(l),h()},error:function(a){console.log(a)}})}else{var x=l.find(".simcal-events-list-container"),y=x.data("prev"),z=x.data("next"),A="prev"==a?y:z;c.ajax({url:simcal_default_calendar.ajax_url,type:"POST",dataType:"json",cache:!1,data:{action:k,ts:A,id:m},beforeSend:function(){s.fadeToggle()},success:function(b){x.replaceWith(b.data),t.attr("data-calendar-current",A),f(l),e(r,l,o,p,a,A),s.fadeToggle(),h()},error:function(a){console.log(a)}})}})});var i=c(".simcal-default-calendar-grid");i.each(function(a,b){g(b),c(b).on("change",function(){g(this)})}),a.onresize=function(){i.each(function(a,b){g(b)})},h()})}(this,moment);