window.tec=window.tec||{},tec.classicEditorEvents=tec.classicEditorEvents||{},tec.classicEditorEvents.default=tec.classicEditorEvents.default||{},function(e,t){"use strict";t.selectors={eventEndDate:"#EventEndDate",eventStartDate:"#EventStartDate",exclusionDescription:".tribe-event-recurrence-description",datepicker:".tribe-datepicker",recurrenceEnd:".recurrence_end",recurrenceEndCount:".recurrence_end_count",recurrenceEndSelect:".recurrence-end-range select",recurrenceSameTimeSelect:".tribe-same-time-select",recurrenceTypeButton:".tribe-event-recurrence-rule > .tribe-buttonset .tribe-button-field[data-value]",exclusionTypeButton:".tribe-event-recurrence-exclusion > .tribe-buttonset .tribe-button-field[data-value]",ruleEndsText:".recurrence-end-range .tribe-field-inline-text",ruleTypeDropdown:"select.tec-events-pro-rule-type__dropdown",onceButton:'a[data-value="Date"]'},t.hideExclusionDescription=function(e){e.forEach((function(e){e.querySelectorAll(t.selectors.exclusionDescription).forEach((function(e){e.style.display="none"}))}))},t.setExclusionDatepickerMinDates=function(n){const c=e(t.selectors.eventStartDate).val();c&&n.forEach((function(n){const r=e(n).find(t.selectors.datepicker);r.val()||r.datepicker("option","minDate",c)}))},t.setRuleEndsText=function(e){const n=tecEventSettings.textSubstitution&&tecEventSettings.textSubstitution.ruleEnds?tecEventSettings.textSubstitution.ruleEnds:"";n&&e.forEach((function(e){const c=e.querySelector(t.selectors.ruleEndsText);c&&(c.innerText=n)}))},t.setNewEndsOnDefault=function(e){e.forEach((function(e){e.querySelectorAll(t.selectors.recurrenceEndSelect).forEach((function(e){e.value="Never",e.dispatchEvent(new Event("change"))}))}))},t.setNewEndDateDefault=function(e){e.forEach((function(e){const n=e.querySelectorAll(t.selectors.recurrenceEnd);let c=document.querySelector(t.selectors.eventStartDate).value;if(!c&&(c=document.querySelector(t.selectors.eventEndDate).value,!c))return;const r=c.match(/\W/g)[0];let o,s;c.split(r).forEach((function(e){4===e.length&&(o=e,s=parseInt(e)+1)})),o&&s&&(c=c.replace(o,s),n.forEach((function(e){e.value||(e.value=c,e.placeholder=c)})))}))},t.setNewEndCountDefault=function(e){e.forEach((function(e){e.querySelectorAll(t.selectors.recurrenceEndCount).forEach((function(e){e.value||(e.value=10,e.placeholder=10)}))}))},t.setNewOnceTimeSelectDefault=function(e){e.forEach((function(e){e.querySelectorAll(t.selectors.recurrenceSameTimeSelect).forEach((function(e){e.value="no",e.dispatchEvent(new Event("change"))}))}))},t.setNewRuleType=function(e){e.forEach((function(e){const n=e.querySelector(t.selectors.onceButton);n&&n.click()}))},t.addSameTimeRowClass=function(e){e.forEach((function(e){e.querySelector(t.selectors.recurrenceSameTimeSelect).closest(".recurrence-row").classList.add("recurrence-same-time")}))},t.handleRuleTypeDropdownChange=function(t){const n=e(t.target).closest(".tribe-buttonset"),c=n.parent(),r=t.target.selectedOptions[0],o=n.find('a[data-value="'+t.target.value+'"]');tec.classicEditorEvents.offStart.setRuleOffStartFromSelectedOption(c[0],r),o.length&&o.click()},t.bindRuleEvents=function(n){n.forEach((function(n){const c=n.querySelector(t.selectors.ruleTypeDropdown);c&&e(c).on("change",t.handleRuleTypeDropdownChange)}))},t.setRuleTypeDropdownToMatchButtons=function(n){n.forEach((function(n){const c=n.querySelector(t.selectors.ruleTypeDropdown);if(!c)return;if(tec.classicEditorEvents.offStart.isRuleOffStart(n))return;const r=n.classList.contains(tec.classicEditorEvents.selectors.recurrence.replace(".",""))?n.querySelector(t.selectors.recurrenceTypeButton+".tribe-active"):n.querySelector(t.selectors.exclusionTypeButton+".tribe-active");if(!r)return;const o=r.getAttribute("data-value");e(c).val(o).trigger("change")}))},t.setDefaultsSetFlag=function(e){e.forEach((function(e){e.setAttribute("data-defaults-set","1")}))}}(jQuery,tec.classicEditorEvents.default),window.tec=window.tec||{},window.tec.eventsPro=window.tec.eventsPro||{},window.tec.eventsPro.customTablesV1=window.tec.eventsPro.customTablesV1||{},window.tec.eventsPro.customTablesV1.classicEditorEventsDefault={};