!function(a){"use strict";var b,c=a.Base64,d="2.1.5";"undefined"!=typeof module&&module.exports&&(b=require("buffer").Buffer);var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=function(a){for(var b={},c=0,d=a.length;d>c;c++)b[a.charAt(c)]=c;return b}(e),g=String.fromCharCode,h=function(a){if(a.length<2){var b=a.charCodeAt(0);return 128>b?a:2048>b?g(192|b>>>6)+g(128|63&b):g(224|b>>>12&15)+g(128|b>>>6&63)+g(128|63&b)}var b=65536+1024*(a.charCodeAt(0)-55296)+(a.charCodeAt(1)-56320);return g(240|b>>>18&7)+g(128|b>>>12&63)+g(128|b>>>6&63)+g(128|63&b)},i=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,j=function(a){return a.replace(i,h)},k=function(a){var b=[0,2,1][a.length%3],c=a.charCodeAt(0)<<16|(a.length>1?a.charCodeAt(1):0)<<8|(a.length>2?a.charCodeAt(2):0),d=[e.charAt(c>>>18),e.charAt(c>>>12&63),b>=2?"=":e.charAt(c>>>6&63),b>=1?"=":e.charAt(63&c)];return d.join("")},l=a.btoa?function(b){return a.btoa(b)}:function(a){return a.replace(/[\s\S]{1,3}/g,k)},m=b?function(a){return new b(a).toString("base64")}:function(a){return l(j(a))},n=function(a,b){return b?m(a).replace(/[+\/]/g,function(a){return"+"==a?"-":"_"}).replace(/=/g,""):m(a)},o=function(a){return n(a,!0)},p=new RegExp(["[À-ß][-¿]","[à-ï][-¿]{2}","[ð-÷][-¿]{3}"].join("|"),"g"),q=function(a){switch(a.length){case 4:var b=(7&a.charCodeAt(0))<<18|(63&a.charCodeAt(1))<<12|(63&a.charCodeAt(2))<<6|63&a.charCodeAt(3),c=b-65536;return g((c>>>10)+55296)+g((1023&c)+56320);case 3:return g((15&a.charCodeAt(0))<<12|(63&a.charCodeAt(1))<<6|63&a.charCodeAt(2));default:return g((31&a.charCodeAt(0))<<6|63&a.charCodeAt(1))}},r=function(a){return a.replace(p,q)},s=function(a){var b=a.length,c=b%4,d=(b>0?f[a.charAt(0)]<<18:0)|(b>1?f[a.charAt(1)]<<12:0)|(b>2?f[a.charAt(2)]<<6:0)|(b>3?f[a.charAt(3)]:0),e=[g(d>>>16),g(d>>>8&255),g(255&d)];return e.length-=[0,0,2,1][c],e.join("")},t=a.atob?function(b){return a.atob(b)}:function(a){return a.replace(/[\s\S]{1,4}/g,s)},u=b?function(a){return new b(a,"base64").toString()}:function(a){return r(t(a))},v=function(a){return u(a.replace(/[-_]/g,function(a){return"-"==a?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))},w=function(){var b=a.Base64;return a.Base64=c,b};if(a.Base64={VERSION:d,atob:t,btoa:l,fromBase64:v,toBase64:n,utob:j,encode:n,encodeURI:o,btou:r,decode:v,noConflict:w},"function"==typeof Object.defineProperty){var x=function(a){return{value:a,enumerable:!1,writable:!0,configurable:!0}};a.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",x(function(){return v(this)})),Object.defineProperty(String.prototype,"toBase64",x(function(a){return n(this,a)})),Object.defineProperty(String.prototype,"toBase64URI",x(function(){return n(this,!0)}))}}}(this),this.Meteor&&(Base64=global.Base64),function(){"use strict";var a,b,c=[],d=1e3,e={},f={},g={},h={},i="migamecenter",j="__msg_type",k="__callback_id",l="__event_id",m="dispatch_message/",n=function(){return b=document.createElement("iframe"),b.id="__miGCJsBridgeIframe_setResult",b.style.display="none",document.documentElement.appendChild(b),a=document.createElement("iframe"),a.id="__miGCJsBridgeIframe",a.style.display="none",document.documentElement.appendChild(a),a},o=function(b){b&&(c.push(b),a.src=i+"://"+m)},p=function(){var a=JSON.stringify(c);c=[],q("SCENE_FETCHQUEUE",a)},q=function(a,c){void 0===c&&(c="none"),b.src=i+"://private/setresult/"+a+"&"+Base64.encode(c)},r=function(a,b,c,f){if(a&&"string"==typeof a){"object"!=typeof b&&(b={});var g=(d++).toString();"function"==typeof c&&(e[g]={cb:c,ctx:f||this});var h={func:a,params:b};h[j]="call",h[k]=g,o(h)}},s=function(a){a&&r("android.showLog",a)},t=function(a,b,c){a&&"string"==typeof a&&"function"==typeof b&&(f[a]={cb:b,ctx:c||this})},u=function(a,b){var c=f[a];"function"==typeof c.cb&&c.cb.apply(c.ctx,[b])},v=function(a){if(a){var b,c,d,g={};switch(b=JSON.parse(Base64.decode(a)),b[j]){case"callback":return c=e[b[k]],"string"==typeof b[k]&&"function"==typeof c.cb?(g.result=c.cb.call(c.ctx,b.__params),delete e[b[k]],void q("SCENE_HANDLEMSGFROMCLIENT",JSON.stringify(g))):(g.__err_code="cb404",void q("SCENE_HANDLEMSGFROMCLIENT",JSON.stringify(g)));case"event":return d=f[b[l]],"string"==typeof b[l]&&"function"==typeof d.cb?(g.result=d.cb.call(d.ctx,b.__params),void q("SCENE_HANDLEMSGFROMCLIENT",JSON.stringify(g))):(g.__err_code="cb404",void q("SCENE_HANDLEMSGFROMCLIENT",JSON.stringify(g)))}}},w=function(a){return h[a]},x=function(){u("sys:init",{}),u("sys:bridged",{})},y=function(){"onhashchange"in window&&(window.onhashchange=function(){r("hashChange",{hash:window.location.hash})})},z=function(a,b,c){a&&a.id&&(g[a.id]=a,b&&b.call(c||this))},A=function(a,b,c){a in g&&(delete g[a],b&&b.call(c||this))},B=function(){return h},C=function(){h&&h.env&&h.env.isDebug&&D()},D=function(){var a=document.createElement("div");a.id="__jb_info_tip",a.innerHTML='
',document.body.appendChild(a);var b=document.createElement("div");b.id="__jb_btn",b.innerHTML=' 刷新',document.body.appendChild(b);var c=document.createElement("style");c.type="text/css";var d="#__jb_info_tip,#__jb_btn{z-index:100;position:absolute;top:0;right:0;color:#fff;background-color:rgba(0,0,0,.4);padding:5% 4% 3%;margin:0;border-radius:0 0 5px 5px}#__jb_info_tip ._close{width:20px;height:20px;border-radius:50%;position:absolute;top:4px;left:4px}#__jb_info_tip ._close:before,#__jb_info_tip ._close:after{content:'';position:absolute;height:1px;width:100%;top:50%;left:0;margin-top:-1px;background:#fff}#__jb_info_tip ._close:before{transform:rotate(-45deg)}#__jb_info_tip ._close:after{transform:rotate(45deg)}#__jb_info_tip ._cont{margin:12px 0 10px}#__jb_btn{left: 2%; width: 20%;top: 2%;padding: 0;font-size: 1.2rem;text-align: center;}#__jb_btn span{background: rgba(0,0,0,0.5);padding: 10%;display: block;}";try{c.appendChild(document.createTextNode(d))}catch(e){c.styleSheet.cssText=d}document.head.appendChild(c)},E=function(a){if(h&&h.env&&h.env.isDebug){var b=h.env.stampTime||(new Date).getTime(),c=(new Date).getTime(),d=document.querySelector("#__jb_tip_cont"),e=d.innerHTML||"debug model:
";d.innerHTML=e+"
"+(a||"")+(c-b)+"ms"}},F=function(){t("sys:init",function(){window.JsBridge._hasInit||(window.JsBridge._hasInit=!0,r("get_session_data",{},function(a){h=a,C();var b=document.createEvent("Events");b.initEvent("JsBridgeReady"),document.dispatchEvent(b)}))}),t("sys:bridged",function(){window.JsBridge._hasInit||y()}),t("download_loading",function(a){var b=a;if(b&&b.length)for(var c,d,e=0,f=b.length;f>e&&(c=b[e],d=g[c.id],d);e++){var h=d.ctx||this;switch(c.status){case"start":d.start&&d.start.call(h);break;case"pause":d.pause&&d.pause.call(h);break;case"wait":d.wait&&d.wait.call(h);break;case"download_complete":d.downloadComplete&&d.downloadComplete.call(h);break;case"install_complete":d.installComplete&&d.installComplete.call(h);break;case"downloading":d.downloading&&d.downloading.call(h,c.progress,c.current_bytes);break;case"remove":d.remove&&d.remove.call(h);break;case"fail":d.fail&&d.fail.call(h);break;default:d.process&&d.process.call(h)}}}),t("sys:refresh",function(a){r("get_session_data",{},function(a){h=a;var b=document.createEvent("Events");b.initEvent("JsBridgeRefresh"),document.dispatchEvent(b)})}),t("sys:pause",function(a){var b=document.createEvent("Events");b.initEvent("JsBridgePause"),document.dispatchEvent(b)}),t("sys:resume",function(a){var b=document.createEvent("Events");b.initEvent("JsBridgeResume"),document.dispatchEvent(b)}),t("sys:abort",function(a){var b=document.createEvent("Events");b.initEvent("JsBridgeAbort"),document.dispatchEvent(b)}),t("sys:back",function(a){var b=document.createEvent("Events");b.initEvent("JsBridgeBack"),document.dispatchEvent(b)}),t("sys:position",function(a){r("get_session_data",{},function(a){h=a;var b=document.createEvent("Events");b.initEvent("JsBridgePosition"),document.dispatchEvent(b)})})};window.JsBridge=window.JsBridge||function(){return n(),F(),{version:"1.0.1",invoke:r,on:t,env:w,debugTime:E,pushItemInDLMap:z,shiftItemFrDLMap:A,log:s,_init:x,_fetchQueue:p,_handleMessageFromClient:v,getSessionData:B,_hasInit:!1}}()}(),function(){var a=window.clientApi={},b=function(a){var b=typeof a;if(!("function"===b||"object"===b&&a))return a;for(var c,d,e=0,f=arguments.length;f>e;e++){c=arguments[e];for(d in c)hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a};a.showToolBar=function(){JsBridge.invoke("showToolBar")},a.hideToolBar=function(){JsBridge.invoke("hideToolBar")},a.copy=function(a,b){if(a&&"string"==typeof a){var c={txt:a};JsBridge.invoke("copy",c,b)}},a.openBrowser=function(a){var b={url:a||window.location.href};JsBridge.invoke("openInBrowser",b)},a.enableDebugMode=function(a){window.onerror=function(b,c,d,e){if("function"==typeof a)return void a({message:b,script:c,line:d,column:e});var f=[];f.push("额,代码有错。。。"),f.push("\n错误信息:",b),f.push("\n出错文件:",c),f.push("\n出错位置:",d+"行,"+e+"列"),alert(f.join(""))}},a.download=function(a,b,c){JsBridge.pushItemInDLMap({id:a.gameId,start:a.start,pause:a.pause,wait:a.wait,downloading:a.downloading,downloadComplete:a.downloadComplete,installComplete:a.installComplete,remove:a.remove,fail:a.fail,ctx:a.ctx,channel:a.channel,from:a.from,trace:a.trace},function(){JsBridge.invoke("download_start",{id:a.gameId,packageName:a.packageName,channel:a.channel,from:a.from,trace:a.trace},b,c)})},a.pushItemInDownLoadMap=function(a,b,c){JsBridge.pushItemInDLMap({id:a.gameId,start:a.start,pause:a.pause,wait:a.wait,downloading:a.downloading,downloadComplete:a.downloadComplete,installComplete:a.installComplete,remove:a.remove,fail:a.fail,ctx:a.ctx,channel:a.channel},b,c)},a.downloadPause=function(a,b,c){JsBridge.invoke("download_pause",{id:a.gameId,channel:a.channel},function(a){b&&b.call(c)},c)},a.downloadContinue=function(a,b,c){JsBridge.invoke("download_continue",{id:a.gameId,channel:a.channel},function(a){b&&b.call(c)},c)},a.downloadInstall=function(a,b,c){JsBridge.invoke("download_install",{id:a.gameId,channel:a.channel},function(d){JsBridge.shiftItemFrDLMap(a.gameId),b&&b.call(c)},c)},a.openGame=function(a,b,c){JsBridge.invoke("open_game",{id:a.gameId,packageName:a.packageName,channel:a.channel},function(a){},c)},a.initPageByNativeData=function(a,b,c){JsBridge.invoke("init_web",{gameList:a.gameList},function(a){b&&b.call(c,a)},c)},a.initPageByClientData=function(a,b,c,d){JsBridge.invoke("init_web_by_type",{type:a,param:b},function(a){c&&c.call(d,a)},d)};var c=function(a){var b=!1,c=function(c){b||(b=!0,a(c))},d=document.getElementsByTagName("img");if(!d.length)return c();var e,f,g,h,i={},j=!1;for(f=0,g=d.length;g>f;f++)e=d[f],"none"!=e.style.display&&"hidden"!=e.style.visibility&&(i[e.src]||(i[e.src]=1,h=new Image,h.onload=function(){j||this.width>290&&this.height>290&&(j=!0,c(this))},h.src=e.src));i=null,setTimeout(function(){j||c()},1e3)};a.videoPlay=function(a,b,c){JsBridge.invoke("video_play",{url:a,title:b},c)},a.showMenu=function(a){JsBridge.on("menu:show",function(b){a&&a(b)})},a.share=function(a){var b;if(b="string"==typeof a.title?a:{link:document.documentURI,desc:document.documentURI,title:document.title},a.imgUrl)return b.img_url=a.imgUrl,void JsBridge.invoke("share",b);var d=function(a){a&&(b.img_url=a.src),JsBridge.invoke("share",b)};c(d)},a.inputTxtByNative=function(a,b){JsBridge.invoke("submit_input_txt",{content:a},b)},a.nativeRequest=function(a,b){if(""!==a.url&&""!==a.type){var c={url:a.url,param:a.param||{},http_method:a.http_method||"get",secertKey:a.secertKey||"",type:a.type};JsBridge.invoke("native_request",c,b)}},a.showDialog=function(a,c){var d={type:"show:txt",title:"",content:"",isLazyClose:!1,lazyTime:0,isShowCancelBtn:!1,cancelBtnTxt:"取消",isShowOkBtn:!1,okBtnTxt:"确定"},e=function(a){if(a&&a.operat)switch(a.operat){case"ok":c.ok&&c.ok(a.content);break;case"cancel":c.cancel&&c.cancel(a.content)}};d=b(d,a),"submit"==d.type&&(d.isLazyClose=!1),JsBridge.invoke("show_dialog",d,e)},a.preventSwipeBack=function(a,b){a=a||{prevent:!0},b=b||function(){},JsBridge.invoke("prevent_swipe_back",a,b)},a.uploadImg=function(a){JsBridge.invoke("upload_img",{},a)},a.clientLog=function(a){JsBridge.invoke("client_log",{info:a})},a.reinstate=function(a,b,c){switch(a*=1){case 1:JsBridge.invoke("service_token_invalidate",{tagurl:b,param:c});break;case 2:JsBridge.invoke("login_invalidate",{tagurl:b,param:c})}},a.historyNotRecords=function(a){JsBridge.invoke("history_not_records",{},a)},a.historyJumpOutWebview=function(a){JsBridge.invoke("history_jumpout_webview",{},a)},a.goBack=function(a){JsBridge.invoke("web_go_back",{},a)},a.viewImgList=function(a,b){var c={screenShot:a.screenShot||[],curIndex:a.curIndex||0};c.screenShot.length&&JsBridge.invoke("view_img_list",c,b)},a.getBaseDataFromClient=function(a,b){var c={type:a};JsBridge.invoke("get_basedata_by_type",c,b)},a.notifyLoadingOver=function(a){JsBridge.invoke("client_loading_over",{},a)},a.getSessionData=function(){return JsBridge.getSessionData()},a.commentTxtByNative=function(a,b){var c={news_id:a};JsBridge.invoke("client_comment_txt",c,b)},a.h5GameLogin=function(a,b){return a?a.appId?a.appKey?void JsBridge.invoke("h5_game_login",a,b):void(b&&b({result:-102,errorMessage:"appKey is null"})):void(b&&b({result:-101,errorMessage:"appId is null"})):void(b&&b({result:-100,errorMessage:"options is null"}))},a.h5GamePay=function(a,b){return a?(a.cpOrderId||b&&b({result:-104,errorMessage:"cpOrderId is null"}),a.cpUserInfo||b&&b({result:-105,errorMessage:"cpUserInfo is null"}),void JsBridge.invoke("h5_game_pay",a,b)):void(b&&b({result:-103,errorMessage:"options is null"}))},a.executeClientMethod=function(a,b,c,d){JsBridge.invoke("client_method_execute",{method:a,param:b},function(a){c&&c.call(d,a)},d)},a.showImgFromNative=function(a,b,c){var d={imgList:a,index:b};JsBridge.invoke("show_img_list",d,c)},a.jumpMiBiRechargeList=function(a,b){JsBridge.invoke("jumpMiBiRechargeList",a,b)},a.saveDataToNative=function(a,b,c){var d={};d[a]=b,JsBridge.invoke("saveDataToNative",d,c)},a.showErrorTip=function(){JsBridge.invoke("showErrorTip")},a.getBatteryByNative=function(a,b){JsBridge.invoke("battery_by_native",{},function(c){a&&a.call(b,c)},b)},a.dimmingByScreen=function(a,b,c){JsBridge.invoke("dimming_by_screen",{param:a},function(a){b&&b.call(c,a)},c)},a.checkGameStatus=function(a,b,c,d){JsBridge.invoke("check_game_status",{method:a,param:b},function(a){c&&c.call(d,a)},d)},a.sendStatistic=function(a,b,c){JsBridge.invoke("send_statistic",{param:a},function(a){b&&b.call(c,a)},c)},a.changeNavigationBar=function(a,b,c){JsBridge.invoke("change_navigation_bar",{param:a},function(a){b&&b.call(c,a)},c)},a.finishActivity=function(){JsBridge.invoke("finish_activity")},a.showNativeDialog=function(a,b,c){JsBridge.invoke("show_native_dialog",{param:a},function(a){b&&b.call(c,a)},c)},a.notifyBackKey=function(){JsBridge.invoke("notify_back_key")},a.closeBackKey=function(){JsBridge.invoke("close_back_key")},a.getNativeNotify=function(a,b,c){JsBridge.invoke("get_native_notify",{param:a},function(a){b&&b.call(c,a)},c)},a.logoutByNative=function(a,b){JsBridge.invoke("logout_by_native",{},function(c){a&&a.call(b,c)},b)},a.cacheByNative=function(a,b,c){JsBridge.invoke("cache_data_by_native",{param:a},function(a){b&&b.call(c,a)},c)},a.setDataToNative=function(a,b,c){JsBridge.invoke("set_data_to_native",{param:a},function(a){b&&b.call(c,a)},c)},a.getGameUpdateByNative=function(a,b,c){JsBridge.invoke("game_list_update",{gameList:a.gameList},function(a){b&&b.call(c,a)},c)}}();