!function(){"use strict";function t(t){t&&(t.classList.add("aipkit_hidden"),t.classList.remove("aipkit_starters_ready"))}function e(t){!t||t.classList.contains("aipkit_hidden")||(t.classList.remove("aipkit_starters_ready"),t.offsetHeight,requestAnimationFrame(()=>{t.classList.contains("aipkit_hidden")||t.classList.add("aipkit_starters_ready")}))}window.aipkit_initConversationStarters=function(i,n,a,r,s,d){let{startersContainer:o,messagesEl:p,inputField:c}=a,l=(n.botId,n.starters||[]);if(!(i&&n&&o&&p&&c))return;if("function"!=typeof r)return void t(o);if("function"!=typeof d)return void t(o);if(0===l.length)return void t(o);o.innerHTML="",l.forEach((e,i)=>{if("string"==typeof e&&""!==e.trim()){let n=document.createElement("button");n.type="button",n.className="aipkit_starter_btn",n.textContent=e.trim(),n.style.setProperty("--aipkit-starter-index",String(i)),n.addEventListener("click",e=>{if(e.preventDefault(),s&&!d())return;let i=n.textContent;r(i),t(o)}),o.appendChild(n)}});let u=i=>{let n=!(i&&"aipkit:popupOpened"===i.type&&i.detail&&!1===i.detail.replayIntro);s&&!d()||!function(t){return!t||0===t.querySelectorAll(".aipkit_chat_message:not(.aipkit_initial_greeting)").length}(p)?t(o):function(t,i=!0){t&&(t.classList.remove("aipkit_hidden"),i&&e(t))}(o,n)},f=()=>t(o);i.addEventListener("aipkit:messageSent",f),i.addEventListener("aipkit:messageReceived",f),i.addEventListener("aipkit:messageError",f),i.addEventListener("aipkit:chatCleared",u),i.addEventListener("aipkit:chatLoaded",u),i.addEventListener("aipkit:popupOpened",u),i.addEventListener("aipkit:consentGiven",()=>{u()}),u()},window.aipkit_chatUI_refreshStartersAnimation=e}();