(()=>{"use strict";var o={120:(t,e,o)=>{o.d(e,{RW:()=>function(t){return t&&0!==t.length?'\t\n        <ul class="tutor-dropdown" style="width: 100%; margin: 0; max-height: 200px; overflow: scroll;">\n            '.concat(t.map(function(t){return'\n                    <li>\n                        <a class="tutor-dropdown-item tutor-d-flex tutor-justify-between" href="#" data-state-text="'.concat(t.placeholder,'">\n                            <span class="tutor-color-muted">').concat(t.placeholder,"</span>\n                            <span>").concat(t.label,"</span>\n                        </a>\n                    </li>\n                ")}).join(""),"\n        </ul>\n    "):""},fW:()=>function(t){t=t.selection.getRng().getClientRects()[0];if(t)return{offsetTop:t.top+124,offsetLeft:t.left};return{}}});o=wp.i18n;o.__,o._x,o._n,o._nx}},r={};function n(t){var e=r[t];return void 0!==e||(e=r[t]={exports:{}},o[t](e,e.exports,n)),e.exports}n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var i;i=n(120),window.addEventListener("DOMContentLoaded",function(){document.querySelectorAll(".tutor-option-field-input.tutor-email-placeholders").forEach(function(t){var e=t.dataset.placeholders,o=document.createElement("div"),e=(o.setAttribute("class","tutor-dropdown-parent"),o.innerHTML=(0,i.RW)(e?JSON.parse(e):window._tutorEmailPlaceholders),t.classList.contains("tutor-has-tinymce-editor"));t.insertBefore(o,e?t.firstChild:t.lastChild)}),document.querySelectorAll('.tutor-option-field-input.tutor-email-placeholders input[type="text"], .tutor-option-field-input.tutor-email-placeholders textarea').forEach(function(t){t.addEventListener("input",function(t){var e=t.target.parentNode.querySelector(".tutor-dropdown-parent");e&&("{"===t.data?(t.target.blur(),e.classList.add("is-open"),e.querySelectorAll(".tutor-dropdown-item")[0].classList.add("is-active"),e.querySelectorAll(".tutor-dropdown-item")[0].focus(),document.querySelector("body").style.overflow="hidden",setTimeout(function(){e.querySelector(".tutor-dropdown").scrollTop=0},100)):(e.classList.remove("is-open"),document.querySelector("body").style.overflow="auto"))})});document.querySelectorAll(".tutor-option-field-input.tutor-email-placeholders .tutor-dropdown-item").forEach(function(n){n.addEventListener("click",function(t){t.preventDefault();var e,o,t=(t=n.getAttribute("data-state-text")).slice(1,t.length),r=n.closest(".tutor-option-field-input").querySelector(":scope > input, :scope > textarea");r?(o=(e=r.selectionStart)+t.length,r.value=r.value.substring(0,e)+t+r.value.substring(e),r.dispatchEvent(new Event("input",{bubbles:!0})),r.setSelectionRange(o,o),r.focus()):tinymce.activeEditor&&(tinymce.activeEditor.insertContent(t),tinymce.triggerSave())})});var n=0;document.addEventListener("keydown",function(t){var e,o,r=document.querySelector(".tutor-email-placeholders .tutor-dropdown-parent.is-open");r&&(e=r.querySelectorAll(".tutor-dropdown-item"),"ArrowUp"===t.key?0<n&&(--n,e.forEach(function(t){t.classList.remove("is-active"),t.blur()}),e[n].classList.add("is-active"),e[n].focus()):"ArrowDown"===t.key?n<e.length-1&&(n+=1,e.forEach(function(t){t.classList.remove("is-active"),t.blur()}),e[n].classList.add("is-active"),e[n].focus()):"Enter"===t.key?(o=document.querySelector(".tutor-email-placeholders .tutor-dropdown-item.is-active"))&&(o.click(),n=0,e.forEach(function(t){t.classList.remove("is-active"),t.blur()})):n=0,"Escape"===t.key)&&(r.classList.remove("is-open"),e.forEach(function(t){t.classList.remove("is-active"),t.blur()}),(o=r.closest(".tutor-option-field-input").querySelector(":scope > input, :scope > textarea"))?o.focus():tinymce.activeEditor&&tinymce.activeEditor.focus())}),document.querySelectorAll(".tutor-email-placeholders .tutor-dropdown-parent").forEach(function(t){t.addEventListener("tutor_dropdown_closed",function(t){document.querySelector("body").style.overflow="auto",t.target.querySelectorAll(".tutor-dropdown-item").forEach(function(t){return t.classList.remove("is-active")})})})}),document.addEventListener("readystatechange",function(){"undefined"!=typeof tinymce&&tinymce.activeEditor&&tinymce.activeEditor.on("input",function(t){var e=(0,i.fW)(tinymce.activeEditor),o=e.offsetTop,r=(e.offsetLeft,document.querySelector(".wp-editor-wrap").parentNode.querySelector(".tutor-dropdown-parent"));r&&("{"===t.data?(e=document.createElement("input"),r.appendChild(e),e.focus(),r.removeChild(e),r.classList.add("is-open"),r.querySelector(".tutor-dropdown").style.top=o+"px",r.querySelectorAll(".tutor-dropdown-item")[0].classList.add("is-active"),r.querySelectorAll(".tutor-dropdown-item")[0].focus(),document.querySelector("body").style.overflow="hidden",setTimeout(function(){r.querySelector(".tutor-dropdown").scrollTop=0},100)):(r.classList.remove("is-open"),document.querySelector("body").style.overflow="auto"))})})})();