"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("vue"),u=require("hls.js"),d=require("lodash"),J=require("nanoid"),M=require("../../commons/core/datasource/index.js"),O=["poster","autoplay","controls","loop","muted"],_=n.defineComponent({name:"zv-media-m3u8-dynamic"}),k=n.defineComponent({..._,props:{basicOption:{},sources:{},useEvents:{},uuid:{}},emits:["on-video-progress","on-video-play","on-video-pause","on-video-ended","on-video-playing","on-video-timeupdate","on-video-error","on-video-volumechange"],setup(c,{expose:p,emit:E}){const e=c,y=()=>{const o=n.ref(),s=n.ref(""),b=n.ref(J.nanoid()),v=()=>{M.SHJDatasourceV2.parse({tId:e.uuid,sources:e.sources,callback:({data:l})=>{try{if(window.SHJParseEvent(e.useEvents,"dataListener",l),s.value=l[0].data[0].src,s.value)if(u.isSupported()){const r=new u;r.loadSource(s.value),r.attachMedia(o.value),r.on(u.Events.MANIFEST_PARSED,()=>{e.basicOption.autoplay&&o.value.play()})}else o.value.canPlayType("application/vnd.apple.mpegurl")&&(o.value.src=s.value)}catch{window.SHJParseEvent(e.useEvents,"dataListener",null)}}})};return n.onMounted(()=>v()),{key:b,videoRef:o,initM3u8Video:v}},{key:f,videoRef:t,initM3u8Video:a}=y();n.watch(()=>d.cloneDeep(e.basicOption),(o,s)=>{d.isEqual(o,s)||a()},{deep:!0}),n.watch(()=>d.cloneDeep(e.sources),(o,s)=>{d.isEqual(o,s)||a()},{deep:!0});const i=E,m=()=>{i("on-video-progress"),window.SHJParseEvent(e.useEvents,"on-video-progress")},w=()=>{i("on-video-play"),window.SHJParseEvent(e.useEvents,"on-video-play")},P=()=>{i("on-video-pause"),window.SHJParseEvent(e.useEvents,"on-video-pause")},g=()=>{i("on-video-ended"),window.SHJParseEvent(e.useEvents,"on-video-ended")},S=()=>{i("on-video-playing"),window.SHJParseEvent(e.useEvents,"on-video-playing")},h=()=>{i("on-video-timeupdate"),window.SHJParseEvent(e.useEvents,"on-video-timeupdate")},V=()=>{i("on-video-error"),window.SHJParseEvent(e.useEvents,"on-video-error")},H=()=>{i("on-video-volumechange"),window.SHJParseEvent(e.useEvents,"on-video-volumechange")};return p({play:()=>{t.value&&t.value.play()},pause:()=>{t.value&&t.value.pause()},refresh:()=>a(),refreshView:()=>a(),refreshData:()=>a()}),(o,s)=>(n.openBlock(),n.createElementBlock("video",{key:n.unref(f),ref_key:"videoRef",ref:t,class:"zerov-widget",poster:o.basicOption.poster,autoplay:o.basicOption.autoplay,controls:o.basicOption.controls,loop:o.basicOption.loop,muted:o.basicOption.muted,onProgress:m,onPlay:w,onEnded:g,onPlaying:S,onPause:P,onTimeupdate:h,onError:V,onVolumechange:H},null,40,O))}});exports.default=k;
