import{u as T,r as h,a as M,G as $,w as c,c as A,n as D,o as N,b,d as z,e as L,v as B,f as g,g as x,h as F,i as C,l as O,E as U}from"./index-DmCbOAxb.js";import{e as n}from"./artplayer-ueyOVO3X.js";import{l as P,a as R}from"./containers-B-x1Py5x.js";import{_ as j}from"./_plugin-vue_export-helper-DlAUqK2U.js";const V={__name:"AudioContainer",props:{id:String,layoutId:String,partner:String,code:String},setup(S){const _=T();n.CONTEXTMENU=!1,n.NOTICE_TIME=0,n.CONTROL_HIDE_TIME=0,n.RECONNECT_TIME_MAX=10;const p="https://display24.ru",s=h(!1);let d=null;const i=S,e=M({id:null,displayCode:null,layoutId:null,content:null,schedule:null,scheduleData:null,top:0,left:0,width:0,height:0,background:{color:"#000"},zIndex:0,border:{width:0,style:"solid",color:"#fff",radius:0},shadow:{x:0,y:0,b:0,color:"transparent"}}),l=h(null),u=h($(32));c(()=>_.mute,t=>{l.value&&(l.value.muted=t)});const I=A(()=>{var t,a,o,r,f,y,m,v,w;return{position:"absolute",top:e.top+"px",left:e.left+"px",width:e.width+"px",height:e.height+"px",backgroundColor:D((t=e.background)==null?void 0:t.color)||"#000",zIndex:e.zIndex||0,borderColor:((a=e.border)==null?void 0:a.color)||"#fff",borderStyle:((o=e.border)==null?void 0:o.style)||"solid",borderWidth:(((r=e.border)==null?void 0:r.width)||0)+"px",borderRadius:((f=e.border)==null?void 0:f.radius)+"px",boxShadow:"".concat((y=e.shadow)==null?void 0:y.x,"px ").concat((m=e.shadow)==null?void 0:m.y,"px ").concat((v=e.shadow)==null?void 0:v.b,"px ").concat((w=e.shadow)==null?void 0:w.color)}}),E=t=>{var a,o;switch(t){case 1:return{objectFit:"fill",width:e.width+"px",height:e.height+"px"};case 2:return{objectFit:"cover",width:"100%",height:"100%"};default:return{objectFit:"none",width:((a=e.content)==null?void 0:a.width)+"px",height:((o=e.content)==null?void 0:o.height)+"px"}}},k=async t=>{const a="https://cdn.display24.ru/partners/".concat(i.partner,"/").concat(t);return await U(a)};return N(async()=>{e.id=i.id,e.displayCode=i.code,e.layoutId=i.layoutId,await P(e,p,"AudioContainer (layouts)"),await R(e,s,p,"AudioContainer (schedule)"),d=setInterval(()=>{s.value=b(e==null?void 0:e.scheduleData)},1e3)}),z(()=>{d&&clearInterval(d),l.value&&l.value.destroy(!1)}),c(()=>e.content,async t=>{if(!t||!t.filename)return;const a=document.querySelector(".audio-"+u.value);if(!a){console.error("Контейнер для аудио-плеера не найден");return}l.value&&(l.value.destroy(!1),l.value=null);const o=await k(t.filename);l.value=new n({container:a,url:o,autoplay:!1,muted:!1,loop:!0,volume:1,isLive:!1,setting:!1,hotkey:!1,pip:!1,mutex:!1,fullscreen:!1,fullscreenWeb:!1,miniProgressBar:!1,preload:"auto",playsinline:!0,controlsList:"nodownload",controls:[],clickToPlay:!1,show:!1,icons:{state:""},moreVideoAttr:{playsinline:!0,controlsList:"nodownload"}}),l.value.play().catch(r=>{console.warn("Автозапуск заблокирован/ошибка",r)})}),c(s,t=>{const a=l.value;if(!a)return;const o=a.template.$video||a.template.video;if(o)if(t)a.play().catch(r=>{console.warn("Автозапуск заблокирован/ошибка",r)});else try{o.pause(),o.currentTime=0}catch(r){}}),c(()=>e.scheduleData,t=>{s.value=b(t)}),(t,a)=>{var o;return L((x(),g("div",{class:"container",style:C(I.value)},[F("",!0),(x(),g("div",{class:O("audio-"+u.value),style:C(E((o=e.content)==null?void 0:o.mediaMode)),key:u.value},null,6))],4)),[[B,s.value]])}}},H=j(V,[["__scopeId","data-v-2578c914"]]);export{H as default};
