import{r as N,a as j,c as m,n as I,o as L,b as i,d as T,w as J,e as $,v as k,f as w,g,l as z,u as c,p as B,q as M,h as E,i as v,s as S,j as _}from"./index-DNcc_XYj.js";import{p as F}from"./purify.es-DOXEtq--.js";import{_ as R}from"./_plugin-vue_export-helper-DlAUqK2U.js";const U=["innerHTML"],q={__name:"HtmlContainer",props:{id:String,layoutId:String,partner:String},setup(b){const d="https://display24.ru",r=N(!1);let u=null;const h=b;let e=j({id:null,layoutId:null,content:[]});const C=m(()=>{var n,l,t,a,o,s,p,f,y;return{top:e.top+"px",left:e.left+"px",width:e.width+"px",height:e.height+"px",backgroundColor:I((n=e.background)==null?void 0:n.color)||"#000",zIndex:e.zIndex||0,borderColor:((l=e.border)==null?void 0:l.color)||"#fff",borderStyle:((t=e.border)==null?void 0:t.style)||"solid",borderWidth:(((a=e.border)==null?void 0:a.width)||0)+"px",borderRadius:((o=e.border)==null?void 0:o.radius)+"px",boxShadow:"".concat((s=e.shadow)==null?void 0:s.x,"px ").concat((p=e.shadow)==null?void 0:p.y,"px ").concat((f=e.shadow)==null?void 0:f.b,"px ").concat((y=e.shadow)==null?void 0:y.color)}}),x=n=>F.sanitize(n),O=m(()=>{if(!e.content)return"";switch(e.content.mediaMode){case 1:return"stretch";case 2:return"crop";default:return"original"}});async function H(){var n;try{const t=(await v.get("".concat(d,"/api/v1/player/layouts/").concat(e.layoutId,"?v=")+Date.now(),{headers:{"Content-Type":"application/json"},timeout:5e3})).data;if(!t||typeof t!="object"||t.online!==!0)throw new Error("OFFLINE_OR_HTML_STUB_200");if((t==null?void 0:t.code)==200){let a=((n=t.data)==null?void 0:n[0])||{};a=JSON.parse(JSON.stringify(a));let o=a==null?void 0:a.content.find(s=>s.id==e.id);o&&Object.assign(e,o),S("layouts",e.layoutId,a).then(s=>s&&console.info("HtmlContainer (layouts): Сохранение данных в кэш")).catch(console.error)}else console.warn("HtmlContainer (layouts): Нет данных")}catch(l){let t=await _("layouts",e.layoutId)||{};if(t=JSON.parse(JSON.stringify(t)),t){let a=t==null?void 0:t.content.find(o=>o.id==e.id);return a&&Object.assign(e,a),console.warn("HtmlContainer (layouts): Данные загружены из кэша"),!0}else return console.error("HtmlContainer (layouts): Нет данных в кэше."),!1}}async function D(){var n;if(e.schedule)try{const t=(await v.get("".concat(d,"/api/v1/player/schedules/").concat(e.schedule,"?v=")+Date.now(),{headers:{"Content-Type":"application/json"},timeout:5e3})).data;if(!t||typeof t!="object"||t.online!==!0)throw new Error("OFFLINE_OR_HTML_STUB_200");if((t==null?void 0:t.code)==200){let a=((n=t.data)==null?void 0:n[0])||{};a=JSON.parse(JSON.stringify(a));let o=(a==null?void 0:a.content)||null;Object.assign(e,{scheduleData:o}),r.value=i(e==null?void 0:e.scheduleData),S("schedule",e.schedule,a).then(s=>s&&console.info("HtmlContainer (schedules): Сохранение данных в кэш")).catch(console.error)}else console.warn("HtmlContainer (schedules): Нет данных")}catch(l){let t=await _("schedule",e.schedule)||{};if(t=JSON.parse(JSON.stringify(t)),t){let a=(t==null?void 0:t.content)||null;return Object.assign(e,{scheduleData:a}),r.value=i(e==null?void 0:e.scheduleData),console.warn("HtmlContainer (schedules): Данные загружены из кэша"),!0}else return console.error("HtmlContainer (schedules): Нет данных в кэше"),!1}}return L(async()=>{e.id=h.id,e.layoutId=h.layoutId,await H(),await D(),u=setInterval(()=>{r.value=i(e==null?void 0:e.scheduleData)},1e3)}),T(()=>{u&&clearInterval(u)}),J(()=>e.scheduleData,n=>{r.value=i(n)}),(n,l)=>{var t,a,o;return $((g(),w("div",{class:"container",style:E(C.value)},[c(e).content&&((a=(t=c(e).content)==null?void 0:t.html)!=null&&a.length)?(g(),w("div",{key:0,class:B(["content",O.value]),innerHTML:x(c(M)((o=c(e).content)==null?void 0:o.html))},null,10,U)):z("",!0)],4)),[[k,r.value]])}}},G=R(q,[["__scopeId","data-v-80edc668"]]);export{G as default};
