(function(h,t){"use strict";class m{constructor(){}}class c{constructor(){}}class n extends t.EventDispatcher{constructor(e){super(),this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this)}static get instance(){return n._instance=n._instance||new n(0),n._instance}on(e,i,a,o=null){return super.on(e,i,a,o),t.ILaya.Browser.window.addEventListener("devicemotion",this.onDeviceOrientationChange),this}off(e,i,a,o=!1){return this.hasListener(e)||t.ILaya.Browser.window.removeEventListener("devicemotion",this.onDeviceOrientationChange),super.off(e,i,a,o)}onDeviceOrientationChange(e){var i=e.interval;n.acceleration.x=e.acceleration.x,n.acceleration.y=e.acceleration.y,n.acceleration.z=e.acceleration.z,n.accelerationIncludingGravity.x=e.accelerationIncludingGravity.x,n.accelerationIncludingGravity.y=e.accelerationIncludingGravity.y,n.accelerationIncludingGravity.z=e.accelerationIncludingGravity.z,n.rotationRate.alpha=e.rotationRate.gamma*-1,n.rotationRate.beta=e.rotationRate.alpha*-1,n.rotationRate.gamma=e.rotationRate.beta,t.ILaya.Browser.onAndroid?(t.ILaya.Browser.userAgent.indexOf("Chrome")>-1&&(n.rotationRate.alpha*=180/Math.PI,n.rotationRate.beta*=180/Math.PI,n.rotationRate.gamma*=180/Math.PI),n.acceleration.x*=-1,n.accelerationIncludingGravity.x*=-1):t.ILaya.Browser.onIOS&&(n.acceleration.y*=-1,n.acceleration.z*=-1,n.accelerationIncludingGravity.y*=-1,n.accelerationIncludingGravity.z*=-1,i*=1e3),this.event(t.Event.CHANGE,[n.acceleration,n.accelerationIncludingGravity,n.rotationRate,i])}static getTransformedAcceleration(e){n.transformedAcceleration=n.transformedAcceleration||new m,n.transformedAcceleration.z=e.z,t.ILaya.Browser.window.orientation==90?(n.transformedAcceleration.x=e.y,n.transformedAcceleration.y=-e.x):t.ILaya.Browser.window.orientation==-90?(n.transformedAcceleration.x=-e.y,n.transformedAcceleration.y=e.x):t.ILaya.Browser.window.orientation?t.ILaya.Browser.window.orientation==180&&(n.transformedAcceleration.x=-e.x,n.transformedAcceleration.y=-e.y):(n.transformedAcceleration.x=e.x,n.transformedAcceleration.y=e.y);var i;return t.ILaya.stage.canvasDegree==-90?(i=n.transformedAcceleration.x,n.transformedAcceleration.x=-n.transformedAcceleration.y,n.transformedAcceleration.y=i):t.ILaya.stage.canvasDegree==90&&(i=n.transformedAcceleration.x,n.transformedAcceleration.x=n.transformedAcceleration.y,n.transformedAcceleration.y=-i),n.transformedAcceleration}}n.acceleration=new m,n.accelerationIncludingGravity=new m,n.rotationRate=new c;class l extends t.EventDispatcher{constructor(){super()}static get instance(){return l._instance=l._instance||new l,l._instance}start(e,i){this.throushold=e,this.shakeInterval=i,this.lastX=this.lastY=this.lastZ=NaN,n.instance.on(t.Event.CHANGE,this,this.onShake)}stop(){n.instance.off(t.Event.CHANGE,this,this.onShake)}onShake(e,i,a,o){if(isNaN(this.lastX)){this.lastX=i.x,this.lastY=i.y,this.lastZ=i.z,this.lastMillSecond=t.ILaya.Browser.now();return}var E=Math.abs(this.lastX-i.x),p=Math.abs(this.lastY-i.y),w=Math.abs(this.lastZ-i.z);if(this.isShaked(E,p,w)){var T=t.ILaya.Browser.now()-this.lastMillSecond;T>this.shakeInterval&&(this.event(t.Event.CHANGE),this.lastMillSecond=t.ILaya.Browser.now())}this.lastX=i.x,this.lastY=i.y,this.lastZ=i.z}isShaked(e,i,a){return e>this.throushold&&i>this.throushold||e>this.throushold&&a>this.throushold||i>this.throushold&&a>this.throushold}}class y{setPosition(e){this.pos=e,this.coords=e.coords}get latitude(){return this.coords.latitude}get longitude(){return this.coords.longitude}get altitude(){return this.coords.altitude}get accuracy(){return this.coords.accuracy}get altitudeAccuracy(){return this.coords.altitudeAccuracy}get heading(){return this.coords.heading}get speed(){return this.coords.speed}get timestamp(){return this.pos.timestamp}}class r{constructor(){}static getCurrentPosition(e,i=null){r.navigator.geolocation.getCurrentPosition(function(a){r.position.setPosition(a),e.runWith(r.position)},function(a){i.runWith(a)},{enableHighAccuracy:r.enableHighAccuracy,timeout:r.timeout,maximumAge:r.maximumAge})}static watchPosition(e,i){return r.navigator.geolocation.watchPosition(function(a){r.position.setPosition(a),e.runWith(r.position)},function(a){i.runWith(a)},{enableHighAccuracy:r.enableHighAccuracy,timeout:r.timeout,maximumAge:r.maximumAge})}static clearWatch(e){r.navigator.geolocation.clearWatch(e)}}r.navigator=navigator,r.position=new y,r.PERMISSION_DENIED=1,r.POSITION_UNAVAILABLE=2,r.TIMEOUT=3,r.supported=!!r.navigator.geolocation,r.enableHighAccuracy=!1,r.timeout=1e10,r.maximumAge=0;class u extends t.Bitmap{constructor(){super(),this._w=0,this._h=0,this._width=1,this._height=1,this.createDomElement()}createDomElement(){this._source=this.video=t.ILaya.Browser.createElement("video"),this.video.setAttribute("crossorigin","Anonymous");var e=this.video.style;e.position="absolute",e.top="0px",e.left="0px",this.video.addEventListener("loadedmetadata",()=>{this._w=this.video.videoWidth,this._h=this.video.videoHeight})}setSource(e,i){for(;this.video.childElementCount;)this.video.firstChild.remove();i&1&&this.appendSource(e,"video/mp4"),i&2&&this.appendSource(e+".ogg","video/ogg")}appendSource(e,i){var a=t.ILaya.Browser.createElement("source");a.src=e,a.type=i,this.video.appendChild(a)}getVideo(){return this.video}_getSource(){return this._source}destroy(){super.destroy();var e=t.ILaya.Render.isConchApp;e&&this.video._destroy()}}u.create=function(){return new u};class f{constructor(){}static supported(){return!!t.ILaya.Browser.window.navigator.getUserMedia}static getMedia(e,i,a){t.ILaya.Browser.window.navigator.getUserMedia&&t.ILaya.Browser.window.navigator.getUserMedia(e,function(o){i.runWith(t.ILaya.Browser.window.URL.createObjectURL(o))},function(o){a.runWith(o)})}}class v extends u{constructor(){super();var e=t.LayaGL.instance;this.gl=t.ILaya.Render.isConchApp?window.LayaGLContext.instance:t.WebGLContext.mainContext,this._source=this.gl.createTexture(),t.WebGLContext.bindTexture(this.gl,e.TEXTURE_2D,this._source),this.gl.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),this.gl.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),this.gl.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),this.gl.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),t.WebGLContext.bindTexture(this.gl,e.TEXTURE_2D,null)}updateTexture(){var e=t.LayaGL.instance;t.WebGLContext.bindTexture(this.gl,e.TEXTURE_2D,this._source),this.gl.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),this.gl.texImage2D(e.TEXTURE_2D,0,e.RGB,e.RGB,e.UNSIGNED_BYTE,this.video),this.gl.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),v.curBindSource=this._source}get _glTexture(){return this._source}destroy(){this._source&&(this.gl=t.ILaya.Render.isConchApp?window.LayaGLContext.instance:t.WebGLContext.mainContext,this.gl&&(v.curBindSource==this._source&&(t.WebGLContext.bindTexture(this.gl,this.gl.TEXTURE_2D,null),v.curBindSource=null),this.gl.deleteTexture(this._source))),super.destroy()}}class s extends t.Sprite{constructor(e=320,i=240){super(),this.htmlVideo=new v,this.videoElement=this.htmlVideo.getVideo(),this.videoElement.layaTarget=this,this.internalTexture=new t.Texture(this.htmlVideo),this.videoElement.addEventListener("abort",s.onAbort),this.videoElement.addEventListener("canplay",s.onCanplay),this.videoElement.addEventListener("canplaythrough",s.onCanplaythrough),this.videoElement.addEventListener("durationchange",s.onDurationchange),this.videoElement.addEventListener("emptied",s.onEmptied),this.videoElement.addEventListener("error",s.onError),this.videoElement.addEventListener("loadeddata",s.onLoadeddata),this.videoElement.addEventListener("loadedmetadata",s.onLoadedmetadata),this.videoElement.addEventListener("loadstart",s.onLoadstart),this.videoElement.addEventListener("pause",s.onPause),this.videoElement.addEventListener("play",s.onPlay),this.videoElement.addEventListener("playing",s.onPlaying),this.videoElement.addEventListener("progress",s.onProgress),this.videoElement.addEventListener("ratechange",s.onRatechange),this.videoElement.addEventListener("seeked",s.onSeeked),this.videoElement.addEventListener("seeking",s.onSeeking),this.videoElement.addEventListener("stalled",s.onStalled),this.videoElement.addEventListener("suspend",s.onSuspend),this.videoElement.addEventListener("timeupdate",s.onTimeupdate),this.videoElement.addEventListener("volumechange",s.onVolumechange),this.videoElement.addEventListener("waiting",s.onWaiting),this.videoElement.addEventListener("ended",this.onPlayComplete.bind(this)),this.size(e,i),t.ILaya.Browser.onMobile&&(this.videoElement["x5-playsInline"]=!0,this.videoElement["x5-playsinline"]=!0,this.videoElement.x5PlaysInline=!0,this.videoElement.playsInline=!0,this.videoElement["webkit-playsInline"]=!0,this.videoElement["webkit-playsinline"]=!0,this.videoElement.webkitPlaysInline=!0,this.videoElement.playsinline=!0,this.videoElement.style.playsInline=!0,this.videoElement.crossOrigin="anonymous",this.videoElement.setAttribute("crossorigin","anonymous"),this.videoElement.setAttribute("playsinline","true"),this.videoElement.setAttribute("x5-playsinline","true"),this.videoElement.setAttribute("webkit-playsinline","true"),this.videoElement.autoplay=!0,this._clickhandle=this.onDocumentClick.bind(this),t.ILaya.Browser.document.addEventListener("touchend",this._clickhandle))}static onAbort(e){e.target.layaTarget.event("abort")}static onCanplay(e){e.target.layaTarget.event("canplay")}static onCanplaythrough(e){e.target.layaTarget.event("canplaythrough")}static onDurationchange(e){e.target.layaTarget.event("durationchange")}static onEmptied(e){e.target.layaTarget.event("emptied")}static onError(e){e.target.layaTarget.event("error")}static onLoadeddata(e){e.target.layaTarget.event("loadeddata")}static onLoadedmetadata(e){e.target.layaTarget.event("loadedmetadata")}static onLoadstart(e){e.target.layaTarget.event("loadstart")}static onPause(e){e.target.layaTarget.event("pause")}static onPlay(e){e.target.layaTarget.event("play")}static onPlaying(e){e.target.layaTarget.event("playing")}static onProgress(e){e.target.layaTarget.event("progress")}static onRatechange(e){e.target.layaTarget.event("ratechange")}static onSeeked(e){e.target.layaTarget.event("seeked")}static onSeeking(e){e.target.layaTarget.event("seeking")}static onStalled(e){e.target.layaTarget.event("stalled")}static onSuspend(e){e.target.layaTarget.event("suspend")}static onTimeupdate(e){e.target.layaTarget.event("timeupdate")}static onVolumechange(e){e.target.layaTarget.event("volumechange")}static onWaiting(e){e.target.layaTarget.event("waiting")}onPlayComplete(e){(!t.ILaya.Render.isConchApp||!this.videoElement||!this.videoElement.loop)&&t.ILaya.timer.clear(this,this.renderCanvas),this.event("ended")}load(e){e.indexOf("blob:")==0?this.videoElement.src=e:this.htmlVideo.setSource(e,1)}play(){this.videoElement.play(),t.ILaya.timer.frameLoop(1,this,this.renderCanvas)}pause(){this.videoElement.pause(),t.ILaya.timer.clear(this,this.renderCanvas)}reload(){this.videoElement.load()}canPlayType(e){var i;switch(e){case 1:i="video/mp4";break;case 2:i="video/ogg";break;case 8:i="video/webm";break}return this.videoElement.canPlayType(i)}renderCanvas(){this.readyState!==0&&(this.htmlVideo.updateTexture(),this.graphics.clear(),this.graphics.drawTexture(this.internalTexture,0,0,this.width,this.height))}onDocumentClick(){!this.videoElement||this.videoElement!=0||(t.Browser.onIOS?this.videoElement.load():(this.videoElement.play(),this.videoElement.pause()),t.ILaya.Browser.document.removeEventListener("touchend",this._clickhandle))}get buffered(){return this.videoElement.buffered}get currentSrc(){return this.videoElement.currentSrc}get currentTime(){return this.videoElement.currentTime}set currentTime(e){this.videoElement.currentTime=e,this.renderCanvas()}set volume(e){this.videoElement.volume=e}get volume(){return this.videoElement.volume}get readyState(){return this.videoElement.readyState}get videoWidth(){return this.videoElement.videoWidth}get videoHeight(){return this.videoElement.videoHeight}get duration(){return this.videoElement.duration}get ended(){return this.videoElement.ended}get error(){return this.videoElement.error}get loop(){return this.videoElement.loop}set loop(e){this.videoElement.loop=e}set x(e){if(super.x=e,t.ILaya.Render.isConchApp){var i=t.ILaya.Utils.getTransformRelativeToWindow(this,0,0);this.videoElement.style.left=i.x}}get x(){return super.x}set y(e){if(super.y=e,t.ILaya.Render.isConchApp){var i=t.ILaya.Utils.getTransformRelativeToWindow(this,0,0);this.videoElement.style.top=i.y}}get y(){return super.y}get playbackRate(){return this.videoElement.playbackRate}set playbackRate(e){this.videoElement.playbackRate=e}get muted(){return this.videoElement.muted}set muted(e){this.videoElement.muted=e}get paused(){return this.videoElement.paused}get preload(){return this.videoElement.preload}set preload(e){this.videoElement.preload=e}get seekable(){return this.videoElement.seekable}get seeking(){return this.videoElement.seeking}size(e,i){if(super.size(e,i),t.ILaya.Render.isConchApp){var a=t.ILaya.Utils.getTransformRelativeToWindow(this,0,0);this.videoElement.width=e*a.scaleX}else this.videoElement.width=e/t.ILaya.Browser.pixelRatio,this.videoElement.height=i/t.Browser.pixelRatio;return this.paused&&this.renderCanvas(),this}set width(e){if(t.ILaya.Render.isConchApp){var i=t.ILaya.Utils.getTransformRelativeToWindow(this,0,0);this.videoElement.width=e*i.scaleX}else this.videoElement.width=this.width/t.ILaya.Browser.pixelRatio;super.width=e,this.paused&&this.renderCanvas()}get width(){return super.width}set height(e){if(t.ILaya.Render.isConchApp){var i=t.ILaya.Utils.getTransformRelativeToWindow(this,0,0);this.videoElement.height=e*i.scaleY}else this.videoElement.height=this.height/t.ILaya.Browser.pixelRatio;super.height=e}get height(){return super.height}destroy(e=!0){super.destroy(e),this.videoElement.removeEventListener("abort",s.onAbort),this.videoElement.removeEventListener("canplay",s.onCanplay),this.videoElement.removeEventListener("canplaythrough",s.onCanplaythrough),this.videoElement.removeEventListener("durationchange",s.onDurationchange),this.videoElement.removeEventListener("emptied",s.onEmptied),this.videoElement.removeEventListener("error",s.onError),this.videoElement.removeEventListener("loadeddata",s.onLoadeddata),this.videoElement.removeEventListener("loadedmetadata",s.onLoadedmetadata),this.videoElement.removeEventListener("loadstart",s.onLoadstart),this.videoElement.removeEventListener("pause",s.onPause),this.videoElement.removeEventListener("play",s.onPlay),this.videoElement.removeEventListener("playing",s.onPlaying),this.videoElement.removeEventListener("progress",s.onProgress),this.videoElement.removeEventListener("ratechange",s.onRatechange),this.videoElement.removeEventListener("seeked",s.onSeeked),this.videoElement.removeEventListener("seeking",s.onSeeking),this.videoElement.removeEventListener("stalled",s.onStalled),this.videoElement.removeEventListener("suspend",s.onSuspend),this.videoElement.removeEventListener("timeupdate",s.onTimeupdate),this.videoElement.removeEventListener("volumechange",s.onVolumechange),this.videoElement.removeEventListener("waiting",s.onWaiting),this.videoElement.removeEventListener("ended",this.onPlayComplete),this.pause(),this.videoElement.layaTarget=null,this.videoElement=null,this.htmlVideo.destroy()}syncVideoPosition(){var e=t.ILaya.stage,i;i=t.ILaya.Utils.getGlobalPosAndScale(this);var a=e._canvasTransform.a,o=e._canvasTransform.d,E=i.x*e.clientScaleX*a+e.offset.x,p=i.y*e.clientScaleY*o+e.offset.y;this.videoElement.style.left=E+"px",this.videoElement.style.top=p+"px",this.videoElement.width=this.width/t.ILaya.Browser.pixelRatio,this.videoElement.height=this.height/t.ILaya.Browser.pixelRatio}}s.MP4=1,s.OGG=2,s.CAMERA=4,s.WEBM=8,s.SUPPORT_PROBABLY="probably",s.SUPPORT_MAYBY="maybe",s.SUPPORT_NO="";class d extends t.EventDispatcher{constructor(e){super(),this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this)}static get instance(){return d._instance=d._instance||new d(0),d._instance}on(e,i,a,o=null){return super.on(e,i,a,o),t.ILaya.Browser.window.addEventListener("deviceorientation",this.onDeviceOrientationChange),this}off(e,i,a,o=!1){return this.hasListener(e)||t.ILaya.Browser.window.removeEventListener("deviceorientation",this.onDeviceOrientationChange),super.off(e,i,a,o)}onDeviceOrientationChange(e){d.info.alpha=e.alpha,d.info.beta=e.beta,d.info.gamma=e.gamma,e.webkitCompassHeading&&(d.info.alpha=e.webkitCompassHeading*-1,d.info.compassAccuracy=e.webkitCompassAccuracy),this.event(t.Event.CHANGE,[e.absolute,d.info])}}d.info=new c,h.AccelerationInfo=m,h.Accelerator=n,h.Geolocation=r,h.GeolocationInfo=y,h.Gyroscope=d,h.HtmlVideo=u,h.Media=f,h.RotationInfo=c,h.Shake=l,h.Video=s,h.WebGLVideo=v})(window.Laya=window.Laya||{},Laya);