-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgameservice-sdk.js
2 lines (2 loc) · 84.4 KB
/
gameservice-sdk.js
1
2
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("gameservice-sdk",[],t):"object"==typeof exports?exports["gameservice-sdk"]=t():e["gameservice-sdk"]=t()}(self,(function(){return(()=>{var e={9669:(e,t,n)=>{e.exports=n(1609)},5448:(e,t,n)=>{"use strict";var o=n(4867),i=n(6026),r=n(4372),a=n(1246),s=n(4097),c=n(4109),d=n(7985),u=n(5061);e.exports=function(e){return new Promise((function(t,n){var l=e.data,m=e.headers;o.isFormData(l)&&delete m["Content-Type"];var h=new XMLHttpRequest;if(e.auth){var v=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";m.Authorization="Basic "+btoa(v+":"+f)}var S=s(e.baseURL,e.url);if(h.open(e.method.toUpperCase(),a(S,e.params,e.paramsSerializer),!0),h.timeout=e.timeout,h.onreadystatechange=function(){if(h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))){var o="getAllResponseHeaders"in h?c(h.getAllResponseHeaders()):null,r={data:e.responseType&&"text"!==e.responseType?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:o,config:e,request:h};i(t,n,r),h=null}},h.onabort=function(){h&&(n(u("Request aborted",e,"ECONNABORTED",h)),h=null)},h.onerror=function(){n(u("Network Error",e,null,h)),h=null},h.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(u(t,e,"ECONNABORTED",h)),h=null},o.isStandardBrowserEnv()){var p=(e.withCredentials||d(S))&&e.xsrfCookieName?r.read(e.xsrfCookieName):void 0;p&&(m[e.xsrfHeaderName]=p)}if("setRequestHeader"in h&&o.forEach(m,(function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete m[t]:h.setRequestHeader(t,e)})),o.isUndefined(e.withCredentials)||(h.withCredentials=!!e.withCredentials),e.responseType)try{h.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&h.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){h&&(h.abort(),n(e),h=null)})),l||(l=null),h.send(l)}))}},1609:(e,t,n)=>{"use strict";var o=n(4867),i=n(1849),r=n(321),a=n(7185);function s(e){var t=new r(e),n=i(r.prototype.request,t);return o.extend(n,r.prototype,t),o.extend(n,t),n}var c=s(n(5655));c.Axios=r,c.create=function(e){return s(a(c.defaults,e))},c.Cancel=n(5263),c.CancelToken=n(4972),c.isCancel=n(6502),c.all=function(e){return Promise.all(e)},c.spread=n(8713),c.isAxiosError=n(6268),e.exports=c,e.exports.default=c},5263:e=>{"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},4972:(e,t,n)=>{"use strict";var o=n(5263);function i(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;e((function(e){n.reason||(n.reason=new o(e),t(n.reason))}))}i.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},i.source=function(){var e;return{token:new i((function(t){e=t})),cancel:e}},e.exports=i},6502:e=>{"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:(e,t,n)=>{"use strict";var o=n(4867),i=n(1246),r=n(782),a=n(3572),s=n(7185);function c(e){this.defaults=e,this.interceptors={request:new r,response:new r}}c.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=s(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[a,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)n=n.then(t.shift(),t.shift());return n},c.prototype.getUri=function(e){return e=s(this.defaults,e),i(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},o.forEach(["delete","get","head","options"],(function(e){c.prototype[e]=function(t,n){return this.request(s(n||{},{method:e,url:t,data:(n||{}).data}))}})),o.forEach(["post","put","patch"],(function(e){c.prototype[e]=function(t,n,o){return this.request(s(o||{},{method:e,url:t,data:n}))}})),e.exports=c},782:(e,t,n)=>{"use strict";var o=n(4867);function i(){this.handlers=[]}i.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},i.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},i.prototype.forEach=function(e){o.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=i},4097:(e,t,n)=>{"use strict";var o=n(1793),i=n(7303);e.exports=function(e,t){return e&&!o(t)?i(e,t):t}},5061:(e,t,n)=>{"use strict";var o=n(481);e.exports=function(e,t,n,i,r){var a=new Error(e);return o(a,t,n,i,r)}},3572:(e,t,n)=>{"use strict";var o=n(4867),i=n(8527),r=n(6502),a=n(5655);function s(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return s(e),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),o.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return s(e),t.data=i(t.data,t.headers,e.transformResponse),t}),(function(t){return r(t)||(s(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:e=>{"use strict";e.exports=function(e,t,n,o,i){return e.config=t,n&&(e.code=n),e.request=o,e.response=i,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},7185:(e,t,n)=>{"use strict";var o=n(4867);e.exports=function(e,t){t=t||{};var n={},i=["url","method","data"],r=["headers","auth","proxy","params"],a=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],s=["validateStatus"];function c(e,t){return o.isPlainObject(e)&&o.isPlainObject(t)?o.merge(e,t):o.isPlainObject(t)?o.merge({},t):o.isArray(t)?t.slice():t}function d(i){o.isUndefined(t[i])?o.isUndefined(e[i])||(n[i]=c(void 0,e[i])):n[i]=c(e[i],t[i])}o.forEach(i,(function(e){o.isUndefined(t[e])||(n[e]=c(void 0,t[e]))})),o.forEach(r,d),o.forEach(a,(function(i){o.isUndefined(t[i])?o.isUndefined(e[i])||(n[i]=c(void 0,e[i])):n[i]=c(void 0,t[i])})),o.forEach(s,(function(o){o in t?n[o]=c(e[o],t[o]):o in e&&(n[o]=c(void 0,e[o]))}));var u=i.concat(r).concat(a).concat(s),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===u.indexOf(e)}));return o.forEach(l,d),n}},6026:(e,t,n)=>{"use strict";var o=n(5061);e.exports=function(e,t,n){var i=n.config.validateStatus;n.status&&i&&!i(n.status)?t(o("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},8527:(e,t,n)=>{"use strict";var o=n(4867);e.exports=function(e,t,n){return o.forEach(n,(function(n){e=n(e,t)})),e}},5655:(e,t,n)=>{"use strict";var o=n(4867),i=n(6016),r={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var s,c={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(s=n(5448)),s),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.isObject(e)?(a(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};o.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),o.forEach(["post","put","patch"],(function(e){c.headers[e]=o.merge(r)})),e.exports=c},1849:e=>{"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),o=0;o<n.length;o++)n[o]=arguments[o];return e.apply(t,n)}}},1246:(e,t,n)=>{"use strict";var o=n(4867);function i(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var r;if(n)r=n(t);else if(o.isURLSearchParams(t))r=t.toString();else{var a=[];o.forEach(t,(function(e,t){null!=e&&(o.isArray(e)?t+="[]":e=[e],o.forEach(e,(function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),a.push(i(t)+"="+i(e))})))})),r=a.join("&")}if(r){var s=e.indexOf("#");-1!==s&&(e=e.slice(0,s)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}},7303:e=>{"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},4372:(e,t,n)=>{"use strict";var o=n(4867);e.exports=o.isStandardBrowserEnv()?{write:function(e,t,n,i,r,a){var s=[];s.push(e+"="+encodeURIComponent(t)),o.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),o.isString(i)&&s.push("path="+i),o.isString(r)&&s.push("domain="+r),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},1793:e=>{"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},6268:e=>{"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},7985:(e,t,n)=>{"use strict";var o=n(4867);e.exports=o.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function i(e){var o=e;return t&&(n.setAttribute("href",o),o=n.href),n.setAttribute("href",o),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=i(window.location.href),function(t){var n=o.isString(t)?i(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},6016:(e,t,n)=>{"use strict";var o=n(4867);e.exports=function(e,t){o.forEach(e,(function(n,o){o!==t&&o.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[o])}))}},4109:(e,t,n)=>{"use strict";var o=n(4867),i=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,r,a={};return e?(o.forEach(e.split("\n"),(function(e){if(r=e.indexOf(":"),t=o.trim(e.substr(0,r)).toLowerCase(),n=o.trim(e.substr(r+1)),t){if(a[t]&&i.indexOf(t)>=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([n]):a[t]?a[t]+", "+n:n}})),a):a}},8713:e=>{"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},4867:(e,t,n)=>{"use strict";var o=n(1849),i=Object.prototype.toString;function r(e){return"[object Array]"===i.call(e)}function a(e){return void 0===e}function s(e){return null!==e&&"object"==typeof e}function c(e){if("[object Object]"!==i.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function d(e){return"[object Function]"===i.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}e.exports={isArray:r,isArrayBuffer:function(e){return"[object ArrayBuffer]"===i.call(e)},isBuffer:function(e){return null!==e&&!a(e)&&null!==e.constructor&&!a(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:s,isPlainObject:c,isUndefined:a,isDate:function(e){return"[object Date]"===i.call(e)},isFile:function(e){return"[object File]"===i.call(e)},isBlob:function(e){return"[object Blob]"===i.call(e)},isFunction:d,isStream:function(e){return s(e)&&d(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&"undefined"!=typeof window&&"undefined"!=typeof document},forEach:u,merge:function e(){var t={};function n(n,o){c(t[o])&&c(n)?t[o]=e(t[o],n):c(n)?t[o]=e({},n):r(n)?t[o]=n.slice():t[o]=n}for(var o=0,i=arguments.length;o<i;o++)u(arguments[o],n);return t},extend:function(e,t,n){return u(t,(function(t,i){e[i]=n&&"function"==typeof t?o(t,n):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},2454:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Achievements=void 0;const r=n(7595),a=n(1563),s=i(n(9669)),c=n(6707);t.Achievements=class{constructor(){}GetAchievements(){return o(this,void 0,void 0,(function*(){try{let{data:e}=yield s.default.get(`${r.Url.Api.Endpoint}${r.Url.Api.GetAchievements}`,{headers:{"x-access-token":c.GameService.Authentication.gameToken}});return a.Log("GetAchievements",e),e.achievement}catch(e){throw e.response?e.response.data.msg:e}}))}Unlock(e){return o(this,void 0,void 0,(function*(){try{let{data:t}=yield s.default.post(`${r.Url.Api.Endpoint}${r.Url.Api.GetAchievementsv2}/${e}`,null,{headers:{"x-access-token":c.GameService.Authentication.gameToken}});return a.Log("Unlock",t),t.new}catch(e){throw e.response?e.response.data.msg:e}}))}}},8732:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Assets=void 0;const r=n(7595),a=n(1563),s=i(n(9669)),c=n(6707);t.Assets=class{constructor(){}GetAssetInfo(e){return o(this,void 0,void 0,(function*(){try{let{data:t}=yield s.default.get(`${r.Url.Api.Endpoint}${r.Url.Api.DownloadAssets}/${c.GameService.ClientID}/datapack/?tag=${e}`,{headers:{"x-access-token":c.GameService.Authentication.gameToken}});return a.Log("GetAssetInfo",t),t.data}catch(e){throw e.response?e.response.data.msg:e}}))}}},9182:function(e,t,n){"use strict";var o=this&&this.__createBinding||(Object.create?function(e,t,n,o){void 0===o&&(o=n),Object.defineProperty(e,o,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},a=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Authentication=void 0;const c=n(7595),d=n(1563),u=r(n(8827)),l=n(6707),m=n(5877),h=s(n(9669));t.Authentication=class{constructor(){this.userToken="",this.gameToken="",this.gameID=""}Login(e,t){return a(this,void 0,void 0,(function*(){try{let{data:n}=yield h.default.post(`${c.Url.Api.Endpoint}${c.Url.Api.Login}`,{email:e,password:t,device_id:m.v4()});return this.userToken=n.token,yield this.Start(),n.token}catch(e){if(e&&e.response){if(e.response.data)throw e.response.data;throw e.response}throw e}}))}LoginWithToken(e){return a(this,void 0,void 0,(function*(){this.userToken=e,yield this.Start()}))}SignUp(e,t,n){return a(this,void 0,void 0,(function*(){try{let{data:o}=yield h.default.post(`${c.Url.Api.Endpoint}${c.Url.Api.Login}`,{mode:"register",name:e,client_id:l.GameService.ClientID,email:t,password:n,device_id:m.v4()});return d.Log("SignUp",o),this.userToken=o.token,yield this.Start(),o.token}catch(e){throw e&&e.response?e.response.data.msg:e}}))}CheckSmsStatus(){return a(this,void 0,void 0,(function*(){return!0}))}SendLoginCodeSms(e){return a(this,void 0,void 0,(function*(){try{let{data:t}=yield h.default.post(`${c.Url.Api.Endpoint}${c.Url.Api.SMSAuth}`,{game:l.GameService.ClientID,secret:l.GameService.ClientSecret,phone_number:e});return d.Log("SendLoginCodeSms",t),!0}catch(e){throw e&&e.response?e.response.data.msg:e}}))}LoginOrSignUpWithSms(e,t,n){return a(this,void 0,void 0,(function*(){try{let{data:o}=yield h.default.post(`${c.Url.Api.Endpoint}${c.Url.Api.SMSAuthCallback}`,{name:e,code:n,phone_number:t,device_id:m.v4()});return d.Log("SendLoginCodeSms",o),o.token}catch(e){throw e&&e.response?e.response.data.msg:e}}))}LoginAsGuest(){return a(this,void 0,void 0,(function*(){try{let{data:e}=yield h.default.post(`${c.Url.Api.Endpoint}${c.Url.Api.Login}`,{device_id:m.v4()});return d.Log("LoginAsGuest",e),this.userToken=e.token,yield this.Start(),e.token}catch(e){throw e&&e.response?e.response.data.msg:e}}))}Start(){return a(this,void 0,void 0,(function*(){try{let{data:e}=yield h.default.post(`${c.Url.Api.Endpoint}${c.Url.Api.Start}`,{game:l.GameService.ClientID,system_info:u.get(),secret:l.GameService.ClientSecret,token:this.userToken,connectionType:"wss"});return this.gameToken=e.token,this.gameID=e.game._id,yield l.GameService.GSLive.Command.Initilize(e.command),e.token}catch(e){throw e&&e.response?e.response.data.msg:e}}))}}},1351:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.Chats=void 0;const i=n(6707),r=n(7595),a=n(6351),s=n(3264);t.Chats=class{constructor(){this.OnSubscribeChannel=e=>{},this.OnChatReceived=()=>{},this.ChannelsSubscribed=()=>{},this.ChannelsRecentMessages=()=>{},this.ChannelMembers=()=>{},this.PendingMessages=()=>{},this.OnUnSubscribeChannel=()=>{}}SubscribeChannel(e){return o(this,void 0,void 0,(function*(){let t=new a.Packet;t.SetHead(r.Actions.Command.ActionSubscribe),t.SetToken(i.GameService.GSLive.Command.commandToken),t.SetMsg(e),t.Send()}))}SendChannelMessage(e,t){return o(this,void 0,void 0,(function*(){let n=new s.Message;n.SetTo(e),n.SetText(t);let o=new a.Packet;o.SetHead(r.Actions.Command.ActionChat),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}SendPrivateMessage(e,t){return o(this,void 0,void 0,(function*(){let n=new s.Message;n.SetTo(e),n.SetText(t);let o=new a.Packet;o.SetHead(r.Actions.Command.ActionPrivateChat),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}GetChannelsSubscribed(){return o(this,void 0,void 0,(function*(){let e=new a.Packet;e.SetHead(r.Actions.Command.ActionGetSubscribedChannels),e.SetToken(i.GameService.GSLive.Command.commandToken),e.Send()}))}GetChannelRecentMessages(e){return o(this,void 0,void 0,(function*(){let t=new a.Data;t.SetID(e);let n=new a.Packet;n.SetHead(r.Actions.Command.ActionGetLastGroupMessages),n.SetToken(i.GameService.GSLive.Command.commandToken),n.SetData(t.ToString()),n.Send()}))}GetChannelMembers(e,t=0,n=25){return o(this,void 0,void 0,(function*(){let o=new a.Data;o.SetID(e),o.SetMin(t),o.SetMax(n);let s=new a.Packet;s.SetHead(r.Actions.Command.ActionGetMembersOfChannel),s.SetToken(i.GameService.GSLive.Command.commandToken),s.SetData(o.ToString()),s.Send()}))}GetPendingMessages(){return o(this,void 0,void 0,(function*(){let e=new a.Packet;e.SetHead(r.Actions.Command.ActionGetPendingMessages),e.SetToken(i.GameService.GSLive.Command.commandToken),e.Send()}))}UnSubscribeChannel(e){return o(this,void 0,void 0,(function*(){let t=new a.Packet;t.SetHead(r.Actions.Command.ActionUnSubscribe),t.SetToken(i.GameService.GSLive.Command.commandToken),t.SetMsg(e),t.Send()}))}}},3264:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Message=void 0,t.Message=class{constructor(){}GetIsPrivate(){return this.IsPrivate}SetIsPrivate(e){this.IsPrivate=e}GetTo(){return this.To}SetTo(e){this.To=e}GetFrom(){return this.From}SetFrom(e){this.From=e}GetText(){return this.Text}SetText(e){this.Text=e}GetTime(){return this.Time}SetTime(e){this.Time=e}GetChannel(){return this.Channel}SetChannel(e){this.Channel=e}Cast(){return{0:this.IsPrivate,1:this.To,2:this.From,3:this.Text,4:this.Time,5:this.Channel}}Parse(e){let t=JSON.parse(e);this.SetIsPrivate(t[0]),this.SetTo(t[1]),this.SetFrom(t[2]),this.SetText(t[3]),this.SetTime(t[4]),this.SetChannel(t[5])}ToString(){return JSON.stringify(this.Cast())}}},6587:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Command=void 0;const r=n(7595),a=n(6707),s=i(n(7026)),c=n(6351),d=n(3264),u=n(1563),l=n(7663);t.Command=class{constructor(){this.commandToken="",this.isInAutoMatchQueue=!1,this.OnConnect=e=>{let t=new c.Payload;t.SetGameID(a.GameService.Authentication.gameID),t.SetToken(a.GameService.Authentication.userToken);let n=new c.Packet;n.SetHead(r.Actions.Command.ActionAuth),n.SetData(t.ToString()),n.Send(!1)},this.OnReceive=e=>o(this,void 0,void 0,(function*(){var t;let n=new c.Packet;switch(n.Parse(e.data,""!=a.GameService.GSLive.Cipher&&""!=this.commandToken),n.GetHead()){case r.Actions.Command.ActionAuth:this.commandToken=n.GetToken(),a.GameService.onReady();break;case r.Actions.Command.ActionChat:let e=new d.Message;e.Parse(n.GetData()),a.GameService.GSLive.Chats.OnChatReceived(e.GetChannel(),e.GetFrom(),e.GetText(),!1);break;case r.Actions.Command.ActionPrivateChat:let o=new d.Message;o.Parse(n.GetData()),a.GameService.GSLive.Chats.OnChatReceived(o.GetChannel(),o.GetFrom(),o.GetText(),!0);break;case r.Actions.Command.ActionSubscribe:a.GameService.GSLive.Chats.OnSubscribeChannel(n.GetMsg());break;case r.Actions.Command.ActionUnSubscribe:a.GameService.GSLive.Chats.OnUnSubscribeChannel(n.GetMsg());break;case r.Actions.Command.ActionGetLastGroupMessages:let i=JSON.parse(n.GetData());a.GameService.GSLive.Chats.ChannelsRecentMessages(i);break;case r.Actions.Command.ActionGetMembersOfChannel:let s=JSON.parse(n.GetData());a.GameService.GSLive.Chats.ChannelMembers(s);break;case r.Actions.Command.ActionGetSubscribedChannels:let u=JSON.parse(n.GetData());a.GameService.GSLive.Chats.ChannelsSubscribed(u);break;case r.Actions.Command.ActionGetPendingMessages:let l=JSON.parse(n.GetData());a.GameService.GSLive.Chats.PendingMessages(l);break;case r.Actions.Command.ActionAutoMatch:let m;null!=n.GetData()&&(m=JSON.parse(n.GetData())),n.GetMsg()&&(m=n.GetMsg()),a.GameService.GSLive.TurnBased.OnAutoMatchUpdated(m),a.GameService.GSLive.RealTime.OnAutoMatchUpdated(m),this.isInAutoMatchQueue=!0;break;case r.Actions.Command.LeftWaitingQ:a.GameService.GSLive.TurnBased.OnAutoMatchCanceled(n.GetMsg()||""),a.GameService.GSLive.RealTime.OnAutoMatchCanceled(n.GetMsg()||""),this.isInAutoMatchQueue=!1;break;case r.Actions.Command.ActionGetRooms:break;case r.Actions.Command.ActionJoinRoom:let h=new c.StartGame;h.parse(n.GetData()),1==h.Room.syncMode?yield a.GameService.GSLive.TurnbasedController.Initilize(h.Room._id,h.Area.Endpoint,h.Area.Port):yield a.GameService.GSLive.RealTimeController.Initilize(h.Room._id,null===(t=h.Area)||void 0===t?void 0:t.Hash,h.Area.Endpoint,h.Area.Port),this.isInAutoMatchQueue=!1;break;case r.Actions.Error:console.error(`[Command] [Error] [Msg: ${n.GetMsg()}]`)}})),this.onDisconnect=e=>{e.wasClean?u.Log("[Command]",`[close] Connection closed cleanly, code = ${e.code} reason = ${e.reason}`):u.Log("[Command]","[close] Connection died"),this.commandToken=""}}Initilize(e){if(null==e.ip||null==e.port)return console.error("No valid command returned from HttpServices",{relay:e});"undefined"==typeof window?(u.Log("[Command]",`[Node] [Connecting] [${e.ip}:${e.port}]`),l.GSLive.CommandConnection=new s.default(`ws://${e.ip}:${e.port}`)):(u.Log("[Command]",`[Browser] [Connecting] [${e.port}:${e.port}]`),l.GSLive.CommandConnection=new WebSocket(`ws://${e.ip}:${e.port}`)),a.GameService.GSLive.Cipher=e.cipher,a.GameService.GSLive.isEncriptionActive="deactive"!=e.encription,l.GSLive.CommandConnection.onopen=this.OnConnect,l.GSLive.CommandConnection.onmessage=this.OnReceive,l.GSLive.CommandConnection.onclose=this.onDisconnect,l.GSLive.CommandConnection.onerror=e=>{throw e}}}},6351:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Area=t.StartGame=t.Data=t.Payload=t.Packet=t.Rc4=void 0;const o=n(7663),i=n(6707);function r(e,t){for(var n,o=[],i=0,r="",a=0;a<256;a++)o[a]=a;for(a=0;a<256;a++)i=(i+o[a]+e.charCodeAt(a%e.length))%256,n=o[a],o[a]=o[i],o[i]=n;a=0,i=0;for(var s=0;s<t.length;s++)i=(i+o[a=(a+1)%256])%256,n=o[a],o[a]=o[i],o[i]=n,r+=String.fromCharCode(t.charCodeAt(s)^o[(o[a]+o[i])%256]);return r}t.Rc4=r,t.Packet=class{constructor(){this.Send=(e=!0)=>{let t=this.ToString(e);if(void 0===o.GSLive.CommandConnection)throw"User not connected to Command Server";o.GSLive.CommandConnection.send(t)}}Parse(e,t=!0){let n=JSON.parse(e),o=n[2],a=n[3];i.GameService.GSLive.isEncriptionActive&&t&&(n[2]&&(o=Buffer.from(r(i.GameService.GSLive.Cipher,Buffer.from(n[2],"base64").toString("latin1")),"latin1").toString("utf-8")),n[3]&&100!=n[1]&&(a=Buffer.from(r(i.GameService.GSLive.Cipher,Buffer.from(n[3],"base64").toString("latin1")),"latin1").toString("utf-8"))),this.SetToken(n[0]),this.SetHead(n[1]),this.SetData(o),this.SetMsg(a)}GetToken(){return this.Token}SetToken(e){this.Token=e}GetHead(){return this.Head}SetHead(e){this.Head=e}GetData(){return this.Data}SetData(e){this.Data=e}GetMsg(){return this.Msg}SetMsg(e){this.Msg=e}Export(){return{0:this.Token,1:this.Head,2:this.Data,3:this.Msg}}Cast(e=!0){if(i.GameService.GSLive.isEncriptionActive&&e){if(this.Data){let e=r(i.GameService.GSLive.Cipher,Buffer.from(this.Data).toString("utf-8")),t=Buffer.from(e,"latin1").toString("base64");this.Data=t}if(this.Msg){let e=r(i.GameService.GSLive.Cipher,Buffer.from(this.Msg).toString("utf-8")),t=Buffer.from(e,"latin1").toString("base64");this.Msg=t}}return{0:this.Token,1:this.Head,2:this.Data,3:this.Msg}}ToString(e=!0){return JSON.stringify(this.Cast(e))}},t.Payload=class{constructor(){}GetGameID(){return this.GameID}SetGameID(e){this.GameID=e}GetToken(){return this.Token}SetToken(e){this.Token=e}Cast(){return{0:this.GameID,1:this.Token}}ToString(){return JSON.stringify(this.Cast())}},t.Data=class{constructor(){}GetID(){return this.ID}SetID(e){this.ID=e}GetUser(){return this.User}SetUser(e){this.User=e}GetInvite(){return this.Invite}SetInvite(e){this.Invite=e}GetName(){return this.Name}SetName(e){this.Name=e}GetHead(){return this.Head}SetHead(e){this.Head=e}GetMin(){return this.Min}SetMin(e){this.Min=e}GetMax(){return this.Max}SetMax(e){this.Max=e}GetSyncMode(){return this.SyncMode}SetSyncMode(e){this.SyncMode=e}GetRole(){return this.Role}SetRole(e){this.Role=e}GetPrivate(){return this.Private}SetPrivate(e){this.Private=e}GetPersist(){return this.Persist}SetPersist(e){this.Persist=e}GetExtra(){return this.Extra}SetExtra(e){this.Extra=e}GetPassword(){return this.Password}SetPassword(e){this.Password=e}Parse(e){this.ID=e[0],this.User=e[1],this.Invite=e[2],this.Name=e[3],this.Head=e[4],this.Min=e[5],this.Max=e[6],this.SyncMode=e[7],this.Role=e[8],this.Private=e[9],this.Persist=e[10],this.Extra=e[11],this.Password=e[12]}Export(){return{ID:this.ID,User:this.User,Invite:this.Invite,Name:this.Name,Head:this.Head,Min:this.Min,Max:this.Max,SyncMode:this.SyncMode,Role:this.Role,Private:this.Private,Persist:this.Persist,Extra:this.Extra,Password:this.Password}}Cast(){return{0:this.ID,1:this.User,2:this.Invite,3:this.Name,4:this.Head,5:this.Min,6:this.Max,7:this.SyncMode,8:this.Role,9:this.Private,10:this.Persist,11:this.Extra,12:this.Password}}ToString(){return JSON.stringify(this.Cast())}},t.StartGame=class{parse(e){let t=JSON.parse(e),n=new a;n.parse(JSON.stringify(t[2])),this.Room=t[0],this.MemerID=t[1],this.Area=n}cast(){return{0:this.Room,1:this.MemerID,2:this.Area}}toString(){return JSON.stringify(this.cast())}};class a{constructor(){this.Endpoint="",this.Port=0}parse(e){let t=JSON.parse(e);this.Endpoint=t[0],this.Protocol=t[1],this.Port=t[2],this.Token=t[3],this.PublicKey=t[4],this.Hash=t[5]}cast(){return{0:this.Endpoint,1:this.Protocol,2:this.Port,3:this.Token,4:this.PublicKey,5:this.Hash}}toString(){return JSON.stringify(this.cast())}}t.Area=a},3904:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.RealTime=void 0;const i=n(7595),r=n(6707),a=n(6137),s=n(6137),c=o(n(7026)),d=n(1563),u=n(4841),l=n(49);class m{constructor(){this.realtimeToken=BigInt(0),this.RoomID="",this.ConnectHash="",this.OnConnect=e=>{d.Log("[RealTime]","[onConnect]");let t=new s.AuthPayload;t.RoomID=this.RoomID,t.Token=r.GameService.Authentication.gameToken,t.Hash=this.ConnectHash;let n=new s.Packet;n.Action=i.Actions.RealTime.ActionAuth,n.Payload=t.ToBuffer(),n.Send()},this.OnReceive=e=>{var t,n;let o=new s.Packet;switch(o.Deserialize(Buffer.from(e.data.toString(),"base64")),o.Action){case i.Actions.RealTime.ActionAuth:this.realtimeToken=o.Token;break;case i.Actions.RealTime.ActionPublicMessage:let e=new a.Data;e.Deserialize(o.Payload),r.GameService.GSLive.RealTime.NewMessageReceived({MessageInfo:{MessageType:u.MessageType[o.Action],SendType:u.GProtocolSendType[o.Type],ClientReceiveTime:o.ClientSendTime},Message:e.Export()});break;case i.Actions.RealTime.ActionPrivateMessage:let c=new a.Data;c.Deserialize(o.Payload),r.GameService.GSLive.RealTime.NewMessageReceived({MessageInfo:{MessageType:u.MessageType[o.Action],SendType:u.GProtocolSendType[o.Type],ClientReceiveTime:o.ClientSendTime},Message:c.Export()});break;case i.Actions.RealTime.ActionJoin:let h=new a.JoinPayload;h.Parse(JSON.parse(s.BufferToString(o.Payload))),r.GameService.GSLive.RealTime.OnJoinedRoom(h.Export());break;case i.Actions.RealTime.ActionMembersDetail:let v=JSON.parse(s.BufferToString(o.Payload));r.GameService.GSLive.RealTime.RoomMembersDetailReceived(v);break;case i.Actions.RealTime.ActionLeave:let f=JSON.parse(s.BufferToString(o.Payload));r.GameService.GSLive.RealTime.OnLeaveRoom(f),f.user.isMe&&(null===(t=m.Connection)||void 0===t||t.close(),this.realtimeToken=BigInt(0),this.ConnectHash="",this.RoomID="",m.Connection=void 0);break;case i.Actions.RealTime.ActionEventMessage:let S=new a.Data;S.Deserialize(o.Payload);let p=new u.EventPayload;p.Deserialize(S.Payload),r.GameService.GSLive.RealTime.OnPropertyEvent({By:S.SenderID,Name:p.Name,Value:s.BufferToString(p.Value),Action:S.GetExtra().Action,Type:S.GetExtra().Type});break;case i.Actions.RealTime.ActionRoomInfo:let g=JSON.parse(s.BufferToString(o.Payload)),T=new l.Room;T.Parse(g),r.GameService.GSLive.RealTime.CurrentRoomInfoReceived(T.Export());break;case i.Actions.Error:console.error(`[Error] [Msg: ${null===(n=o.Payload)||void 0===n?void 0:n.toString()}]`);break;default:d.Log("[RealTime]",`[OnReceive]: ${o.ToString()}`)}},this.onDisconnect=e=>{e.wasClean?d.Log("[RealTime]",`[close] Connection closed cleanly, code=${e.code} reason=${e.reason}`):d.Log("[RealTime]","[close] Connection died"),this.realtimeToken=BigInt(0),this.ConnectHash=""}}Initilize(e,t,n,o){d.Log("[RealTime]",`[Connecting] [${e}] [ws://${n}:${o}]`),this.RoomID=e,this.ConnectHash=t,m.Connection=new c.default(`ws://${n}:${o}`),m.Connection.binaryType="arraybuffer",m.Connection.onopen=this.OnConnect,m.Connection.onmessage=this.OnReceive,m.Connection.onclose=this.onDisconnect,m.Connection.onerror=function(e){throw e}}}t.RealTime=m,m.Connection=void 0},6137:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JoinPayload=t.AuthPayload=t.BufferToString=t.StringToBuffer=t.Operations=t.Types=t.Data=t.Packet=void 0;const o=n(3904),i=n(49);function r(e){let t=unescape(encodeURIComponent(e)).split(""),n=[];for(var o=0;o<t.length;o++)n.push(t[o].charCodeAt(0));return new Uint8Array(n)}function a(e){var t=String.fromCharCode.apply(null,[].slice.call(e));return decodeURIComponent(escape(t))}var s,c;t.Packet=class{constructor(){this._Token=BigInt(0),this._Type=0,this.Send=()=>{let e=this.Serialize();o.RealTime.Connection.readyState&&o.RealTime.Connection.send(e,{binary:!0,compress:!1})}}get Action(){return this._Action}set Action(e){e>255&&(e=255),this._Action=e}get Token(){return this._Token}set Token(e){this._Token=e}get Type(){return this._Type}set Type(e){e>255&&(e=255),this._Type=e}Cast(){return{1:this.Action,2:a(this.Payload),3:Number(this.Token),4:this.Type,5:this.ClientSendTime}}ToString(){return JSON.stringify(this.Cast())}Parse(e){this.Action=e[1],this.Payload=e[2],this.Token=e[3],this.Type=e[4],this.ClientSendTime=e[5]}Serialize(){var e;let t=0,n=0;this.Payload&&(t=1),this.ClientSendTime&&(n=1);let o=[this.Action,n,t];if(1===t){let t=Buffer.alloc(2);t.writeUInt16LE(null===(e=this.Payload)||void 0===e?void 0:e.length),o=[...o,...t.valueOf()]}o.push(this.Type);let i=Buffer.alloc(8);if(i.writeBigUInt64LE(this.Token),o=[...o,...i.valueOf()],1===t&&(o=[...o,...this.Payload]),1===n){let e=Buffer.alloc(8);e.writeBigInt64LE(BigInt(this.ClientSendTime)),o=[...o,...e.valueOf()]}return new Uint8Array(o)}Deserialize(e){let t=Buffer.from(e),n=0,o=0,i=0,r=0;this.Action=t.readUInt8(n++),o=t.readUInt8(n++),i=t.readUInt8(n++),i>0&&(r=t.readUInt16LE(n),n+=2),this.Type=t.readUInt8(n++),this.Token=t.readBigUInt64LE(n),n+=8,i>0&&(this.Payload=t.slice(n,n+r),n+=r),o>0&&(this.ClientSendTime=Number(t.readBigInt64LE(n)))}},t.Data=class{constructor(){this._Extra=new Uint8Array}get SenderID(){return this._SenderID}set SenderID(e){this._SenderID=e}get ReceiverID(){return this._ReceiverID}set ReceiverID(e){this._ReceiverID=e}get Payload(){return this._Payload}set Payload(e){this._Payload=e}GetExtra(){let e=Buffer.from(this._Extra);return{Type:e.readUInt8(),Action:e.readUInt8(1)}}SetExtra(e,t){this._Extra=new Uint8Array([e,t])}Cast(){return{1:this.SenderID,2:this.ReceiverID,3:a(this.Payload),4:this._Extra}}Parse(e){this.SenderID=e[1],this.ReceiverID=e[2],this.Payload=e[3],this._Extra=e[4]}Export(){return{SenderID:this.SenderID,ReceiverID:this.ReceiverID,Payload:a(this.Payload),Extra:this.GetExtra()}}Serialize(){var e,t;let n=0,o=0,i=0,a=0;this.SenderID&&(n=1),this.ReceiverID&&(o=1),this.Payload.length>0&&(i=1),this._Extra&&(a=1);let s=[n,o,i,a],c=r(this.ReceiverID),d=r(this.SenderID);if(n>0&&s.push(d.length),o>0&&s.push(c.length),i>0){let t=Buffer.alloc(2);t.writeUInt16LE(null===(e=this.Payload)||void 0===e?void 0:e.length),s=[...s,...t.valueOf()]}if(a>0){let e=Buffer.alloc(2);e.writeUInt16LE(null===(t=this._Extra)||void 0===t?void 0:t.length),s=[...s,...e.valueOf()]}return n>0&&(s=[...s,...d]),o>0&&(s=[...s,...c]),i>0&&(s=[...s,...this.Payload]),a>0&&(s=[...s,...this._Extra]),new Uint8Array(s)}Deserialize(e){let t=Buffer.from(e),n=0,o=0,i=0,r=0,s=0,c=t.readUInt8(n++),d=t.readUInt8(n++),u=t.readUInt8(n++),l=t.readUInt8(n++);c>0&&(o=t.readUInt8(n++)),d>0&&(i=t.readUInt8(n++)),u>0&&(r=t.readUInt16LE(n),n+=2),l>0&&(s=t.readUInt16LE(n),n+=2),c>0&&(this.SenderID=a(t.slice(n,n+o)),n+=o),d>0&&(this.ReceiverID=a(t.slice(n,n+i)),n+=i),u>0&&(this.Payload=t.slice(n,n+r),n+=r),l>0&&(this._Extra=t.slice(n,n+s),n+=s)}},(c=t.Types||(t.Types={}))[c.Object=1]="Object",c[c.Function=2]="Function",c[c.Property=3]="Property",(s=t.Operations||(t.Operations={}))[s.SetMemberProperty=2]="SetMemberProperty",s[s.DelMemberProperty=3]="DelMemberProperty",s[s.SetRoomProperty=0]="SetRoomProperty",s[s.DelRoomProperty=1]="DelRoomProperty",s[s.BufferedFunction=2]="BufferedFunction",s[s.InstanceObject=0]="InstanceObject",s[s.DestroyObject=1]="DestroyObject",t.StringToBuffer=r,t.BufferToString=a,t.AuthPayload=class{Cast(){return{1:this.RoomID,2:this.Token,3:this.Hash}}Parse(e){this.RoomID=e[1],this.Token=e[2],this.Hash=e[3]}ToString(){return JSON.stringify(this.Cast())}ToBuffer(){return r(this.ToString())}},t.JoinPayload=class{Cast(){return{1:this.JoinType,2:this.Room,3:this.UserJoined,4:this.JoinMemberOrder}}Parse(e){this.JoinType=e[1];let t=new i.Room;t.Parse(e[2]),this.Room=t.Export(),this.UserJoined=e[3],this.JoinMemberOrder=e[4]}ToString(){return JSON.stringify(this.Cast())}ToBuffer(){return r(this.ToString())}Export(){return{JoinType:this.JoinType,Room:this.Room,UserJoined:this.UserJoined,JoinMemberOrder:this.JoinMemberOrder}}}},2780:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.TurnBased=void 0;const i=n(7595),r=n(6707),a=n(6351),s=n(49),c=o(n(7026)),d=n(1563);class u{constructor(){this.turnbasedToken="",this.RoomID="",this.OnConnect=e=>{let t=new a.Payload;t.SetGameID(this.RoomID),t.SetToken(r.GameService.Authentication.gameToken);let n=new s.Packet;n.SetHead(i.Actions.TurnBased.ActionAuth),n.SetData(t.ToString()),n.Send(!1)},this.OnReceive=e=>{var t;let n=new s.Packet;switch(n.Parse(e.data,""!=r.GameService.GSLive.Cipher),n.GetHead()){case i.Actions.TurnBased.ActionAuth:this.turnbasedToken=n.GetToken();break;case i.Actions.TurnBased.ActionJoin:let e=JSON.parse(n.GetData()),o=new s.JoinDetail;o.Parse(e),r.GameService.GSLive.TurnBased.OnJoinedRoom(o.Export());break;case i.Actions.TurnBased.ActionTakeTurn:let a=JSON.parse(n.GetData());r.GameService.GSLive.TurnBased.OnTakeTurn(a[1],a[0]);break;case i.Actions.TurnBased.ActionChooseNext:let c=JSON.parse(n.GetData());r.GameService.GSLive.TurnBased.OnChoosedNext(c);break;case i.Actions.TurnBased.ActionLeave:let d=JSON.parse(n.GetData());r.GameService.GSLive.TurnBased.OnLeaveRoom(d),d.user.isMe&&(null===(t=u.Connection)||void 0===t||t.close(),this.turnbasedToken="",this.RoomID="",u.Connection=void 0);break;case i.Actions.TurnBased.ActionVote:let l=JSON.parse(n.GetData()),m=new s.VoteDetail;m.Parse(l),r.GameService.GSLive.TurnBased.OnVoteReceived(m.Member,m.Outcome);break;case i.Actions.TurnBased.ActionAcceptVote:let h=JSON.parse(n.GetData()),v=new s.GameResult;v.Parse(h),r.GameService.GSLive.TurnBased.OnComplete(v);break;case i.Actions.TurnBased.ActionGetUsers:let f=JSON.parse(n.GetData());r.GameService.GSLive.TurnBased.OnRoomMembersDetailReceived(f);break;case i.Actions.TurnBased.ActionCurrentTurnDetail:let S=JSON.parse(n.GetData());r.GameService.GSLive.TurnBased.OnCurrentTurnMember(S);break;case i.Actions.TurnBased.ModifyValue:let p=JSON.parse(n.GetData()),g=new s.PropertyChange;g.Parse(p),r.GameService.GSLive.TurnBased.OnPropertyUpdated(g);break;case i.Actions.TurnBased.GetRoomInfo:let T=JSON.parse(n.GetData()),A=new s.Room;A.Parse(T),r.GameService.GSLive.TurnBased.OnCurrentRoomInfoReceived(A.Export());break;case i.Actions.Error:console.error(`[Error] [Msg: ${n.GetMsg()}]`)}},this.onDisconnect=e=>{e.wasClean?d.Log("[TurnBased]",`[close] Connection closed cleanly, code=${e.code} reason=${e.reason}`):d.Log("[TurnBased]","[close] Connection died"),this.turnbasedToken=""}}Initilize(e,t,n){if(this.RoomID=e,null==t||null==n)throw`No valid area returned from Command, ${e}, ${t}, ${n}`;"undefined"==typeof window?(d.Log("[TurnBased]",`[Node] [Connecting] [ws://${t}:${n}]`),u.Connection=new c.default(`ws://${t}:${n}`,{maxPayload:2048})):(d.Log("[TurnBased]",`[Browser] [Connecting] [ws://${t}:${n}]`),u.Connection=new WebSocket(`ws://${t}:${n}`)),u.Connection.onopen=this.OnConnect,u.Connection.onmessage=this.OnReceive,u.Connection.onclose=this.onDisconnect,u.Connection.onerror=e=>{throw e}}}t.TurnBased=u,u.Connection=void 0},49:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GameResult=t.VoteDetail=t.JoinDetail=t.PropertyChange=t.Room=t.Packet=void 0;const o=n(2780),i=n(6707),r=n(1175),a=n(6351);t.Packet=class{constructor(){this.Send=(e=!0)=>{let t=this.ToString(e);o.TurnBased.Connection.send(t)}}Parse(e,t=!0){let n=JSON.parse(e),o=n[2],r=n[3];i.GameService.GSLive.isEncriptionActive&&t&&(n[2]&&(o=Buffer.from(a.Rc4(i.GameService.GSLive.Cipher,Buffer.from(n[2],"base64").toString("latin1")),"latin1").toString("utf-8")),n[3]&&100!==n[1]&&(r=Buffer.from(a.Rc4(i.GameService.GSLive.Cipher,Buffer.from(n[3],"base64").toString("latin1")),"latin1").toString("utf-8"))),this.SetToken(n[0]),this.SetHead(n[1]),this.SetData(o),this.SetMsg(r)}GetToken(){return this.Token}SetToken(e){this.Token=e}GetHead(){return this.Head}SetHead(e){this.Head=e}GetData(){return this.Data}SetData(e){this.Data=e}GetMsg(){return this.Msg}SetMsg(e){this.Msg=e}Cast(e=!0){if(i.GameService.GSLive.isEncriptionActive&&e){if(this.Data){let e=a.Rc4(i.GameService.GSLive.Cipher,Buffer.from(this.Data).toString("utf-8")),t=Buffer.from(e,"latin1").toString("base64");this.Data=t}if(this.Msg){let e=a.Rc4(i.GameService.GSLive.Cipher,Buffer.from(this.Msg).toString("utf-8")),t=Buffer.from(e,"latin1").toString("base64");this.Msg=t}}return{0:this.Token,1:this.Head,2:this.Data,3:this.Msg}}ToString(e=!0){return JSON.stringify(this.Cast(e))}};class s{constructor(){this._Name="",this._Private=!1,this._Persist=!1}Parse(e){this.ID=e[1],this.Name=e[2],this.Logo=e[3],this.Creator=e[4],this.Min=e[5],this.Max=e[6],this.Role=e[7],this.Private=e[8],this.Status=e[9],this.NumOfMembers=e[10],this.Variables=e[11],this.Persist=e[12],this.CreatedAt=e[13]}get ID(){return this._ID}set ID(e){this._ID=e}get Name(){return this._Name}set Name(e){this._Name=e}get Logo(){return this._Logo}set Logo(e){this._Logo=e}get Creator(){return this._Creator}set Creator(e){this._Creator=e}get Min(){return this._Min}set Min(e){this._Min=e}get Max(){return this._Max}set Max(e){this._Max=e}get Role(){return this._Role}set Role(e){this._Role=e}get Private(){return this._Private}set Private(e){this._Private=e}get Status(){return this._Status}set Status(e){this._Status=e}get NumOfMembers(){return this._NumOfMembers}set NumOfMembers(e){this._NumOfMembers=e}get Variables(){return this._Variables}set Variables(e){this._Variables=e}get Persist(){return this._Persist}set Persist(e){this._Persist=e}get CreatedAt(){return this._CreatedAt}set CreatedAt(e){this._CreatedAt=e}Export(){return{ID:this.ID,Name:this.Name,Logo:this.Logo,Creator:this.Creator,Min:this.Min,Max:this.Max,Role:this.Role,Private:this.Private,Status:this.Status,NumOfMembers:this.NumOfMembers,Variables:this.Variables,Persist:this.Persist,CreatedAt:this.CreatedAt}}Cast(){return{1:this.ID,2:this.Name,3:this.Logo,4:this.Creator,5:this.Min,6:this.Max,7:this.Role,8:this.Private,9:this.Status,10:this.NumOfMembers,11:this.Variables,12:this.Persist,13:this.CreatedAt}}ToString(){return JSON.stringify(this.Cast())}}t.Room=s,t.PropertyChange=class{Parse(e){1==e[1]?this.Type=r.PropertyType.Room:this.Type=r.PropertyType.Member,3==e[2]||1==e[2]?this.Action="SetOtUpdate":this.Action="Delete",this.Sender=e[3],this.Name=e[4],this.Value=e[5]}Export(){return{Type:this.Type,Action:this.Action,Sender:this.Sender,Name:this.Name,Value:this.Value}}},t.JoinDetail=class{Parse(e){let t=new s;t.Parse(e[2]),this.JoinType=e[1],this.UserJoined=e[3],this.Room=t,this.JoinOrder=e[4]}Export(){var e;return{JoinType:this.JoinType,UserJoined:this.UserJoined,Room:null===(e=this.Room)||void 0===e?void 0:e.Export(),JoinOrder:this.JoinOrder}}},t.VoteDetail=class{Parse(e){this.Member=e[0];let t={};for(let n in e[1]){let o=new r.Outcome;o.Parse(e[1][n]),t[n]=o}this.Outcome=t}},t.GameResult=class{Parse(e){this.AcceptCount=e.Accept;let t={};for(let n in e.Outcomes){let o=new r.Outcome;o.Parse(e.Outcomes[n]),t[n]=o}this.Outcome=t}}},6745:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.RealTime=void 0;const i=n(6707),r=n(7595),a=n(4841),s=n(6351),c=n(6137);t.RealTime=class{constructor(){this.OnReconnected=()=>{},this.OnJoinedRoom=()=>{},this.OnAutoMatchUpdated=()=>{},this.OnAutoMatchCanceled=()=>{},this.OnAvailableRoomsReceived=()=>{},this.OnFindMemberReceived=()=>{},this.OnInvitationSent=()=>{},this.CurrentRoomInfoReceived=()=>{},this.RoomMembersDetailReceived=()=>{},this.NewMessageReceived=()=>{},this.OnLeaveRoom=()=>{},this.OnPropertyEvent=()=>{}}CreateRoom(e){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(i.GameService.GSLive.RealTimeController.RoomID)throw"User is already in game room, please left from it first.";let t=new s.Data;t.SetMax(e.maxPlayer),t.SetMin(e.minPlayer),t.SetName(e.roomName),t.SetPassword(e.roomPassword),t.SetRole(e.role),t.SetPersist(e.isPersist),t.SetPrivate(e.isPrivate),t.SetExtra(e.extra),t.SetSyncMode(2);let n=new s.Packet;n.SetHead(r.Actions.Command.ActionCreateRoom),n.SetToken(i.GameService.GSLive.Command.commandToken),n.SetData(t.ToString()),n.Send()}))}AutoMatch(e){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(i.GameService.GSLive.Command.isInAutoMatchQueue)throw"User is in automatch queue already";if(i.GameService.GSLive.RealTimeController.RoomID)throw"User is already in game room, please left from it first.";let t=new s.Data;t.SetMax(e.maxPlayer),t.SetMin(e.minPlayer),t.SetRole(e.role),t.SetPersist(e.isPersist),t.SetExtra(e.extra),t.SetSyncMode(2);let n=new s.Packet;n.SetHead(r.Actions.Command.ActionAutoMatch),n.SetToken(i.GameService.GSLive.Command.commandToken),n.SetData(t.ToString()),n.Send()}))}CancelAutoMatch(){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(!i.GameService.GSLive.Command.isInAutoMatchQueue)throw"User is not in automatch queue";let e=new s.Packet;e.SetHead(r.Actions.Command.LeftWaitingQ),e.SetToken(i.GameService.GSLive.Command.commandToken),e.Send()}))}GetAvailableRooms(e,t){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";let n=new s.Data;n.SetMax(t),n.SetRole(e);let o=new s.Packet;o.SetHead(r.Actions.Command.ActionGetRooms),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}JoinRoom(e,t,n){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(i.GameService.GSLive.RealTimeController.RoomID)throw"User is already in game room, please left from it first.";let o=new s.Data;o.SetID(e),o.SetExtra(t),o.SetPassword(n);let a=new s.Packet;a.SetHead(r.Actions.Command.ActionJoinRoom),a.SetToken(i.GameService.GSLive.Command.commandToken),a.SetData(o.ToString()),a.Send()}))}FindMember(e,t){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";let n=new s.Data;n.SetUser(e),n.SetMax(t);let o=new s.Packet;o.SetHead(r.Actions.Command.ActionFindUser),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}InviteUser(e,t){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";let n=new s.Data;n.SetID(e),n.SetUser(t);let o=new s.Packet;o.SetHead(r.Actions.Command.ActionInviteUser),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}GetInviteInbox(){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";let e=new s.Data;e.SetSyncMode(2);let t=new s.Packet;t.SetHead(r.Actions.Command.ActionGetInviteList),t.SetToken(i.GameService.GSLive.Command.commandToken),t.SetData(e.ToString()),t.Send()}))}AcceptInvite(e,t){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(i.GameService.GSLive.RealTimeController.RoomID)throw"User is already in game room, please left from it first.";let n=new s.Data;n.SetInvite(e),n.SetExtra(t);let o=new s.Packet;o.SetHead(r.Actions.Command.ActionAcceptInvite),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}GetCurrentRoomInfo(){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let e=new c.Packet;e.Action=r.Actions.RealTime.ActionRoomInfo,e.Token=i.GameService.GSLive.RealTimeController.realtimeToken,e.Send()}))}GetRoomMembersDetail(){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let e=new c.Packet;e.Action=r.Actions.RealTime.ActionMembersDetail,e.Token=i.GameService.GSLive.RealTimeController.realtimeToken,e.Send()}))}SendPublicMessage(e,t){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let n=new c.Packet;n.Action=r.Actions.RealTime.ActionPublicMessage,n.Token=i.GameService.GSLive.RealTimeController.realtimeToken,n.Type=t,n.Payload=c.StringToBuffer(e),n.Send()}))}SendPrivateMessage(e,t){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let n=new c.Data;n.ReceiverID=e,n.Payload=c.StringToBuffer(t);let o=new c.Packet;o.Action=r.Actions.RealTime.ActionPrivateMessage,o.Token=i.GameService.GSLive.RealTimeController.realtimeToken,o.Payload=n.Serialize(),o.Send()}))}SetOrUpdateMemberProperty(e,t){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let n=new a.EventPayload;n.Name=e,n.Value=c.StringToBuffer(t),(new c.Data).Payload=n.Serialize();let o=new c.Data;o.SetExtra(c.Types.Property,c.Operations.SetMemberProperty),o.Payload=n.Serialize();let s=new c.Packet;s.Action=r.Actions.RealTime.ActionEventMessage,s.Token=i.GameService.GSLive.RealTimeController.realtimeToken,s.Payload=o.Serialize(),s.Send()}))}RemoveMemberProperty(e){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let t=new a.EventPayload;t.Name=e,(new c.Data).Payload=t.Serialize();let n=new c.Data;n.SetExtra(c.Types.Property,c.Operations.DelMemberProperty),n.Payload=t.Serialize();let o=new c.Packet;o.Action=r.Actions.RealTime.ActionEventMessage,o.Token=i.GameService.GSLive.RealTimeController.realtimeToken,o.Payload=n.Serialize(),o.Send()}))}SetOrUpdateRoomProperty(e,t){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let n=new a.EventPayload;n.Name=e,n.Value=c.StringToBuffer(t),(new c.Data).Payload=n.Serialize();let o=new c.Data;o.SetExtra(c.Types.Property,c.Operations.SetRoomProperty),o.Payload=n.Serialize();let s=new c.Packet;s.Action=r.Actions.RealTime.ActionEventMessage,s.Token=i.GameService.GSLive.RealTimeController.realtimeToken,s.Payload=o.Serialize(),s.Send()}))}RemoveRoomProperty(e){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let t=new a.EventPayload;t.Name=e,(new c.Data).Payload=t.Serialize();let n=new c.Data;n.SetExtra(c.Types.Property,c.Operations.DelRoomProperty),n.Payload=t.Serialize();let o=new c.Packet;o.Action=r.Actions.RealTime.ActionEventMessage,o.Token=i.GameService.GSLive.RealTimeController.realtimeToken,o.Payload=n.Serialize(),o.Send()}))}GetRoomProperties(){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let e=new c.Packet;e.Action=r.Actions.RealTime.ActionGetRoomSnapshot,e.Token=i.GameService.GSLive.RealTimeController.realtimeToken,e.Send()}))}LeaveRoom(){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.RealTimeController.RoomID.length<1)throw"User is not in any game room";let e=new c.Packet;e.Action=r.Actions.RealTime.ActionLeave,e.Token=i.GameService.GSLive.RealTimeController.realtimeToken,e.Send()}))}}},4841:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventPayload=t.MessageType=t.GProtocolSendType=t.AutoMatchOptions=t.CreateRoomOptions=t.PropertyType=void 0;const o=n(6137);var i,r,a;(i=t.PropertyType||(t.PropertyType={})).Room="room",i.Member="member",t.CreateRoomOptions=class{constructor(){this.roomName="default",this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPrivate=!1,this.isPersist=!1,this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.extra=void 0,this.isPrivate=!1,this.roomPassword=void 0,this.roomName="default"}},t.AutoMatchOptions=class{constructor(){this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.extra=null}},(a=t.GProtocolSendType||(t.GProtocolSendType={}))[a.UnReliable=0]="UnReliable",a[a.Reliable=1]="Reliable",(r=t.MessageType||(t.MessageType={}))[r.Private=4]="Private",r[r.Public=3]="Public",t.EventPayload=class{constructor(){this.Name="",this.Value=new Uint8Array}Serialize(){var e;let t=Buffer.alloc(2);t.writeUInt16LE(o.StringToBuffer(this.Name).length);let n=Buffer.alloc(2);n.writeUInt16LE(null===(e=this.Value)||void 0===e?void 0:e.length);let i=[2,12,...t.valueOf(),...o.StringToBuffer(this.Name),13,...n.valueOf(),...this.Value];return new Uint8Array(i)}Deserialize(e){let t=Buffer.from(e),n=1;n++;let i=t.readUInt16LE(n);n+=2;let r=t.slice(n,n+i);n+=i,this.Name=o.BufferToString(r),n++;let a=t.readUInt16LE(n);n+=2;let s=t.slice(n,n+a);n+=a,this.Value=s}Export(){return{Name:this.Name,Value:o.BufferToString(this.Value)}}}},9875:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.TurnBased=void 0;const i=n(6707),r=n(7595),a=n(1175),s=n(49),c=n(6351);t.TurnBased=class{constructor(){this.OnReconnected=()=>{},this.OnJoinedRoom=()=>{},this.OnAutoMatchUpdated=()=>{},this.OnAutoMatchCanceled=()=>{},this.OnAvailableRoomsReceived=()=>{},this.OnFindMemberReceived=()=>{},this.NewInviteReceived=()=>{},this.OnInvitationSent=()=>{},this.OnInviteInboxReceived=()=>{},this.OnCurrentRoomInfoReceived=()=>{},this.OnRoomMembersDetailReceived=()=>{},this.OnChoosedNext=()=>{},this.OnTakeTurn=()=>{},this.OnCurrentTurnMember=()=>{},this.OnVoteReceived=()=>{},this.OnComplete=()=>{},this.OnPropertyUpdated=()=>{},this.OnLeaveRoom=()=>{}}CreateRoom(e){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(i.GameService.GSLive.TurnbasedController.RoomID)throw"User is already in game room, please left from it first.";let t=new c.Data;t.SetMax(e.maxPlayer),t.SetMin(e.minPlayer),t.SetName(e.roomName),t.SetPassword(e.roomPassword),t.SetRole(e.role),t.SetPersist(e.isPersist),t.SetPrivate(e.isPrivate),t.SetExtra(e.extra),t.SetSyncMode(1);let n=new c.Packet;n.SetHead(r.Actions.Command.ActionCreateRoom),n.SetToken(i.GameService.GSLive.Command.commandToken),n.SetData(t.ToString()),n.Send()}))}AutoMatch(e){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(i.GameService.GSLive.Command.isInAutoMatchQueue)throw"User is in automatch queue already";if(i.GameService.GSLive.TurnbasedController.RoomID)throw"User is already in game room, please left from it first.";let t=new c.Data;t.SetMax(e.maxPlayer),t.SetMin(e.minPlayer),t.SetRole(e.role),t.SetPersist(e.isPersist),t.SetExtra(e.extra),t.SetSyncMode(1);let n=new c.Packet;n.SetHead(r.Actions.Command.ActionAutoMatch),n.SetToken(i.GameService.GSLive.Command.commandToken),n.SetData(t.ToString()),n.Send()}))}CancelAutoMatch(){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(!i.GameService.GSLive.Command.isInAutoMatchQueue)throw"User is not in automatch queue";let e=new c.Packet;e.SetHead(r.Actions.Command.LeftWaitingQ),e.SetToken(i.GameService.GSLive.Command.commandToken),e.Send()}))}GetAvailableRooms(e,t){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";let n=new c.Data;n.SetMax(t),n.SetRole(e);let o=new c.Packet;o.SetHead(r.Actions.Command.ActionGetRooms),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}JoinRoom(e,t,n){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(i.GameService.GSLive.TurnbasedController.RoomID)throw"User is already in game room, please left from it first.";let o=new c.Data;o.SetID(e),o.SetExtra(t),o.SetPassword(n);let a=new c.Packet;a.SetHead(r.Actions.Command.ActionJoinRoom),a.SetToken(i.GameService.GSLive.Command.commandToken),a.SetData(o.ToString()),a.Send()}))}FindMember(e,t){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";let n=new c.Data;n.SetUser(e),n.SetMax(t);let o=new c.Packet;o.SetHead(r.Actions.Command.ActionFindUser),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}InviteUser(e,t){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";let n=new c.Data;n.SetID(e),n.SetUser(t);let o=new c.Packet;o.SetHead(r.Actions.Command.ActionInviteUser),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}GetInviteInbox(){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";let e=new c.Data;e.SetSyncMode(1);let t=new c.Packet;t.SetHead(r.Actions.Command.ActionGetInviteList),t.SetToken(i.GameService.GSLive.Command.commandToken),t.SetData(e.ToString()),t.Send()}))}AcceptInvite(e,t){return o(this,void 0,void 0,(function*(){if(""==i.GameService.GSLive.Command.commandToken)throw"User not connected to Command Server";if(i.GameService.GSLive.TurnbasedController.RoomID)throw"User is already in game room, please left from it first.";let n=new c.Data;n.SetInvite(e),n.SetExtra(t);let o=new c.Packet;o.SetHead(r.Actions.Command.ActionAcceptInvite),o.SetToken(i.GameService.GSLive.Command.commandToken),o.SetData(n.ToString()),o.Send()}))}GetCurrentRoomInfo(){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let e=new s.Packet;e.SetHead(r.Actions.TurnBased.GetRoomInfo),e.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),e.Send()}))}GetRoomMembersDetail(){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let e=new s.Packet;e.SetHead(r.Actions.TurnBased.ActionGetUsers),e.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),e.Send()}))}ChooseNext(e){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let t=new a.Data;e&&(t.Next=e);let n=new s.Packet;n.SetHead(r.Actions.TurnBased.ActionChooseNext),n.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),n.SetData(t.ToString()),n.Send()}))}TakeTurn(e,t){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let n=new a.Data;t&&(n.Next=t),n.Data=e;let o=new s.Packet;o.SetHead(r.Actions.TurnBased.ActionTakeTurn),o.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),o.SetData(n.ToString()),o.Send()}))}GetCurrentTurnMember(){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let e=new s.Packet;e.SetHead(r.Actions.TurnBased.ActionCurrentTurnDetail),e.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),e.Send()}))}Vote(e){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let t=new a.Data,n={};Object.keys(e).map((t=>{n[t]={0:e[t].Rank,1:`${e[t].Value}`}})),t.Outcomes=n;let o=new s.Packet;o.SetHead(r.Actions.TurnBased.ActionVote),o.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),o.SetData(t.ToString()),o.Send()}))}AcceptVote(e){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let t=new a.Data;t.ID=e;let n=new s.Packet;n.SetHead(r.Actions.TurnBased.ActionAcceptVote),n.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),n.SetData(t.ToString()),n.Send()}))}SetOrUpdateProperty(e,t){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let n=new a.Data;if(n.Head=1,e===a.PropertyType.Room&&(n.Head=3),!t.name||t.name.length<5||t.name.length>32)throw new Error("name of value should be between 5-32");if(!t.value||t.value.length>1024)throw new Error("value of value should less than 1024");n.ID=t.name,n.Data=t.value;let o=new s.Packet;o.SetHead(r.Actions.TurnBased.ModifyValue),o.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),o.SetData(n.ToString()),o.Send()}))}RemoveProperty(e,t){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let n=new a.Data;if(n.Head=2,e===a.PropertyType.Room&&(n.Head=4),!t||t.length<5||t.length>32)throw new Error("name of value should be between 5-32");n.ID=t;let o=new s.Packet;o.SetHead(r.Actions.TurnBased.ModifyValue),o.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),o.SetData(n.ToString()),o.Send()}))}LeaveRoom(e){return o(this,void 0,void 0,(function*(){if(i.GameService.GSLive.TurnbasedController.RoomID.length<1)throw"User is not in any game room";let t=new a.Data;t.Next=e;let n=new s.Packet;n.SetHead(r.Actions.TurnBased.ActionLeave),n.SetToken(i.GameService.GSLive.TurnbasedController.turnbasedToken),n.SetData(t.ToString()),n.Send()}))}}},1175:(e,t)=>{"use strict";var n;Object.defineProperty(t,"__esModule",{value:!0}),t.Outcome=t.AutoMatchOptions=t.CreateRoomOptions=t.PropertyType=t.Data=void 0,t.Data=class{constructor(){}Cast(){return{0:this.Head,1:this.ID,2:this.Data,3:this.Next,4:this.Outcomes,5:this.Private}}ToString(){return JSON.stringify(this.Cast())}},(n=t.PropertyType||(t.PropertyType={})).Room="room",n.Member="member",t.CreateRoomOptions=class{constructor(){this.roomName="default",this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPrivate=!1,this.isPersist=!1,this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.extra=void 0,this.isPrivate=!1,this.roomPassword=void 0,this.roomName="default"}},t.AutoMatchOptions=class{constructor(){this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.role="default",this.minPlayer=2,this.maxPlayer=2,this.isPersist=!1,this.extra=null}},t.Outcome=class{get Value(){return this._Value}set Value(e){this._Value=e}get Rank(){return this._Rank}set Rank(e){this._Rank=e}Parse(e){this.Rank=e[0],this.Value=e[1]}}},7663:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GSLive=void 0;const o=n(1351),i=n(9875),r=n(6745),a=n(6587),s=n(2780),c=n(3904);class d{constructor(){this.Cipher="",this.isEncriptionActive=!1,this.Command=new a.Command,this.TurnbasedController=new s.TurnBased,this.RealTimeController=new c.RealTime,this.TurnBased=new i.TurnBased,this.RealTime=new r.RealTime,this.Chats=new o.Chats}IsCommandAvailable(){return!0}IsTurnBasedAvailable(){return!0}IsRealTimeAvailable(){return!0}GetPing(){return 0}}t.GSLive=d,d.CommandConnection=void 0},1764:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Leaderboards=void 0;const r=i(n(9669)),a=n(6707),s=n(7595),c=n(1563);t.Leaderboards=class{constructor(){}GetLeaderBoards(){return o(this,void 0,void 0,(function*(){try{let{data:e}=yield r.default.get(`${s.Url.Api.Endpoint}${s.Url.Api.Leaderboard}`,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return c.Log("GetLeaderBoards",e),e.leaderboard}catch(e){throw console.error(e),e.response?e.response.data.msg:e}}))}SubmitScore(e,t){return o(this,void 0,void 0,(function*(){try{let{data:n}=yield r.default.post(`${s.Url.Api.Endpoint}${s.Url.Api.LeaderboardV2}${e}`,{value:t},{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return c.Log("SubmitScore",n),n.leaderboard}catch(e){throw e.response?e.response.data.msg:e}}))}GetLeaderBoardDetails(e,t=0,n=25){return o(this,void 0,void 0,(function*(){try{let{data:o}=yield r.default.get(`${s.Url.Api.Endpoint}${s.Url.Api.LeaderboardV2}${e}?skip=${t}&limit=${n}`,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return c.Log("GetLeaderBoardDetails",o),{scores:o.scores,leaderboard:o.leaderboard}}catch(e){throw e.response?e.response.data.msg:e}}))}GetCurrentPlayerScore(e){return o(this,void 0,void 0,(function*(){try{let{data:t}=yield r.default.get(`${s.Url.Api.Endpoint}${s.Url.Api.LeaderboardV2}${e}/me`,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return c.Log("GetCurrentPlayerScore",t),t}catch(e){throw e.response?e.response.data.msg:e}}))}}},965:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Player=void 0;const r=n(7595),a=n(7339),s=n(1563),c=i(n(9669)),d=n(6707),u=n(5877);t.Player=class{constructor(){}GetCurrentPlayer(){return o(this,void 0,void 0,(function*(){try{let{data:e}=yield c.default.get(`${r.Url.Api.Endpoint}${r.Url.Api.GetCurrentPlayer}`,{headers:{"x-access-token":d.GameService.Authentication.gameToken}});return s.Log("GetCurrentPlayer",e),e.data}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetMemberData(e){return o(this,void 0,void 0,(function*(){try{let{data:t}=yield c.default.get(`${r.Url.Api.Endpoint}${r.Url.Api.GetCurrentPlayer}/${e}`,{headers:{"x-access-token":d.GameService.Authentication.gameToken}});return s.Log("GetCurrentPlayer",t),t}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetLastLoginMemberInfo(){return o(this,void 0,void 0,(function*(){try{let{data:e}=yield c.default.post(`${r.Url.Api.Endpoint}${r.Url.Api.LastLoginInfo}`,{game:d.GameService.ClientID,secret:d.GameService.ClientSecret,device_id:u.v4()},{headers:{"x-access-token":d.GameService.Authentication.gameToken}});s.Log("GetLastLoginMemberInfo",e);let t=new a.MemberInfo;return t.Parse(e),t}catch(e){throw e&&e.response?e.response.data.msg:e}}))}EditCurrentPlayerProfile(e){return o(this,void 0,void 0,(function*(){try{let{data:t}=yield c.default.put(`${r.Url.Api.Endpoint}${r.Url.Api.GetCurrentPlayer}`,e.Export(),{headers:{"x-access-token":d.GameService.Authentication.gameToken}}),n=new a.MemberInfo;return n.Parse(t),n}catch(e){throw e&&e.response?e.response.data.msg:e}}))}ChangePassword(e,t){return o(this,void 0,void 0,(function*(){try{let{data:n}=yield c.default.post(`${r.Url.Api.Endpoint}${r.Url.Api.GetCurrentUser}/changepassword`,{old_password:e,new_password:t},{headers:{"x-access-token":d.GameService.Authentication.gameToken}});return s.Log("ChangePassword",n),n.data}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetActiveDevices(){return o(this,void 0,void 0,(function*(){try{let{data:e}=yield c.default.get(`${r.Url.Api.Endpoint}${r.Url.Api.Devices}`,{headers:{"x-access-token":d.GameService.Authentication.gameToken}});return s.Log("GetActiveDevices",e),e}catch(e){throw console.error(e),e&&e.response?e.response.data.msg:e}}))}RevokeActiveDevice(e){return o(this,void 0,void 0,(function*(){try{let{data:t}=yield c.default.post(`${r.Url.Api.Endpoint}${r.Url.Api.Devices}/${e}`,{headers:{"x-access-token":d.GameService.Authentication.gameToken}});return s.Log("RevokeActiveDevice",t),!0}catch(e){throw e&&e.response?e.response.data.msg:e}}))}}},7339:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Profile=t.MemberInfo=void 0,t.MemberInfo=class{constructor(){this.Parse=e=>{this.Id=e._id,this.Logo=e.logo,this.Name=e.name,this.Label=e.label,this.Tags=e.tags,this.Extra=e.extra,this.GlobalProperty=e.global_property,this.Email=e.email,this.PhoneNumber=e.phonenumber}}},t.Profile=class{Export(){return{name:this.Name,label:this.Label,tags:this.Tags,extra:this.Extra,global_property:this.GlobalProperty,options:this.Options,email:this.Email,mobile:this.Mobile}}}},3927:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Save=void 0;const r=i(n(9669)),a=n(6707),s=n(7595),c=n(1563);t.Save=class{constructor(){}Set(e,t){return o(this,void 0,void 0,(function*(){try{"object"==typeof t&&(t=JSON.stringify(t));let{data:n}=yield r.default.post(`${s.Url.Api.Endpoint}${s.Url.Api.SaveGame}`,{data:t,name:e},{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return c.Log("SetSave",n),n.new}catch(e){throw e.response?e.response.data.msg:e}}))}Get(e=""){return o(this,void 0,void 0,(function*(){try{let{data:t}=yield r.default.get(`${s.Url.Api.Endpoint}${s.Url.Api.SaveGame}${e}`,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return c.Log("GetSave",t),t}catch(e){throw e.response?e.response.data.msg:e}}))}Remove(e){return o(this,void 0,void 0,(function*(){try{let{data:t}=yield r.default.delete(`${s.Url.Api.Endpoint}${s.Url.Api.SaveGame}${e}`,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return c.Log("RemoveSave",t),!0}catch(e){throw e.response?e.response.data.msg:e}}))}}},8529:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Friends=void 0;const r=n(6707),a=n(7595),s=n(1563),c=i(n(9669));t.Friends=class{constructor(){}FindMembers(e,t=0,n=25){return o(this,void 0,void 0,(function*(){try{let o=`${a.Url.Api.Endpoint}${a.Url.Api.Friends}?q=${e}&skip=${t}&limit=${n}`,{data:i}=yield c.default.get(o,{headers:{"x-access-token":r.GameService.Authentication.gameToken}});return s.Log("FindMembers",i),[i.count,i.list]}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetMyFriends(e=0,t=25){return o(this,void 0,void 0,(function*(){try{let n=`${a.Url.Api.Endpoint}${a.Url.Api.Friends}/me?skip=${e}&limit=${t}`,{data:o}=yield c.default.get(n,{headers:{"x-access-token":r.GameService.Authentication.gameToken}});return s.Log("GetMyFriends",o),[o.count,o.list]}catch(e){throw e&&e.response?e.response.data.msg:e}}))}GetFriendRequests(e=0,t=25){return o(this,void 0,void 0,(function*(){try{let n=`${a.Url.Api.Endpoint}${a.Url.Api.Friends}/me/pending?skip=${e}&limit=${t}`,{data:o}=yield c.default.get(n,{headers:{"x-access-token":r.GameService.Authentication.gameToken}});return s.Log("GetFriendRequests",o),[o.count,o.list]}catch(e){throw e&&e.response?e.response.data.msg:e}}))}SendFriendRequest(e){return o(this,void 0,void 0,(function*(){try{let t=`${a.Url.Api.Endpoint}${a.Url.Api.Friends}/${e}`,{data:n}=yield c.default.post(t,void 0,{headers:{"x-access-token":r.GameService.Authentication.gameToken}});return s.Log("SendFriendRequest",n),n.status}catch(e){throw e&&e.response?e.response.data.msg:e}}))}AcceptFriendRequest(e){return o(this,void 0,void 0,(function*(){try{let t=`${a.Url.Api.Endpoint}${a.Url.Api.Friends}/${e}`,{data:n}=yield c.default.put(t,void 0,{headers:{"x-access-token":r.GameService.Authentication.gameToken}});return s.Log("AcceptFriendRequest",n),n.status}catch(e){throw e&&e.response?e.response.data.msg:e}}))}DeleteFriend(e){return o(this,void 0,void 0,(function*(){try{let t=`${a.Url.Api.Endpoint}${a.Url.Api.Friends}/${e}`,{data:n}=yield c.default.put(t,void 0,{headers:{"x-access-token":r.GameService.Authentication.gameToken}});return s.Log("AcceptFriendRequest",n),n.status}catch(e){throw e&&e.response?e.response.data.msg:e}}))}}},7137:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Social=void 0;const o=n(8529);t.Social=class{constructor(){this.Friends=new o.Friends}}},869:function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))((function(i,r){function a(e){try{c(o.next(e))}catch(e){r(e)}}function s(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((o=o.apply(e,t||[])).next())}))},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Table=void 0;const r=i(n(9669)),a=n(6707),s=n(7595);t.Table=class{constructor(){}GetTableItems(e,t={skip:0,limit:25,find:void 0,rowsOwner:void 0,sort:void 0}){return o(this,void 0,void 0,(function*(){try{let n=`${s.Url.Api.Endpoint}${s.Url.Api.Table}${e}?skip=${t.skip}&limit=${t.limit}`;t.rowsOwner&&""!=t.rowsOwner&&(n+=`&owner=${t.rowsOwner}`),t.sort&&t.sort[0]&&t.sort[1]&&""!=t.sort[0]&&(n+=`&sort=${t.sort[0]}&sortby=${t.sort[1]}`),t.find&&t.find[0]&&t.find[1]&&""!=t.find[0]&&(n+=`&conditionProperty=${t.find[0]}&conditionValue=${t.find[1]}`);let{data:o}=yield r.default.get(n,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return o}catch(e){throw e.response?e.response.data.msg:e}}))}Aggrigation(e){}GetTableItem(e,t){return o(this,void 0,void 0,(function*(){try{let n=`${s.Url.Api.Endpoint}${s.Url.Api.Table}${e}/${t}`,{data:o}=yield r.default.get(n,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return o.data}catch(e){throw e.response?e.response.data.msg:e}}))}AddItemToTable(e,t){return o(this,void 0,void 0,(function*(){try{let n=`${s.Url.Api.Endpoint}${s.Url.Api.Table}${e}`,{data:o}=yield r.default.post(n,t,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return o.data}catch(e){throw e.response?e.response.data.msg:e}}))}UpdateTableItem(e,t,n){return o(this,void 0,void 0,(function*(){try{let o=`${s.Url.Api.Endpoint}${s.Url.Api.Table}${e}/${t}`,{data:i}=yield r.default.put(o,n,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return i.data}catch(e){throw e.response?e.response.data.msg:e}}))}DeleteTableItem(e,t){return o(this,void 0,void 0,(function*(){try{let n=`${s.Url.Api.Endpoint}${s.Url.Api.Table}${e}/${t}`,{data:o}=yield r.default.delete(n,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return o.status}catch(e){throw e.response?e.response.data.msg:e}}))}DeleteAllTableItems(e){return o(this,void 0,void 0,(function*(){try{let t=`${s.Url.Api.Endpoint}${s.Url.Api.Table}${e}`,{data:n}=yield r.default.delete(t,{headers:{"x-access-token":a.GameService.Authentication.gameToken}});return n.status}catch(e){throw e.response?e.response.data.msg:e}}))}}},6707:function(e,t,n){"use strict";var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.GameService=void 0;const i=n(9182),r=o(n(6555)),a=n(8732),s=n(1764),c=n(2454),d=n(965),u=n(3927),l=n(869),m=n(7663),h=n(7137);class v{static Initilize(e,t,n=!0){if("string"!=typeof e||"string"!=typeof t)throw new Error(r.default.Internal.InvalidInput);v.ClientID=e,v.ClientSecret=t,v.Verbose=n,v.Authentication=new i.Authentication,v.Assets=new a.Assets,v.Achievements=new c.Achievements,v.Leaderboards=new s.Leaderboards,v.Player=new d.Player,v.Save=new u.Save,v.Table=new l.Table,v.GSLive=new m.GSLive,v.Social=new h.Social}IsAuthenticated(){return""!=v.Authentication.gameToken}IsCommandAvailabe(){var e;return(null===(e=m.GSLive.CommandConnection)||void 0===e?void 0:e.readyState)===WebSocket.OPEN&&""!=v.GSLive.Command.commandToken}}t.GameService=v,v.ClientID="",v.ClientSecret="",v.Verbose=!1,v.onReady=()=>{}},7595:(e,t)=>{"use strict";var n,o,i;Object.defineProperty(t,"__esModule",{value:!0}),t.Actions=t.Url=void 0,function(e){e.Endpoint="https://api.gamesservice.ir",e.Login="/auth/app/login",e.Start="/auth/start",e.SMSAuth="/auth/phone",e.SMSAuthCallback="/Auth/phone/callback",e.GetCurrentPlayer="/v1/member/",e.GetCurrentUser="/v1/User",e.LastLoginInfo="/auth/app/login/info",e.Devices="/v1/devices",e.GetAchievements="/v1/achievement",e.GetAchievementsv2="/v2/achievement",e.DownloadAssets="/game/",e.SaveGame="/v1/savegame/",e.Leaderboard="/v1/leaderboard/",e.LeaderboardV2="/v2/leaderboard/",e.Table="/v1/bucket/",e.Friends="/v1/friends"}(n||(n={})),function(e){e.Endpoint="https://dbaas.gamesservice.ir"}(o||(o={})),function(e){e.Endpoint="ws://localhost:3004"}(i||(i={}));let r={Api:n,DBaaS:o,Command:i};var a,s,c;t.Url=r,function(e){e[e.ActionAuth=0]="ActionAuth",e[e.ActionAutoMatch=1]="ActionAutoMatch",e[e.ActionCreateRoom=2]="ActionCreateRoom",e[e.ActionGetRooms=3]="ActionGetRooms",e[e.ActionJoinRoom=4]="ActionJoinRoom",e[e.ActionPing=5]="ActionPing",e[e.ActionInviteUser=6]="ActionInviteUser",e[e.ActionKickUser=7]="ActionKickUser",e[e.ActionGetInviteList=8]="ActionGetInviteList",e[e.ActionAcceptInvite=9]="ActionAcceptInvite",e[e.ActionFindUser=10]="ActionFindUser",e[e.ActionNotification=11]="ActionNotification",e[e.ActionInviteNotif=15]="ActionInviteNotif",e[e.ActionMirror=99]="ActionMirror",e[e.LeftWaitingQ=16]="LeftWaitingQ",e[e.ActionSubscribe=12]="ActionSubscribe",e[e.ActionPrivateChat=18]="ActionPrivateChat",e[e.ActionChat=13]="ActionChat",e[e.ActionUnSubscribe=14]="ActionUnSubscribe",e[e.ActionGetSubscribedChannels=17]="ActionGetSubscribedChannels",e[e.ActionGetMembersOfChannel=19]="ActionGetMembersOfChannel",e[e.ActionGetLastGroupMessages=20]="ActionGetLastGroupMessages",e[e.ActionGetPendingMessages=21]="ActionGetPendingMessages"}(a||(a={})),function(e){e[e.ActionAuth=1]="ActionAuth",e[e.ActionPing=2]="ActionPing",e[e.ActionCreate=10]="ActionCreate",e[e.ActionJoin=11]="ActionJoin",e[e.ActionTakeTurn=4]="ActionTakeTurn",e[e.ActionChooseNext=5]="ActionChooseNext",e[e.ActionLeave=6]="ActionLeave",e[e.ActionVote=7]="ActionVote",e[e.ActionAcceptVote=8]="ActionAcceptVote",e[e.ActionGetUsers=9]="ActionGetUsers",e[e.ActionCurrentTurnDetail=12]="ActionCurrentTurnDetail",e[e.ModifyValue=13]="ModifyValue",e[e.ModifyRoomValue=16]="ModifyRoomValue",e[e.GetRoomInfo=14]="GetRoomInfo",e[e.GetMemberSnapShot=15]="GetMemberSnapShot"}(s||(s={})),function(e){e[e.ActionAuth=1]="ActionAuth",e[e.ActionData=2]="ActionData",e[e.ActionPublicMessage=3]="ActionPublicMessage",e[e.ActionPrivateMessage=4]="ActionPrivateMessage",e[e.ActionJoin=5]="ActionJoin",e[e.ActionMembersDetail=6]="ActionMembersDetail",e[e.ActionLeave=7]="ActionLeave",e[e.ActionDestroy=8]="ActionDestroy",e[e.ActionStatus=9]="ActionStatus",e[e.ActionMirror=10]="ActionMirror",e[e.ActionEventMessage=11]="ActionEventMessage",e[e.ActionGetRoomSnapshot=12]="ActionGetRoomSnapshot",e[e.ActionObserver=13]="ActionObserver",e[e.ActionRoomInfo=14]="ActionRoomInfo"}(c||(c={}));let d={Command:a,TurnBased:s,RealTime:c,Error:100};t.Actions=d},6555:(e,t)=>{"use strict";var n,o;Object.defineProperty(t,"__esModule",{value:!0}),function(e){e.InvalidInput="Check input parameters of function"}(n||(n={})),function(e){e.INVALID_ID="Request input's are not valid"}(o||(o={})),t.default={Internal:n,Command:o}},1563:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Log=void 0,t.Log=function(e,t){console.log(e,t)}},8827:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.get=void 0;const o=n(5877);t.get=function(){let e={DeviceID:o.v4()};return JSON.stringify(e)}},5877:(e,t,n)=>{var o=n(3570),i=n(1171),r=i;r.v1=o,r.v4=i,e.exports=r},5327:e=>{for(var t=[],n=0;n<256;++n)t[n]=(n+256).toString(16).substr(1);e.exports=function(e,n){var o=n||0,i=t;return[i[e[o++]],i[e[o++]],i[e[o++]],i[e[o++]],"-",i[e[o++]],i[e[o++]],"-",i[e[o++]],i[e[o++]],"-",i[e[o++]],i[e[o++]],"-",i[e[o++]],i[e[o++]],i[e[o++]],i[e[o++]],i[e[o++]],i[e[o++]]].join("")}},5217:e=>{var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(t){var n=new Uint8Array(16);e.exports=function(){return t(n),n}}else{var o=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),o[t]=e>>>((3&t)<<3)&255;return o}}},3570:(e,t,n)=>{var o,i,r=n(5217),a=n(5327),s=0,c=0;e.exports=function(e,t,n){var d=t&&n||0,u=t||[],l=(e=e||{}).node||o,m=void 0!==e.clockseq?e.clockseq:i;if(null==l||null==m){var h=r();null==l&&(l=o=[1|h[0],h[1],h[2],h[3],h[4],h[5]]),null==m&&(m=i=16383&(h[6]<<8|h[7]))}var v=void 0!==e.msecs?e.msecs:(new Date).getTime(),f=void 0!==e.nsecs?e.nsecs:c+1,S=v-s+(f-c)/1e4;if(S<0&&void 0===e.clockseq&&(m=m+1&16383),(S<0||v>s)&&void 0===e.nsecs&&(f=0),f>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");s=v,c=f,i=m;var p=(1e4*(268435455&(v+=122192928e5))+f)%4294967296;u[d++]=p>>>24&255,u[d++]=p>>>16&255,u[d++]=p>>>8&255,u[d++]=255&p;var g=v/4294967296*1e4&268435455;u[d++]=g>>>8&255,u[d++]=255&g,u[d++]=g>>>24&15|16,u[d++]=g>>>16&255,u[d++]=m>>>8|128,u[d++]=255&m;for(var T=0;T<6;++T)u[d+T]=l[T];return t||a(u)}},1171:(e,t,n)=>{var o=n(5217),i=n(5327);e.exports=function(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var a=(e=e||{}).random||(e.rng||o)();if(a[6]=15&a[6]|64,a[8]=63&a[8]|128,t)for(var s=0;s<16;++s)t[r+s]=a[s];return t||i(a)}},7026:e=>{"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}}},t={};function n(o){var i=t[o];if(void 0!==i)return i.exports;var r=t[o]={exports:{}};return e[o].call(r.exports,r,r.exports,n),r.exports}var o={};return(()=>{"use strict";var e=o;Object.defineProperty(e,"__esModule",{value:!0});const t=n(6707);e.default=t.GameService})(),o})()}));
//# sourceMappingURL=gameservice-sdk.js.map