document.addEventListener("DOMContentLoaded",function(){const s=document.getElementById("aiStaffCreateForm");if(!s)return;const{translations:r}=window;s.addEventListener("submit",function(i){var t;if(!l())return i.preventDefault(),!1;const e=s.querySelector('button[type="submit"]')||document.querySelector(`button[type="submit"][form="${s.id}"]`);return e&&(e.disabled=!0,e.innerHTML='<i class="fas fa-spinner fa-spin me-2"></i>'+(((t=r.buttons)==null?void 0:t.saving)||"Saving...")),!0});function l(){var a,d;let i=!0;const e=document.getElementById("name");e&&!e.value.trim()?(e.classList.add("is-invalid"),o(e,((a=r.validation)==null?void 0:a.name_required)||"Name is required."),i=!1):e&&(e.classList.remove("is-invalid"),n(e));const t=document.getElementById("job_title");return t&&!t.value.trim()?(t.classList.add("is-invalid"),o(t,((d=r.validation)==null?void 0:d.job_title_required)||"Job title is required."),i=!1):t&&(t.classList.remove("is-invalid"),n(t)),i}function o(i,e){n(i);const t=document.createElement("div");t.className="invalid-feedback",t.textContent=e,i.parentNode.appendChild(t)}function n(i){const e=i.parentNode.querySelector(".invalid-feedback");e&&e.remove()}["name","job_title"].forEach(function(i){const e=document.getElementById(i);e&&(e.addEventListener("blur",function(){var t;if(this.value.trim())this.classList.remove("is-invalid"),n(this);else{this.classList.add("is-invalid");const a=((t=r.validation)==null?void 0:t[i+"_required"])||i.replace("_"," ")+" is required.";o(this,a)}}),e.addEventListener("input",function(){this.value.trim()&&(this.classList.remove("is-invalid"),n(this))}))})});
