var d=Object.defineProperty;var f=(m,e,a)=>e in m?d(m,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):m[e]=a;var t=(m,e,a)=>f(m,typeof e!="symbol"?e+"":e,a);import{V as y,f as g,P as h,R as P,W as b,E as l,C}from"./index-DGn1DPCK.js";var v=Object.defineProperty,S=Object.getOwnPropertyDescriptor,i=(m,e,a,c)=>{for(var s=c>1?void 0:c?S(e,a):e,n=m.length-1,o;n>=0;n--)(o=m[n])&&(s=(c?o(e,a,s):o(s))||s);return c&&s&&v(e,a,s),s};let r=class extends y{constructor(){super(...arguments);t(this,"camera");t(this,"crossorigin");t(this,"streamingElement");t(this,"cameraTransformStyle","");t(this,"animating",!1);t(this,"status","disconnected");t(this,"cameraName","");t(this,"cameraNameMenuItems",[]);t(this,"framesPerSecond",-1);t(this,"rawCameraUrl","")}onCamera(){this.stopPlayback(),this.checkPlayback()}get apiUrl(){return this.$typedState.config.apiUrl}get cameraStyle(){return{transform:this.cameraTransformStyle||void 0}}get autoRaiseFrameEvent(){return!0}createTransform(){const e=this.streamingElement,{rotation:a,flip_horizontal:c,flip_vertical:s}=this.camera,n=[],{clientWidth:o,clientHeight:u}=e,p=a===0||a===180||u===0||o===0?1:u<o?u/o:o/u;return(p!==1||c)&&n.push(`scaleX(${c?-p:p})`),(p!==1||s)&&n.push(`scaleY(${s?-p:p})`),a!==0&&n.push(`rotate(${a}deg`),n.join(" ")}updateCameraTransformStyle(){requestAnimationFrame(()=>{this.animating&&(this.streamingElement&&(this.cameraTransformStyle=this.createTransform(),this.autoRaiseFrameEvent&&this.$emit("frame",this.streamingElement)),this.updateCameraTransformStyle())})}created(){this.animating=!0,this.updateCameraTransformStyle()}mounted(){document.addEventListener("visibilitychange",this.checkPlayback,!1),this.checkPlayback()}beforeDestroy(){this.animating=!1,document.removeEventListener("visibilitychange",this.checkPlayback),this.stopPlayback()}checkPlayback(){document.hidden?this.stopPlayback():this.startPlayback()}buildAbsoluteUrl(e){const{origin:a}=new URL(document.URL);return new URL(e,a)}updateStatus(e){this.status=e}updateCameraName(e){this.cameraName=e}updateCameraNameMenuItems(e){this.cameraNameMenuItems=e}updateFramesPerSecond(e){this.framesPerSecond=e}updateRawCameraUrl(e){this.rawCameraUrl=e}startPlayback(){}stopPlayback(){}menuItemClick(e){g.debug("Menu item click",e)}};i([h({type:Object,required:!0})],r.prototype,"camera",2);i([h({type:String})],r.prototype,"crossorigin",2);i([P("streamingElement")],r.prototype,"streamingElement",2);i([b("camera")],r.prototype,"onCamera",1);i([l("update:status")],r.prototype,"updateStatus",1);i([l("update:camera-name")],r.prototype,"updateCameraName",1);i([l("update:camera-name-menu-items")],r.prototype,"updateCameraNameMenuItems",1);i([l("update:frames-per-second")],r.prototype,"updateFramesPerSecond",1);i([l("update:raw-camera-url")],r.prototype,"updateRawCameraUrl",1);r=i([C],r);export{r as C};
