window.wxMiniGame=function(e,t){"use strict";class i{static isLocalNativeFile(e){for(var t=0,i=l.nativefiles.length;t=52428800&&(t.size>l.minClearSize&&(l.minClearSize=t.size),i.onClearCacheRes()),i.deleteFile(e,n,a,o,t.size)},fail:function(e){null!=a&&a.runWith([1,e])}}):null!=a&&a.runWith([0]):i.fs.getFileInfo({filePath:e,success:function(t){s&&f+4194304+t.size>=52428800&&(t.size>l.minClearSize&&(l.minClearSize=t.size),i.onClearCacheRes()),i.fs.copyFile({srcPath:e,destPath:h,success:function(e){i.onSaveFile(n,d,!0,o,a,t.size)},fail:function(e){null!=a&&a.runWith([1,e])}})},fail:function(e){null!=a&&a.runWith([1,e])}})}static onClearCacheRes(){var e=l.minClearSize,t=[];for(var n in i.filesListObj)"fileUsedSize"!=n&&t.push(i.filesListObj[n]);i.sortOn(t,"times",i.NUMERIC);for(var a=0,o=1,s=t.length;o=e)break;a+=r.size,i.deleteFile("",r.readyUrl)}}static sortOn(e,t,n=0){return n==i.NUMERIC?e.sort((function(e,i){return e[t]-i[t]})):n==(i.NUMERIC|i.DESCENDING)?e.sort((function(e,i){return i[t]-e[t]})):e.sort((function(e,i){return e[t]-i[t]}))}static getFileNativePath(e){return i.fileNativeDir+"/"+e}static deleteFile(e,t="",n=null,a="",o=0){var s=i.getFileInfo(t),r=i.getFileNativePath(s.md5),l=""!=e;i.onSaveFile(t,e,l,a,n,o),i.fs.unlink({filePath:r,success:function(t){if(""!=e){var a=i.getFileNativePath(e);i.fs.copyFile({srcPath:e,destPath:a,success:function(e){},fail:function(e){null!=n&&n.runWith([1,e])}})}},fail:function(e){}})}static deleteAll(){var e=[];for(var t in i.filesListObj)"fileUsedSize"!=t&&e.push(i.filesListObj[t]);for(var n=1,a=e.length;n0&&this.loops--,this.startTime=0,this.play()}play(){this.isStopped=!1,t.SoundManager.addChannel(this),this._audio.play()}set startTime(e){this._audio&&(this._audio.startTime=e)}set autoplay(e){this._audio.autoplay=e}get autoplay(){return this._audio.autoplay}get position(){return this._audio?this._audio.currentTime:0}get duration(){return this._audio?this._audio.duration:0}stop(){this.isStopped=!0,t.SoundManager.removeChannel(this),this.completeHandler=null,this._audio&&(this._audio.stop(),this.loop||(this._audio.offEnded(null),this._miniSound.dispose(),this._audio=null,this._miniSound=null,this._onEnd=null))}pause(){this.isStopped=!0,this._audio.pause()}get loop(){return this._audio.loop}set loop(e){this._audio.loop=e}resume(){this._audio&&(this.isStopped=!1,t.SoundManager.addChannel(this),this._audio.play())}set volume(e){this._audio&&(this._audio.volume=e)}get volume(){return this._audio?this._audio.volume:1}}class a extends t.EventDispatcher{constructor(){super(),this.loaded=!1}static _createSound(){return a._id++,l.window.wx.createInnerAudioContext()}load(e){if(a._musicAudio||(a._musicAudio=a._createSound()),i.isLocalNativeFile(e)){if(-1!=e.indexOf("http://")||-1!=e.indexOf("https://"))if(""!=i.loadPath)e=e.split(i.loadPath)[1];else{var n=""!=t.URL.rootPath?t.URL.rootPath:t.URL._basePath;""!=n&&(e=e.split(n)[1])}}else e=t.URL.formatURL(e);if(this.url=e,this.readyUrl=e,a._audioCache[this.readyUrl])this.event(t.Event.COMPLETE);else if(l.autoCacheFile&&i.getFileInfo(e))this.onDownLoadCallBack(e,0);else if(l.autoCacheFile)if(i.isLocalNativeFile(e)){var o=e;if(""!=(n=""!=t.URL.rootPath?t.URL.rootPath:t.URL._basePath)&&(e=e.split(n)[1]),e||(e=o),l.subNativeFiles&&0==l.subNativeheads.length)for(var s in l.subNativeFiles){var r=l.subNativeFiles[s];l.subNativeheads=l.subNativeheads.concat(r);for(var d=0;d=0?"/":"\\",o=e.lastIndexOf(a),s=o>=0?e.substr(0,o+1):"",r=0,d=n.length;r\s+<");try{t=(new l.window.Parser.DOMParser).parseFromString(e,"text/xml")}catch(e){throw"需要引入xml解析库文件"}return t},l.idx=1;class d extends t.EventDispatcher{constructor(){super()}static __init__(){try{var e;if(!(e=t.Accelerator))return;e.prototype.on=d.prototype.on,e.prototype.off=d.prototype.off}catch(e){}}static startListen(e){if(d._callBack=e,!d._isListening){d._isListening=!0;try{l.window.wx.onAccelerometerChange(d.onAccelerometerChange)}catch(e){}}}static stopListen(){d._isListening=!1;try{l.window.wx.stopAccelerometer({})}catch(e){}}static onAccelerometerChange(e){var t;(t={}).acceleration=e,t.accelerationIncludingGravity=e,t.rotationRate={},null!=d._callBack&&d._callBack(t)}on(e,t,i,n=null){return super.on(e,t,i,n),d.startListen(this.onDeviceOrientationChange),this}off(e,t,i,n=!1){return this.hasListener(e)||d.stopListen(),super.off(e,t,i,n)}}d._isListening=!1;class u{constructor(){}static __init__(){l.window.navigator.geolocation.getCurrentPosition=u.getCurrentPosition,l.window.navigator.geolocation.watchPosition=u.watchPosition,l.window.navigator.geolocation.clearWatch=u.clearWatch}static getCurrentPosition(e=null,t=null,i=null){var n;(n={}).success=function(t){null!=e&&e(t)},n.fail=t,l.window.wx.getLocation(n)}static watchPosition(e=null,i=null,n=null){var a;return u._curID++,(a={}).success=e,a.error=i,u._watchDic[u._curID]=a,t.Laya.systemTimer.loop(1e3,null,u._myLoop),u._curID}static clearWatch(e){delete u._watchDic[e],u._hasWatch()||t.Laya.systemTimer.clear(null,u._myLoop)}static _hasWatch(){var e;for(e in u._watchDic)if(u._watchDic[e])return!0;return!1}static _myLoop(){u.getCurrentPosition(u._mySuccess,u._myError)}static _mySuccess(e){var i,n={};for(i in n.coords=e,n.timestamp=t.Browser.now(),u._watchDic)u._watchDic[i].success&&u._watchDic[i].success(n)}static _myError(e){var t;for(t in u._watchDic)u._watchDic[t].error&&u._watchDic[t].error(e)}}u._watchDic={},u._curID=0;e.MiniAccelerator=d,e.MiniAdpter=l,e.MiniFileMgr=i,e.MiniInput=o,e.MiniLoader=s,e.MiniLocalStorage=r,e.MiniLocation=u,e.MiniSound=a,e.MiniSoundChannel=n,e.MiniVideo=class{constructor(e=320,t=240){this.videoend=!1,this.videourl="",this.videoElement=l.window.wx.createVideo({width:e,height:t,autoplay:!0})}static __init__(){}on(e,t,i){"loadedmetadata"==e?(this.onPlayFunc=i.bind(t),this.videoElement.onPlay=this.onPlayFunction.bind(this)):"ended"==e&&(this.onEndedFunC=i.bind(t),this.videoElement.onEnded=this.onEndedFunction.bind(this)),this.videoElement.onTimeUpdate=this.onTimeUpdateFunc.bind(this)}onTimeUpdateFunc(e){this.position=e.position,this._duration=e.duration}get duration(){return this._duration}onPlayFunction(){this.videoElement&&(this.videoElement.readyState=200),console.log("=====视频加载完成========"),null!=this.onPlayFunc&&this.onPlayFunc()}onEndedFunction(){this.videoElement&&(this.videoend=!0,console.log("=====视频播放完毕========"),null!=this.onEndedFunC&&this.onEndedFunC())}off(e,t,i){"loadedmetadata"==e?(this.onPlayFunc=i.bind(t),this.videoElement.offPlay=this.onPlayFunction.bind(this)):"ended"==e&&(this.onEndedFunC=i.bind(t),this.videoElement.offEnded=this.onEndedFunction.bind(this))}load(e){this.videoElement&&(this.videoElement.src=e)}play(){this.videoElement&&(this.videoend=!1,this.videoElement.play())}pause(){this.videoElement&&(this.videoend=!0,this.videoElement.pause())}get currentTime(){return this.videoElement?this.videoElement.initialTime:0}set currentTime(e){this.videoElement&&(this.videoElement.initialTime=e)}get videoWidth(){return this.videoElement?this.videoElement.width:0}get videoHeight(){return this.videoElement?this.videoElement.height:0}get ended(){return this.videoend}get loop(){return!!this.videoElement&&this.videoElement.loop}set loop(e){this.videoElement&&(this.videoElement.loop=e)}get playbackRate(){return this.videoElement?this.videoElement.playbackRate:0}set playbackRate(e){this.videoElement&&(this.videoElement.playbackRate=e)}get muted(){return!!this.videoElement&&this.videoElement.muted}set muted(e){this.videoElement&&(this.videoElement.muted=e)}get paused(){return!!this.videoElement&&this.videoElement.paused}size(e,t){this.videoElement&&(this.videoElement.width=e,this.videoElement.height=t)}get x(){return this.videoElement?this.videoElement.x:0}set x(e){this.videoElement&&(this.videoElement.x=e)}get y(){return this.videoElement?this.videoElement.y:0}set y(e){this.videoElement&&(this.videoElement.y=e)}get currentSrc(){return this.videoElement.src}destroy(){this.videoElement&&this.videoElement.destroy(),this.videoElement=null,this.onEndedFunC=null,this.onPlayFunc=null,this.videoend=!1,this.videourl=null}reload(){this.videoElement&&(this.videoElement.src=this.videourl)}}};