twitch-js
Version:
Javascript library for the Twitch Messaging Interface.
1 lines • 106 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])})(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}).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}));const h=()=>{const t=new Error("Delay aborted");return t.name="AbortError",t},d=({clearTimeout:t,setTimeout:e,willResolve:r})=>(n,{value:o,signal:i}={})=>{if(i&&i.aborted)return Promise.reject(h());let s,a,u;const c=t||clearTimeout,l=()=>{c(s),u(h())},f=new Promise((t,c)=>{a=()=>{i&&i.removeEventListener("abort",l),r?t(o):c(o)},u=c,s=(e||setTimeout)(a,n)});return i&&i.addEventListener("abort",l,{once:!0}),f.clear=()=>{c(s),s=null,a()},f},p=d({willResolve:!0});p.reject=d({willResolve:!1}),p.range=(t,e,r)=>p(((t,e)=>Math.floor(Math.random()*(e-t+1)+t))(t,e),r),p.createWithTimers=({clearTimeout:t,setTimeout:e})=>{const r=d({clearTimeout:t,setTimeout:e,willResolve:!0});return r.reject=d({clearTimeout:t,setTimeout:e,willResolve:!1}),r};var v=p,_=p;v.default=_;class y extends Error{constructor(t){super(t||"Promise was canceled"),this.name="CancelError"}get isCanceled(){return!0}}class E{static fn(t){return(...e)=>new E((r,n,o)=>{e.push(o),t(...e).then(r,n)})}constructor(t){this._cancelHandlers=[],this._isPending=!0,this._isCanceled=!1,this._rejectOnCancel=!0,this._promise=new Promise((e,r)=>{this._reject=r;const n=t=>{if(!this._isPending)throw new Error("The `onCancel` handler was attached after the promise settled.");this._cancelHandlers.push(t)};return Object.defineProperties(n,{shouldReject:{get:()=>this._rejectOnCancel,set:t=>{this._rejectOnCancel=t}}}),t(t=>{this._isPending=!1,e(t)},t=>{this._isPending=!1,r(t)},n)})}then(t,e){return this._promise.then(t,e)}catch(t){return this._promise.catch(t)}finally(t){return this._promise.finally(t)}cancel(t){if(this._isPending&&!this._isCanceled){if(this._cancelHandlers.length>0)try{for(const t of this._cancelHandlers)t()}catch(t){this._reject(t)}this._isCanceled=!0,this._rejectOnCancel&&this._reject(new y(t))}}get isCanceled(){return this._isCanceled}}Object.setPrototypeOf(E.prototype,Promise.prototype);var O=E,m=y;O.CancelError=m;var S=(t,e)=>(e=e||(()=>{}),t.then(t=>new Promise(t=>{t(e())}).then(()=>t),t=>new Promise(t=>{t(e())}).then(()=>{throw t})));class T extends Error{constructor(t){super(t),this.name="TimeoutError"}}const b=(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 T("string"==typeof r?r:`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),o(i)},e);S(t.then(n,o),()=>{clearTimeout(i)})});var g=b,A=b,C=T;g.default=A,g.TimeoutError=C;const N=Symbol.asyncIterator||"@@asyncIterator",I=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)}},w=t=>Array.isArray(t)?t:[t],R=(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=w(e),a=[],{addListener:u,removeListener:c}=I(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=g(o,r.timeout);return t.cancel=n,t}return o},D=(t,e,r)=>{"function"==typeof r&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};const n=R(t,e,r),o=n.then(t=>t[0]);return o.cancel=n.cancel,o};var P=D,U=D,L=R,j=g.TimeoutError;P.default=U,P.multiple=L,P.iterator=(t,e,r)=>{"function"==typeof r&&(r={filter:r});const n=w(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}=I(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,y);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()},y=(...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,y);return{[N](){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})}},P.TimeoutError=j;class M extends Error{constructor(t){super(t),this.name="TimeoutError"}}const F=(t,e,r,n)=>{let o;const i=new Promise((i,s)=>{if("number"!=typeof e||e<0)throw new TypeError("Expected `milliseconds` to be a positive number");e!==1/0?(n={customTimers:{setTimeout:setTimeout,clearTimeout:clearTimeout},...n},o=n.customTimers.setTimeout.call(void 0,()=>{if("function"==typeof r){try{i(r())}catch(t){s(t)}return}const n=r instanceof Error?r:new M("string"==typeof r?r:`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),s(n)},e),(async()=>{try{i(await t)}catch(t){s(t)}finally{n.customTimers.clearTimeout.call(void 0,o)}})()):i(t)});return i.clear=()=>{clearTimeout(o),o=void 0},i};var x=F,H=F,B=M;x.default=H,x.TimeoutError=B;var G="object"==typeof u&&u&&u.Object===Object&&u,k="object"==typeof self&&self&&self.Object===Object&&self,z=G||k||Function("return this")(),W=z.Symbol,V=Object.prototype,Y=V.hasOwnProperty,q=V.toString,K=W?W.toStringTag:void 0;var J=function(t){var e=Y.call(t,K),r=t[K];try{t[K]=void 0;var n=!0}catch(t){}var o=q.call(t);return n&&(e?t[K]=r:delete t[K]),o},$=Object.prototype.toString;var Z=function(t){return $.call(t)},Q=W?W.toStringTag:void 0;var X=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Q&&Q in Object(t)?J(t):Z(t)};var tt=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)};var et,rt=function(t){if(!tt(t))return!1;var e=X(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},nt=z["__core-js_shared__"],ot=(et=/[^.]+$/.exec(nt&&nt.keys&&nt.keys.IE_PROTO||""))?"Symbol(src)_1."+et:"";var it=function(t){return!!ot&&ot in t},st=Function.prototype.toString;var at=function(t){if(null!=t){try{return st.call(t)}catch(t){}try{return t+""}catch(t){}}return""},ut=/^\[object .+?Constructor\]$/,ct=Function.prototype,lt=Object.prototype,ft=ct.toString,ht=lt.hasOwnProperty,dt=RegExp("^"+ft.call(ht).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var pt=function(t){return!(!tt(t)||it(t))&&(rt(t)?dt:ut).test(at(t))};var vt=function(t,e){return null==t?void 0:t[e]};var _t=function(t,e){var r=vt(t,e);return pt(r)?r:void 0},yt=_t(Object,"create");var Et=function(){this.__data__=yt?yt(null):{},this.size=0};var Ot=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},mt=Object.prototype.hasOwnProperty;var St=function(t){var e=this.__data__;if(yt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return mt.call(e,t)?e[t]:void 0},Tt=Object.prototype.hasOwnProperty;var bt=function(t){var e=this.__data__;return yt?void 0!==e[t]:Tt.call(e,t)};var gt=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=yt&&void 0===e?"__lodash_hash_undefined__":e,this};function At(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])}}At.prototype.clear=Et,At.prototype.delete=Ot,At.prototype.get=St,At.prototype.has=bt,At.prototype.set=gt;var Ct=At;var Nt=function(){this.__data__=[],this.size=0};var It=function(t,e){return t===e||t!=t&&e!=e};var wt=function(t,e){for(var r=t.length;r--;)if(It(t[r][0],e))return r;return-1},Rt=Array.prototype.splice;var Dt=function(t){var e=this.__data__,r=wt(e,t);return!(r<0)&&(r==e.length-1?e.pop():Rt.call(e,r,1),--this.size,!0)};var Pt=function(t){var e=this.__data__,r=wt(e,t);return r<0?void 0:e[r][1]};var Ut=function(t){return wt(this.__data__,t)>-1};var Lt=function(t,e){var r=this.__data__,n=wt(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};function jt(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])}}jt.prototype.clear=Nt,jt.prototype.delete=Dt,jt.prototype.get=Pt,jt.prototype.has=Ut,jt.prototype.set=Lt;var Mt=jt,Ft=_t(z,"Map");var xt=function(){this.size=0,this.__data__={hash:new Ct,map:new(Ft||Mt),string:new Ct}};var Ht=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Bt=function(t,e){var r=t.__data__;return Ht(e)?r["string"==typeof e?"string":"hash"]:r.map};var Gt=function(t){var e=Bt(this,t).delete(t);return this.size-=e?1:0,e};var kt=function(t){return Bt(this,t).get(t)};var zt=function(t){return Bt(this,t).has(t)};var Wt=function(t,e){var r=Bt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function Vt(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])}}Vt.prototype.clear=xt,Vt.prototype.delete=Gt,Vt.prototype.get=kt,Vt.prototype.has=zt,Vt.prototype.set=Wt;var Yt=Vt;var qt=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this};var Kt=function(t){return this.__data__.has(t)};function Jt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Yt;++e<r;)this.add(t[e])}Jt.prototype.add=Jt.prototype.push=qt,Jt.prototype.has=Kt;var $t=Jt;var Zt=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 Qt=function(t){return t!=t};var Xt=function(t,e,r){for(var n=r-1,o=t.length;++n<o;)if(t[n]===e)return n;return-1};var te=function(t,e,r){return e==e?Xt(t,e,r):Zt(t,Qt,r)};var ee=function(t,e){return!!(null==t?0:t.length)&&te(t,e,0)>-1};var re=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 ne=function(t,e){return t.has(e)},oe=_t(z,"Set");var ie=function(){};var se=function(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r},ae=oe&&1/se(new oe([,-0]))[1]==1/0?function(t){return new oe(t)}:ie;var ue=function(t,e,r){var n=-1,o=ee,i=t.length,s=!0,a=[],u=a;if(r)s=!1,o=re;else if(i>=200){var c=e?null:ae(t);if(c)return se(c);s=!1,o=ne,u=new $t}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 ce,le,fe,he,de,pe,ve,_e,ye,Ee,Oe=function(t){return t&&t.length?ue(t):[]};!function(t){t.Helix="helix",t.Kraken="kraken"}(ce||(ce={})),function(t){t.tags="twitch.tv/tags",t.commands="twitch.tv/commands",t.membership="twitch.tv/membership"}(le||(le={})),function(t){t.JOIN="JOIN",t.MODE="MODE",t.PART="PART",t.NAMES="353",t.NAMES_END="366"}(fe||(fe={})),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"}(he||(he={})),function(t){t.WELCOME="001",t.PING="PING",t.PONG="PONG",t.WHISPER="WHISPER"}(de||(de={})),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"}(pe||(pe={})),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"}(ve||(ve={})),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"}(_e||(_e={})),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"}(ye||(ye={})),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"}(Ee||(Ee={}));Object.entries(Ee).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 me,Se,Te=Object.keys(Ee).reduce((function(t,e){var n;return r(r({},t),((n={})[e]=e,n[ve.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"}(me||(me={})),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 be,ge,Ae=Object.keys(Se).reduce((function(t,e){var n;return r(r({},t),((n={})[e]=e,n[ve.USER_NOTICE+"/"+e]=e,n))}),{}),Ce=r(r(r(r(r(r(r(r({},fe),he),de),pe),_e),Te),me),Ae);function Ne(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"}(be||(be={})),function(t){t[t.bits=0]="bits",t[t.bitsLeader=1]="bitsLeader",t[t.subscriber=2]="subscriber"}(ge||(ge={}));var Ie=function(t,e,r){var n=r&&r.stringify||Ne;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 we=Pe,Re=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||{},De={mapHttpRequest:Be,mapHttpResponse:Be,wrapRequestSerializer:Ge,wrapResponseSerializer:Ge,wrapErrorSerializer:Ge,req:Be,res:Be,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 Pe(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||Re;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=ke),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,Ue(u,a,"error","log"),Ue(u,a,"fatal","error"),Ue(u,a,"warn","error"),Ue(u,a,"info","log"),Ue(u,a,"debug","log"),Ue(u,a,"trace","log")}});var u={transmit:e,serialize:o,asObject:t.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:He(t)};return a.levels=Pe.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=ke,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,je([r],a,s,this._stdErrSerialize)}function u(t){this._childLevel=1+(0|t._childLevel),this.error=Me(t,r,"error"),this.fatal=Me(t,r,"fatal"),this.warn=Me(t,r,"warn"),this.info=Me(t,r,"info"),this.debug=Me(t,r,"debug"),this.trace=Me(t,r,"trace"),s&&(this.serializers=s,this._serialize=a),e&&(this._logEvent=xe([].concat(t._logEvent.bindings,r)))}return u.prototype=this,new u(this)},e&&(a._logEvent=xe()),a}function Ue(t,e,r,n){var o=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?ke:o[r]?o[r]:Re[r]||Re[n]||ke,function(t,e,r){if(!t.transmit&&e[r]===ke)return;e[r]=(n=e[r],function(){for(var o=t.timestamp(),i=new Array(arguments.length),s=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Re?Re:this,a=0;a<i.length;a++)i[a]=arguments[a];if(t.serialize&&!t.asObject&&je(i,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(s,Le(this,r,i,o)):n.apply(s,i),t.transmit){var u=t.transmit.level||e.level,c=Pe.levels.values[u],l=Pe.levels.values[r];if(l<c)return;Fe(this,{ts:o,methodLevel:r,methodValue:l,transmitLevel:u,transmitValue:Pe.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},i)}});var n}(t,e,r)}function Le(t,e,r,n){t._serialize&&je(r,t._serialize,t.serializers,t._stdErrSerialize);var o=r.slice(),i=o[0],s={};n&&(s.time=n),s.level=Pe.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?Ie(o.shift(),o):void 0}else"string"==typeof i&&(i=Ie(o.shift(),o));return void 0!==i&&(s.msg=i),s}function je(t,e,r,n){for(var o in t)if(n&&t[o]instanceof Error)t[o]=Pe.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 Me(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 Fe(t,e,r){var n=e.send,o=e.ts,i=e.methodLevel,s=e.methodValue,a=e.val,u=t._logEvent.bindings;je(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=xe(u)}function xe(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function He(t){return"function"==typeof t.timestamp?t.timestamp:!1===t.timestamp?ze:We}function Be(){return{}}function Ge(t){return t}function ke(){}function ze(){return!1}function We(){return Date.now()}Pe.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"}},Pe.stdSerializers=De,Pe.stdTimeFunctions=Object.assign({},{nullTime:ze,epochTime:We,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}});var Ve=function(t){void 0===t&&(t={});var e=t.name,o=n(t,["name"]),i=["TwitchJS"].concat(e||[]).join("/"),s=we(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 Ye;"undefined"!=typeof WebSocket?Ye=WebSocket:"undefined"!=typeof MozWebSocket?Ye=MozWebSocket:void 0!==u?Ye=u.WebSocket||u.MozWebSocket:"undefined"!=typeof window?Ye=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(Ye=self.WebSocket||self.MozWebSocket);var qe=Ye;class Ke extends Error{constructor(t){super(t),this.name="TimeoutError"}}const Je=(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 Ke("string"==typeof r?r:`Promise timed out after ${e} milliseconds`);"function"==typeof t.cancel&&t.cancel(),o(i)},e);S(t.then(n,o),()=>{clearTimeout(i)})});var $e=Je,Ze=Je,Qe=Ke;$e.default=Ze,$e.TimeoutError=Qe;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 tr=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(tr);var er=c(l((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=()=>{},n=new $e.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:tr.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():$e.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}}}))),rr=15e4,nr=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(nr);nr.ParseError,nr.FormatError;var or=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(or);or.shouldEscapeString,or.escapeString,or.unescapeString;var ir=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||or.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 nr.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 nr.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 nr.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(ir);ir.parseTags,ir.parsePrefix;var sr=ir.parse;const ar=t=>"object"==typeof t&&null!==t,ur=t=>ar(t)&&!(t instanceof RegExp)&&!(t instanceof Error)&&!(t instanceof Date),cr=(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=>ur(t)?cr(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&&ur(c)&&(c=Array.isArray(c)?i(c):cr(c,e,r,n)),o[u]=c}return o};var lr=(t,e,r)=>{if(!ar(t))throw new TypeError(`Expected an object, got \`${t}\` (${typeof t})`);return cr(t,e,r)};const fr=(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(0===(t=Array.isArray(t)?t.map(t=>t.trim()).filter(t=>t.length).join("-"):t.trim()).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 hr=fr,dr=fr;hr.default=dr;class pr{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 vr=new pr({maxSize:1e5}),_r=t=>!("object"!=typeof t||null===t||t instanceof RegExp||t instanceof Error||t instanceof Date),yr=(t,e)=>{if(!_r(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&&_r(o)){const r=void 0===t?e:`${t}.${e}`;s.has(r)||(o=lr(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(vr.has(t))e=vr.get(t);else{const r=hr(e,{pascalCase:n});e.length<100&&vr.set(t,r),e=r}}return[e,o]};return lr(t,a(void 0))};var Er=(t,e)=>Array.isArray(t)?Object.keys(t).map(r=>yr(t[r],e)):yr(t,e),Or=Object.prototype;var mr=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Or)};var Sr=function(t,e){return function(r){return t(e(r))}}(Object.keys,Object),Tr=Object.prototype.hasOwnProperty;var br=function(t){if(!mr(t))return Sr(t);var e=[];for(var r in Object(t))Tr.call(t,r)&&"constructor"!=r&&e.push(r);return e},gr=_t(z,"DataView"),Ar=_t(z,"Promise"),Cr=_t(z,"WeakMap"),Nr="[object Map]",Ir="[object Promise]",wr="[object Set]",Rr="[object WeakMap]",Dr="[object DataView]",Pr=at(gr),Ur=at(Ft),Lr=at(Ar),jr=at(oe),Mr=at(Cr),Fr=X;(gr&&Fr(new gr(new ArrayBuffer(1)))!=Dr||Ft&&Fr(new Ft)!=Nr||Ar&&Fr(Ar.resolve())!=Ir||oe&&Fr(new oe)!=wr||Cr&&Fr(new Cr)!=Rr)&&(Fr=function(t){var e=X(t),r="[object Object]"==e?t.constructor:void 0,n=r?at(r):"";if(n)switch(n){case Pr:return Dr;case Ur:return Nr;case Lr:return Ir;case jr:return wr;case Mr:return Rr}return e});var xr=Fr;var Hr=function(t){return null!=t&&"object"==typeof t};var Br=function(t){return Hr(t)&&"[object Arguments]"==X(t)},Gr=Object.prototype,kr=Gr.hasOwnProperty,zr=Gr.propertyIsEnumerable,Wr=Br(function(){return arguments}())?Br:function(t){return Hr(t)&&kr.call(t,"callee")&&!zr.call(t,"callee")},Vr=Array.isArray;var Yr=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991};var qr=function(t){return null!=t&&Yr(t.length)&&!rt(t)};var Kr=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?z.Buffer:void 0,i=(o?o.isBuffer:void 0)||Kr;t.exports=i})),$r={};$r["[object Float32Array]"]=$r["[object Float64Array]"]=$r["[object Int8Array]"]=$r["[object Int16Array]"]=$r["[object Int32Array]"]=$r["[object Uint8Array]"]=$r["[object Uint8ClampedArray]"]=$r["[object Uint16Array]"]=$r["[object Uint32Array]"]=!0,$r["[object Arguments]"]=$r["[object Array]"]=$r["[object ArrayBuffer]"]=$r["[object Boolean]"]=$r["[object DataView]"]=$r["[object Date]"]=$r["[object Error]"]=$r["[object Function]"]=$r["[object Map]"]=$r["[object Number]"]=$r["[object Object]"]=$r["[object RegExp]"]=$r["[object Set]"]=$r["[object String]"]=$r["[object WeakMap]"]=!1;var Zr=function(t){return Hr(t)&&Yr(t.length)&&!!$r[X(t)]};var Qr=function(t){return function(e){return t(e)}},Xr=l((function(t,e){var r=e&&!e.nodeType&&e,n=r&&t&&!t.nodeType&&t,o=n&&n.exports===r&&G.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})),tn=Xr&&Xr.isTypedArray,en=tn?Qr(tn):Zr,rn=Object.prototype.hasOwnProperty;var nn=function(t){if(null==t)return!0;if(qr(t)&&(Vr(t)||"string"==typeof t||"function"==typeof t.splice||Jr(t)||en(t)||Wr(t)))return!t.length;var e=xr(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(mr(t))return!br(t).length;for(var r in t)if(rn.call(t,r))return!1;return!0};var on=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 sn=function(t){return"symbol"==typeof t||Hr(t)&&"[object Symbol]"==X(t)},an=W?W.prototype:void 0,un=an?an.toString:void 0;var cn=function t(e){if("string"==typeof e)return e;if(Vr(e))return on(e,t)+"";if(sn(e))return un?un.call(e):"";var r=e+"";return"0"==r&&1/e==-Infinity?"-0":r};var ln=function(t){return null==t?"":cn(t)};var fn=function(t){return ln(t).toLowerCase()},hn=function(t){var e=new Date(parseInt(t,10));return"Invalid Date"!==e.toString()?e:new Date},dn=function(t,e){return void 0===e&&(e=""),t.split(/\r?\n/g).reduce((function(t,r){if(!r.length)return t;var n=sr(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],y=String(u["tmi-sent-ts"])||Date.now().toString(),E=nn(u)?{}:Er(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":fn(e).split(".")[0]}),void 0)}(d,f,h,E.login,E.username,E.displayName);return a(t,[{_raw:r,timestamp:hn(y),command:o,event:o,channel:"*"!==v?v:"",username:O,isSelf:"string"==typeof O&&fn(e)===O,tags:E,message:_}])}),[])},pn=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 vn=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 _n=function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n},yn=/^(?:0|[1-9]\d*)$/;var En=function(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&yn.test(t))&&t>-1&&t%1==0&&t<e},On=Object.prototype.hasOwnProperty;var mn=function(t,e){var r=Vr(t),n=!r&&Wr(t),o=!r&&!n&&Jr(t),i=!r&&!n&&!o&&en(t),s=r||n||o||i,a=s?_n(t.length,String):[],u=a.length;for(var c in t)!e&&!On.call(t,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||i&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||En(c,u))||a.push(c);return a};var Sn=function(t){return qr(t)?mn(t):br(t)};var Tn=function(t,e){return null==e||vn(t,e,Sn(e))};var bn=function(t){return t};var gn=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)},An=Math.max;var Cn=function(t,e,r){return e=An(void 0===e?t.length-1:e,0),function(){for(var n=arguments,o=-1,i=An(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),gn(t,this,a)}};var Nn=function(t){return function(){return t}},In=function(){try{var t=_t(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),wn=In?function(t,e){return In(t,"toString",{configurable:!0,enumerable:!1,value:Nn(e),writable:!0})}:bn,Rn=Date.now;var Dn=function(t){var e=0,r=0;return function(){var n=Rn(),o=16-(n-r);if(r=n,o>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(wn);var Pn=function(t,e){return Dn(Cn(t,e,bn),t+"")};var Un=function(t,e,r){if(!tt(r))return!1;var n=typeof e;return!!("number"==n?qr(r)&&En(e,r.length):"string"==n&&e in r)&&It(r[e],t)};var Ln=function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e},jn=Object.prototype.hasOwnProperty;var Mn=function(t){if(!tt(t))return Ln(t);var e=mr(t),r=[];for(var n in t)("constructor"!=n||!e&&jn.call(t,n))&&r.push(n);return r};var Fn=function(t){return qr(t)?mn(t,!0):Mn(t)},xn=Object.prototype,Hn=xn.hasOwnProperty,Bn=Pn((function(t,e){t=Object(t);var r=-1,n=e.length,o=n>2?e[2]:void 0;for(o&&Un(e[0],e[1],o)&&(n=1);++r<n;)for(var i=e[r],s=Fn(i),a=-1,u=s.length;++a<u;){var c=s[a],l=t[c];(void 0===l||It(l,xn[c])&&!Hn.call(t,c))&&(t[c]=i[c])}return t}));var Gn=function(t){return"string"==typeof t||!Vr(t)&&Hr(t)&&"[object String]"==X(t)},kn=z.isFinite;var zn=function(t){return"number"==typeof t&&kn(t)};var Wn=function(t){return!0===t||!1===t||Hr(t)&&"[object Boolean]"==X(t)};var Vn=function(t){return null==t},Yn=Math.floor,qn=Math.random;var Kn=function(t,e){return t+Yn(qn()*(e-t+1))},Jn=/^\s+|\s+$/g,$n=/^[-+]0x[0-9a-f]+$/i,Zn=/^0b[01]+$/i,Qn=/^0o[0-7]+$/i,Xn=parseInt;var to=function(t){if("number"==typeof t)return t;if(sn(t))return NaN;if(tt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=tt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Jn,"");var r=Zn.test(t);return r||Qn.test(t)?Xn(t.slice(2),r?2:8):$n.test(t)?NaN:+t},eo=1/0;var ro=function(t){return t?(t=to(t))===eo||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0},no=parseFloat,oo=Math.min,io=Math.random;var so,ao=function(t,e,r){if(r&&"boolean"!=typeof r&&Un(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=ro(t),void 0===e?(e=t,t=0):e=ro(e)),t>e){var n=t;t=e,e=n}if(r||t%1||e%1){var o=io();return oo(t+o*(e-t+no("1e-"+((o+"").length-1))),e)}return Kn(t,e)},uo=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"}(so||(so={}));var co=r(r({},ve),so),lo=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 Vn(t)||Gn(t)},token:function(t){return Vn(t)||Gn(t)},server:Gn,port:zn,ssl:Wn,isKnown:Wn,isVerified:Wn},o=Bn(r(r({},t),{username:(e=t.username,nn(e)||"justinfan"===e?"justinfan"+ao(8e4,81e3):e),token:t.token?uo(t.token):void 0}),{server:"irc-ws.chat.twitch.tv",port:443,ssl:!0,isKnown:!1,isVerified:!1});return pn(Tn(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=Ve(r({name:"Chat/Client"},u));var c=i?"wss":"ws";return n._ws=new qe(c+"://"+s+":"+a),n._ws.onopen=n._handleOpen.bind(n),n._ws.onmessage=n._han