UNPKG

106 kBJavaScriptView Raw
1var 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._handleMessage.bind(n),n._ws.onerror=n._handleError.bind(n),n._ws.onclose=n._handleClose.bind(n),n._queueAuthenticate=n._options.isVerified?new er({intervalCap:200,interval:1e4}):new er({intervalCap:20,interval:1e4}),n._queueJoin=n._options.isVerified?new er({intervalCap:2e3,interval:1e4}):new er({intervalCap:20,interval:1e4}),n._queue=new er({intervalCap:20,interval:3e4}),n._moderatorQueue=new er({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(le).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=dn(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(co.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===ve.NOTICE&&""===t.channel&&"Login authentication failed"===t.message}(t)?t.command===ve.PING?e.send("PONG :tmi.twitch.tv",{priority:a}):i||t.command!==ve.WELCOME?t.command===ve.GLOBALUSERSTATE?(e._multiEmit([co.ALL,co.GLOBALUSERSTATE],r(r({},t),{event:co.GLOBALUSERSTATE})),i&&s&&e._multiEmit([co.ALL,co.CONNECTED],r(r({},t),{event:co.CONNECTED}))):t.command===ve.RECONNECT?e._multiEmit([co.ALL,co.RECONNECT],r(r({},t),{event:co.RECONNECT})):e.emit(co.ALL,t):e._multiEmit([co.ALL,co.CONNECTED],r(r({},t),{event:co.CONNECTED})):(e._multiEmit([co.ALL,co.AUTHENTICATION_FAILED],r(r({},t),{event:co.AUTHENTICATION_FAILED})),e.disconnect())})),this.emit(co.RAW,n)},n.prototype._handleError=function(t){this._log.error(t)},n.prototype._handleClose=function(t){this.emit(co.DISCONNECTED)},n.prototype._handleHeartbeat=function(){var t=this;this._handleHeartbeatReset();var e=this._clientPriority;this._heartbeatTimeoutId=setTimeout((function(){t.send(ve.PING,{priority:e})}),rr),this._reconnectTimeoutId=setTimeout((function(){t.emit(co.RECONNECT)}),151e3)},n.prototype._handleHeartbeatReset=function(){this._heartbeatTimeoutId&&clearTimeout(this._heartbeatTimeoutId),this._reconnectTimeoutId&&clearTimeout(this._reconnectTimeoutId)},n.prototype._multiEmit=function(t,e){var r=this;Array.isArray(t)?t.forEach((function(t){return r.emit(t,e)})):this.emit(t,e)},n}(f);var fo=function(){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)e.hasOwnProperty(r)&&(t[r]=e[r])})(e,r)};return function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}}(),ho=function(t){function r(e){var r=t.call(this,e)||this;return r.timestamp=new Date,r.message="[TwitchJS] "+e,r}return e(r,t),r}(function(t){function e(e){var r,n,o,i=this.constructor,s=t.call(this,e)||this;return Object.defineProperty(s,"name",{value:i.name,enumerable:!1,configurable:!0}),r=s,n=i.prototype,(o=Object.setPrototypeOf)?o(r,n):r.__proto__=n,function(t,e){void 0===e&&(e=t.constructor);var r=Error.captureStackTrace;r&&r(t,e)}(s),s}return fo(e,t),e}(Error)),po=function(t){function r(e,n){var o=t.call(this,(e instanceof Error?e.message:e)+" [Chat]")||this;return Object.setPrototypeOf(o,r.prototype),void 0!==n&&"string"!=typeof n&&(o.command=n.command),o}return e(r,t),r}(ho),vo=function(t){function r(e,n){var o=t.call(this,"Authentication error encountered",n)||this;return Object.setPrototypeOf(o,r.prototype),Object.assign(o,e),Object.assign(o,n),o}return e(r,t),r}(po);(function(t){function r(e,n){var o=t.call(this,"Parse error encountered")||this;return Object.setPrototypeOf(o,r.prototype),Object.assign(o,e),o._raw=n,o.command=_e.PARSE_ERROR_ENCOUNTERED,o}e(r,t)})(po),function(t){function r(e){void 0===e&&(e="Error: join");var n=t.call(this,e)||this;return Object.setPrototypeOf(n,r.prototype),n}e(r,t)}(po),function(t){function r(e){void 0===e&&(e="Error: timeout");var n=t.call(this,e)||this;return Object.setPrototypeOf(n,r.prototype),n}e(r,t)}(po);var _o=function(t){return function(e,r){return"string"==typeof e&&"string"==typeof r||(e=to(e),r=to(r)),t(e,r)}}((function(t,e){return t>e}));var yo=function(t){return ln(t).toUpperCase()},Eo=new RegExp("^msgParam(\\w+)"),Oo=/:.+@jtv\.tmi\.twitch\.tv PRIVMSG #?(\w+) :(\w+) is now (?:(auto) )?hosting[A-z ]+(\d+)?/;var mo=function(t,e,r){var n=-1,o=t.length;e<0&&(e=-e>o?0:o+e),(r=r>o?o:r)<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+e];return i};var So=function(t,e,r){var n=t.length;return r=void 0===r?n:r,!e&&r>=n?t:mo(t,e,r)},To=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");var bo=function(t){return To.test(t)};var go=function(t){return t.split("")},Ao="[\\ud800-\\udfff]",Co="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",No="\\ud83c[\\udffb-\\udfff]",Io="[^\\ud800-\\udfff]",wo="(?:\\ud83c[\\udde6-\\uddff]){2}",Ro="[\\ud800-\\udbff][\\udc00-\\udfff]",Do="(?:"+Co+"|"+No+")"+"?",Po="[\\ufe0e\\ufe0f]?",Uo=Po+Do+("(?:\\u200d(?:"+[Io,wo,Ro].join("|")+")"+Po+Do+")*"),Lo="(?:"+[Io+Co+"?",Co,wo,Ro,Ao].join("|")+")",jo=RegExp(No+"(?="+No+")|"+Lo+Uo,"g");var Mo=function(t){return t.match(jo)||[]};var Fo=function(t){return bo(t)?Mo(t):go(t)};var xo=function(t){return function(e){e=ln(e);var r=bo(e)?Fo(e):void 0,n=r?r[0]:e.charAt(0),o=r?So(r,1).join(""):e.slice(1);return n[t]()+o}}("toUpperCase");var Ho=function(t){return xo(ln(t).toLowerCase())};var Bo=function(t,e,r,n){var o=-1,i=null==t?0:t.length;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r};var Go=function(t){return function(e){return null==t?void 0:t[e]}}({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),ko=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,zo=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");var Wo=function(t){return(t=ln(t))&&t.replace(ko,Go).replace(zo,"")},Vo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;var Yo=function(t){return t.match(Vo)||[]},qo=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;var Ko=function(t){return qo.test(t)},Jo="\\u2700-\\u27bf",$o="a-z\\xdf-\\xf6\\xf8-\\xff",Zo="A-Z\\xc0-\\xd6\\xd8-\\xde",Qo="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Xo="["+Qo+"]",ti="\\d+",ei="[\\u2700-\\u27bf]",ri="["+$o+"]",ni="[^\\ud800-\\udfff"+Qo+ti+Jo+$o+Zo+"]",oi="(?:\\ud83c[\\udde6-\\uddff]){2}",ii="[\\ud800-\\udbff][\\udc00-\\udfff]",si="["+Zo+"]",ai="(?:"+ri+"|"+ni+")",ui="(?:"+si+"|"+ni+")",ci="(?:['’](?:d|ll|m|re|s|t|ve))?",li="(?:['’](?:D|LL|M|RE|S|T|VE))?",fi="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",hi="[\\ufe0e\\ufe0f]?",di=hi+fi+("(?:\\u200d(?:"+["[^\\ud800-\\udfff]",oi,ii].join("|")+")"+hi+fi+")*"),pi="(?:"+[ei,oi,ii].join("|")+")"+di,vi=RegExp([si+"?"+ri+"+"+ci+"(?="+[Xo,si,"$"].join("|")+")",ui+"+"+li+"(?="+[Xo,si+ai,"$"].join("|")+")",si+"?"+ai+"+"+ci,si+"+"+li,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ti,pi].join("|"),"g");var _i=function(t){return t.match(vi)||[]};var yi=function(t,e,r){return t=ln(t),void 0===(e=r?void 0:e)?Ko(t)?_i(t):Yo(t):t.match(e)||[]},Ei=RegExp("['’]","g");var Oi=function(t){return function(e){return Bo(yi(Wo(e).replace(Ei,"")),t,"")}}((function(t,e,r){return e=e.toLowerCase(),t+(r?Ho(e):e)}));var mi,Si,Ti,bi,gi,Ai=function(){var t=arguments,e=ln(t[0]);return t.length<3?e:e.replace(t[1],t[2])},Ci=function(t){return"string"==typeof t?Ai(t,/\\[sn]/g," "):void 0},Ni=function(t){var e=parseInt(t,10);return zn(e)?e:void 0},Ii=function(t){return"1"===t},wi=function(t){return s(t.split(": "),2)[1].split(", ")},Ri=function(t){return Object.entries(t).reduce((function(t,e){var n,o,i,a,u,c,l=s(e,2),f=l[0],h=l[1];switch(f){case"followersOnly":return r(r({},t),((n={})[f]=0===(c=parseInt(h,10))||c>0&&c,n));case"broadcasterLang":return r(r({},t),((o={})[f]=Ci(h),o));case"slow":return r(r({},t),((i={})[f]=Ni(h),i));case"emoteOnly":case"r9k":case"subsOnly":return r(r({},t),((a={})[f]=Ii(h),a));default:return r(r({},t),((u={})[f]=h,u))}}),{})},Di=function(t){return r(r({},t),{badges:(i=t.badges,"string"==typeof i?i.split(",").reduce((function(t,e){var n,o,i,a=s(e.split("/"),2),u=a[0],c=a[1];if(void 0===c)return t;var l=Oi(u);return r(r({},t),l in be?((n={})[l]=Ii(c),n):l in ge?((o={})[l]=parseInt(c,10),o):((i={})[l]=c,i))}),{}):{}),bits:Ni(t.bits),color:t.color,displayName:t.displayName,emotes:(o=t.emotes,"string"!=typeof o?[]:o.split("/").reduce((function(t,e){var r=s(e.split(":"),2),n=r[0],o=r[1];return n?a(t,o.split(",").map((function(t){var e=s(t.split("-"),2),r=e[0],o=e[1];return{id:n,start:parseInt(r,10),end:parseInt(o,10)}}))):t}),[])),emoteSets:(n=t.emoteSets,"string"==typeof n?n.split(","):[]),userType:(e=t.userType,"string"==typeof e?e:void 0),username:t.displayName?fn(t.displayName):t.username,isModerator:"1"===t.mod});var e,n,o,i},Pi=function(t){return r(r({},t),Di(t))},Ui=Di,Li=function(t){var e,o=t.tags,i=n(t,["tags"]),s=void 0!==(e=t)&&e.command===ve.NOTICE&&""===e.channel&&"Login authentication failed"===e.message?r(r({},o),{msgId:fn(Ce.AUTHENTICATION_FAILED)}):o,a=yo(s.msgId);switch(s.msgId){case Ee.ROOM_MODS:return r(r({},i),{command:ve.NOTICE,event:Te.ROOM_MODS,tags:s,mods:wi(i.message)});default:return r(r({},i),{command:ve.NOTICE,event:a,tags:s})}},ji=function(t){var e=t.tags,o=n(t,["tags"]);return r(r({},o),{command:ve.USER_STATE,event:ve.USER_STATE,tags:Di(e)})},Mi=function(t){var e=ve.USER_NOTICE,n=r(r({},Ui(t.tags)),{systemMsg:Ci(t.tags.systemMsg)}),o=Ci(t.tags.systemMsg)||"",i=function(t){return Object.entries(t).reduce((function(t,e){var n,o,i=s(e,2),a=i[0],u=i[1],c=s(Eo.exec(a)||[],2)[1];switch(c){case"Months":case"MassGiftCount":case"PromoGiftTotal":case"SenderCount":case"ViewerCount":return r(r({},t),((n={})[Oi(c)]=Ni(u),n));case void 0:return t;default:return r(r({},t),((o={})[Oi(c)]=Ci(u),o))}}),{})}(n);switch(n.msgId){case Se.ANON_GIFT_PAID_UPGRADE:return r(r({},t),{command:e,event:_e.ANON_GIFT_PAID_UPGRADE,parameters:i,tags:n,systemMessage:o});case Se.GIFT_PAID_UPGRADE:return r(r({},t),{command:e,event:_e.GIFT_PAID_UPGRADE,parameters:i,tags:n,systemMessage:o});case Se.RAID:return r(r({},t),{command:e,event:_e.RAID,parameters:i,tags:n,systemMessage:o});case Se.RESUBSCRIPTION:return r(r({},t),{command:e,event:_e.RESUBSCRIPTION,parameters:i,tags:n,systemMessage:o});case Se.RITUAL:return r(r({},t),{command:e,event:_e.RITUAL,parameters:i,tags:n,systemMessage:o});case Se.SUBSCRIPTION_GIFT_COMMUNITY:return r(r({},t),{command:e,event:_e.SUBSCRIPTION_GIFT_COMMUNITY,parameters:i,tags:n,systemMessage:o});case Se.SUBSCRIPTION_GIFT:return r(r({},t),{command:e,event:_e.SUBSCRIPTION_GIFT,parameters:i,tags:n,systemMessage:o});case Se.SUBSCRIPTION:return r(r({},t),{command:e,event:_e.SUBSCRIPTION,parameters:i,tags:n,systemMessage:o});default:return r(r({},t),{command:e,event:yo(n.msgId),tags:n,parameters:i,systemMessage:o})}},Fi=function(t){return"string"!=typeof t||0===t.length?"":(t=t.toLowerCase()).startsWith("#")?t:"#"+t},xi=function(t){return null==t?"TWITCHJS":t.startsWith("oauth:")?t:"oauth:"+t},Hi=function(t){var e,n={username:function(t){return Vn(t)||Gn(t)},token:function(t){return Vn(t)||Gn(t)},isKnown:Wn,isVerified:Wn,connectionTimeout:zn,joinTimeout:zn,onAuthenticationFailure:rt},o=Bn(r(r({},t),{username:t.username?(e=t.username,nn(e)||"justinfan"===e?"justinfan"+ao(8e4,81e3):e):void 0,token:t.token?xi(t.token):void 0}),{isKnown:!1,isVerified:!1,connectionTimeout:5e3,joinTimeout:1e3,onAuthenticationFailure:function(){return Promise.reject()}});return pn(Tn(o,n),"[twitch-js/Chat] options: Expected valid options"),o},Bi=function(t){if(!(t=Fi(t)))throw new Error("Channel required");return t};!function(t){t[t.WAITING=0]="WAITING",t[t.CONNECTING=1]="CONNECTING",t[t.RECONNECTING=2]="RECONNECTING",t[t.CONNECTED=3]="CONNECTED",t[t.DISCONNECTING=4]="DISCONNECTING",t[t.DISCONNECTED=5]="DISCONNECTED"}(mi||(mi={})),function(t){t.ALREADY_BANNED="NOTICE/ALREADY_BANNED",t.ALREADY_EMOTE_ONLY_OFF="NOTICE/ALREADY_EMOTE_ONLY_OFF",t.ALREADY_EMOTE_ONLY_ON="NOTICE/ALREADY_EMOTE_ONLY_ON",t.ALREADY_R9K_OFF="NOTICE/ALREADY_R9K_OFF",t.ALREADY_R9K_ON="NOTICE/ALREADY_R9K_ON",t.ALREADY_SUBS_OFF="NOTICE/ALREADY_SUBS_OFF",t.ALREADY_SUBS_ON="NOTICE/ALREADY_SUBS_ON",t.BAD_HOST_HOSTING="NOTICE/BAD_HOST_HOSTING",t.BAD_MOD_MOD="NOTICE/BAD_MOD_MOD",t.BAN_SUCCESS="NOTICE/BAN_SUCCESS",t.BAD_UNBAN_NO_BAN="NOTICE/BAD_UNBAN_NO_BAN",t.COLOR_CHANGED="NOTICE/COLOR_CHANGED",t.CMDS_AVAILABLE="NOTICE/CMDS_AVAILABLE",t.COMMERCIAL_SUCCESS="NOTICE/COMMERCIAL_SUCCESS",t.EMOTE_ONLY_OFF="NOTICE/EMOTE_ONLY_OFF",t.EMOTE_ONLY_ON="NOTICE/EMOTE_ONLY_ON",t.FOLLOWERS_OFF="NOTICE/FOLLOWERS_OFF",t.FOLLOWERS_ON="NOTICE/FOLLOWERS_ON",t.FOLLOWERS_ONZERO="NOTICE/FOLLOWERS_ONZERO",t.HOST_OFF="NOTICE/HOST_OFF",t.HOST_ON="NOTICE/HOST_ON",t.HOSTS_REMAINING="NOTICE/HOSTS_REMAINING",t.MSG_CHANNEL_SUSPENDED="NOTICE/MSG_CHANNEL_SUSPENDED",t.MOD_SUCCESS="NOTICE/MOD_SUCCESS",t.NOT_HOSTING="NOTICE/NOT_HOSTING",t.R9K_OFF="NOTICE/R9K_OFF",t.R9K_ON="NOTICE/R9K_ON",t.ROOM_MODS="NOTICE/ROOM_MODS",t.SLOW_OFF="NOTICE/SLOW_OFF",t.SLOW_ON="NOTICE/SLOW_ON",t.SUBS_OFF="NOTICE/SUBS_OFF",t.SUBS_ON="NOTICE/SUBS_ON",t.TIMEOUT_SUCCESS="NOTICE/TIMEOUT_SUCCESS",t.UNBAN_SUCCESS="NOTICE/UNBAN_SUCCESS",t.UNMOD_SUCCESS="NOTICE/UNMOD_SUCCESS",t.UNRAID_SUCCESS="NOTICE/UNRAID_SUCCESS",t.UNRECOGNIZED_CMD="NOTICE/UNRECOGNIZED_CMD"}(Si||(Si={})),function(t){t.CHEER="PRIVMSG/CHEER",t.HOSTED_WITHOUT_VIEWERS="PRIVMSG/HOSTED_WITHOUT_VIEWERS",t.HOSTED_WITH_VIEWERS="PRIVMSG/HOSTED_WITH_VIEWERS",t.HOSTED_AUTO="PRIVMSG/HOSTED_AUTO"}(Ti||(Ti={})),function(t){t.ANON_GIFT_PAID_UPGRADE="USERNOTICE/ANON_GIFT_PAID_UPGRADE",t.GIFT_PAID_UPGRADE="USERNOTICE/GIFT_PAID_UPGRADE",t.RAID="USERNOTICE/RAID",t.RESUBSCRIPTION="USERNOTICE/RESUBSCRIPTION",t.RITUAL="USERNOTICE/RITUAL",t.SUBSCRIPTION="USERNOTICE/SUBSCRIPTION",t.SUBSCRIPTION_GIFT="USERNOTICE/SUBSCRIPTION_GIFT",t.SUBSCRIPTION_GIFT_COMMUNITY="USERNOTICE/SUBSCRIPTION_GIFT_COMMUNITY"}(bi||(bi={}));var Gi=function(t){function u(e){var n=t.call(this)||this;return n._readyState=mi.WAITING,n._connectionAttempts=0,n._channelState={},n._isAuthenticated=!1,n._options=Hi(e),n._log=Ve(r({name:"Chat"},n._options.log)),n}return e(u,t),u.prototype.connect=function(){return o(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,7]),this._readyState=mi.CONNECTING,this._connectionInProgress?[2,this._connectionInProgress]:(t=this,[4,x(this._handleConnectionAttempt(),this._options.connectionTimeout)]);case 1:return t._connectionInProgress=r.sent(),this._readyState=mi.CONNECTED,this._connectionAttempts=0,[3,7];case 2:return e=r.sent(),this._readyState===mi.DISCONNECTING||this._readyState===mi.DISCONNECTED?[3,5]:(this._log.info("Retrying ..."),[4,v(this._options.connectionTimeout)]);case 3:return r.sent(),[4,this._handleAuthenticationFailure()];case 4:return r.sent(),[2,this.connect()];case 5:throw e;case 6:return[3,7];case 7:return[2]}}))}))},u.prototype.updateOptions=function(t){var e=this._options,n=e.token,o=e.username;this._options=Hi(r(r({},t),{token:n,username:o}))},u.prototype.send=function(t,e){if(!this._client)throw new po("Not connected");return this._client.send(t,e)},u.prototype.disconnect=function(){var t;this._readyState=mi.DISCONNECTING,null===(t=this._client)||void 0===t||t.disconnect(),this._readyState=mi.DISCONNECTED},u.prototype.reconnect=function(t){return o(this,void 0,void 0,(function(){var e,n=this;return i(this,(function(o){switch(o.label){case 0:return t&&(this._options=Hi(r(r({},this._options),t))),this._connectionInProgress=void 0,this._readyState=mi.RECONNECTING,e=this._getChannels(),this.disconnect(),[4,this.connect()];case 1:return o.sent(),[2,Promise.all(e.map((function(t){return n.join(t)})))]}}))}))},u.prototype.join=function(t){return o(this,void 0,void 0,(function(){var e,r,n,o,a;return i(this,(function(i){switch(i.label){case 0:return t=Bi(t),e=this._log.profile("Joining "+t),[4,Promise.all([P(this,ve.ROOM_STATE+"/"+t),this._isAuthenticated?P(this,ve.USER_STATE+"/"+t):void 0,this.send(ve.JOIN+" "+t)])];case 1:return r=s.apply(void 0,[i.sent(),2]),n=r[0],o=r[1],a={roomState:n.tags,userState:o?o.tags:void 0},this._setChannelState(n.channel,a),e.done("Joined "+t),[2,a]}}))}))},u.prototype.part=function(t){return t=Bi(t),this._log.info("Parting "+t),this._removeChannelState(t),this.send(ve.PART+" "+t)},u.prototype.say=function(t,e,n){var s,a;return void 0===n&&(n={}),o(this,void 0,void 0,(function(){var o,u,c;return i(this,(function(i){switch(i.label){case 0:if(!this._isAuthenticated)throw new po("To send messages, please connect with a token and username");return t=Bi(t),o=e.startsWith("/"),u="1"===(null===(a=null===(s=this._channelState[t])||void 0===s?void 0:s.userState)||void 0===a?void 0:a.mod),o?this._log.info("CMD/"+t+" :"+e):this._log.info("PRIVMSG/"+t+" :"+e),c=o?Promise.resolve():P(this,ve.USER_STATE+"/"+t),[4,Promise.all([c,this.send(ve.PRIVATE_MESSAGE+" "+t+" :"+e,r({isModerator:u},n))])];case 1:return i.sent(),[2]}}))}))},u.prototype.broadcast=function(t){return o(this,void 0,void 0,(function(){var e=this;return i(this,(function(r){if(!this._isAuthenticated)throw new po("To broadcast, please connect with a token and username");return[2,this._getChannels().map((function(r){return e.say(r,t)}))]}))}))},u.prototype.ban=function(t,e){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return t=Bi(t),r="/"+ye.BAN+" "+e,[4,Promise.all([P(this,[Si.BAN_SUCCESS+"/"+t,Si.ALREADY_BANNED+"/"+t]),this.say(t,r)])];case 1:return n=s.apply(void 0,[o.sent(),1]),[2,n[0]]}}))}))},u.prototype.block=function(t,e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){return t=Bi(t),r="/"+ye.BLOCK+" "+e,[2,this.say(t,r)]}))}))},u.prototype.delete=function(t,e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){return t=Bi(t),r="/"+ye.DELETE+" "+e,[2,this.say(t,r)]}))}))},u.prototype.clear=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.CLEAR,[4,Promise.all([P(this,[ve.CLEAR_CHAT+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.color=function(t,e){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return t=Bi(t),r="/"+ye.COLOR+" "+e,[4,Promise.all([P(this,[Si.COLOR_CHANGED+"/"+t]),this.say(t,r)])];case 1:return n=s.apply(void 0,[o.sent(),1]),[2,n[0]]}}))}))},u.prototype.commercial=function(t,e){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return t=Bi(t),r="/"+ye.COMMERCIAL+" "+e,[4,Promise.all([P(this,[Si.COMMERCIAL_SUCCESS+"/"+t]),this.say(t,r)])];case 1:return n=s.apply(void 0,[o.sent(),1]),[2,n[0]]}}))}))},u.prototype.emoteOnly=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.EMOTE_ONLY,[4,Promise.all([P(this,[Si.EMOTE_ONLY_ON+"/"+t,Si.ALREADY_EMOTE_ONLY_ON+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.emoteOnlyOff=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.EMOTE_ONLY_OFF,[4,Promise.all([P(this,[Si.EMOTE_ONLY_OFF+"/"+t,Si.ALREADY_EMOTE_ONLY_OFF+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.followersOnly=function(t,e){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return t=Bi(t),r="/"+ye.FOLLOWERS_ONLY+" "+e,[4,Promise.all([P(this,[Si.FOLLOWERS_ONZERO+"/"+t,Si.FOLLOWERS_ON+"/"+t]),this.say(t,r)])];case 1:return n=s.apply(void 0,[o.sent(),1]),[2,n[0]]}}))}))},u.prototype.followersOnlyOff=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.FOLLOWERS_ONLY_OFF,[4,Promise.all([P(this,[Si.FOLLOWERS_OFF+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.help=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.HELP,[4,Promise.all([P(this,[Si.CMDS_AVAILABLE+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.host=function(t,e){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return t=Bi(t),r="/"+ye.HOST+" "+e,[4,Promise.all([P(this,[Si.HOST_ON+"/"+t]),this.say(t,r)])];case 1:return n=s.apply(void 0,[o.sent(),1]),[2,n[0]]}}))}))},u.prototype.marker=function(t,e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){return t=Bi(t),r="/"+ye.MARKER+" "+e.slice(0,140),[2,this.say(t,r)]}))}))},u.prototype.me=function(t,e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){return t=Bi(t),r="/"+ye.ME+" "+e,[2,this.say(t,r)]}))}))},u.prototype.mod=function(t,e){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return t=Bi(t),r="/"+ye.MOD+" "+e,[4,Promise.all([P(this,[Si.MOD_SUCCESS+"/"+t]),this.say(t,r)])];case 1:return n=s.apply(void 0,[o.sent(),1]),[2,n[0]]}}))}))},u.prototype.mods=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.MODS,[4,Promise.all([P(this,[Si.ROOM_MODS+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.r9K=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.R9K,[4,Promise.all([P(this,[Si.R9K_ON+"/"+t,Si.ALREADY_R9K_ON+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.r9KOff=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.R9K_OFF,[4,Promise.all([P(this,[Si.R9K_OFF+"/"+t,Si.ALREADY_R9K_OFF+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.raid=function(t,e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){return t=Bi(t),r="/"+ye.RAID+" "+e,[2,this.say(t,r)]}))}))},u.prototype.slow=function(t,e){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return t=Bi(t),r="/"+ye.SLOW+" "+e,[4,Promise.all([P(this,[Si.SLOW_ON+"/"+t]),this.say(t,r)])];case 1:return n=s.apply(void 0,[o.sent(),1]),[2,n[0]]}}))}))},u.prototype.slowOff=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.SLOW_OFF,[4,Promise.all([P(this,[Si.SLOW_OFF+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.subscribers=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.SUBSCRIBERS,[4,Promise.all([P(this,[Si.SUBS_ON+"/"+t,Si.ALREADY_SUBS_ON+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.subscribersOff=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.SUBSCRIBERS_OFF,[4,Promise.all([P(this,[Si.SUBS_OFF+"/"+t,Si.ALREADY_SUBS_OFF+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.timeout=function(t,e,r){return o(this,void 0,void 0,(function(){var n,o,a;return i(this,(function(i){switch(i.label){case 0:return t=Bi(t),n=r?" "+r:"",o="/"+ye.TIMEOUT+" "+e+n,[4,Promise.all([P(this,[Si.TIMEOUT_SUCCESS+"/"+t]),this.say(t,o)])];case 1:return a=s.apply(void 0,[i.sent(),1]),[2,a[0]]}}))}))},u.prototype.unban=function(t,e){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return t=Bi(t),r="/"+ye.UNBAN+" "+e,[4,Promise.all([P(this,[Si.UNBAN_SUCCESS+"/"+t]),this.say(t,r)])];case 1:return n=s.apply(void 0,[o.sent(),1]),[2,n[0]]}}))}))},u.prototype.unblock=function(t,e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){return t=Bi(t),r="/"+ye.UNBLOCK+" "+e,[2,this.say(t,r)]}))}))},u.prototype.unhost=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.UNHOST,[4,Promise.all([P(this,[Si.HOST_OFF+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.unmod=function(t,e){return o(this,void 0,void 0,(function(){var r,n;return i(this,(function(o){switch(o.label){case 0:return t=Bi(t),r="/"+ye.UNMOD+" "+e,[4,Promise.all([P(this,[Si.UNMOD_SUCCESS+"/"+t]),this.say(t,r)])];case 1:return n=s.apply(void 0,[o.sent(),1]),[2,n[0]]}}))}))},u.prototype.unraid=function(t){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return t=Bi(t),e="/"+ye.UNRAID,[4,Promise.all([P(this,[Si.UNRAID_SUCCESS+"/"+t]),this.say(t,e)])];case 1:return r=s.apply(void 0,[n.sent(),1]),[2,r[0]]}}))}))},u.prototype.unvip=function(t,e){t=Bi(t);var r="/"+ye.UNVIP+" "+e;return this.say(t,r)},u.prototype.vip=function(t,e){t=Bi(t);var r="/"+ye.VIP+" "+e;return this.say(t,r)},u.prototype.vips=function(t){t=Bi(t);var e="/"+ye.VIPS;return this.say(t,e)},u.prototype.whisper=function(t,e){return o(this,void 0,void 0,(function(){var r;return i(this,(function(n){if(!this._isAuthenticated)throw new po("To whisper, please connect with a token and username");return r="/"+ye.WHISPER+" "+t+" "+e,[2,this.send(r)]}))}))},u.prototype._handleConnectionAttempt=function(){var t=this;return new O((function(e,r){var n=t._log.profile("Connecting ..."),o=t._options,i=o.token,s=o.username;t._readyState=mi.CONNECTING,t._connectionAttempts+=1,t._client&&t._client.removeAllListeners(),t._client=new lo(t._options),t._client.on(co.DISCONNECTED,t._handleDisconnect,t),t._client.once(co.RECONNECT,(function(){return t.reconnect()})),t._client.once(co.AUTHENTICATION_FAILED,r),t._client.once(co.CONNECTED,(function(r){i&&s&&t._handleAuthenticated(r),t._handleJoinsAfterConnect(),e(),n.done("Connected")})),t._client.on(co.ALL,t._handleMessage,t)}))},u.prototype._handleDisconnect=function(){this._log.info("Disconnecting ..."),this._connectionInProgress&&this._connectionInProgress.clear(),this._connectionInProgress=void 0,this._isAuthenticated=!1,this._clearChannelState(),this._log.info("Disconnected")},u.prototype._handleAuthenticated=function(t){var e,o,i,s=(o=(e=t).tags,i=n(e,["tags"]),r(r({},i),{command:ve.GLOBALUSERSTATE,event:ve.GLOBALUSERSTATE,tags:Pi(o)}));this._globalUserState=s.tags,this._isAuthenticated=!0},u.prototype._handleAuthenticationFailure=function(){var t,e;return o(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this._log.info("Retrying ..."),[4,null===(e=(t=this._options).onAuthenticationFailure)||void 0===e?void 0:e.call(t)];case 1:return(n=i.sent())?(this._log.info("Re-authenticating ..."),this._options=r(r({},this._options),{token:n}),[2,this.connect()]):[3,3];case 2:throw o=i.sent(),this._log.error("Re-authentication failed"),new vo(o);case 3:return[2]}}))}))},u.prototype._handleMessage=function(t){if(t instanceof Error)this.emit("error",t);else try{var e=s(this._parseMessageForEmitter(t),2),r=e[0],n=e[1];this._emit(r,n)}catch(e){this._log.error("\nAn error occurred while attempting to parse a message into a event. 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"+e+"\n\nBase message:\n"+JSON.stringify(t)),this.emit(co.ERROR_ENCOUNTERED,e)}},u.prototype._handleJoinsAfterConnect=function(){return o(this,void 0,void 0,(function(){var t,e=this;return i(this,(function(r){switch(r.label){case 0:return t=this._getChannels(),[4,Promise.all(t.map((function(t){return e.join(t)})))];case 1:return r.sent(),[2]}}))}))},u.prototype._getChannels=function(){return Object.keys(this._channelState)},u.prototype._getChannelState=function(t){return this._channelState[t]},u.prototype._setChannelState=function(t,e){this._channelState[t]=e},u.prototype._removeChannelState=function(t){this._channelState=Object.entries(this._channelState).reduce((function(e,n){var o,i=s(n,2),a=i[0],u=i[1];return a===t?e:r(r({},e),((o={})[a]=u,o))}),{})},u.prototype._clearChannelState=function(){this._channelState={}},u.prototype._parseMessageForEmitter=function(t){var e=Fi(t.channel),o=t.event||t.command;switch(t.command){case Ce.JOIN:return[a=o+"/"+e,i=function(t){var e=s(/:(.+)!(.+)@(.+).tmi.twitch.tv JOIN (#.+)/g.exec(t._raw),5),n=e[1],o=e[4];return r(r({},t),{channel:o,command:ve.JOIN,event:ve.JOIN,username:n})}(t)];case Ce.PART:return[a=o+"/"+e,i=function(t){var e=s(/:(.+)!(.+)@(.+).tmi.twitch.tv PART (#.+)/g.exec(t._raw),5),n=e[1],o=e[4];return r(r({},t),{channel:o,command:ve.PART,event:ve.PART,username:n})}(t)];case Ce.NAMES:return[a=o+"/"+e,i=function(t){var e=s(/:(.+).tmi.twitch.tv 353 (.+) = (#.+) :(.+)/g.exec(t._raw),5),n=e[3],o=e[4].split(" ");return r(r({},t),{channel:n,command:ve.NAMES,event:ve.NAMES,usernames:o})}(t)];case Ce.NAMES_END:return[a=o+"/"+e,i=function(t){var e=s(/:(.+).tmi.twitch.tv 366 (.+) (#.+) :(.+)/g.exec(t._raw),4),n=e[1],o=e[3];return r(r({},t),{channel:o,command:ve.NAMES_END,event:ve.NAMES_END,username:n})}(t)];case Ce.CLEAR_CHAT:return[a=o+"/"+(i=function(t){var e=t.tags,o=t.message,i=n(t,["tags","message"]);return r(r({},i),void 0!==o?{tags:r(r({},e),{banReason:Ci(e.banReason),banDuration:Ni(e.banDuration)}),command:ve.CLEAR_CHAT,event:_e.USER_BANNED,username:o}:{command:ve.CLEAR_CHAT,event:ve.CLEAR_CHAT})}(t)).event+"/"+e,i];case Ce.CLEAR_MESSAGE:return[a=o+"/"+e,i=function(t){var e=t.tags;return r(r({},t),{tags:{login:e.login,targetMsgId:e.targetMsgId},command:ve.CLEAR_MESSAGE,event:ve.CLEAR_MESSAGE,targetMessageId:e.targetMsgId})}(t)];case Ce.HOST_TARGET:return[a=o+"/"+e,i=function(t){var e=s(/:tmi.twitch.tv HOSTTARGET (#[^\s]+) :([^\s]+)?\s?(\d+)?/g.exec(t._raw),4),n=e[1],o=e[2],i=e[3],a="-"===o;return r(r({},t),{channel:n,username:o,command:ve.HOST_TARGET,event:a?_e.HOST_OFF:_e.HOST_ON,numberOfViewers:zn(to(i))?parseInt(i,10):void 0})}(t)];case Ce.MODE:var i=function(t){var e=s(/:[^\s]+ MODE (#[^\s]+) (-|\+)o ([^\s]+)/g.exec(t._raw),4),n=e[1],o=e[2],i=e[3],a="+"===o,u=r(r({},t),{command:ve.MODE,channel:n,username:i});return r(r({},u),a?{event:_e.MOD_GAINED,message:"+o",isModerator:!0}:{event:_e.MOD_LOST,message:"-o",isModerator:!1})}(t),a=o+"/"+e,u=this._getChannelState(e);return this._isAuthenticated&&void 0!==(null==u?void 0:u.userState)&&i.username===this._options.username&&this._setChannelState(e,r(r({},u),{userState:r(r({},u.userState),{mod:i.isModerator?"1":"0",isModerator:i.isModerator})})),[a,i];case Ce.USER_STATE:i=ji(t),a=o+"/"+e;return(u=this._getChannelState(e))&&this._setChannelState(e,r(r({},u),{userState:i.tags})),[a,i];case Ce.ROOM_STATE:i=function(t){var e=t.tags,o=n(t,["tags"]);return r(r({},o),{command:ve.ROOM_STATE,event:ve.ROOM_STATE,tags:Ri(e)})}(t),a=o+"/"+e;return this._setChannelState(e,r(r({},this._getChannelState(e)),{roomState:i})),[a,i];case Ce.NOTICE:return[a=o+"/"+(i=Li(t)).event+"/"+e,i];case Ce.USER_NOTICE:return[a=o+"/"+(i=Mi(t)).event+"/"+e,i];case Ce.PRIVATE_MESSAGE:return[a=o+"/"+(i=function(t){var e=t._raw,n=t.tags;if(_o(n.bits,0))return r(r({},ji(t)),{command:ve.PRIVATE_MESSAGE,event:_e.CHEER,bits:parseInt(n.bits,10)});var o=s(Oo.exec(e)||[],5),i=o[0],a=o[1],u=o[2],c=o[3],l=o[4];return i?r(r({},t),c?{command:ve.PRIVATE_MESSAGE,event:_e.HOSTED_AUTO,channel:"#"+a,tags:{displayName:u},numberOfViewers:Ni(l)}:l?{command:ve.PRIVATE_MESSAGE,event:_e.HOSTED_WITH_VIEWERS,channel:"#"+a,tags:{displayName:u},numberOfViewers:Ni(l)}:{command:ve.PRIVATE_MESSAGE,event:_e.HOSTED_WITHOUT_VIEWERS,channel:"#"+a,tags:{displayName:u}}):r(r({},ji(t)),{command:ve.PRIVATE_MESSAGE,event:ve.PRIVATE_MESSAGE})}(t)).event+"/"+e,i];default:return[a=e?o+"/"+e:o,t]}},u.prototype._emit=function(e,r){var n=this;try{if(e)this._log.info(r,e),Oe(e.split("/")).filter((function(t){return"#"!==t})).reduce((function(e,o){var i=a(e,[o]),s=i.join("/");return i.length>1&&t.prototype.emit.call(n,o,r),t.prototype.emit.call(n,s,r),i}),[]);t.prototype.emit.call(this,Ce.ALL,r)}catch(t){this._log.error("\nWhile attempting to handle the "+r.command+" event, an error occurred in your implementation. To avoid seeing this message, please resolve the error:\n\n"+t.stack+"\n\nParsed messages:\n"+JSON.stringify(r)),this.emit(co.ERROR_ENCOUNTERED,t)}},u.Commands=ve,u.Events=Ce,u.CompoundEvents=((gi={})[Ce.NOTICE]=Si,gi[Ce.PRIVATE_MESSAGE]=Ti,gi[Ce.USER_NOTICE]=bi,gi),u}(f);var ki=function(t){var e=ro(t),r=e%1;return e==e?r?e-r:e:0};var zi=function(t,e){return on(e,(function(e){return t[e]}))};var Wi=function(t){return null==t?[]:zi(t,Sn(t))},Vi=Math.max;var Yi=function(t,e,r,n){t=qr(t)?t:Wi(t),r=r&&!n?ki(r):0;var o=t.length;return r<0&&(r=Vi(o+r,0)),Gn(t)?r<=o&&t.indexOf(e,r)>-1:!!o&&te(t,e,r)>-1},qi=l((function(t,e){var r=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:u);!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),i="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function l(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function d(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function v(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function _(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&o&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=_(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=_(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=d(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var t,e,r,n=d(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=p(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,e){t=c(t),e=l(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},h.prototype.delete=function(t){delete this.map[c(t)]},h.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},h.prototype.set=function(t,e){this.map[c(t)]=l(e)},h.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),f(t)},h.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),f(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),f(t)},n&&(h.prototype[Symbol.iterator]=h.prototype.entries);var E=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function O(t,e){var r,n,o=(e=e||{}).body;if(t instanceof O){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),E.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function S(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}O.prototype.clone=function(){return new O(this,{body:this._bodyInit})},y.call(O.prototype),y.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},S.error=function(){var t=new S(null,{status:0,statusText:""});return t.type="error",t};var T=[301,302,303,307,308];S.redirect=function(t,e){if(-1===T.indexOf(e))throw new RangeError("Invalid status code");return new S(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,r){return new Promise((function(n,i){var s=new O(t,r);if(s.signal&&s.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;n(new S(o,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&o&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=h,t.Request=O,t.Response=S),e.Headers=h,e.Request=O,e.Response=S,e.fetch=b}({})}(r),delete r.fetch.polyfill,(e=r.fetch).default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e}));qi.fetch,qi.Headers,qi.Request,qi.Response;let Ki;void 0!==u&&void 0!==u.FormData?Ki=u.FormData:"undefined"!=typeof window&&void 0!==window.FormData?Ki=window.FormData:"undefined"!=typeof self&&void 0!==self.FormData&&(Ki=self.FormData);var Ji=Ki,$i=Object.prototype.hasOwnProperty,Zi=Array.isArray,Qi=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),Xi=function(t,e){for(var r=e&&e.plainObjects?Object.create(null):{},n=0;n<t.length;++n)void 0!==t[n]&&(r[n]=t[n]);return r},ts={arrayToObject:Xi,assign:function(t,e){return Object.keys(e).reduce((function(t,r){return t[r]=e[r],t}),t)},combine:function(t,e){return[].concat(t,e)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],r=[],n=0;n<e.length;++n)for(var o=e[n],i=o.obj[o.prop],s=Object.keys(i),a=0;a<s.length;++a){var u=s[a],c=i[u];"object"==typeof c&&null!==c&&-1===r.indexOf(c)&&(e.push({obj:i,prop:u}),r.push(c))}return function(t){for(;t.length>1;){var e=t.pop(),r=e.obj[e.prop];if(Zi(r)){for(var n=[],o=0;o<r.length;++o)void 0!==r[o]&&n.push(r[o]);e.obj[e.prop]=n}}}(e),t},decode:function(t,e,r){var n=t.replace(/\+/g," ");if("iso-8859-1"===r)return n.replace(/%[0-9a-f]{2}/gi,unescape);try{return decodeURIComponent(n)}catch(t){return n}},encode:function(t,e,r){if(0===t.length)return t;var n=t;if("symbol"==typeof t?n=Symbol.prototype.toString.call(t):"string"!=typeof t&&(n=String(t)),"iso-8859-1"===r)return escape(n).replace(/%u[0-9a-f]{4}/gi,(function(t){return"%26%23"+parseInt(t.slice(2),16)+"%3B"}));for(var o="",i=0;i<n.length;++i){var s=n.charCodeAt(i);45===s||46===s||95===s||126===s||s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122?o+=n.charAt(i):s<128?o+=Qi[s]:s<2048?o+=Qi[192|s>>6]+Qi[128|63&s]:s<55296||s>=57344?o+=Qi[224|s>>12]+Qi[128|s>>6&63]+Qi[128|63&s]:(i+=1,s=65536+((1023&s)<<10|1023&n.charCodeAt(i)),o+=Qi[240|s>>18]+Qi[128|s>>12&63]+Qi[128|s>>6&63]+Qi[128|63&s])}return o},isBuffer:function(t){return!(!t||"object"!=typeof t)&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},maybeMap:function(t,e){if(Zi(t)){for(var r=[],n=0;n<t.length;n+=1)r.push(e(t[n]));return r}return e(t)},merge:function t(e,r,n){if(!r)return e;if("object"!=typeof r){if(Zi(e))e.push(r);else{if(!e||"object"!=typeof e)return[e,r];(n&&(n.plainObjects||n.allowPrototypes)||!$i.call(Object.prototype,r))&&(e[r]=!0)}return e}if(!e||"object"!=typeof e)return[e].concat(r);var o=e;return Zi(e)&&!Zi(r)&&(o=Xi(e,n)),Zi(e)&&Zi(r)?(r.forEach((function(r,o){if($i.call(e,o)){var i=e[o];i&&"object"==typeof i&&r&&"object"==typeof r?e[o]=t(i,r,n):e.push(r)}else e[o]=r})),e):Object.keys(r).reduce((function(e,o){var i=r[o];return $i.call(e,o)?e[o]=t(e[o],i,n):e[o]=i,e}),o)}},es=String.prototype.replace,rs=/%20/g,ns={RFC1738:"RFC1738",RFC3986:"RFC3986"},os=ts.assign({default:ns.RFC3986,formatters:{RFC1738:function(t){return es.call(t,rs,"+")},RFC3986:function(t){return String(t)}}},ns),is=Object.prototype.hasOwnProperty,ss={brackets:function(t){return t+"[]"},comma:"comma",indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},as=Array.isArray,us=Array.prototype.push,cs=function(t,e){us.apply(t,as(e)?e:[e])},ls=Date.prototype.toISOString,fs=os.default,hs={addQueryPrefix:!1,allowDots:!1,charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encoder:ts.encode,encodeValuesOnly:!1,format:fs,formatter:os.formatters[fs],indices:!1,serializeDate:function(t){return ls.call(t)},skipNulls:!1,strictNullHandling:!1},ds=function t(e,r,n,o,i,s,a,u,c,l,f,h,d){var p,v=e;if("function"==typeof a?v=a(r,v):v instanceof Date?v=l(v):"comma"===n&&as(v)&&(v=ts.maybeMap(v,(function(t){return t instanceof Date?l(t):t})).join(",")),null===v){if(o)return s&&!h?s(r,hs.encoder,d,"key"):r;v=""}if("string"==typeof(p=v)||"number"==typeof p||"boolean"==typeof p||"symbol"==typeof p||"bigint"==typeof p||ts.isBuffer(v))return s?[f(h?r:s(r,hs.encoder,d,"key"))+"="+f(s(v,hs.encoder,d,"value"))]:[f(r)+"="+f(String(v))];var _,y=[];if(void 0===v)return y;if(as(a))_=a;else{var E=Object.keys(v);_=u?E.sort(u):E}for(var O=0;O<_.length;++O){var m=_[O],S=v[m];if(!i||null!==S){var T=as(v)?"function"==typeof n?n(r,m):r:r+(c?"."+m:"["+m+"]");cs(y,t(S,T,n,o,i,s,a,u,c,l,f,h,d))}}return y},ps=(Object.prototype.hasOwnProperty,Array.isArray,function(t,e){var r,n=t,o=function(t){if(!t)return hs;if(null!==t.encoder&&void 0!==t.encoder&&"function"!=typeof t.encoder)throw new TypeError("Encoder has to be a function.");var e=t.charset||hs.charset;if(void 0!==t.charset&&"utf-8"!==t.charset&&"iso-8859-1"!==t.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");var r=os.default;if(void 0!==t.format){if(!is.call(os.formatters,t.format))throw new TypeError("Unknown format option provided.");r=t.format}var n=os.formatters[r],o=hs.filter;return("function"==typeof t.filter||as(t.filter))&&(o=t.filter),{addQueryPrefix:"boolean"==typeof t.addQueryPrefix?t.addQueryPrefix:hs.addQueryPrefix,allowDots:void 0===t.allowDots?hs.allowDots:!!t.allowDots,charset:e,charsetSentinel:"boolean"==typeof t.charsetSentinel?t.charsetSentinel:hs.charsetSentinel,delimiter:void 0===t.delimiter?hs.delimiter:t.delimiter,encode:"boolean"==typeof t.encode?t.encode:hs.encode,encoder:"function"==typeof t.encoder?t.encoder:hs.encoder,encodeValuesOnly:"boolean"==typeof t.encodeValuesOnly?t.encodeValuesOnly:hs.encodeValuesOnly,filter:o,formatter:n,serializeDate:"function"==typeof t.serializeDate?t.serializeDate:hs.serializeDate,skipNulls:"boolean"==typeof t.skipNulls?t.skipNulls:hs.skipNulls,sort:"function"==typeof t.sort?t.sort:null,strictNullHandling:"boolean"==typeof t.strictNullHandling?t.strictNullHandling:hs.strictNullHandling}}(e);"function"==typeof o.filter?n=(0,o.filter)("",n):as(o.filter)&&(r=o.filter);var i,s=[];if("object"!=typeof n||null===n)return"";i=e&&e.arrayFormat in ss?e.arrayFormat:e&&"indices"in e?e.indices?"indices":"repeat":"indices";var a=ss[i];r||(r=Object.keys(n)),o.sort&&r.sort(o.sort);for(var u=0;u<r.length;++u){var c=r[u];o.skipNulls&&null===n[c]||cs(s,ds(n[c],c,a,o.strictNullHandling,o.skipNulls,o.encode?o.encoder:null,o.filter,o.sort,o.allowDots,o.serializeDate,o.formatter,o.encodeValuesOnly,o.charset))}var l=s.join(o.delimiter),f=!0===o.addQueryPrefix?"?":"";return o.charsetSentinel&&("iso-8859-1"===o.charset?f+="utf8=%26%2310003%3B&":f+="utf8=%E2%9C%93&"),l.length>0?f+l:""}),vs=function(t){function r(e,n){var o=this,i=(null==n?void 0:n.message)||e.url+" "+e.statusText;return o=t.call(this,i)||this,Object.setPrototypeOf(o,r.prototype),o.ok=!1,o.status=e.status,o.statusText=e.statusText,o.url=e.url,o.body=n,o}return e(r,t),r}(ho);var _s,ys,Es=function(t){return void 0===t},Os=function(t){var e={token:Gn,clientId:function(t){return Gn(t)||Es(t)},onAuthenticationFailure:function(t){return rt(t)||Es(t)}};return t=Bn(t,{clientId:void 0,onAuthenticationFailure:void 0}),pn(Tn(t,e),"Expected valid options"),t};!function(t){t[t.NOT_READY=0]="NOT_READY",t[t.READY=1]="READY",t[t.INITIALIZED=2]="INITIALIZED"}(ys||(ys={}));var ms=((_s={})[ce.Helix]={baseUrl:"https://api.twitch.tv/helix",authorizationHeader:"Bearer"},_s[ce.Kraken]={baseUrl:"https://api.twitch.tv/kraken",authorizationHeader:"OAuth"},_s),Ss=function(){function t(t){this._readyState=ys.READY,this._options=Os(t),this._log=Ve(r({name:"Api"},this._options.log))}return Object.defineProperty(t.prototype,"readyState",{get:function(){return this._readyState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"status",{get:function(){return this._status},enumerable:!1,configurable:!0}),t.prototype.updateOptions=function(t){var e=this._options,n=e.clientId,o=e.token;this._options=Os(r(r({},t),{clientId:n,token:o}))},t.prototype.initialize=function(t){return o(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return t&&(this._options=Os(r(r({},this._options),t))),t||2!==this.readyState?[4,this.get("",{version:ce.Kraken})]:[2,Promise.resolve()];case 1:return"token"in(e=n.sent())&&(this._readyState=ys.INITIALIZED,this._status=e),[2,e]}}))}))},t.prototype.hasScope=function(t){var e=this;return new Promise((function(r,n){return 2===e.readyState&&e.status&&Yi(e.status.token.authorization.scopes,t)?r(!0):n(!1)}))},t.prototype.get=function(t,e){return void 0===t&&(t=""),this._handleFetch(t,e)},t.prototype.post=function(t,e){return this._handleFetch(t,r(r({},e),{method:"post"}))},t.prototype.put=function(t,e){return this._handleFetch(t,r(r({},e),{method:"put"}))},t.prototype._isVersionHelix=function(t){return fn(t)===ce.Helix},t.prototype._getBaseUrl=function(t){return ms[t].baseUrl},t.prototype._getHeaders=function(t){var e=this._options,r=e.clientId,n=e.token,o={};return this._isVersionHelix(t)||(o.Accept="application/vnd.twitchtv.v5+json"),r&&(o["Client-ID"]=r),n&&(o.Authorization=ms[t].authorizationHeader+" "+n),o},t.prototype._handleFetch=function(t,e){return void 0===t&&(t=""),void 0===e&&(e={}),o(this,void 0,void 0,(function(){var a,u,c,l,f,h,d,p,v,_,y,E,O,m,S,T,b,g,A,C;return i(this,(function(N){switch(N.label){case 0:a=e.version,u=void 0===a?ce.Helix:a,c=n(e,["version"]),l=this._getBaseUrl(u),f=l+"/"+t,h=(yo(c.method)||"GET")+" "+f,d=this._log.profile(),p=this._getHeaders(u),v=Object.entries(c.headers||{});try{for(_=function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(v),y=_.next();!y.done;y=_.next())E=s(y.value,2),O=E[0],m=E[1],p[String(O)]=m}catch(t){A={error:t}}finally{try{y&&!y.done&&(C=_.return)&&C.call(_)}finally{if(A)throw A.error}}S=function(){return function(t,e,n){return void 0===e&&(e={}),o(void 0,void 0,void 0,(function(){var o,s,a,u,c,l,f,h;return i(this,(function(i){switch(i.label){case 0:return o=e.body&&!(e.body instanceof Ji)&&"object"==typeof e.body,s=o?JSON.stringify(e.body):e.body,a=o?r(r({},e.headers),{"Content-Type":"application/json"}):e.headers,u="object"==typeof e.search?"?"+ps(e.search,n):"",c=r(r({},e),s?{method:e.method||"get",headers:a,body:s}:{method:e.method||"get",headers:a}),[4,qi(""+t+u,c)];case 1:return[4,(l=i.sent()).json().catch((function(){}))];case 2:if(f=i.sent(),h=f?Er(f,{deep:!0}):void 0,!l.ok)throw new vs(l,h);return h?[2,h]:[2,l]}}))}))}(f,r(r({},c),{headers:p}))},N.label=1;case 1:return N.trys.push([1,3,9,10]),[4,S()];case 2:return[2,N.sent()];case 3:return b=N.sent(),T=b,"function"==typeof this._options.onAuthenticationFailure&&b instanceof vs&&401===b.status?[4,this._options.onAuthenticationFailure()]:[3,8];case 4:return(g=N.sent())?[4,this.initialize({token:g})]:[3,6];case 5:N.sent(),this._log.info(h+" ... re-initializing with new token"),N.label=6;case 6:return this._log.info(h+" ... retrying"),[4,S()];case 7:return[2,N.sent()];case 8:throw b;case 9:return d.done(h,T),[7];case 10:return[2]}}))}))},t}();return function(){function t(t){var e=t.token,n=t.username,o=t.clientId,i=t.log,s=t.onAuthenticationFailure,a=t.chat,u=t.api;this.chat=new Gi(r(r({log:i},a),{token:e,username:n,onAuthenticationFailure:s})),this.api=new Ss(r(r({log:i},u),{token:e,clientId:o,onAuthenticationFailure:s}))}return t.prototype.updateOptions=function(t){var e=t.chat,r=t.api;e&&this.chat.updateOptions(e),r&&this.api.updateOptions(r)},t.Chat=Gi,t.Api=Ss,t}()}();
2//# sourceMappingURL=twitch.js.map