var Typer=function(t){this.element=t;var e=t.dataset.delim||",",s=t.dataset.words||"override these,sample typing";this.words=s.split(e).filter((t=>t)),this.delay=t.dataset.delay||200,this.loop=t.dataset.loop||"true","false"===this.loop&&(this.loop=1),this.deleteDelay=t.dataset.deletedelay||t.dataset.deleteDelay||800,this.progress={word:0,char:0,building:!0,looped:0},this.typing=!0;var o=t.dataset.colors||"black";this.colors=o.split(","),this.element.style.color=this.colors[0],this.colorIndex=0,this.doTyping()};Typer.prototype.start=function(){this.typing||(this.typing=!0,this.doTyping())},Typer.prototype.stop=function(){this.typing=!1},Typer.prototype.doTyping=function(){var t,e=this.element,s=this.progress,o=s.word,i=s.char,r=[...this.words[o]].slice(0,i).join("");this.cursor&&(this.cursor.element.style.opacity="1",this.cursor.on=!0,clearInterval(this.cursor.interval),this.cursor.interval=setInterval((()=>this.cursor.updateBlinkState()),400)),e.innerHTML=r,s.building?(t=s.char===this.words[o].length)?s.building=!1:s.char+=1:0===s.char?(s.building=!0,s.word=(s.word+1)%this.words.length,this.colorIndex=(this.colorIndex+1)%this.colors.length,this.element.style.color=this.colors[this.colorIndex]):s.char-=1,s.word===this.words.length-1&&(s.looped+=1),!s.building&&this.loop<=s.looped&&(this.typing=!1),setTimeout((()=>{this.typing&&this.doTyping()}),t?this.deleteDelay:this.delay)};var Cursor=function(t){this.element=t,this.cursorDisplay=t.dataset.cursordisplay||t.dataset.cursorDisplay||"_",t.innerHTML=this.cursorDisplay,this.on=!0,t.style.transition="all 0.1s",this.interval=setInterval((()=>this.updateBlinkState()),400)};function TyperSetup(){var t={};for(let e of document.getElementsByClassName("typer"))t[e.id]=new Typer(e);for(let e of document.getElementsByClassName("typer-stop")){let s=t[e.dataset.owner];e.onclick=()=>s.stop()}for(let e of document.getElementsByClassName("typer-start")){let s=t[e.dataset.owner];e.onclick=()=>s.start()}for(let e of document.getElementsByClassName("cursor")){let s=new Cursor(e);s.owner=t[e.dataset.owner],s.owner.cursor=s}}Cursor.prototype.updateBlinkState=function(){this.on?(this.element.style.opacity="0",this.on=!1):(this.element.style.opacity="1",this.on=!0)},TyperSetup();