cq-websocket
Version:
A Node SDK for developing QQ chatbots based on WebSocket, which is depending on CoolQ and CQHTTP API plugin.
1 lines • 47 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["cq-websocket"]=e():t.CQWebSocketSDK=e()}(window,(function(){return function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=14)}([function(t,e,r){const o=r(30);t.exports=class t{constructor(t,e=null){this.data=e,this._type=t,this._modifier=null}get tagName(){return this._type}get modifier(){return this._modifier||new Proxy({},{set:(t,e,r)=>(this._modifier={[e]:r},!0)})}set modifier(t){this._modifier=t}equals(e){return e instanceof t&&(this._type===e._type&&o(this.data,e.data,{strict:!0}))}toJSON(){const t={};for(let e of Object.keys(this.data||{}))void 0!==this.data[e]&&(t[e]=String(this.data[e]));for(let e of Object.keys(this._modifier||{}))void 0!==this._modifier[e]&&(t[e]=String(this._modifier[e]));return{type:this._type,data:Object.keys(t).length>0?t:null}}valueOf(){return this.toString()}toString(){let t=`[CQ:${this._type}`;for(let e of Object.keys(this.data||{}))void 0!==this.data[e]&&(t+=`,${e}=${this.data[e]}`);for(let e of Object.keys(this._modifier||{}))void 0!==this._modifier[e]&&(t+=`,${e}=${this._modifier[e]}`);return t+="]",t}coerce(){return this}}},function(t,e,r){"use strict";var o,n,i,s=r(21),a="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function c(){i=!1}function u(t){if(t){if(t!==o){if(t.length!==a.length)throw new Error("Custom alphabet for shortid must be "+a.length+" unique characters. You submitted "+t.length+" characters: "+t);var e=t.split("").filter((function(t,e,r){return e!==r.lastIndexOf(t)}));if(e.length)throw new Error("Custom alphabet for shortid must be "+a.length+" unique characters. These characters were not unique: "+e.join(", "));o=t,c()}}else o!==a&&(o=a,c())}function p(){return i||(i=function(){o||u(a);for(var t,e=o.split(""),r=[],n=s.nextValue();e.length>0;)n=s.nextValue(),t=Math.floor(n*e.length),r.push(e.splice(t,1)[0]);return r.join("")}())}t.exports={get:function(){return o||a},characters:function(t){return u(t),o},seed:function(t){s.seed(t),n!==t&&(c(),n=t)},lookup:function(t){return p()[t]},shuffled:p}},function(t,e,r){"use strict";var o=r(36);t.exports=Function.prototype.bind||o},function(t,e,r){"use strict";var o=r(7),n="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),i=Object.prototype.toString,s=Array.prototype.concat,a=Object.defineProperty,c=a&&function(){var t={};try{for(var e in a(t,"x",{enumerable:!1,value:t}),t)return!1;return t.x===t}catch(t){return!1}}(),u=function(t,e,r,o){var n;(!(e in t)||"function"==typeof(n=o)&&"[object Function]"===i.call(n)&&o())&&(c?a(t,e,{configurable:!0,enumerable:!1,value:r,writable:!0}):t[e]=r)},p=function(t,e){var r=arguments.length>2?arguments[2]:{},i=o(e);n&&(i=s.call(i,Object.getOwnPropertySymbols(e)));for(var a=0;a<i.length;a+=1)u(t,i[a],e[i[a]],r[i[a]])};p.supportsDescriptors=!!c,t.exports=p},function(t,e){t.exports=function(t,e){return void 0!==t?e(t):void 0}},function(t,e,r){(function(e){var r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,o=/^\w*$/,n=/^\./,i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,s=/\\(\\)?/g,a=/^\[object .+?Constructor\]$/,c="object"==typeof e&&e&&e.Object===Object&&e,u="object"==typeof self&&self&&self.Object===Object&&self,p=c||u||Function("return this")();var l,f=Array.prototype,h=Function.prototype,d=Object.prototype,y=p["__core-js_shared__"],g=(l=/[^.]+$/.exec(y&&y.keys&&y.keys.IE_PROTO||""))?"Symbol(src)_1."+l:"",m=h.toString,_=d.hasOwnProperty,b=d.toString,v=RegExp("^"+m.call(_).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),S=p.Symbol,E=f.splice,w=T(p,"Map"),x=T(Object,"create"),k=S?S.prototype:void 0,O=k?k.toString:void 0;function A(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function j(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function P(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}function C(t,e){for(var r,o,n=t.length;n--;)if((r=t[n][0])===(o=e)||r!=r&&o!=o)return n;return-1}function I(t,e){for(var n,i=0,s=(e=function(t,e){if(F(t))return!1;var n=typeof t;if("number"==n||"symbol"==n||"boolean"==n||null==t||R(t))return!0;return o.test(t)||!r.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:F(n=e)?n:D(n)).length;null!=t&&i<s;)t=t[M(e[i++])];return i&&i==s?t:void 0}function N(t){return!(!U(t)||(e=t,g&&g in e))&&(function(t){var e=U(t)?b.call(t):"";return"[object Function]"==e||"[object GeneratorFunction]"==e}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?v:a).test(function(t){if(null!=t){try{return m.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function B(t,e){var r,o,n=t.__data__;return("string"==(o=typeof(r=e))||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==r:null===r)?n["string"==typeof e?"string":"hash"]:n.map}function T(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return N(r)?r:void 0}A.prototype.clear=function(){this.__data__=x?x(null):{}},A.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},A.prototype.get=function(t){var e=this.__data__;if(x){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return _.call(e,t)?e[t]:void 0},A.prototype.has=function(t){var e=this.__data__;return x?void 0!==e[t]:_.call(e,t)},A.prototype.set=function(t,e){return this.__data__[t]=x&&void 0===e?"__lodash_hash_undefined__":e,this},j.prototype.clear=function(){this.__data__=[]},j.prototype.delete=function(t){var e=this.__data__,r=C(e,t);return!(r<0)&&(r==e.length-1?e.pop():E.call(e,r,1),!0)},j.prototype.get=function(t){var e=this.__data__,r=C(e,t);return r<0?void 0:e[r][1]},j.prototype.has=function(t){return C(this.__data__,t)>-1},j.prototype.set=function(t,e){var r=this.__data__,o=C(r,t);return o<0?r.push([t,e]):r[o][1]=e,this},P.prototype.clear=function(){this.__data__={hash:new A,map:new(w||j),string:new A}},P.prototype.delete=function(t){return B(this,t).delete(t)},P.prototype.get=function(t){return B(this,t).get(t)},P.prototype.has=function(t){return B(this,t).has(t)},P.prototype.set=function(t,e){return B(this,t).set(t,e),this};var D=$((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(R(t))return O?O.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var r=[];return n.test(t)&&r.push(""),t.replace(i,(function(t,e,o,n){r.push(o?n.replace(s,"$1"):e||t)})),r}));function M(t){if("string"==typeof t||R(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function $(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var o=arguments,n=e?e.apply(this,o):o[0],i=r.cache;if(i.has(n))return i.get(n);var s=t.apply(this,o);return r.cache=i.set(n,s),s};return r.cache=new($.Cache||P),r}$.Cache=P;var F=Array.isArray;function U(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function R(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==b.call(t)}t.exports=function(t,e,r){var o=null==t?void 0:I(t,e);return void 0===o?r:o}}).call(this,r(6))},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";var o=Array.prototype.slice,n=r(8),i=Object.keys,s=i?function(t){return i(t)}:r(31),a=Object.keys;s.shim=function(){Object.keys?function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2)||(Object.keys=function(t){return n(t)?a(o.call(t)):a(t)}):Object.keys=s;return Object.keys||s},t.exports=s},function(t,e,r){"use strict";var o=Object.prototype.toString;t.exports=function(t){var e=o.call(t),r="[object Arguments]"===e;return r||(r="[object Array]"!==e&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===o.call(t.callee)),r}},function(t,e,r){"use strict";var o=Object,n=TypeError;t.exports=function(){if(null!=this&&this!==o(this))throw new n("RegExp.prototype.flags getter called on non-object");var t="";return this.global&&(t+="g"),this.ignoreCase&&(t+="i"),this.multiline&&(t+="m"),this.dotAll&&(t+="s"),this.unicode&&(t+="u"),this.sticky&&(t+="y"),t}},function(t,e,r){"use strict";var o=r(9),n=r(3).supportsDescriptors,i=Object.getOwnPropertyDescriptor,s=TypeError;t.exports=function(){if(!n)throw new s("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");if("gim"===/a/gim.flags){var t=i(RegExp.prototype,"flags");if(t&&"function"==typeof t.get&&"boolean"==typeof/a/.dotAll)return t.get}return o}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(t){super("text",{text:t})}get text(){return this.data.text}coerce(){return this.data.text=String(this.data.text),this}toString(){return this.data.text}}},function(t,e){const r=["face","emoji","bface","sface","image","record","at","rps","dice","shake","anonymous","music","share","text"];t.exports=function(t){return r.includes(t)}},function(t,e,r){const o=r(47),n=r(48),i=r(49),s=r(50),a=r(51),c=r(52),u=r(53),p=r(54),l=r(55),f=r(56),h=r(57),d=r(58),y=r(59),g=r(60),m=r(11);t.exports={CQAnonymous:o,CQAt:n,CQBFace:i,CQCustomMusic:s,CQDice:a,CQEmoji:c,CQFace:u,CQImage:p,CQMusic:l,CQRecord:f,CQRPS:h,CQSFace:d,CQShake:y,CQShare:g,CQText:m}},function(t,e,r){const o=r(15).w3cwebsocket,n=r(19),i=r(5),s=r(28).CQEventBus,a=r(44),c=r(45),{parse:u}=c,{SocketError:p,InvalidWsTypeError:l,InvalidContextError:f,APITimeoutError:h,UnexpectedContextError:d}=r(61),y={API:"/api",EVENT:"/event"},g={DISABLED:-1,INIT:0,CONNECTING:1,CONNECTED:2,CLOSING:3,CLOSED:4},m=["https:","http:","ws:","wss:"];class _ extends a{constructor({protocol:t="ws:",host:e="127.0.0.1",port:r=6700,accessToken:o="",baseUrl:n,enableAPI:i=!0,enableEvent:a=!0,qq:c=-1,reconnection:u=!0,reconnectionAttempts:p=1/0,reconnectionDelay:l=1e3,requestOptions:f={},fragmentOutgoingMessages:h=!1,fragmentationThreshold:d,tlsOptions:y}={}){super("__call__"),(t=t.toLowerCase())&&!t.endsWith(":")&&(t+=":"),n&&0===m.filter(t=>n.startsWith(t+"//")).length&&(n=`${t}//${n}`),this._token=String(o),this._qq=parseInt(c),this._baseUrl=n||`${t}//${e}:${r}`,this._reconnectOptions={reconnection:u,reconnectionAttempts:p,reconnectionDelay:l},this._requestOptions=f,this._wsOptions={},Object.entries({fragmentOutgoingMessages:h,fragmentationThreshold:d,tlsOptions:y}).filter(([t,e])=>void 0!==e).forEach(([t,e])=>{this._wsOptions[t]=e}),this._monitor={EVENT:{attempts:0,state:a?g.INIT:g.DISABLED,reconnecting:!1},API:{attempts:0,state:i?g.INIT:g.DISABLED,reconnecting:!1}},this._responseHandlers=new Map,this._eventBus=new s(this)}off(t,e){return this._eventBus.off(t,e),this}on(t,e){return this._eventBus.on(t,e),this}once(t,e){return this._eventBus.once(t,e),this}__call__(t,e,r){if(!this._apiSock)return Promise.reject(new Error("API socket has not been initialized."));let o={timeout:1/0,...this._requestOptions};return"number"==typeof r?o.timeout=r:"object"==typeof r&&(o={...o,...r}),new Promise((r,i)=>{let s;const a={action:t,params:e};this._eventBus.emit("api.send.pre",a);const c=t=>{this._responseHandlers.delete(u),i(t)},u=n.generate();this._responseHandlers.set(u,{onFailure:c,onSuccess:t=>{s&&(clearTimeout(s),s=void 0),this._responseHandlers.delete(u),delete t.echo,r(t)}}),this._apiSock.send(JSON.stringify({...a,echo:{reqid:u}})),this._eventBus.emit("api.send.post"),o.timeout<1/0&&(s=setTimeout(()=>{this._responseHandlers.delete(u),c(new h(o.timeout,a))},o.timeout))})}_handle(t){switch(t.post_type){case"message":const e=u(t.message);switch(t.message_type){case"private":this._eventBus.emit("message.private",t,e);break;case"discuss":{const r=e.filter(t=>"at"===t.tagName);r.length>0?r.filter(t=>t.qq===this._qq).length>0?this._eventBus.emit("message.discuss.@.me",t,e):this._eventBus.emit("message.discuss.@",t,e):this._eventBus.emit("message.discuss",t,e)}break;case"group":{const r=e.filter(t=>"at"===t.tagName);r.length>0?r.filter(t=>t.qq===this._qq).length>0?this._eventBus.emit("message.group.@.me",t,e):this._eventBus.emit("message.group.@",t,e):this._eventBus.emit("message.group",t,e)}break;default:this._eventBus.emit("error",new d(t,'unexpected "message_type"'))}break;case"notice":switch(t.notice_type){case"group_upload":this._eventBus.emit("notice.group_upload",t);break;case"group_admin":switch(t.sub_type){case"set":this._eventBus.emit("notice.group_admin.set",t);break;case"unset":this._eventBus.emit("notice.group_admin.unset",t);break;default:this._eventBus.emit("error",new d(t,'unexpected "sub_type"'))}break;case"group_decrease":switch(t.sub_type){case"leave":this._eventBus.emit("notice.group_decrease.leave",t);break;case"kick":this._eventBus.emit("notice.group_decrease.kick",t);break;case"kick_me":this._eventBus.emit("notice.group_decrease.kick_me",t);break;default:this._eventBus.emit("error",new d(t,'unexpected "sub_type"'))}break;case"group_increase":switch(t.sub_type){case"approve":this._eventBus.emit("notice.group_increase.approve",t);break;case"invite":this._eventBus.emit("notice.group_increase.invite",t);break;default:this._eventBus.emit("error",new d(t,'unexpected "sub_type"'))}break;case"friend_add":this._eventBus.emit("notice.friend_add",t);break;case"group_ban":switch(t.sub_type){case"ban":this._eventBus.emit("notice.group_ban.ban",t);break;case"lift_ban":this._eventBus.emit("notice.group_ban.lift_ban",t);break;default:this._eventBus.emit("error",new d(t,'unexpected "sub_type"'))}break;default:this._eventBus.emit("error",new d(t,'unexpected "notice_type"'))}break;case"request":switch(t.request_type){case"friend":this._eventBus.emit("request.friend",t);break;case"group":switch(t.sub_type){case"add":this._eventBus.emit("request.group.add",t);break;case"invite":this._eventBus.emit("request.group.invite",t);break;default:this._eventBus.emit("error",new d(t,'unexpected "sub_type"'))}break;default:this._eventBus.emit("error",new d(t,'unexpected "request_type"'))}break;case"meta_event":switch(t.meta_event_type){case"lifecycle":this._eventBus.emit("meta_event.lifecycle",t);break;case"heartbeat":this._eventBus.emit("meta_event.heartbeat",t);break;default:this._eventBus.emit("error",new d(t,'unexpected "meta_event_type"'))}break;default:this._eventBus.emit("error",new d(t,'unexpected "post_type"'))}}_forEachSock(t,e=[y.EVENT,y.API]){Array.isArray(e)||(e=[e]),e.forEach(e=>{t(e,e===y.EVENT?"EVENT":"API")})}isSockConnected(t){if(t===y.API)return this._monitor.API.state===g.CONNECTED;if(t===y.EVENT)return this._monitor.EVENT.state===g.CONNECTED;throw new l(t)}connect(t){return this._forEachSock((t,e)=>{if([g.INIT,g.CLOSED].includes(this._monitor[e].state)){const r=this._token?`?access_token=${this._token}`:"";let n=new o(`${this._baseUrl}/${e.toLowerCase()}${r}`,void 0,this._wsOptions);t===y.EVENT?this._eventSock=n:this._apiSock=n,n.addEventListener("open",()=>{this._monitor[e].state=g.CONNECTED,this._eventBus.emit("socket.connect",y[e],n,this._monitor[e].attempts),this._monitor[e].reconnecting&&this._eventBus.emit("socket.reconnect",y[e],this._monitor[e].attempts),this._monitor[e].attempts=0,this._monitor[e].reconnecting=!1,this.isReady()&&(this._eventBus.emit("ready",this),this._monitor.API.state!==g.DISABLED&&this._qq<0&&this("get_login_info").then(t=>{this._qq=parseInt(i(t,"data.user_id",-1))}).catch(t=>{this._eventBus.emit("error",t)}))},{once:!0});const s=e=>{let r;try{r=JSON.parse(e.data)}catch(r){return void this._eventBus.emit("error",new f(t,e.data))}if(t===y.EVENT)this._handle(r);else{const t=i(r,"echo.reqid","");let{onSuccess:e}=this._responseHandlers.get(t)||{};"function"==typeof e&&e(r),this._eventBus.emit("api.response",r)}};n.addEventListener("message",s),n.addEventListener("close",r=>{this._monitor[e].state=g.CLOSED,this._eventBus.emit("socket.close",y[e],r.code,r.reason),1e3!==r.code&&this._reconnectOptions.reconnection&&this.reconnect(this._reconnectOptions.reconnectionDelay,y[e]),n.removeEventListener("message",s),n=null,t===y.EVENT?this._eventSock=null:this._apiSock=null},{once:!0}),n.addEventListener("error",()=>{const t=this._monitor[e].state===g.CONNECTING?"Failed to establish the websocket connection.":this._monitor[e].state===g.CONNECTED?"The websocket connection has been hung up unexpectedly.":`Unknown error occured. Conection state: ${this._monitor[e].state}`;this._eventBus.emit("socket.error",y[e],new p(t)),this._monitor[e].state===g.CONNECTED?(this._monitor[e].state=g.CLOSING,this._eventBus.emit("socket.closing",y[e])):this._monitor[e].state===g.CONNECTING&&(this._monitor[e].state=g.CLOSED,this._eventBus.emit("socket.failed",y[e],this._monitor[e].attempts),this._monitor[e].reconnecting&&this._eventBus.emit("socket.reconnect_failed",y[e],this._monitor[e].attempts),this._monitor[e].reconnecting=!1,this._reconnectOptions.reconnection&&this._monitor[e].attempts<=this._reconnectOptions.reconnectionAttempts?this.reconnect(this._reconnectOptions.reconnectionDelay,y[e]):this._eventBus.emit("socket.max_reconnect",y[e],this._monitor[e].attempts))},{once:!0}),this._monitor[e].state=g.CONNECTING,this._monitor[e].attempts++,this._eventBus.emit("socket.connecting",t,this._monitor[e].attempts)}},t),this}disconnect(t){return this._forEachSock((t,e)=>{if(this._monitor[e].state===g.CONNECTED){const r=t===y.EVENT?this._eventSock:this._apiSock;this._monitor[e].state=g.CLOSING,r.close(1e3,"Normal connection closure"),this._eventBus.emit("socket.closing",t)}},t),this}reconnect(t,e){"number"!=typeof t&&(t=0);const r=(e,r)=>{setTimeout(()=>{this.connect(e)},t)};return this._forEachSock((t,e)=>{if(!this._monitor[e].reconnecting)switch(this._monitor[e].state){case g.CONNECTED:this._monitor[e].reconnecting=!0,this._eventBus.emit("socket.reconnecting",t,this._monitor[e].attempts),this.disconnect(t),this._eventBus.once("socket.close",e=>e===t&&r(t));break;case g.CLOSED:case g.INIT:this._monitor[e].reconnecting=!0,this._eventBus.emit("socket.reconnecting",t,this._monitor[e].attempts),r(t)}},e),this}isReady(){let t=this._monitor.EVENT.state===g.DISABLED||this._monitor.EVENT.state===g.CONNECTED,e=this._monitor.API.state===g.DISABLED||this._monitor.API.state===g.CONNECTED;return t&&e}}t.exports={default:_,CQWebSocket:_,WebSocketType:y,WebSocketState:g,SocketError:p,InvalidWsTypeError:l,InvalidContextError:f,APITimeoutError:h,UnexpectedContextError:d,...c}},function(t,e,r){var o;try{o=r(16)}catch(t){}finally{if(o||"undefined"==typeof window||(o=window),!o)throw new Error("Could not determine global this")}var n=o.WebSocket||o.MozWebSocket,i=r(17);function s(t,e){return e?new n(t,e):new n(t)}n&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach((function(t){Object.defineProperty(s,t,{get:function(){return n[t]}})})),t.exports={w3cwebsocket:n?s:null,version:i}},function(t,e){var r=function(){if("object"==typeof self&&self)return self;if("object"==typeof window&&window)return window;throw new Error("Unable to resolve global `this`")};t.exports=function(){if(this)return this;if("object"==typeof globalThis&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch(t){return r()}try{return __global__||r()}finally{delete Object.prototype.__global__}}()},function(t,e,r){t.exports=r(18).version},function(t){t.exports=JSON.parse('{"name":"websocket","description":"Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.","keywords":["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],"author":"Brian McKelvey <theturtle32@gmail.com> (https://github.com/theturtle32)","contributors":["Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"],"version":"1.0.31","repository":{"type":"git","url":"https://github.com/theturtle32/WebSocket-Node.git"},"homepage":"https://github.com/theturtle32/WebSocket-Node","engines":{"node":">=0.10.0"},"dependencies":{"debug":"^2.2.0","es5-ext":"^0.10.50","nan":"^2.14.0","typedarray-to-buffer":"^3.1.5","yaeti":"^0.0.6"},"devDependencies":{"buffer-equal":"^1.0.0","faucet":"^0.0.1","gulp":"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1","jshint":"^2.0.0","tape":"^4.9.1"},"config":{"verbose":false},"scripts":{"install":"(node-gyp rebuild 2> builderror.log) || (exit 0)","test":"faucet test/unit","gulp":"gulp"},"main":"index","directories":{"lib":"./lib"},"browser":"lib/browser.js","license":"Apache-2.0","_resolved":"https://registry.npmjs.org/websocket/-/websocket-1.0.31.tgz","_integrity":"sha512-VAouplvGKPiKFDTeCCO65vYHsyay8DqoBSlzIO3fayrfOgU94lQN5a1uWVnFrMLceTJw/+fQXR5PGbUVRaHshQ==","_from":"websocket@1.0.31"}')},function(t,e,r){"use strict";t.exports=r(20)},function(t,e,r){"use strict";var o=r(1),n=r(22),i=r(26),s=r(27)||0;function a(){return n(s)}t.exports=a,t.exports.generate=a,t.exports.seed=function(e){return o.seed(e),t.exports},t.exports.worker=function(e){return s=e,t.exports},t.exports.characters=function(t){return void 0!==t&&o.characters(t),o.shuffled()},t.exports.isValid=i},function(t,e,r){"use strict";var o=1;t.exports={nextValue:function(){return(o=(9301*o+49297)%233280)/233280},seed:function(t){o=t}}},function(t,e,r){"use strict";var o,n,i=r(23);r(1);t.exports=function(t){var e="",r=Math.floor(.001*(Date.now()-1567752802062));return r===n?o++:(o=0,n=r),e+=i(7),e+=i(t),o>0&&(e+=i(o)),e+=i(r)}},function(t,e,r){"use strict";var o=r(1),n=r(24),i=r(25);t.exports=function(t){for(var e,r=0,s="";!e;)s+=i(n,o.get(),1),e=t<Math.pow(16,r+1),r++;return s}},function(t,e,r){"use strict";var o,n="object"==typeof window&&(window.crypto||window.msCrypto);o=n&&n.getRandomValues?function(t){return n.getRandomValues(new Uint8Array(t))}:function(t){for(var e=[],r=0;r<t;r++)e.push(Math.floor(256*Math.random()));return e},t.exports=o},function(t,e){t.exports=function(t,e,r){for(var o=(2<<Math.log(e.length-1)/Math.LN2)-1,n=-~(1.6*o*r/e.length),i="";;)for(var s=t(n),a=n;a--;)if((i+=e[s[a]&o]||"").length===+r)return i}},function(t,e,r){"use strict";var o=r(1);t.exports=function(t){return!(!t||"string"!=typeof t||t.length<6)&&!new RegExp("[^"+o.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(t)}},function(t,e,r){"use strict";t.exports=0},function(t,e,r){const o=r(5),n=r(29),i=r(0),s=r(11);function a(t,e){throw e.which=t,console.error('\nYou should listen on "socket.error" yourself to avoid those unhandled promise warnings.\n'),e}class c{constructor(){this._isCanceled=!1,this._message="",this._responseHandler=null,this._responseOptions=null,this._errorHandler=null}get messageFormat(){return"string"==typeof this._message?"string":"array"}stopPropagation(){this._isCanceled=!0}getMessage(){return this._message}hasMessage(){return"string"==typeof this._message?Boolean(this._message):this._message.length>0}setMessage(t){Array.isArray(t)&&(t=t.map(t=>"string"==typeof t?new s(t):t)),this._message=t}appendMessage(t){"string"==typeof this._message?this._message+=String(t):("string"==typeof t&&(t=new s(t)),this._message.push(t))}onResponse(t,e){"function"!=typeof t&&(e=t,t=null),this._responseHandler=t,this._responseOptions=e}onError(t){this._errorHandler=t}}t.exports={CQEventBus:class{constructor(t){this._EventMap={message:{"":[],private:[],group:{"":[],"@":{"":[],me:[]}},discuss:{"":[],"@":{"":[],me:[]}}},event:[],notice:{"":[],group_upload:[],group_admin:{"":[],set:[],unset:[]},group_decrease:{"":[],leave:[],kick:[],kick_me:[]},group_increase:{"":[],approve:[],invite:[]},friend_add:[],group_ban:{"":[],ban:[],lift_ban:[]}},request:{"":[],friend:[],group:{"":[],add:[],invite:[]}},ready:[],error:[],socket:{connecting:[],connect:[],failed:[],reconnecting:[],reconnect:[],reconnect_failed:[],max_reconnect:[],error:[],closing:[],close:[]},api:{response:[],send:{pre:[],post:[]}},meta_event:{"":[],lifecycle:[],heartbeat:[]}},this._onceListeners=new WeakMap,this._isSocketErrorHandled=!1,this._bot=t,this._installDefaultErrorHandler()}_getHandlerQueue(t){let e=o(this._EventMap,t);return Array.isArray(e)?e:(e=o(this._EventMap,`${t}.`),Array.isArray(e)?e:void 0)}count(t){let e=this._getHandlerQueue(t);return e?e.length:void 0}has(t){return void 0!==this._getHandlerQueue(t)}emit(t,...e){return this._emitThroughHierarchy(t,...e)}async _emitThroughHierarchy(t,...e){let r=[],o=t.startsWith("message");for(let e=t.split(".");e.length>0;e.pop()){let t=this._getHandlerQueue(e.join("."));t&&t.length>0&&r.push(...t)}if(r&&r.length>0){let t=o?new c:void 0;o&&Array.isArray(e)&&e.unshift(t);for(let n of r){o&&(t._errorHandler=t._responseHandler=t._responseOptions=null);let r=await Promise.resolve(n(...e));if(o&&("string"==typeof r||Array.isArray(r))&&(t.stopPropagation(),t.setMessage(r)),o&&t._isCanceled)break}if(o&&t.hasMessage()){let r=t.getMessage();r=Array.isArray(r)?r.filter(t=>"object"==typeof t).map(t=>t instanceof i?t.toJSON():t):r,this._bot("send_msg",{...e[1],message:r},t._responseOptions).then(e=>{"function"==typeof t._responseHandler&&t._responseHandler(e)}).catch(e=>{"function"==typeof t._errorHandler?t._errorHandler(e):this.emit("error",e)})}}}once(t,e){const r=(...o)=>{let n=e(...o);if(!1!==n)return this.off(t,r),n};return this._onceListeners.set(e,r),this.on(t,r)}off(t,e){if("string"!=typeof t)return this._onceListeners=new WeakMap,n(this._EventMap,t=>{if(Array.isArray(t))return t.splice(0,t.length),!1}),this._installDefaultErrorHandler(),this;const r=this._getHandlerQueue(t);if(void 0===r)return this;if("function"!=typeof e)return r.splice(0,r.length),"socket.error"===t&&this._installDefaultErrorHandler(),this;const o=r.indexOf(e),i=this._onceListeners.has(e)?r.indexOf(this._onceListeners.get(e)):-1,s=o>=0&&i>=0?Math.min(o,i):o>=0?o:i>=0?i:-1;return s>=0?(r.splice(s,1),s===i&&this._onceListeners.delete(e),"socket.error"===t&&0===r.length&&this._installDefaultErrorHandler(),this):this}_installDefaultErrorHandler(){0===this._EventMap.socket.error.length&&(this._EventMap.socket.error.push(a),this._isSocketErrorHandled=!1)}_removeDefaultErrorHandler(){this._isSocketErrorHandled||(this._EventMap.socket.error.splice(0,this._EventMap.socket.error.length),this._isSocketErrorHandled=!0)}on(t,e){if(t.endsWith("@me")&&(t=t.replace(/\.@me$/,".@.me")),!this.has(t))return this;"socket.error"===t&&this._removeDefaultErrorHandler();let r=this._getHandlerQueue(t);return r&&r.push(e),this}},CQEvent:c}},function(t,e){t.exports=function t(e,r=function(){}){"object"==typeof e&&Object.keys(e).forEach((function(o){!1!==r(e[o],o,e)&&t(e[o],r)}))}},function(t,e,r){var o=r(7),n=r(32),i=r(33),s=r(34),a=r(37),c=r(43),u=Date.prototype.getTime;function p(t,e,r){var h=r||{};return!!(h.strict?i(t,e):t===e)||(!t||!e||"object"!=typeof t&&"object"!=typeof e?h.strict?i(t,e):t==e:function(t,e,r){var i,h;if(typeof t!=typeof e)return!1;if(l(t)||l(e))return!1;if(t.prototype!==e.prototype)return!1;if(n(t)!==n(e))return!1;var d=s(t),y=s(e);if(d!==y)return!1;if(d||y)return t.source===e.source&&a(t)===a(e);if(c(t)&&c(e))return u.call(t)===u.call(e);var g=f(t),m=f(e);if(g!==m)return!1;if(g||m){if(t.length!==e.length)return!1;for(i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}if(typeof t!=typeof e)return!1;try{var _=o(t),b=o(e)}catch(t){return!1}if(_.length!==b.length)return!1;for(_.sort(),b.sort(),i=_.length-1;i>=0;i--)if(_[i]!=b[i])return!1;for(i=_.length-1;i>=0;i--)if(h=_[i],!p(t[h],e[h],r))return!1;return!0}(t,e,h))}function l(t){return null==t}function f(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]))}t.exports=p},function(t,e,r){"use strict";var o;if(!Object.keys){var n=Object.prototype.hasOwnProperty,i=Object.prototype.toString,s=r(8),a=Object.prototype.propertyIsEnumerable,c=!a.call({toString:null},"toString"),u=a.call((function(){}),"prototype"),p=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(t){var e=t.constructor;return e&&e.prototype===t},f={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},h=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!f["$"+t]&&n.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();o=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===i.call(t),o=s(t),a=e&&"[object String]"===i.call(t),f=[];if(!e&&!r&&!o)throw new TypeError("Object.keys called on a non-object");var d=u&&r;if(a&&t.length>0&&!n.call(t,0))for(var y=0;y<t.length;++y)f.push(String(y));if(o&&t.length>0)for(var g=0;g<t.length;++g)f.push(String(g));else for(var m in t)d&&"prototype"===m||!n.call(t,m)||f.push(String(m));if(c)for(var _=function(t){if("undefined"==typeof window||!h)return l(t);try{return l(t)}catch(t){return!1}}(t),b=0;b<p.length;++b)_&&"constructor"===p[b]||!n.call(t,p[b])||f.push(p[b]);return f}}t.exports=o},function(t,e,r){"use strict";var o="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,n=Object.prototype.toString,i=function(t){return!(o&&t&&"object"==typeof t&&Symbol.toStringTag in t)&&"[object Arguments]"===n.call(t)},s=function(t){return!!i(t)||null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Array]"!==n.call(t)&&"[object Function]"===n.call(t.callee)},a=function(){return i(arguments)}();i.isLegacyArguments=s,t.exports=a?i:s},function(t,e,r){"use strict";var o=function(t){return t!=t};t.exports=function(t,e){return 0===t&&0===e?1/t==1/e:t===e||!(!o(t)||!o(e))}},function(t,e,r){"use strict";var o=r(35),n=RegExp.prototype.exec,i=Object.getOwnPropertyDescriptor,s=Object.prototype.toString,a="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!a)return"[object RegExp]"===s.call(t);var e=i(t,"lastIndex");return!(!e||!o(e,"value"))&&function(t){try{var e=t.lastIndex;return t.lastIndex=0,n.call(t),!0}catch(t){return!1}finally{t.lastIndex=e}}(t)}},function(t,e,r){"use strict";var o=r(2);t.exports=o.call(Function.call,Object.prototype.hasOwnProperty)},function(t,e,r){"use strict";var o="Function.prototype.bind called on incompatible ",n=Array.prototype.slice,i=Object.prototype.toString;t.exports=function(t){var e=this;if("function"!=typeof e||"[object Function]"!==i.call(e))throw new TypeError(o+e);for(var r,s=n.call(arguments,1),a=function(){if(this instanceof r){var o=e.apply(this,s.concat(n.call(arguments)));return Object(o)===o?o:this}return e.apply(t,s.concat(n.call(arguments)))},c=Math.max(0,e.length-s.length),u=[],p=0;p<c;p++)u.push("$"+p);if(r=Function("binder","return function ("+u.join(",")+"){ return binder.apply(this,arguments); }")(a),e.prototype){var l=function(){};l.prototype=e.prototype,r.prototype=new l,l.prototype=null}return r}},function(t,e,r){"use strict";var o=r(3),n=r(38),i=r(9),s=r(10),a=r(42),c=n(i);o(c,{getPolyfill:s,implementation:i,shim:a}),t.exports=c},function(t,e,r){"use strict";var o=r(2),n=r(39)("%Function%"),i=n.apply,s=n.call;t.exports=function(){return o.apply(s,arguments)},t.exports.apply=function(){return o.apply(i,arguments)}},function(t,e,r){"use strict";var o=TypeError,n=Object.getOwnPropertyDescriptor;if(n)try{n({},"")}catch(t){n=null}var i=function(){throw new o},s=n?function(){try{return arguments.callee,i}catch(t){try{return n(arguments,"callee").get}catch(t){return i}}}():i,a=r(40)(),c=Object.getPrototypeOf||function(t){return t.__proto__},u=void 0,p="undefined"==typeof Uint8Array?void 0:c(Uint8Array),l={"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayBufferPrototype%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer.prototype,"%ArrayIteratorPrototype%":a?c([][Symbol.iterator]()):void 0,"%ArrayPrototype%":Array.prototype,"%ArrayProto_entries%":Array.prototype.entries,"%ArrayProto_forEach%":Array.prototype.forEach,"%ArrayProto_keys%":Array.prototype.keys,"%ArrayProto_values%":Array.prototype.values,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":void 0,"%AsyncFunctionPrototype%":void 0,"%AsyncGenerator%":void 0,"%AsyncGeneratorFunction%":void 0,"%AsyncGeneratorPrototype%":void 0,"%AsyncIteratorPrototype%":u&&a&&Symbol.asyncIterator?u[Symbol.asyncIterator]():void 0,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%Boolean%":Boolean,"%BooleanPrototype%":Boolean.prototype,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%DataViewPrototype%":"undefined"==typeof DataView?void 0:DataView.prototype,"%Date%":Date,"%DatePrototype%":Date.prototype,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%ErrorPrototype%":Error.prototype,"%eval%":eval,"%EvalError%":EvalError,"%EvalErrorPrototype%":EvalError.prototype,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float32ArrayPrototype%":"undefined"==typeof Float32Array?void 0:Float32Array.prototype,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%Float64ArrayPrototype%":"undefined"==typeof Float64Array?void 0:Float64Array.prototype,"%Function%":Function,"%FunctionPrototype%":Function.prototype,"%Generator%":void 0,"%GeneratorFunction%":void 0,"%GeneratorPrototype%":void 0,"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int8ArrayPrototype%":"undefined"==typeof Int8Array?void 0:Int8Array.prototype,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int16ArrayPrototype%":"undefined"==typeof Int16Array?void 0:Int8Array.prototype,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%Int32ArrayPrototype%":"undefined"==typeof Int32Array?void 0:Int32Array.prototype,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":a?c(c([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%JSONParse%":"object"==typeof JSON?JSON.parse:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&a?c((new Map)[Symbol.iterator]()):void 0,"%MapPrototype%":"undefined"==typeof Map?void 0:Map.prototype,"%Math%":Math,"%Number%":Number,"%NumberPrototype%":Number.prototype,"%Object%":Object,"%ObjectPrototype%":Object.prototype,"%ObjProto_toString%":Object.prototype.toString,"%ObjProto_valueOf%":Object.prototype.valueOf,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%PromisePrototype%":"undefined"==typeof Promise?void 0:Promise.prototype,"%PromiseProto_then%":"undefined"==typeof Promise?void 0:Promise.prototype.then,"%Promise_all%":"undefined"==typeof Promise?void 0:Promise.all,"%Promise_reject%":"undefined"==typeof Promise?void 0:Promise.reject,"%Promise_resolve%":"undefined"==typeof Promise?void 0:Promise.resolve,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":RangeError,"%RangeErrorPrototype%":RangeError.prototype,"%ReferenceError%":ReferenceError,"%ReferenceErrorPrototype%":ReferenceError.prototype,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%RegExpPrototype%":RegExp.prototype,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&a?c((new Set)[Symbol.iterator]()):void 0,"%SetPrototype%":"undefined"==typeof Set?void 0:Set.prototype,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%SharedArrayBufferPrototype%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer.prototype,"%String%":String,"%StringIteratorPrototype%":a?c(""[Symbol.iterator]()):void 0,"%StringPrototype%":String.prototype,"%Symbol%":a?Symbol:void 0,"%SymbolPrototype%":a?Symbol.prototype:void 0,"%SyntaxError%":SyntaxError,"%SyntaxErrorPrototype%":SyntaxError.prototype,"%ThrowTypeError%":s,"%TypedArray%":p,"%TypedArrayPrototype%":p?p.prototype:void 0,"%TypeError%":o,"%TypeErrorPrototype%":o.prototype,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ArrayPrototype%":"undefined"==typeof Uint8Array?void 0:Uint8Array.prototype,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint8ClampedArrayPrototype%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray.prototype,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint16ArrayPrototype%":"undefined"==typeof Uint16Array?void 0:Uint16Array.prototype,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%Uint32ArrayPrototype%":"undefined"==typeof Uint32Array?void 0:Uint32Array.prototype,"%URIError%":URIError,"%URIErrorPrototype%":URIError.prototype,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakMapPrototype%":"undefined"==typeof WeakMap?void 0:WeakMap.prototype,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet,"%WeakSetPrototype%":"undefined"==typeof WeakSet?void 0:WeakSet.prototype},f=r(2).call(Function.call,String.prototype.replace),h=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,d=/\\(\\)?/g,y=function(t){var e=[];return f(t,h,(function(t,r,o,n){e[e.length]=o?f(n,d,"$1"):r||t})),e},g=function(t,e){if(!(t in l))throw new SyntaxError("intrinsic "+t+" does not exist!");if(void 0===l[t]&&!e)throw new o("intrinsic "+t+" exists, but is not available. Please file an issue!");return l[t]};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new TypeError("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new TypeError('"allowMissing" argument must be a boolean');for(var r=y(t),i=g("%"+(r.length>0?r[0]:"")+"%",e),s=1;s<r.length;s+=1)if(null!=i)if(n&&s+1>=r.length){var a=n(i,r[s]);if(!e&&!(r[s]in i))throw new o("base intrinsic for "+t+" exists, but the property is not available.");i=a?a.get||a.value:i[r[s]]}else i=i[r[s]];return i}},function(t,e,r){"use strict";(function(e){var o=e.Symbol,n=r(41);t.exports=function(){return"function"==typeof o&&("function"==typeof Symbol&&("symbol"==typeof o("foo")&&("symbol"==typeof Symbol("bar")&&n())))}}).call(this,r(6))},function(t,e,r){"use strict";t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var o=Object.getOwnPropertySymbols(t);if(1!==o.length||o[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var n=Object.getOwnPropertyDescriptor(t,e);if(42!==n.value||!0!==n.enumerable)return!1}return!0}},function(t,e,r){"use strict";var o=r(3).supportsDescriptors,n=r(10),i=Object.getOwnPropertyDescriptor,s=Object.defineProperty,a=TypeError,c=Object.getPrototypeOf,u=/a/;t.exports=function(){if(!o||!c)throw new a("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var t=n(),e=c(u),r=i(e,"flags");return r&&r.get===t||s(e,"flags",{configurable:!0,enumerable:!1,get:t}),t}},function(t,e,r){"use strict";var o=Date.prototype.getDay,n=Object.prototype.toString,i="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;t.exports=function(t){return"object"==typeof t&&null!==t&&(i?function(t){try{return o.call(t),!0}catch(t){return!1}}(t):"[object Date]"===n.call(t))}},function(t,e){function r(t){const e=this.constructor.prototype[t],r=function(){return e.apply(r,arguments)};return Object.setPrototypeOf(r,this.constructor.prototype),Object.getOwnPropertyNames(e).forEach((function(t){Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))})),r}r.prototype=Object.create(Function.prototype),t.exports=r},function(t,e,r){const o=r(12),n=r(46),i=r(13);t.exports={parse:n,isSupportedTag:o,...i}},function(t,e,r){const o=r(12),n=r(0),{CQAt:i,CQAnonymous:s,CQBFace:a,CQCustomMusic:c,CQDice:u,CQEmoji:p,CQFace:l,CQImage:f,CQMusic:h,CQRecord:d,CQRPS:y,CQSFace:g,CQShake:m,CQShare:_,CQText:b}=r(13),v=/\[CQ[^\]]*\]/g,S=/\[CQ:([a-z]+?)(?:,((,?[a-zA-Z0-9-_.]+=[^,[\]]*)*))?\]/;function E(t){let e;switch(t._type){case"anonymous":e=s.prototype;break;case"at":e=i.prototype;break;case"bface":e=a.prototype;break;case"music":e="custom"===t.data.type?c.prototype:h.prototype;break;case"dice":e=u.prototype;break;case"emoji":e=p.prototype;break;case"face":e=l.prototype;break;case"image":e=f.prototype;break;case"record":e=d.prototype;break;case"rps":e=y.prototype;break;case"sface":e=g.prototype;break;case"shake":e=m.prototype;break;case"share":e=_.prototype;break;case"text":e=b.prototype}return Object.setPrototypeOf(t,e).coerce()}t.exports=function(t){if("string"==typeof t){let e=0;const r=(t.match(v)||[]).map(t=>t.match(S)).filter(t=>t&&o(t[1])).map(t=>new n(t[1],function(t=""){return t?t.split(",").map(t=>t.split("=")).reduce((t,[e,r])=>(t[e]=r,t),{}):null}(t[2]))).map(E).reduce((r,o,n)=>{const i=o.toString(),s=t.indexOf(i);if(s!==e){const o=t.substring(e,s);r.push(new b(o))}return r.push(o),e=s+i.length,r},[]);if(e<t.length){const o=t.substring(e);r.push(new b(o))}return r}return Array.isArray(t)?t.filter(t=>o(t.type)).map(t=>new n(t.type,t.data)).map(E):[]}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(t){super("anonymous"),this.modifier.ignore=Boolean(t)}get ignore(){return this.modifier.ignore}set ignore(t){this.modifier.ignore=Boolean(t)}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(t){super("at",{qq:t})}get qq(){return this.data.qq}coerce(){return this.data.qq=Number(this.data.qq),this}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(t,e){super("bface",{id:t}),this.modifier.p=e}get id(){return this.data.id}coerce(){return this.data.id=Number(this.data.id),this}}},function(t,e,r){const o=r(0),n=r(4);t.exports=class extends o{constructor(t,e,r,o,n){super("music",{type:"custom",url:t,audio:e,title:r,content:o,image:n})}get type(){return"custom"}get url(){return this.data.url}get audio(){return this.data.audio}get title(){return this.data.title}get content(){return this.data.content}get image(){return this.data.image}coerce(){return this.data.type="custom",this.data.url=String(this.data.url),this.data.audio=String(this.data.audio),this.data.title=String(this.data.title),this.data.content=n(this.data.content,String),this.data.image=n(this.data.image,String),this}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(){super("dice")}get type(){return this.data.type}coerce(){return this.data.type=Number(this.data.type),this}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(t){super("emoji",{id:t})}get id(){return this.data.id}coerce(){return this.data.id=Number(this.data.id),this}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(t){super("face",{id:t})}get id(){return this.data.id}coerce(){return this.data.id=Number(this.data.id),this}}},function(t,e,r){const o=r(0),n=r(4);t.exports=class extends o{constructor(t,e=!0){super("image",{file:t}),this.cache=e}get file(){return this.data.file}get url(){return this.data.url}get cache(){return this.modifier.cache}set cache(t){this.modifier.cache=t?void 0:0}coerce(){return this.data.file=String(this.data.file),this.data.url=n(this.data.url,String),this}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(t,e){super("music",{type:t,id:e})}get type(){return this.data.type}get id(){return this.data.id}coerce(){return this.data.type=String(this.data.type),this.data.id=Number(this.data.id),this}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(t,e){super("record",{file:t}),this.magic=e}get file(){return this.data.file}hasMagic(){return Boolean(this.modifier.magic)}get magic(){return this.modifier.magic}set magic(t){this.modifier.magic=!!t||void 0}coerce(){return this.data.file=String(this.data.file),this}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(){super("rps")}get type(){return this.data.type}coerce(){return this.data.type=Number(this.data.type),this}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(t){super("sface",{id:t})}get id(){return this.data.id}coerce(){return this.data.id=Number(this.data.id),this}}},function(t,e,r){const o=r(0);t.exports=class extends o{constructor(){super("shake")}}},function(t,e,r){const o=r(0),n=r(4);t.exports=class extends o{constructor(t,e,r,o){super("share",{url:t,title:e,content:r,image:o})}get url(){return this.data.url}get title(){return this.data.title}get content(){return this.data.content}get image(){return this.data.image}coerce(){return this.data.url=String(this.data.url),this.data.title=String(this.data.title),this.data.content=n(this.data.content,String),this.data.image=n(this.data.image,String),this}}},function(t,e){class r extends Error{constructor(t){super(`"${t}" is not a valid websocket type.`),this.which=t}}class o extends SyntaxError{constructor(t,e){super(`[Websocket: ${t}] has received an invalid context.\nRaw data: ${e}`),this.name="InvalidContextError",this.which=t,this.data=e}}class n extends Error{constructor(t,e){super("Unexpected context is received."),this.name="UnexpectedContextError",this.context=t,this.reason=e}}class i extends Error{constructor(t){super(t),this.name="SocketError"}}class s extends Error{constructor(t,e){super(`The API response has reached the timeout (${t} ms).`),this.req=e}}t.exports={SocketError:i,UnexpectedContextError:n,InvalidWsTypeError:r,InvalidContextError:o,APITimeoutError:s}}])}));