import{o as m,c as p,b as u,w as y,F as v,i as x,n as g,d as A,a as _,l as G,_ as M}from"./index.js";import{_ as O}from"./bg2.js";const X={class:"game-text iface-centered"},S=_("img",{class:"game-text--background",src:O},null,-1),w={class:"game-text--data"},$=["innerHTML"];function k(e,t,i,s,o,f){return m(),p("div",X,[u(G,{name:"fade"},{default:y(()=>[(m(!0),p(v,null,x(o.data,a=>(m(),p("div",{class:g(["game-text--content",o.TYPES[a.type]]),key:a.id,style:A(a.offset)},[S,_("div",w,[_("div",{class:"title",innerHTML:a.text},null,8,$)])],6))),128))]),_:1})])}const n=0,h=1,r=2,d=3,I=4,C=5,D=6,T=7,K={props:["openParams"],data(){return{TYPES:["center-type","top-type","right-type","bottom-type","key-type"],id:0,key:0,data:[]}},created(){this.$data.noAdaptation=!0},mounted(){document.addEventListener("keyup",this.onKeyUp)},unmounted(){document.removeEventListener("keyup",this.onKeyUp)},methods:{add(e){const t=JSON.parse(e);if(window.getOpenedControllableInterfaces().length==0&&!window.IsDialogOpened()||t[C]){const i=this.id;let s=this.data.filter(o=>o.type==t[n]);if(s.length){s=s[n],clearTimeout(s.timeout);let o=s;o.text=this.formatText(t[h],t[T]),o.offset=t[d]==0?0:this.formatOffset(t[n],t[d]),t[r]>0&&(o.timeout=setTimeout(()=>{this.remove(s.id)},t[r])),this.data[this.data.indexOf(s)]=o}else t[D]&&window.playSound("notifications/UI_Notification_01.mp3",!1,2,.2),this.data.push({id:this.id++,type:t[n],text:this.formatText(t[h],t[T]),offset:t[d]==0?0:this.formatOffset(t[n],t[d]),keyCode:t[I],timeout:t[r]>0?setTimeout(()=>{this.remove(i)},t[r]):0})}},onKeyUp({keyCode:e}){this.pressKey(e)},pressKey(e){for(let t=0;t<this.data.length;t++)this.data[t].keyCode==e&&setTimeout(()=>{this.remove(this.data[t].id)},300)},hide(e){for(let t in this.data)t.type==e&&this.remove(t.id)},remove(e){this.data.filter(i=>i.id==e).length&&(this.data=this.data.filter(i=>i.id!=e))},formatOffset(e,t){const i=this.TYPES[e];let s=`margin-top: ${t/1080*100}vh`;return i!="center-type"&&(s=`margin-${i}: ${t/1080*100}vh`),s},formatText(e,t){const i=[];let s="";e.split("~n~").forEach(a=>{const E=a.split(/(?=~.~)/).map(c=>{const l=c.match(/^~(.)~(.*)/);return l&&(s=l[1],c=l[2]),`<span class="${s}">${c}</span>`}).join("");i.push(E)});const o=i.map(a=>`<div class="row">${a}</div>`).join("");return`<div style="font-size: ${t}vh">${o}</div>`.split("_").join(" ")}}},Y=M(K,[["render",k]]);export{Y as default};
