const S=({strings:r=["Put your strings here...","and Enjoy!"],typeSpeed:o=100,backSpeed:s=50,backDelay:a=500,startDelay:i=500,cursorChar:l="|",placeholder:c=!1,showCursor:d=!0,disableBackTyping:u=!1,onFinished:h=function(){},loop:g=!0})=>({strings:r,typeSpeed:o,backSpeed:s,cursorChar:l,backDelay:a,placeholder:c,startDelay:i,showCursor:d,loop:g,disableBackTyping:u,onFinished:h}),C=(r,o)=>{let s=0,a,i;const l=(e,t)=>{s===a&&t.loop&&(s=0),setTimeout(()=>{c(e[s],t)},t.startDelay)},c=(e,t)=>{let n=0,y=e.length,f=setInterval(()=>{if(t.placeholder?r.placeholder+=e[n]:r.textContent+=e[n],++n===y)return d(f,t)},t.typeSpeed)},d=(e,t)=>{if(clearInterval(e),t.disableBackTyping&&s===a-1||!t.loop&&s===a-1)return t.onFinished();setTimeout(()=>u(t),t.backDelay)},u=e=>{let t=e.placeholder?r.placeholder:r.textContent,n=t.length,y=setInterval(()=>{if(e.placeholder?r.placeholder=r.placeholder.substr(0,--n):r.textContent=t.substr(0,--n),n===0)return h(y,e)},e.backSpeed)},h=(e,t)=>{clearInterval(e),++s,l(i,t)},g=(e,t)=>{let n=document.createElement("span");n.classList.add("ityped-cursor"),n.textContent="|",n.textContent=t.cursorChar,e.insertAdjacentElement("afterend",n)};return(e=>{let t=S(e||{}),n=t.strings;i=n,a=n.length,typeof r=="string"&&(r=document.querySelector(r)),t.showCursor&&g(r,t),l(n,t)})(o)};export{C as i};
