text: "use strict";var WPFormsFormEmbedWizard=window.WPFormsFormEmbedWizard||function(o,t,i){var n={},a={formId:0,isBuilder:!1,isChallengeActive:!1},r={init:function(){i(r.ready),i(t).on("load",function(){"function"==typeof i.ready.then?i.ready.then(r.load):r.load()})},ready:function(){r.initVars(),r.events()},load:function(){"1"!==wpforms_admin_form_embed_wizard.is_edit_page||a.isChallengeActive||r.initTooltip(),a.isBuilder&&r.initialStateToggle()},initVars:function(){n={$wizardContainer:i("#wpforms-admin-form-embed-wizard-container"),$wizard:i("#wpforms-admin-form-embed-wizard"),$contentInitial:i("#wpforms-admin-form-embed-wizard-content-initial"),$contentSelectPage:i("#wpforms-admin-form-embed-wizard-content-select-page"),$contentCreatePage:i("#wpforms-admin-form-embed-wizard-content-create-page"),$sectionBtns:i("#wpforms-admin-form-embed-wizard-section-btns"),$sectionGo:i("#wpforms-admin-form-embed-wizard-section-go"),$newPageTitle:i("#wpforms-admin-form-embed-wizard-new-page-title"),$selectPage:i("#wpforms-admin-form-embed-wizard-select-page"),$videoTutorial:i("#wpforms-admin-form-embed-wizard-tutorial"),$sectionToggles:i("#wpforms-admin-form-embed-wizard-section-toggles"),$sectionGoBack:i("#wpforms-admin-form-embed-wizard-section-goback"),$shortcode:i("#wpforms-admin-form-embed-wizard-shortcode-wrap"),$shortcodeInput:i("#wpforms-admin-form-embed-wizard-shortcode"),$shortcodeCopy:i("#wpforms-admin-form-embed-wizard-shortcode-copy")},a.isBuilder="undefined"!=typeof WPFormsBuilder,a.isChallengeActive="undefined"!=typeof WPFormsChallenge,a.pagesExists=1===n.$wizard.data("pages-exists")},events:function(){n.$wizard.length&&n.$wizard.on("click","button",r.popupButtonsClick).on("click",".tutorial-toggle",r.tutorialToggle).on("click",".shortcode-toggle",r.shortcodeToggle).on("click",".initialstate-toggle",r.initialStateToggle).on("click",".wpforms-admin-popup-close",r.closePopup).on("click","#wpforms-admin-form-embed-wizard-shortcode-copy",r.copyShortcodeToClipboard)},popupButtonsClick:function(e){var o=i(e.target);if(o.length){var t=o.closest("div"),e=o.data("action")||"";switch(n.$contentInitial.hide(),e){case"select-page":n.$newPageTitle.hide(),n.$contentSelectPage.show();break;case"create-page":n.$selectPage.hide(),n.$contentCreatePage.show();break;case"go":return n.$selectPage.is(":visible")&&""===n.$selectPage.val()?void 0:(o.prop("disabled",!0),void r.saveFormAndRedirect())}t.hide(),t.next().fadeIn(),n.$sectionToggles.hide(),n.$sectionGoBack.fadeIn(),r.tutorialControl("Stop")}},tutorialToggle:function(e){e.preventDefault(),n.$shortcode.hide(),n.$videoTutorial.toggle(),"about:blank"===n.$videoTutorial.attr("src")&&n.$videoTutorial.attr("src",wpforms_admin_form_embed_wizard.video_url),n.$videoTutorial[0].src.indexOf("&autoplay=1")<0?r.tutorialControl("Play"):r.tutorialControl("Stop")},tutorialControl:function(e){var o=n.$videoTutorial[0];void 0!==o&&("Stop"!==e?o.src+=o.src.indexOf("&autoplay=1")<0?"&autoplay=1":"":o.src=o.src.replace("&autoplay=1",""))},shortcodeToggle:function(e){e.preventDefault(),n.$videoTutorial.hide(),r.tutorialControl("Stop"),n.$shortcodeInput.val('[wpforms id="'+a.formId+'" title="false"]'),n.$shortcode.toggle()},copyShortcodeToClipboard:function(){n.$shortcodeInput.prop("disabled",!1).select().prop("disabled",!0),o.execCommand("copy");var e=n.$shortcodeCopy.find("i");e.removeClass("fa-files-o").addClass("fa-check"),t.setTimeout(function(){e.removeClass("fa-check").addClass("fa-files-o")},2500)},initialStateToggle:function(e){e&&e.preventDefault(),a.pagesExists?(n.$contentInitial.show(),n.$contentSelectPage.hide(),n.$contentCreatePage.hide(),n.$selectPage.show(),n.$newPageTitle.show(),n.$sectionBtns.show(),n.$sectionGo.hide()):(n.$contentInitial.hide(),n.$contentSelectPage.hide(),n.$contentCreatePage.show(),n.$selectPage.hide(),n.$newPageTitle.show(),n.$sectionBtns.hide(),n.$sectionGo.show()),n.$shortcode.hide(),n.$videoTutorial.hide(),r.tutorialControl("Stop"),n.$sectionToggles.show(),n.$sectionGoBack.hide()},saveFormAndRedirect:function(){a.isBuilder&&!WPFormsBuilder.formIsSaved()?a.isBuilder&&a.isChallengeActive?WPFormsBuilder.formSave().done(r.embedPageRedirect):i.confirm({title:!1,content:wpforms_builder.exit_confirm,icon:"fa fa-exclamation-circle",type:"orange",closeIcon:!0,buttons:{confirm:{text:wpforms_builder.save_embed,btnClass:"btn-confirm",keys:["enter"],action:function(){WPFormsBuilder.formSave().done(r.embedPageRedirect)}},cancel:{text:wpforms_builder.embed,action:function(){WPFormsBuilder.setCloseConfirmation(!1),r.embedPageRedirect()}}},onClose:function(){n.$sectionGo.find("button").prop("disabled",!1)}}):r.embedPageRedirect()},embedPageRedirectAjaxData:function(){var e={action:"wpforms_admin_form_embed_wizard_embed_page_url",_wpnonce:wpforms_admin_form_embed_wizard.nonce,formId:a.formId};return n.$selectPage.is(":visible")&&(e.pageId=n.$selectPage.val()),n.$newPageTitle.is(":visible")&&(e.pageTitle=n.$newPageTitle.val()),e},embedPageRedirect:function(){var e=r.embedPageRedirectAjaxData();void 0!==e.pageId&&""===e.pageId||i.post(ajaxurl,e,function(e){e.success&&(t.location=e.data)})},openPopup:function(e){e=e||0,a.formId=a.isBuilder?i("#wpforms-builder-form").data("id"):e,n.$wizard.toggleClass("wpforms-challenge-popup",a.isChallengeActive),n.$wizard.find(".wpforms-admin-popup-close").toggle(!a.isChallengeActive),n.$wizard.find(".wpforms-admin-popup-content-regular").toggle(!a.isChallengeActive),n.$wizard.find(".wpforms-admin-popup-content-challenge").toggle(a.isChallengeActive),0===n.$selectPage.length?(n.$sectionBtns.hide(),n.$sectionGo.show()):(n.$sectionBtns.show(),n.$sectionGo.hide()),n.$newPageTitle.show(),n.$selectPage.show(),n.$wizardContainer.fadeIn()},closePopup:function(){n.$wizardContainer.fadeOut(),r.initialStateToggle()},initTooltip:function(){var e,o,t;void 0!==i.fn.tooltipster&&(e=i('<span class="wpforms-admin-form-embed-wizard-dot">&nbsp;</span>'),o=(t=r.isGutenberg())?".block-editor .edit-post-header":"#wp-content-editor-tools .wpforms-insert-form-button",t={content:i("#wpforms-admin-form-embed-wizard-tooltip-content"),trigger:"custom",interactive:!0,animationDuration:0,delay:0,theme:["tooltipster-default","wpforms-admin-form-embed-wizard"],side:t?"bottom":"right",distance:3,functionReady:function(e,o){e._$tooltip.on("click","button",function(){e.close(),i(".wpforms-admin-form-embed-wizard-dot").remove()}),e.reposition()}},e.insertAfter(o).tooltipster(t).tooltipster("open"))},isGutenberg:function(){return"undefined"!=typeof wp&&Object.prototype.hasOwnProperty.call(wp,"blocks")}};return r}(document,window,jQuery);WPFormsFormEmbedWizard.init();