var u=Object.defineProperty;var l=(r,t,e)=>t in r?u(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t,e)=>l(r,typeof t!="symbol"?t+"":t,e);import{m as g,C as p,f,R as d,j as S}from"./index-DNWTsqTH.js";var _=Object.defineProperty,T=Object.getOwnPropertyDescriptor,c=(r,t,e,m)=>{for(var s=m>1?void 0:m?T(t,e):t,i=r.length-1,o;i>=0;i--)(o=r[i])&&(s=(m?o(t,e,s):o(s))||s);return m&&s&&_(t,e,s),s};let n=class extends g(p){constructor(){super(...arguments);a(this,"cameraImage");a(this,"cameraImageSource","");a(this,"cameraImageSourceUrl",null);a(this,"requestStartTime",performance.now());a(this,"startTime",performance.now());a(this,"time",0);a(this,"requestTime",0);a(this,"timeSmoothing",.6);a(this,"requestTimeSmoothing",.1)}handleImageLoad(){const e=!document.hasFocus()&&this.camera.target_fps_idle||this.camera.target_fps||10,m=performance.now(),s=m-this.startTime;this.time=this.time*this.timeSmoothing+s*(1-this.timeSmoothing),this.startTime=m;const i=1e3/e,o=performance.now()-this.requestStartTime;this.requestTime=this.requestTime*this.requestTimeSmoothing+o*(1-this.requestTimeSmoothing);const h=Math.max(0,i-this.requestTime);this.$nextTick(()=>{setTimeout(this.handleRefresh,h)})}handleRefresh(){if(document.hidden)this.stopPlayback();else{const e=Math.round(1e3/this.time).toString().padStart(2,"0");this.$emit("frames-per-second",e),this.$nextTick(()=>this.updateCameraImageSource())}}updateCameraImageSource(){const e=this.cameraImageSourceUrl;e&&(e.searchParams.set("cacheBust",Date.now().toString()),this.requestStartTime=performance.now(),this.cameraImageSource=e.toString())}startPlayback(){this.cameraImageSourceUrl=this.buildAbsoluteUrl(this.camera.snapshot_url||""),this.updateCameraImageSource();const e=this.buildAbsoluteUrl(this.camera.stream_url||"");e.searchParams.set("cacheBust",Date.now().toString()),this.$emit("raw-camera-url",e.toString())}stopPlayback(){this.cameraImageSourceUrl=null,this.cameraImageSource="",this.cameraImage.src=""}};c([d("streamingElement")],n.prototype,"cameraImage",2);n=c([f({})],n);var I=function(){var t=this,e=t._self._c;return t._self._setupProxy,e("img",{ref:"streamingElement",style:t.cameraStyle,attrs:{src:t.cameraImageSource,crossorigin:t.crossorigin},on:{load:t.handleImageLoad}})},v=[],q=S(n,I,v,!1,null,null);const b=q.exports;export{b as default};
