import{cL as b,M as x}from"./index.17037962789732.js";import{a as o}from"./dayjs.min.1703796278973.js";import{d as A,k as c,m as h,o as T,x as u,z as p,F as C,h as Y,A as E,E as P,u as g,G as $,H as z}from"./vue.1703796278973.js";import{_ as O}from"./_plugin-vue_export-helper.1703796278973.js";import"./index.17037962789733.js";import"./isArray.1703796278973.js";import"./editor.api.1703796278973.js";import"./preload-helper.1703796278973.js";import"./monaco.contribution.1703796278973.js";const N=m=>($("data-v-d04fc00a"),m=m(),z(),m),j={class:"time-line-warp"},F={class:"time-line-clock"},G={class:"time-line-progress"},R=["onClick"],V=N(()=>p("div",{id:"btn",class:"time-line-btn"},null,-1)),W={id:"time",class:"time-line"},X=A({__name:"timeLine",props:{onChange:null,data:null,dateTime:null,type:null,playStatus:null,playTime:null,server:null,localToServer:null,getPlayList:null},setup(m,{expose:k}){const a=m,l=c(new Date(o(a.dateTime).startOf("day").format("YYYY-MM-DD HH:mm:ss")).getTime()),D=c(new Date(o(a.dateTime).endOf("day").format("YYYY-MM-DD HH:mm:ss")).getTime()),v=c([]),y=c(0),_=c(),f=b(_),L=i=>{const e=document.getElementById("btn"),t=document.getElementById("time");e&&t&&f.width&&(e.style.visibility="visible",e.style.left=`${i*f.width.value}px`,t.style.visibility="visible",t.style.left=`${i*f.width.value-15}px`)};h(()=>a.dateTime,i=>{l.value=new Date(o(i).startOf("day").format("YYYY-MM-DD HH:mm:ss")).getTime()});const d=(i,e,t,n)=>{y.value=i,a.onChange({startTime:o(i),endTime:o(e),deviceId:t,channelId:n})},I=i=>{const e=a.data.find(t=>(t.startTime||t.mediaStartTime)===i);if(e){const t=e.startTime||e.mediaStartTime,n=e.endTime||e.mediaEndTime,s=a.type==="local"?e.deviceId:e.id;d(t,n,s,e.channelId)}};I(0);const S=()=>{if(y.value){const i=a.data.findIndex(e=>(e.startTime||e.mediaStartTime)===y.value);if(i!==a.data.length-1){const e=a.data[i+1],t=e.startTime||e.mediaStartTime,n=e.endTime||e.mediaEndTime,s=a.type==="local"?e.deviceId:e.id;d(t,n,s,e.channelId)}}};S(),h(()=>a.data,i=>{const{data:e,localToServer:t,type:n}=a;if(e&&Array.isArray(e)&&e.length>0){if(v.value=[...e],n==="local")d(e[0].startTime,e[0].endTime,e[0].deviceId,e[0].channelId);else if(n==="cloud")if(t&&Object.keys(t).length>0){const s=e.find(r=>r.mediaEndTime<=t.endTime&&r.mediaStartTime>=t.startTime);s?d(s.mediaStartTime,s.mediaEndTime,s.id,s.channelId):(a.onChange(void 0),x.error("没有可播放的视频资源"))}else d(e[0].mediaStartTime,e[0].mediaEndTime,e[0].id,e[0].channelId)}else t&&t.startTime?(a.onChange(void 0),x.error("没有可播放的视频资源"),v.value=[]):(v.value=[],a.onChange(void 0))});const H=(i,e)=>{const t=i-l.value>0?i-l.value:0,n=f.width.value,s=(e-i)/(24*36e5)*n;return{left:`${t/(24*36e5)*n}px`,width:`${s<1?1:s}px`}},w=()=>{a.playTime&&a.playTime>=l.value&&a.playTime<=D.value&&a.data&&a.data.length&&L((a.playTime-l.value)/36e5/24)};h(()=>a.playTime,()=>{w()}),h(()=>l.value,()=>{w()});const B=(i,e)=>{var n;const t=(n=_.value)==null?void 0:n.getBoundingClientRect();if(t&&e.endTime){const r=(i.clientX-t.x)/t.width*24*36e5+l.value,M=r<e.startTime?e.startTime:r;d(M,e.endTime,e.deviceId,e.channelId)}};return k({playByStartTime:I,onNextPlay:S}),(i,e)=>(T(),u("div",j,[p("div",F,[(T(!0),u(C,null,Y(Array.from(Array(25),(t,n)=>n),t=>(T(),u("div",{key:t,style:{width:"12px"}},E(t),1))),128))]),p("div",{class:"time-line-content",ref_key:"LineContent",ref:_},[p("div",G,[(T(!0),u(C,null,Y(g(v),(t,n)=>(T(),u("div",{key:`time_${n}`,onClick:s=>B(s,t),style:P(H(t.startTime||t.mediaStartTime,t.endTime||t.mediaEndTime))},null,12,R))),128))]),V,p("div",W,E(g(o)(g(y)||0).format("HH:mm:ss")),1)],512)]))}});const ie=O(X,[["__scopeId","data-v-d04fc00a"]]);export{ie as default};
