(()=>{"use strict";var n={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return n.d(o,{a:o}),o},d:(t,o)=>{for(var e in o)n.o(o,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:o[e]})},o:(n,t)=>Object.prototype.hasOwnProperty.call(n,t)};const t=window.wp.i18n,o=window.jQuery;var e=n.n(o);function s(n){const t=e()("#sugar-calendar-bookings-confirmation-modal");if(0===t.length)return;const o=t.find(".sugar-calendar-bookings-modal-title"),s=t.find(".sugar-calendar-bookings-modal-message"),a=t.find(".sugar-calendar-bookings-modal-icon"),i=t.find("[data-confirm]"),r=t.find("[data-cancel]"),{type:c="info",title:d="",message:l="",html:g="",confirmText:m="",cancelText:u="",showConfirm:h=!0,showCancel:f=!0,hideIcon:b=!1,onConfirm:p=()=>{}}=n;t.removeClass(((n,t)=>(t.match(/sugar-calendar-bookings-confirmation-modal--\S+/g)||[]).join(" "))),t.addClass(`sugar-calendar-bookings-confirmation-modal--${c}`),b?(t.addClass("sugar-calendar-bookings-confirmation-modal--no-icon"),a.hide()):(t.removeClass("sugar-calendar-bookings-confirmation-modal--no-icon"),a.show()),o.text(d),g?s.html(g):s.text(l),i.text(m).data("on-confirm",p),r.text(u),h?i.show():i.hide(),f?r.show():r.hide();const w=t.find(".sugar-calendar-bookings-modal-buttons");h||f?w.show():w.hide(),t.fadeIn(200),e()("body").addClass("modal-open"),setTimeout((()=>{f?r.focus():i.focus()}),250)}function a(){e()("#sugar-calendar-bookings-confirmation-modal").fadeOut(200),e()("body").removeClass("modal-open")}!function(){const n=window.SugarCalendarBookings||{};n.Admin=n.Admin||{},n.Admin.Connect={init(n){this.settings=n,this.$connectBtn=e()("#scbookings-setting-license-key-button"),this.$connectKey=e()('input[name="sugar-calendar-bookings[license][key]"]'),this.originalButtonText=this.$connectBtn.text(),this.$connectBtn.on("click",this.gotoUpgradeUrl.bind(this))},gotoUpgradeUrl(){this.$connectBtn.prop("disabled",!0).text((0,t.__)("Verifying…","sugar-calendar-bookings-scheduling-appointments-lite")),this.$connectKey.prop("disabled",!0);const n=this.$connectKey.val();e().post(this.settings.ajax_url,{action:"sugar_calendar_bookings_connect_url",nonce:this.settings.nonce,key:n}).done((n=>{if(n.success)return n.data.reload?void s({type:"success",title:this.settings.text.almost_done,message:n.data.message,confirmText:this.settings.text.plugin_activate_btn,showCancel:!1,onConfirm:()=>{a(),window.location.reload()}}):void(window.location.href=n.data.url);s({type:"warning",message:n.data&&n.data.message?n.data.message:this.settings.text.server_error,confirmText:this.settings.text.ok,showCancel:!1,onConfirm:()=>{a()}})})).fail((n=>{const t=this.settings.text.server_error+"<br>"+n.status+" "+n.statusText+" "+n.responseText;s({type:"error",title:this.settings.text.oops,message:t,confirmText:this.settings.text.ok,showCancel:!1,onConfirm:()=>{a()}})})).always((()=>{this.$connectBtn.prop("disabled",!1).text(this.originalButtonText),this.$connectKey.prop("disabled",!1)}))}},n.Admin.Connect.init(sugar_calendar_bookings_admin_connect),window.SugarCalendarBookings=n}(sugar_calendar_bookings_admin_connect)})();