!function(){"use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}$((function(){var n,a;new Garnish.MenuBtn($("#add-formatting-template"),{onOptionSelect:function(t){var n=function(t){var n;void 0===t&&(t={});var a=Craft.csrfTokenName,i=Craft.csrfTokenValue;return e(e({},t),((n={})[a]=i,n))}({template:$(t).data("template")});$.ajax(Craft.getCpUrl("freeform/api/templates/demo"),{type:"post",dataType:"json",data:n,complete:function(e){201===e.status&&window.location.reload()}})}}),n=$("#template-method"),a=$("#global-email-block"),n.on("change",(function(){switch($(this).val()){case"all":case"global":a.removeClass("hidden");break;case"form":a.addClass("hidden")}}));var i=$("#session-time"),o=$("#session-count"),r=$("#session-secret");$("select#session-context").on({change:function(){switch($(this).val()){case"payload":r.removeClass("hidden"),o.addClass("hidden"),i.addClass("hidden");break;case"session":case"database":r.addClass("hidden"),o.removeClass("hidden"),i.removeClass("hidden")}}}),$("input[name='purge-toggle']").parents(".lightswitch").on({change:function(){$("input",this).val()||$("select#purge-value").val(0)}}),$("select#spam-protection-behavior").on({change:function(){var e=$("#custom-spam-error-message");"display_errors"===$(this).val()?e.show("fast"):e.hide("fast")}});var s=$('select[name="settings[scriptInsertLocation]"]'),l=$("#script-insert-warning").text();s.on({change:function(){var e=$(this).val(),t=$(this).parents(".field:first");if("manual"===e){var n=document.createElement("div");n.classList.add("warning","with-icon"),n.innerText=l,t.append(n)}else t.find(".warning.with-icon").remove()}}),s.trigger("change");var c=$('select[name="settings[loggingLevel]"]'),f=$("#logging-level-warning").text();c.on({change:function(){var e=$(this).val(),t=$(this).parents(".field:first");if("info"===e||"debug"===e){var n=document.createElement("div");n.classList.add("warning","with-icon"),n.innerText=f,t.append(n)}else t.find(".warning.with-icon").remove()}}),c.trigger("change");var u=$("#files-directory"),d=$("#template-default");$("#storage-type").on({change:function(e){var t=e.target.value,n=["files","files_database"].includes(t);u.toggleClass("hidden",!n),d.toggleClass("combined","files_database"===t).trigger("change")}}),$("#allow-builder-templates").on({change:function(e){var t="1"==$("input",e.target).val();d.toggleClass("builder-templates",t).trigger("change")}}),d.on("change",(function(){var e=d.hasClass("combined")&&d.hasClass("builder-templates");d.toggleClass("hidden",!e)}));var g=$("#notifications-migrator");g&&$("#migrate",g).on({click:function(e){if(!confirm("Are you sure you want to migrate database notifications to file based ones?"))return e.preventDefault(),e.stopPropagation(),!1;var n,a,i,o=$("#remove-files",g).is(":checked");return $.ajax({url:Craft.getCpUrl("freeform/migrate/notifications/db-to-file"),type:"post",dataType:"json",contentType:"application/json",data:JSON.stringify((n={removeDbNotifications:o},a=Craft.csrfTokenName,i=Craft.csrfTokenValue,(a=function(e){var n=function(e){if("object"!=t(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,"string");if("object"!=t(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==t(n)?n:n+""}(a))in n?Object.defineProperty(n,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[a]=i,n)),success:function(e){e.success&&g.html($('<div class="pane">\n                  <p>\n                    <span class="checkmark-icon"></span>\n                    Migrated successfully\n                  </p>\n                </div>\n                '))}}),e.preventDefault(),e.stopPropagation(),!1}}),$(".lock-button").on("click",(function(){var e=$("input",this);e.val("1"===e.val()?"0":"1"),e.toggleClass("locked","1"===e.val())}))}))}();