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