twitch-js
Version:
Javascript library for the Twitch Messaging Interface.
1 lines • 103 kB
JavaScript
var TwitchJs=function(){"use strict";var t=function(e,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},t(e,r)};function e(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)};function n(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function o(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{u(n.next(t))}catch(t){i(t)}}function a(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}u((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,n=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function a(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t}var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function l(t,e){return t(e={exports:{}},e.exports),e.exports}var f=l((function(t){var e=Object.prototype.hasOwnProperty,r="~";function n(){}function o(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function i(t,e,n,i,s){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new o(n,i||t,s),u=r?r+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],a]:t._events[u].push(a):(t._events[u]=a,t._eventsCount++),t}function s(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var t,n,o=[];if(0===this._eventsCount)return o;for(n in t=this._events)e.call(t,n)&&o.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(t)):o},a.prototype.listeners=function(t){var e=r?r+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s},a.prototype.listenerCount=function(t){var e=r?r+t:t,n=this._events[e];return n?n.fn?1:n.length:0},a.prototype.emit=function(t,e,n,o,i,s){var a=r?r+t:t;if(!this._events[a])return!1;var u,c,l=this._events[a],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,o),!0;case 5:return l.fn.call(l.context,e,n,o,i),!0;case 6:return l.fn.call(l.context,e,n,o,i,s),!0}for(c=1,u=new Array(f-1);c<f;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var h,d=l.length;for(c=0;c<d;c++)switch(l[c].once&&this.removeListener(t,l[c].fn,void 0,!0),f){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,e);break;case 3:l[c].fn.call(l[c].context,e,n);break;case 4:l[c].fn.call(l[c].context,e,n,o);break;default:if(!u)for(h=1,u=new Array(f-1);h<f;h++)u[h-1]=arguments[h];l[c].fn.apply(l[c].context,u)}}return!0},a.prototype.on=function(t,e,r){return i(this,t,e,r,!1)},a.prototype.once=function(t,e,r){return i(this,t,e,r,!0)},a.prototype.removeListener=function(t,e,n,o){var i=r?r+t:t;if(!this._events[i])return this;if(!e)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==e||o&&!a.once||n&&a.context!==n||s(this,i);else{for(var u=0,c=[],l=a.length;u<l;u++)(a[u].fn!==e||o&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[i]=1===c.length?c[0]:c:s(this,i)}return this},a.prototype.removeAllListeners=function(t){var e;return t?(e=r?r+t:t,this._events[e]&&s(this,e)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,t.exports=a})),h=(t,e)=>(e=e||(()=>{}),t.then((t=>new Promise((t=>{t(e())})).then((()=>t))),(t=>new Promise((t=>{t(e())})).then((()=>{throw t})))));class d extends Error{constructor(t){super(t),this.name="TimeoutError"}}const p=(t,e,r)=>new Promise(((n,o)=>{if("number"!=typeof e||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0)return void n(t);const i=setTimeout((()=>{if("function"==typeof r){try{n(r())}catch(t){o(t)}return}const i=r instanceof Error?r:new d("string"==typeof r?r:`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),o(i)}),e);h(t.then(n,o),(()=>{clearTimeout(i)}))}));var v=p,_=p,E=d;v.default=_,v.TimeoutError=E;const y=Symbol.asyncIterator||"@@asyncIterator",O=t=>{const e=t.on||t.addListener||t.addEventListener,r=t.off||t.removeListener||t.removeEventListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}},m=t=>Array.isArray(t)?t:[t],S=(t,e,r)=>{let n;const o=new Promise(((o,i)=>{if(!((r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r}).count>=0)||r.count!==1/0&&!Number.isInteger(r.count))throw new TypeError("The `count` option should be at least 0 or more");const s=m(e),a=[],{addListener:u,removeListener:c}=O(t),l=(...t)=>{const e=r.multiArgs?t:t[0];r.filter&&!r.filter(e)||(a.push(e),r.count===a.length&&(n(),o(a)))},f=t=>{n(),i(t)};n=()=>{for(const t of s)c(t,l);for(const t of r.rejectionEvents)c(t,f)};for(const t of s)u(t,l);for(const t of r.rejectionEvents)u(t,f);r.resolveImmediately&&o(a)}));if(o.cancel=n,"number"==typeof r.timeout){const t=v(o,r.timeout);return t.cancel=n,t}return o},T=(t,e,r)=>{"function"==typeof r&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};const n=S(t,e,r),o=n.then((t=>t[0]));return o.cancel=n.cancel,o};var b=T,g=T,A=S,C=v.TimeoutError;b.default=g,b.multiple=A,b.iterator=(t,e,r)=>{"function"==typeof r&&(r={filter:r});const n=m(e);r={rejectionEvents:["error"],resolutionEvents:[],limit:1/0,multiArgs:!1,...r};const{limit:o}=r;if(!(o>=0&&(o===1/0||Number.isInteger(o))))throw new TypeError("The `limit` option should be a non-negative integer or Infinity");if(0===o)return{[Symbol.asyncIterator](){return this},next:async()=>({done:!0,value:void 0})};const{addListener:i,removeListener:s}=O(t);let a,u=!1,c=!1;const l=[],f=[];let h=0,d=!1;const p=(...t)=>{h++,d=h===o;const e=r.multiArgs?t:t[0];if(l.length>0){const{resolve:t}=l.shift();return t({done:!1,value:e}),void(d&&v())}f.push(e),d&&v()},v=()=>{u=!0;for(const t of n)s(t,p);for(const t of r.rejectionEvents)s(t,_);for(const t of r.resolutionEvents)s(t,E);for(;l.length>0;){const{resolve:t}=l.shift();t({done:!0,value:void 0})}},_=(...t)=>{if(a=r.multiArgs?t:t[0],l.length>0){const{reject:t}=l.shift();t(a)}else c=!0;v()},E=(...t)=>{const e=r.multiArgs?t:t[0];if(!r.filter||r.filter(e)){if(l.length>0){const{resolve:t}=l.shift();t({done:!0,value:e})}else f.push(e);v()}};for(const t of n)i(t,p);for(const t of r.rejectionEvents)i(t,_);for(const t of r.resolutionEvents)i(t,E);return{[y](){return this},async next(){if(f.length>0){const t=f.shift();return{done:u&&0===f.length&&!d,value:t}}if(c)throw c=!1,a;return u?{done:!0,value:void 0}:new Promise(((t,e)=>l.push({resolve:t,reject:e})))},return:async t=>(v(),{done:u,value:t})}},b.TimeoutError=C;var N="object"==typeof u&&u&&u.Object===Object&&u,I="object"==typeof self&&self&&self.Object===Object&&self,R=N||I||Function("return this")(),w=R.Symbol,D=Object.prototype,P=D.hasOwnProperty,L=D.toString,U=w?w.toStringTag:void 0;var M=function(t){var e=P.call(t,U),r=t[U];try{t[U]=void 0;var n=!0}catch(t){}var o=L.call(t);return n&&(e?t[U]=r:delete t[U]),o},j=Object.prototype.toString;var F=function(t){return j.call(t)},x=w?w.toStringTag:void 0;var B=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":x&&x in Object(t)?M(t):F(t)};var H=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};var G,k=function(t){if(!H(t))return!1;var e=B(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},z=R["__core-js_shared__"],W=(G=/[^.]+$/.exec(z&&z.keys&&z.keys.IE_PROTO||""))?"Symbol(src)_1."+G:"";var V=function(t){return!!W&&W in t},Y=Function.prototype.toString;var q=function(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""},J=/^\[object .+?Constructor\]$/,K=Function.prototype,$=Object.prototype,Z=K.toString,Q=$.hasOwnProperty,X=RegExp("^"+Z.call(Q).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var tt=function(t){return!(!H(t)||V(t))&&(k(t)?X:J).test(q(t))};var et=function(t,e){return null==t?void 0:t[e]};var rt=function(t,e){var r=et(t,e);return tt(r)?r:void 0},nt=rt(Object,"create");var ot=function(){this.__data__=nt?nt(null):{},this.size=0};var it=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},st=Object.prototype.hasOwnProperty;var at=function(t){var e=this.__data__;if(nt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return st.call(e,t)?e[t]:void 0},ut=Object.prototype.hasOwnProperty;var ct=function(t){var e=this.__data__;return nt?void 0!==e[t]:ut.call(e,t)};var lt=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=nt&&void 0===e?"__lodash_hash_undefined__":e,this};function ft(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}ft.prototype.clear=ot,ft.prototype.delete=it,ft.prototype.get=at,ft.prototype.has=ct,ft.prototype.set=lt;var ht=ft;var dt=function(){this.__data__=[],this.size=0};var pt=function(t,e){return t===e||t!=t&&e!=e};var vt=function(t,e){for(var r=t.length;r--;)if(pt(t[r][0],e))return r;return-1},_t=Array.prototype.splice;var Et=function(t){var e=this.__data__,r=vt(e,t);return!(r<0)&&(r==e.length-1?e.pop():_t.call(e,r,1),--this.size,!0)};var yt=function(t){var e=this.__data__,r=vt(e,t);return r<0?void 0:e[r][1]};var Ot=function(t){return vt(this.__data__,t)>-1};var mt=function(t,e){var r=this.__data__,n=vt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};function St(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}St.prototype.clear=dt,St.prototype.delete=Et,St.prototype.get=yt,St.prototype.has=Ot,St.prototype.set=mt;var Tt=St,bt=rt(R,"Map");var gt=function(){this.size=0,this.__data__={hash:new ht,map:new(bt||Tt),string:new ht}};var At=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Ct=function(t,e){var r=t.__data__;return At(e)?r["string"==typeof e?"string":"hash"]:r.map};var Nt=function(t){var e=Ct(this,t).delete(t);return this.size-=e?1:0,e};var It=function(t){return Ct(this,t).get(t)};var Rt=function(t){return Ct(this,t).has(t)};var wt=function(t,e){var r=Ct(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Dt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}Dt.prototype.clear=gt,Dt.prototype.delete=Nt,Dt.prototype.get=It,Dt.prototype.has=Rt,Dt.prototype.set=wt;var Pt=Dt;var Lt=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this};var Ut=function(t){return this.__data__.has(t)};function Mt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Pt;++e<r;)this.add(t[e])}Mt.prototype.add=Mt.prototype.push=Lt,Mt.prototype.has=Ut;var jt=Mt;var Ft=function(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i<o;)if(e(t[i],i,t))return i;return-1};var xt=function(t){return t!=t};var Bt=function(t,e,r){for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1};var Ht=function(t,e,r){return e==e?Bt(t,e,r):Ft(t,xt,r)};var Gt=function(t,e){return!!(null==t?0:t.length)&&Ht(t,e,0)>-1};var kt=function(t,e,r){for(var n=-1,o=null==t?0:t.length;++n<o;)if(r(e,t[n]))return!0;return!1};var zt=function(t,e){return t.has(e)},Wt=rt(R,"Set");var Vt=function(){};var Yt=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r},qt=Wt&&1/Yt(new Wt([,-0]))[1]==1/0?function(t){return new Wt(t)}:Vt;var Jt=function(t,e,r){var n=-1,o=Gt,i=t.length,s=!0,a=[],u=a;if(r)s=!1,o=kt;else if(i>=200){var c=e?null:qt(t);if(c)return Yt(c);s=!1,o=zt,u=new jt}else u=e?[]:a;t:for(;++n<i;){var l=t[n],f=e?e(l):l;if(l=r||0!==l?l:0,s&&f==f){for(var h=u.length;h--;)if(u[h]===f)continue t;e&&u.push(f),a.push(l)}else o(u,f,r)||(u!==a&&u.push(f),a.push(l))}return a};var Kt,$t,Zt,Qt,Xt,te,ee,re,ne,oe=function(t){return t&&t.length?Jt(t):[]};!function(t){t.tags="twitch.tv/tags",t.commands="twitch.tv/commands",t.membership="twitch.tv/membership"}(Kt||(Kt={})),function(t){t.JOIN="JOIN",t.MODE="MODE",t.PART="PART",t.NAMES="353",t.NAMES_END="366"}($t||($t={})),function(t){t.CLEAR_CHAT="CLEARCHAT",t.GLOBALUSERSTATE="GLOBALUSERSTATE",t.PRIVATE_MESSAGE="PRIVMSG",t.ROOM_STATE="ROOMSTATE",t.USER_NOTICE="USERNOTICE",t.USER_STATE="USERSTATE"}(Zt||(Zt={})),function(t){t.WELCOME="001",t.PING="PING",t.PONG="PONG",t.WHISPER="WHISPER"}(Qt||(Qt={})),function(t){t.CLEAR_CHAT="CLEARCHAT",t.CLEAR_MESSAGE="CLEARMSG",t.HOST_TARGET="HOSTTARGET",t.NOTICE="NOTICE",t.RECONNECT="RECONNECT",t.ROOM_STATE="ROOMSTATE",t.USER_NOTICE="USERNOTICE",t.USER_STATE="USERSTATE"}(Xt||(Xt={})),function(t){t.WELCOME="001",t.PING="PING",t.PONG="PONG",t.RECONNECT="RECONNECT",t.WHISPER="PRIVMSG #jtv",t.JOIN="JOIN",t.MODE="MODE",t.PART="PART",t.NAMES="353",t.NAMES_END="366",t.CLEAR_CHAT="CLEARCHAT",t.CLEAR_MESSAGE="CLEARMSG",t.GLOBALUSERSTATE="GLOBALUSERSTATE",t.HOST_TARGET="HOSTTARGET",t.NOTICE="NOTICE",t.PRIVATE_MESSAGE="PRIVMSG",t.ROOM_STATE="ROOMSTATE",t.USER_NOTICE="USERNOTICE",t.USER_STATE="USERSTATE"}(te||(te={})),function(t){t.RAW="RAW",t.ALL="*",t.CONNECTED="CONNECTED",t.DISCONNECTED="DISCONNECTED",t.RECONNECT="RECONNECT",t.AUTHENTICATED="AUTHENTICATED",t.AUTHENTICATION_FAILED="AUTHENTICATION_FAILED",t.GLOBALUSERSTATE="GLOBALUSERSTATE",t.ERROR_ENCOUNTERED="ERROR_ENCOUNTERED",t.PARSE_ERROR_ENCOUNTERED="PARSE_ERROR_ENCOUNTERED",t.ANON_GIFT_PAID_UPGRADE="ANON_GIFT_PAID_UPGRADE",t.GIFT_PAID_UPGRADE="GIFT_PAID_UPGRADE",t.RAID="RAID",t.RESUBSCRIPTION="RESUBSCRIPTION",t.RITUAL="RITUAL",t.SUBSCRIPTION="SUBSCRIPTION",t.SUBSCRIPTION_GIFT="SUBSCRIPTION_GIFT",t.SUBSCRIPTION_GIFT_COMMUNITY="SUBSCRIPTION_GIFT_COMMUNITY",t.ROOM_MODS="ROOM_MODS",t.MOD_GAINED="MOD_GAINED",t.MOD_LOST="MOD_LOST",t.USER_BANNED="USER_BANNED",t.CHEER="CHEER",t.HOST_ON="HOST_ON",t.HOST_OFF="HOST_OFF",t.HOSTED="HOSTED",t.HOSTED_WITHOUT_VIEWERS="HOSTED/WITHOUT_VIEWERS",t.HOSTED_WITH_VIEWERS="HOSTED/WITH_VIEWERS",t.HOSTED_AUTO="HOSTED/AUTO"}(ee||(ee={})),function(t){t.BAN="ban",t.BLOCK="block",t.CLEAR="clear",t.COLOR="color",t.COMMERCIAL="commercial",t.DELETE="delete",t.EMOTE_ONLY="emoteonly",t.EMOTE_ONLY_OFF="emoteonlyoff",t.FOLLOWERS_ONLY="followers",t.FOLLOWERS_ONLY_OFF="followersoff",t.HELP="help",t.HOST="host",t.MARKER="marker",t.ME="me",t.MOD="mod",t.MODS="mods",t.R9K="r9kbeta",t.R9K_OFF="r9kbetaoff",t.RAID="raid",t.SLOW="slow",t.SLOW_OFF="slowoff",t.SUBSCRIBERS="subscribers",t.SUBSCRIBERS_OFF="subscribersoff",t.TIMEOUT="timeout",t.UNBAN="unban",t.UNBLOCK="unblock",t.UNHOST="unhost",t.UNMOD="unmod",t.UNRAID="unraid",t.UNVIP="unvip",t.VIP="vip",t.VIPS="vips",t.WHISPER="w"}(re||(re={})),function(t){t.ALREADY_BANNED="already_banned",t.ALREADY_EMOTE_ONLY_OFF="already_emote_only_off",t.ALREADY_EMOTE_ONLY_ON="already_emote_only_on",t.ALREADY_R9K_OFF="already_r9k_off",t.ALREADY_R9K_ON="already_r9k_on",t.ALREADY_SUBS_OFF="already_subs_off",t.ALREADY_SUBS_ON="already_subs_on",t.BAD_HOST_HOSTING="bad_host_hosting",t.BAD_MOD_MOD="bad_mod_mod",t.BAN_SUCCESS="ban_success",t.BAD_UNBAN_NO_BAN="bad_unban_no_ban",t.COLOR_CHANGED="color_changed",t.CMDS_AVAILABLE="cmds_available",t.COMMERCIAL_SUCCESS="commercial_success",t.EMOTE_ONLY_OFF="emote_only_off",t.EMOTE_ONLY_ON="emote_only_on",t.FOLLOWERS_OFF="followers_off",t.FOLLOWERS_ON="followers_on",t.FOLLOWERS_ONZERO="followers_onzero",t.HOST_OFF="host_off",t.HOST_ON="host_on",t.HOSTS_REMAINING="hosts_remaining",t.MSG_CHANNEL_SUSPENDED="msg_channel_suspended",t.MOD_SUCCESS="mod_success",t.NOT_HOSTING="not_hosting",t.R9K_OFF="r9k_off",t.R9K_ON="r9k_on",t.ROOM_MODS="room_mods",t.SLOW_OFF="slow_off",t.SLOW_ON="slow_on",t.SUBS_OFF="subs_off",t.SUBS_ON="subs_on",t.TIMEOUT_SUCCESS="timeout_success",t.UNBAN_SUCCESS="unban_success",t.UNMOD_SUCCESS="unmod_success",t.UNRAID_SUCCESS="unraid_success",t.UNRECOGNIZED_CMD="unrecognized_cmd"}(ne||(ne={}));Object.entries(ne).reduce((function(t,e){var n,o=s(e,2),i=o[0],a=o[1];return r(r({},t),((n={})[i]=a.toUpperCase(),n))}),{});var ie,se,ae=Object.keys(ne).reduce((function(t,e){var n;return r(r({},t),((n={})[e]=e,n[te.NOTICE+"/"+e.toUpperCase()]=e,n))}),{});!function(t){t.CHEER="CHEER",t.HOSTED_WITHOUT_VIEWERS="HOSTED_WITHOUT_VIEWERS",t.HOSTED_WITH_VIEWERS="HOSTED_WITH_VIEWERS",t.HOSTED_AUTO="HOSTED_AUTO"}(ie||(ie={})),function(t){t.ANON_GIFT_PAID_UPGRADE="anongiftpaidupgrade",t.GIFT_PAID_UPGRADE="giftpaidupgrade",t.RAID="raid",t.RESUBSCRIPTION="resub",t.RITUAL="ritual",t.SUBSCRIPTION="sub",t.SUBSCRIPTION_GIFT="subgift",t.SUBSCRIPTION_GIFT_COMMUNITY="submysterygift"}(se||(se={}));var ue,ce,le=Object.keys(se).reduce((function(t,e){var n;return r(r({},t),((n={})[e]=e,n[te.USER_NOTICE+"/"+e]=e,n))}),{}),fe=r(r(r(r(r(r(r(r({},$t),Zt),Qt),Xt),ee),ae),ie),le);function he(t){try{return JSON.stringify(t)}catch(t){return'"[Circular]"'}}!function(t){t[t.admin=0]="admin",t[t.broadcaster=1]="broadcaster",t[t.globalMod=2]="globalMod",t[t.moderator=3]="moderator",t[t.partner=4]="partner",t[t.premium=5]="premium",t[t.staff=6]="staff",t[t.subGifter=7]="subGifter",t[t.turbo=8]="turbo",t[t.vip=9]="vip"}(ue||(ue={})),function(t){t[t.bits=0]="bits",t[t.bitsLeader=1]="bitsLeader",t[t.subscriber=2]="subscriber"}(ce||(ce={}));var de=function(t,e,r){var n=r&&r.stringify||he;if("object"==typeof t&&null!==t){var o=e.length+1;if(1===o)return t;var i=new Array(o);i[0]=n(t);for(var s=1;s<o;s++)i[s]=n(e[s]);return i.join(" ")}if("string"!=typeof t)return t;var a=e.length;if(0===a)return t;for(var u="",c=0,l=-1,f=t&&t.length||0,h=0;h<f;){if(37===t.charCodeAt(h)&&h+1<f){switch(l=l>-1?l:0,t.charCodeAt(h+1)){case 100:if(c>=a)break;if(l<h&&(u+=t.slice(l,h)),null==e[c])break;u+=Number(e[c]),l=h+=2;break;case 79:case 111:case 106:if(c>=a)break;if(l<h&&(u+=t.slice(l,h)),void 0===e[c])break;var d=typeof e[c];if("string"===d){u+="'"+e[c]+"'",l=h+2,h++;break}if("function"===d){u+=e[c].name||"<anonymous>",l=h+2,h++;break}u+=n(e[c]),l=h+2,h++;break;case 115:if(c>=a)break;l<h&&(u+=t.slice(l,h)),u+=String(e[c]),l=h+2,h++;break;case 37:l<h&&(u+=t.slice(l,h)),u+="%",l=h+2,h++}++c}++h}if(-1===l)return t;l<f&&(u+=t.slice(l));return u};var pe=Ee,ve=function(){function t(t){return void 0!==t&&t}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(e){return t(self)||t(window)||t(this)||{}}}().console||{},_e={mapHttpRequest:Ae,mapHttpResponse:Ae,wrapRequestSerializer:Ce,wrapResponseSerializer:Ce,wrapErrorSerializer:Ce,req:Ae,res:Ae,err:function(t){var e={type:t.constructor.name,msg:t.message,stack:t.stack};for(var r in t)void 0===e[r]&&(e[r]=t[r]);return e}};function Ee(t){(t=t||{}).browser=t.browser||{};var e=t.browser.transmit;if(e&&"function"!=typeof e.send)throw Error("pino: transmit option must have a send function");var r=t.browser.write||ve;t.browser.write&&(t.browser.asObject=!0);var n=t.serializers||{},o=Array.isArray(t.browser.serialize)?t.browser.serialize.filter((function(t){return"!stdSerializers.err"!==t})):!0===t.browser.serialize&&Object.keys(n),i=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(i=!1);"function"==typeof r&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),!1===t.enabled&&(t.level="silent");var s=t.level||"info",a=Object.create(r);a.log||(a.log=Ne),Object.defineProperty(a,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(a,"level",{get:function(){return this._level},set:function(t){if("silent"!==t&&!this.levels.values[t])throw Error("unknown level "+t);this._level=t,ye(u,a,"error","log"),ye(u,a,"fatal","error"),ye(u,a,"warn","error"),ye(u,a,"info","log"),ye(u,a,"debug","log"),ye(u,a,"trace","log")}});var u={transmit:e,serialize:o,asObject:t.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:ge(t)};return a.levels=Ee.levels,a.level=s,a.setMaxListeners=a.getMaxListeners=a.emit=a.addListener=a.on=a.prependListener=a.once=a.prependOnceListener=a.removeListener=a.removeAllListeners=a.listeners=a.listenerCount=a.eventNames=a.write=a.flush=Ne,a.serializers=n,a._serialize=o,a._stdErrSerialize=i,a.child=function(r){if(!r)throw new Error("missing bindings for child Pino");var i=r.serializers;if(o&&i){var s=Object.assign({},n,i),a=!0===t.browser.serialize?Object.keys(s):o;delete r.serializers,me([r],a,s,this._stdErrSerialize)}function u(t){this._childLevel=1+(0|t._childLevel),this.error=Se(t,r,"error"),this.fatal=Se(t,r,"fatal"),this.warn=Se(t,r,"warn"),this.info=Se(t,r,"info"),this.debug=Se(t,r,"debug"),this.trace=Se(t,r,"trace"),s&&(this.serializers=s,this._serialize=a),e&&(this._logEvent=be([].concat(t._logEvent.bindings,r)))}return u.prototype=this,new u(this)},e&&(a._logEvent=be()),a}function ye(t,e,r,n){var o=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Ne:o[r]?o[r]:ve[r]||ve[n]||Ne,function(t,e,r){if(!t.transmit&&e[r]===Ne)return;e[r]=(n=e[r],function(){for(var o=t.timestamp(),i=new Array(arguments.length),s=Object.getPrototypeOf&&Object.getPrototypeOf(this)===ve?ve:this,a=0;a<i.length;a++)i[a]=arguments[a];if(t.serialize&&!t.asObject&&me(i,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(s,Oe(this,r,i,o)):n.apply(s,i),t.transmit){var u=t.transmit.level||e.level,c=Ee.levels.values[u],l=Ee.levels.values[r];if(l<c)return;Te(this,{ts:o,methodLevel:r,methodValue:l,transmitLevel:u,transmitValue:Ee.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},i)}});var n}(t,e,r)}function Oe(t,e,r,n){t._serialize&&me(r,t._serialize,t.serializers,t._stdErrSerialize);var o=r.slice(),i=o[0],s={};n&&(s.time=n),s.level=Ee.levels.values[e];var a=1+(0|t._childLevel);if(a<1&&(a=1),null!==i&&"object"==typeof i){for(;a--&&"object"==typeof o[0];)Object.assign(s,o.shift());i=o.length?de(o.shift(),o):void 0}else"string"==typeof i&&(i=de(o.shift(),o));return void 0!==i&&(s.msg=i),s}function me(t,e,r,n){for(var o in t)if(n&&t[o]instanceof Error)t[o]=Ee.stdSerializers.err(t[o]);else if("object"==typeof t[o]&&!Array.isArray(t[o]))for(var i in t[o])e&&e.indexOf(i)>-1&&i in r&&(t[o][i]=r[i](t[o][i]))}function Se(t,e,r){return function(){var n=new Array(1+arguments.length);n[0]=e;for(var o=1;o<n.length;o++)n[o]=arguments[o-1];return t[r].apply(this,n)}}function Te(t,e,r){var n=e.send,o=e.ts,i=e.methodLevel,s=e.methodValue,a=e.val,u=t._logEvent.bindings;me(r,t._serialize||Object.keys(t.serializers),t.serializers,void 0===t._stdErrSerialize||t._stdErrSerialize),t._logEvent.ts=o,t._logEvent.messages=r.filter((function(t){return-1===u.indexOf(t)})),t._logEvent.level.label=i,t._logEvent.level.value=s,n(i,t._logEvent,a),t._logEvent=be(u)}function be(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function ge(t){return"function"==typeof t.timestamp?t.timestamp:!1===t.timestamp?Ie:Re}function Ae(){return{}}function Ce(t){return t}function Ne(){}function Ie(){return!1}function Re(){return Date.now()}Ee.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},Ee.stdSerializers=_e,Ee.stdTimeFunctions=Object.assign({},{nullTime:Ie,epochTime:Re,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}});var we=function(t){void 0===t&&(t={});var e=t.name,o=n(t,["name"]),i=["TwitchJS"].concat(e||[]).join("/"),s=pe(r({name:i,prettyPrint:!0,level:"info"},o));return s.profile=function(t){var e=Date.now();return t&&s.info(t),{done:function(t,r){var n=t+" ("+(Date.now()-e)+"ms)";r?s.error(n,r):s.info(n)}}},s};let De;"undefined"!=typeof WebSocket?De=WebSocket:"undefined"!=typeof MozWebSocket?De=MozWebSocket:void 0!==u?De=u.WebSocket||u.MozWebSocket:"undefined"!=typeof window?De=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(De=self.WebSocket||self.MozWebSocket);var Pe=De;class Le extends Error{constructor(t){super(t),this.name="TimeoutError"}}const Ue=(t,e,r)=>new Promise(((n,o)=>{if("number"!=typeof e||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(e===1/0)return void n(t);const i=setTimeout((()=>{if("function"==typeof r){try{n(r())}catch(t){o(t)}return}const i=r instanceof Error?r:new Le("string"==typeof r?r:`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),o(i)}),e);h(t.then(n,o),(()=>{clearTimeout(i)}))}));var Me=Ue,je=Ue,Fe=Le;Me.default=je,Me.TimeoutError=Fe;var xe=l((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,r){let n=0,o=t.length;for(;o>0;){const i=o/2|0;let s=n+i;r(t[s],e)<=0?(n=++s,o-=i+1):o=i}return n}}));c(xe);var Be=l((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this._queue=[]}enqueue(t,e){const r={priority:(e=Object.assign({priority:0},e)).priority,run:t};if(this.size&&this._queue[this.size-1].priority>=e.priority)return void this._queue.push(r);const n=xe.default(this._queue,r,((t,e)=>e.priority-t.priority));this._queue.splice(n,0,r)}dequeue(){const t=this._queue.shift();return null==t?void 0:t.run}filter(t){return this._queue.filter((e=>e.priority===t.priority)).map((t=>t.run))}get size(){return this._queue.length}}}));c(Be);var He=l((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=()=>{},n=new Me.TimeoutError;e.default=class extends f{constructor(t){var e,n,o,i;if(super(),this._intervalCount=0,this._intervalEnd=0,this._pendingCount=0,this._resolveEmpty=r,this._resolveIdle=r,!("number"==typeof(t=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:Be.default},t)).intervalCap&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(n=null===(e=t.intervalCap)||void 0===e?void 0:e.toString())&&void 0!==n?n:""}\` (${typeof t.intervalCap})`);if(void 0===t.interval||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(i=null===(o=t.interval)||void 0===o?void 0:o.toString())&&void 0!==i?i:""}\` (${typeof t.interval})`);this._carryoverConcurrencyCount=t.carryoverConcurrencyCount,this._isIntervalIgnored=t.intervalCap===1/0||0===t.interval,this._intervalCap=t.intervalCap,this._interval=t.interval,this._queue=new t.queueClass,this._queueClass=t.queueClass,this.concurrency=t.concurrency,this._timeout=t.timeout,this._throwOnTimeout=!0===t.throwOnTimeout,this._isPaused=!1===t.autoStart}get _doesIntervalAllowAnother(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}get _doesConcurrentAllowAnother(){return this._pendingCount<this._concurrency}_next(){this._pendingCount--,this._tryToStartAnother(),this.emit("next")}_resolvePromises(){this._resolveEmpty(),this._resolveEmpty=r,0===this._pendingCount&&(this._resolveIdle(),this._resolveIdle=r,this.emit("idle"))}_onResumeInterval(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}_isIntervalPaused(){const t=Date.now();if(void 0===this._intervalId){const e=this._intervalEnd-t;if(!(e<0))return void 0===this._timeoutId&&(this._timeoutId=setTimeout((()=>{this._onResumeInterval()}),e)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}_tryToStartAnother(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){const t=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother)return this.emit("active"),this._queue.dequeue()(),t&&this._initializeIntervalIfNeeded(),!0}return!1}_initializeIntervalIfNeeded(){this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval((()=>{this._onInterval()}),this._interval),this._intervalEnd=Date.now()+this._interval)}_onInterval(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}_processQueue(){for(;this._tryToStartAnother(););}get concurrency(){return this._concurrency}set concurrency(t){if(!("number"==typeof t&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this._concurrency=t,this._processQueue()}async add(t,e={}){return new Promise(((r,o)=>{this._queue.enqueue((async()=>{this._pendingCount++,this._intervalCount++;try{const i=void 0===this._timeout&&void 0===e.timeout?t():Me.default(Promise.resolve(t()),void 0===e.timeout?this._timeout:e.timeout,(()=>{(void 0===e.throwOnTimeout?this._throwOnTimeout:e.throwOnTimeout)&&o(n)}));r(await i)}catch(t){o(t)}this._next()}),e),this._tryToStartAnother(),this.emit("add")}))}async addAll(t,e){return Promise.all(t.map((async t=>this.add(t,e))))}start(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}pause(){this._isPaused=!0}clear(){this._queue=new this._queueClass}async onEmpty(){if(0!==this._queue.size)return new Promise((t=>{const e=this._resolveEmpty;this._resolveEmpty=()=>{e(),t()}}))}async onIdle(){if(0!==this._pendingCount||0!==this._queue.size)return new Promise((t=>{const e=this._resolveIdle;this._resolveIdle=()=>{e(),t()}}))}get size(){return this._queue.size}sizeBy(t){return this._queue.filter(t).length}get pending(){return this._pendingCount}get isPaused(){return this._isPaused}get timeout(){return this._timeout}set timeout(t){this._timeout=t}}})),Ge=c(He),ke=15e4,ze=l((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});class r extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),Object.defineProperty(this,"name",{value:this.constructor.name})}}e.ParseError=class extends r{};e.FormatError=class extends r{}}));c(ze);ze.ParseError,ze.FormatError;var We=l((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.shouldEscapeString=function(t){console.log(t);for(let e=0;e<t.length;e+=1){switch(t.charCodeAt(e)){case 10:case 13:case 32:case 59:case 92:return!0}}return!1},e.escapeString=function(t){if(!t)return"";let e="";for(let r=0;r<t.length;r+=1){let n=t.charCodeAt(r);switch(n){case 10:e+="\\n";break;case 13:e+="\\r";break;case 32:e+="\\s";break;case 59:e+="\\:";break;case 92:e+="\\\\";break;default:e+=String.fromCharCode(n)}}return e},e.unescapeString=function(t){if(!t)return"";let e;if(-1===(e=t.indexOf("\\")))return t;const r=t.length-1;let n=0,o="";do{if(n<e&&(o+=t.slice(n,e)),(n=e+1)>=r)break;let i=t.charCodeAt(n);switch(i){case 58:i=59;break;case 110:i=10;break;case 114:i=13;break;case 115:i=32}n+=1,o+=String.fromCharCode(i)}while(-1!==(e=t.indexOf("\\",n)));return n<=r&&(o+=t.slice(n)),o}}));c(We);We.shouldEscapeString,We.escapeString,We.unescapeString;var Ve=l((function(t,e){function r(t){const e={},r=t.split(";"),n=r.length;for(let t=0;t<n;t+=1){const[n,o]=r[t].split("=");e[n]=void 0===o||We.unescapeString(o)}return e}function n(t){if(!t)return null;let e,r;if(0===(e=t.indexOf("!")))return null;if(0===(r=t.indexOf("@",e+1)))return null;const n={};return e>-1&&r>-1?(n.name=t.slice(0,e),n.user=t.slice(e+1,r),n.host=t.slice(r+1)):e>-1?(n.name=t.slice(0,e),n.user=t.slice(e+1)):r>-1?(n.name=t.slice(0,r),n.host=t.slice(r+1)):n.name=t,n}Object.defineProperty(e,"__esModule",{value:!0}),e.parseTags=r,e.parsePrefix=n,e.parse=function(t){const e={};Object.defineProperties(e,{middle:{writable:!0,value:[]},trailing:{writable:!0,value:void 0},params:{enumerable:!0,get(){return this.middle.concat(this.trailing||[])}}});let o=0,i=0;if(64===t.charCodeAt(o)){if(-1===(i=t.indexOf(" ")))throw new ze.ParseError("Invalid Message");e.tags=r(t.slice(o+1,i)),o=i+1}for(;32===t.charCodeAt(o);)o+=1;if(58===t.charCodeAt(o)){if(-1===(i=t.indexOf(" ",o)))throw new ze.ParseError("Invalid Message");const r=n(t.slice(o+1,i));for(r&&(e.prefix=r),o=i+1;32===t.charCodeAt(o);)o+=1}if(-1===(i=t.indexOf(" ",o))){if(t.length>o)return e.command=t.slice(o),e;throw new ze.ParseError("Invalid Message")}for(e.command=t.slice(o,i),o=i+1;32===t.charCodeAt(o);)o+=1;for(;o<t.length;){if(58===t.charCodeAt(o)){e.trailing=t.slice(o+1);break}if(-1===(i=t.indexOf(" ",o))){e.middle.push(t.slice(o));break}for(e.middle.push(t.slice(o,i)),o=i+1;32===t.charCodeAt(o);)o+=1}return e}}));c(Ve);Ve.parseTags,Ve.parsePrefix;var Ye=Ve.parse;const qe=t=>"object"==typeof t&&null!==t,Je=t=>qe(t)&&!(t instanceof RegExp)&&!(t instanceof Error)&&!(t instanceof Date),Ke=(t,e,r,n=new WeakMap)=>{if(r={deep:!1,target:{},...r},n.has(t))return n.get(t);n.set(t,r.target);const{target:o}=r;delete r.target;const i=t=>t.map((t=>Je(t)?Ke(t,e,r,n):t));if(Array.isArray(t))return i(t);for(const[s,a]of Object.entries(t)){let[u,c]=e(s,a,t);r.deep&&Je(c)&&(c=Array.isArray(c)?i(c):Ke(c,e,r,n)),o[u]=c}return o};var $e=(t,e,r)=>{if(!qe(t))throw new TypeError(`Expected an object, got \`${t}\` (${typeof t})`);return Ke(t,e,r)};const Ze=(t,e)=>{if("string"!=typeof t&&!Array.isArray(t))throw new TypeError("Expected the input to be `string | string[]`");e=Object.assign({pascalCase:!1},e);if(t=Array.isArray(t)?t.map((t=>t.trim())).filter((t=>t.length)).join("-"):t.trim(),0===t.length)return"";if(1===t.length)return e.pascalCase?t.toUpperCase():t.toLowerCase();return t!==t.toLowerCase()&&(t=(t=>{let e=!1,r=!1,n=!1;for(let o=0;o<t.length;o++){const i=t[o];e&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(t=t.slice(0,o)+"-"+t.slice(o),e=!1,n=r,r=!0,o++):r&&n&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(t=t.slice(0,o-1)+"-"+t.slice(o-1),n=r,r=!1,e=!0):(e=i.toLowerCase()===i&&i.toUpperCase()!==i,n=r,r=i.toUpperCase()===i&&i.toLowerCase()!==i)}return t})(t)),t=t.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,((t,e)=>e.toUpperCase())).replace(/\d+(\w|$)/g,(t=>t.toUpperCase())),r=t,e.pascalCase?r.charAt(0).toUpperCase()+r.slice(1):r;var r};var Qe=Ze,Xe=Ze;Qe.default=Xe;class tr{constructor(t={}){if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=t.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(t,e){this.cache.set(t,e),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t)){const e=this.oldCache.get(t);return this.oldCache.delete(t),this._set(t,e),e}}set(t,e){return this.cache.has(t)?this.cache.set(t,e):this._set(t,e),this}has(t){return this.cache.has(t)||this.oldCache.has(t)}peek(t){return this.cache.has(t)?this.cache.get(t):this.oldCache.has(t)?this.oldCache.get(t):void 0}delete(t){const e=this.cache.delete(t);return e&&this._size--,this.oldCache.delete(t)||e}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache)yield t;for(const t of this.oldCache){const[e]=t;this.cache.has(e)||(yield t)}}get size(){let t=0;for(const e of this.oldCache.keys())this.cache.has(e)||t++;return this._size+t}}const er=new tr({maxSize:1e5}),rr=t=>!("object"!=typeof t||null===t||t instanceof RegExp||t instanceof Error||t instanceof Date),nr=(t,e)=>{if(!rr(t))return t;e={deep:!1,pascalCase:!1,...e};const{exclude:r,pascalCase:n,stopPaths:o,deep:i}=e,s=new Set(o),a=t=>(e,o)=>{if(i&&rr(o)){const r=void 0===t?e:`${t}.${e}`;s.has(r)||(o=$e(o,a(r)))}if(!r||!((t,e)=>t.some((t=>"string"==typeof t?t===e:(t.lastIndex=0,t.test(e)))))(r,e)){const t=n?`${e}_`:e;if(er.has(t))e=er.get(t);else{const r=Qe(e,{pascalCase:n});e.length<100&&er.set(t,r),e=r}}return[e,o]};return $e(t,a(void 0))};var or=(t,e)=>Array.isArray(t)?Object.keys(t).map((r=>nr(t[r],e))):nr(t,e),ir=Object.prototype;var sr=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||ir)};var ar=function(t,e){return function(r){return t(e(r))}}(Object.keys,Object),ur=Object.prototype.hasOwnProperty;var cr=function(t){if(!sr(t))return ar(t);var e=[];for(var r in Object(t))ur.call(t,r)&&"constructor"!=r&&e.push(r);return e},lr=rt(R,"DataView"),fr=rt(R,"Promise"),hr=rt(R,"WeakMap"),dr="[object Map]",pr="[object Promise]",vr="[object Set]",_r="[object WeakMap]",Er="[object DataView]",yr=q(lr),Or=q(bt),mr=q(fr),Sr=q(Wt),Tr=q(hr),br=B;(lr&&br(new lr(new ArrayBuffer(1)))!=Er||bt&&br(new bt)!=dr||fr&&br(fr.resolve())!=pr||Wt&&br(new Wt)!=vr||hr&&br(new hr)!=_r)&&(br=function(t){var e=B(t),r="[object Object]"==e?t.constructor:void 0,n=r?q(r):"";if(n)switch(n){case yr:return Er;case Or:return dr;case mr:return pr;case Sr:return vr;case Tr:return _r}return e});var gr=br;var Ar=function(t){return null!=t&&"object"==typeof t};var Cr=function(t){return Ar(t)&&"[object Arguments]"==B(t)},Nr=Object.prototype,Ir=Nr.hasOwnProperty,Rr=Nr.propertyIsEnumerable,wr=Cr(function(){return arguments}())?Cr:function(t){return Ar(t)&&Ir.call(t,"callee")&&!Rr.call(t,"callee")},Dr=wr,Pr=Array.isArray;var Lr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991};var Ur=function(t){return null!=t&&Lr(t.length)&&!k(t)};var Mr=function(){return!1},jr=l((function(t,e){var r=e&&!e.nodeType&&e,n=r&&t&&!t.nodeType&&t,o=n&&n.exports===r?R.Buffer:void 0,i=(o?o.isBuffer:void 0)||Mr;t.exports=i})),Fr={};Fr["[object Float32Array]"]=Fr["[object Float64Array]"]=Fr["[object Int8Array]"]=Fr["[object Int16Array]"]=Fr["[object Int32Array]"]=Fr["[object Uint8Array]"]=Fr["[object Uint8ClampedArray]"]=Fr["[object Uint16Array]"]=Fr["[object Uint32Array]"]=!0,Fr["[object Arguments]"]=Fr["[object Array]"]=Fr["[object ArrayBuffer]"]=Fr["[object Boolean]"]=Fr["[object DataView]"]=Fr["[object Date]"]=Fr["[object Error]"]=Fr["[object Function]"]=Fr["[object Map]"]=Fr["[object Number]"]=Fr["[object Object]"]=Fr["[object RegExp]"]=Fr["[object Set]"]=Fr["[object String]"]=Fr["[object WeakMap]"]=!1;var xr=function(t){return Ar(t)&&Lr(t.length)&&!!Fr[B(t)]};var Br=function(t){return function(e){return t(e)}},Hr=l((function(t,e){var r=e&&!e.nodeType&&e,n=r&&t&&!t.nodeType&&t,o=n&&n.exports===r&&N.process,i=function(){try{var t=n&&n.require&&n.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=i})),Gr=Hr&&Hr.isTypedArray,kr=Gr?Br(Gr):xr,zr=Object.prototype.hasOwnProperty;var Wr=function(t){if(null==t)return!0;if(Ur(t)&&(Pr(t)||"string"==typeof t||"function"==typeof t.splice||jr(t)||kr(t)||Dr(t)))return!t.length;var e=gr(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(sr(t))return!cr(t).length;for(var r in t)if(zr.call(t,r))return!1;return!0};var Vr=function(t,e){for(var r=-1,n=null==t?0:t.length,o=Array(n);++r<n;)o[r]=e(t[r],r,t);return o};var Yr=function(t){return"symbol"==typeof t||Ar(t)&&"[object Symbol]"==B(t)},qr=w?w.prototype:void 0,Jr=qr?qr.toString:void 0;var Kr=function t(e){if("string"==typeof e)return e;if(Pr(e))return Vr(e,t)+"";if(Yr(e))return Jr?Jr.call(e):"";var r=e+"";return"0"==r&&1/e==-Infinity?"-0":r};var $r=function(t){return null==t?"":Kr(t)};var Zr=function(t){return $r(t).toLowerCase()},Qr=function(t){var e=new Date(parseInt(t,10));return"Invalid Date"!==e.toString()?e:new Date},Xr=function(t,e){return void 0===e&&(e=""),t.split(/\r?\n/g).reduce((function(t,r){if(!r.length)return t;var n=Ye(r),o=n.command,i=n.tags,u=void 0===i?{}:i,c=n.prefix,l=void 0===c?{name:void 0,user:void 0,host:void 0}:c,f=l.name,h=l.user,d=l.host,p=s(n.params,2),v=p[0],_=p[1],E=String(u["tmi-sent-ts"])||Date.now().toString(),y=Wr(u)?{}:or(u),O=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.reduce((function(t,e){return"string"!=typeof e?t:"tmi.twitch.tv"===e?"tmi.twitch.tv":Zr(e).split(".")[0]}),void 0)}(d,f,h,y.login,y.username,y.displayName);return a(t,[{_raw:r,timestamp:Qr(E),command:o,event:o,channel:"*"!==v?v:"",username:O,isSelf:"string"==typeof O&&Zr(e)===O,tags:y,message:_}])}),[])},tn=function(t,e,r,n,o,i,s,a){if(!t){var u;if(void 0===e)u=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[r,n,o,i,s,a],l=0;(u=new Error(e.replace(/%s/g,(function(){return c[l++]})))).name="Invariant Violation"}throw u.framesToPop=1,u}};var en=function(t,e,r){var n=r.length;if(null==t)return!n;for(t=Object(t);n--;){var o=r[n],i=e[o],s=t[o];if(void 0===s&&!(o in t)||!i(s))return!1}return!0};var rn=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n},nn=/^(?:0|[1-9]\d*)$/;var on=function(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&nn.test(t))&&t>-1&&t%1==0&&t<e},sn=Object.prototype.hasOwnProperty;var an=function(t,e){var r=Pr(t),n=!r&&Dr(t),o=!r&&!n&&jr(t),i=!r&&!n&&!o&&kr(t),s=r||n||o||i,a=s?rn(t.length,String):[],u=a.length;for(var c in t)!e&&!sn.call(t,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||on(c,u))||a.push(c);return a};var un=function(t){return Ur(t)?an(t):cr(t)};var cn=function(t,e){return null==e||en(t,e,un(e))};var ln=function(t){return t};var fn=function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)},hn=Math.max;var dn=function(t,e,r){return e=hn(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=hn(n.length-e,0),s=Array(i);++o<i;)s[o]=n[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=n[o];return a[e]=r(s),fn(t,this,a)}};var pn=function(t){return function(){return t}},vn=function(){try{var t=rt(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),_n=vn?function(t,e){return vn(t,"toString",{configurable:!0,enumerable:!1,value:pn(e),writable:!0})}:ln,En=Date.now;var yn=function(t){var e=0,r=0;return function(){var n=En(),o=16-(n-r);if(r=n,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}},On=yn(_n);var mn=function(t,e){return On(dn(t,e,ln),t+"")};var Sn=function(t,e,r){if(!H(r))return!1;var n=typeof e;return!!("number"==n?Ur(r)&&on(e,r.length):"string"==n&&e in r)&&pt(r[e],t)};var Tn=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e},bn=Object.prototype.hasOwnProperty;var gn=function(t){if(!H(t))return Tn(t);var e=sr(t),r=[];for(var n in t)("constructor"!=n||!e&&bn.call(t,n))&&r.push(n);return r};var An=function(t){return Ur(t)?an(t,!0):gn(t)},Cn=Object.prototype,Nn=Cn.hasOwnProperty,In=mn((function(t,e){t=Object(t);var r=-1,n=e.length,o=n>2?e[2]:void 0;for(o&&Sn(e[0],e[1],o)&&(n=1);++r<n;)for(var i=e[r],s=An(i),a=-1,u=s.length;++a<u;){var c=s[a],l=t[c];(void 0===l||pt(l,Cn[c])&&!Nn.call(t,c))&&(t[c]=i[c])}return t}));var Rn=function(t){return"string"==typeof t||!Pr(t)&&Ar(t)&&"[object String]"==B(t)},wn=R.isFinite;var Dn=function(t){return"number"==typeof t&&wn(t)};var Pn=function(t){return!0===t||!1===t||Ar(t)&&"[object Boolean]"==B(t)};var Ln=function(t){return null==t},Un=Math.floor,Mn=Math.random;var jn=function(t,e){return t+Un(Mn()*(e-t+1))},Fn=/\s/;var xn=function(t){for(var e=t.length;e--&&Fn.test(t.charAt(e)););return e},Bn=/^\s+/;var Hn=function(t){return t?t.slice(0,xn(t)+1).replace(Bn,""):t},Gn=/^[-+]0x[0-9a-f]+$/i,kn=/^0b[01]+$/i,zn=/^0o[0-7]+$/i,Wn=parseInt;var Vn=function(t){if("number"==typeof t)return t;if(Yr(t))return NaN;if(H(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=H(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Hn(t);var r=kn.test(t);return r||zn.test(t)?Wn(t.slice(2),r?2:8):Gn.test(t)?NaN:+t},Yn=1/0;var qn=function(t){return t?(t=Vn(t))===Yn||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0},Jn=parseFloat,Kn=Math.min,$n=Math.random;var Zn,Qn=function(t,e,r){if(r&&"boolean"!=typeof r&&Sn(t,e,r)&&(e=r=void 0),void 0===r&&("boolean"==typeof e?(r=e,e=void 0):"boolean"==typeof t&&(r=t,t=void 0)),void 0===t&&void 0===e?(t=0,e=1):(t=qn(t),void 0===e?(e=t,t=0):e=qn(e)),t>e){var n=t;t=e,e=n}if(r||t%1||e%1){var o=$n();return Kn(t+o*(e-t+Jn("1e-"+((o+"").length-1))),e)}return jn(t,e)},Xn=function(t){return null==t?"TWITCHJS":t.startsWith("oauth:")?t:"oauth:"+t};!function(t){t.RAW="RAW",t.ALL="*",t.CONNECTED="CONNECTED",t.DISCONNECTED="DISCONNECTED",t.RECONNECT="RECONNECT",t.AUTHENTICATED="AUTHENTICATED",t.AUTHENTICATION_FAILED="AUTHENTICATION_FAILED",t.ERROR_ENCOUNTERED="ERROR_ENCOUNTERED"}(Zn||(Zn={}));var to=r(r({},te),Zn),eo=function(t){function n(e){var n=t.call(this)||this;n._clientPriority=100,n._options=function(t){var e,n={username:function(t){return Ln(t)||Rn(t)},token:function(t){return Ln(t)||Rn(t)},server:Rn,port:Dn,ssl:Pn,isKnown:Pn,isVerified:Pn},o=In(r(r({},t),{username:(e=t.username,Wr(e)||"justinfan"===e?"justinfan"+Qn(8e4,81e3):e),token:t.token?Xn(t.token):void 0}),{server:"irc-ws.chat.twitch.tv",port:443,ssl:!0,isKnown:!1,isVerified:!1});return tn(cn(o,n),"[twitch-js/Chat/Client] options: Expected valid options"),o}(e);var o=n._options,i=o.ssl,s=o.server,a=o.port,u=o.log;n._log=we(r({name:"Chat/Client"},u));var c=i?"wss":"ws";return n._ws=new Pe(c+"://"+s+":"+a),n._ws.onopen=n._handleOpen.bind(n),n._ws.onmessage=n._handleMessage.bind(n),n._ws.onerror=n._handleError.bind(n),n._ws.onclose=n._handleClose.bind(n),n._queueAuthenticate=n._options.isVerified?new Ge({intervalCap:200,interval:1e4}):new Ge({intervalCap:20,interval:1e4}),n._queueJoin=n._options.isVerified?new Ge({intervalCap:2e3,interval:1e4}):new Ge({intervalCap:20,interval:1e4}),n._queue=new Ge({intervalCap:20,interval:3e4}),n._moderatorQueue=new Ge({intervalCap:100,interval:3e4}),n}return e(n,t),n.prototype.isReady=function(){return 1===this._ws.readyState},n.prototype.send=function(t,e){return o(this,void 0,void 0,(function(){var n,o,s,a=this;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=r({priority:0,isModerator:!1},e),o=n.priority,s=n.isModerator,[4,(t.startsWith("JOIN")?this._queueJoin:t.startsWith("PASS")?this._queueAuthenticate:s&&this._moderatorQueue?this._moderatorQueue:this._queue).add((function(){return a._ws.send(t)}),{priority:o})];case 1:return i.sent(),this._log.trace("< "+t),[3,3];case 2:return i.sent(),this._log.error("< "+t),[3,3];case 3:return[2]}}))}))},n.prototype.disconnect=function(){var t,e;this._queueAuthenticate.pause(),this._queueJoin.pause(),this._queue.pause(),null===(t=this._moderatorQueue)||void 0===t||t.pause(),clearTimeout(this._queueAuthenticate._timeoutId),clearTimeout(this._queueJoin._timeoutId),clearTimeout(this._queue._timeoutId),clearTimeout(null===(e=this._moderatorQueue)||void 0===e?void 0:e._timeoutId),this._handleHeartbeatReset(),this._ws.close()},n.prototype._handleOpen=function(){var t=this._clientPriority;this.send("CAP REQ :"+Object.values(Kt).join(" "),{priority:t});var e=this._options,r=e.token,n=e.username;r&&n&&this.send("PASS "+r,{priority:t}),this.send("NICK "+n,{priority:t}),this._handleHeartbeat()},n.prototype._handleMessage=function(t){var e=this,n=t.data.toString();this._log.trace("> "+n.trim());var o=this._options,i=o.token,s=o.username,a=this._clientPriority;this._handleHeartbeat();var u=[];try{u=Xr(n,this._options.username)}catch(t){this._log.error("\nAn error occurred while attempting to parse a message from Twitch. Please use the following stack trace and raw message to resolve the bug in the TwitchJS source code, and then issue a pull request at https://github.com/twitch-js/twitch-js/compare\n\nStack trace:\n"+t+"\n\nRaw message:\n"+n),this.emit(to.ERROR_ENCOUNTERED,t)}u.forEach((function(t){var n=t.command||"";e._log.debug(r(r({},t),{_raw:void 0}),"> %s",n),!function(t){return void 0!==t&&t.command===te.NOTICE&&""===t.channel&&"Login authentication failed"===t.m