UNPKG

jaidbot

Version:

Personal chat bot for my Twitch stream.

7 lines 578 kB
#!/usr/bin/env node /*! *** jaidbot 5.7.0 *** Copyright © 2019, Jaid <jaid.jsx@gmail.com> (https://github.com/Jaid) *** @license MIT *** See https://twitch.tv/jaidchen !*/!function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=196)}([function(t,e,r){"use strict";r.d(e,"a",(function(){return u})),r.d(e,"c",(function(){return c}));var n=r(167),i=r.n(n),o=r(168),s=r.n(o);const a=new i.a({name:"Jaidbot",version:"5.7.0",insecurePort:17441,database:!0,useGot:!0,configSetup:{defaults:s(),secretKeys:["serverPassword","twitchClientId","twitchClientSecret","travisToken","youtubeClientId","youtubeClientSecret","youtubeClientAccessToken","youtubeClientRefreshToken","twitterConsumerKey","twitterConsumerSecret","twitterAccessToken","twitterAccessSecret","githubToken","databasePassword","githubAppPemFilePath","githubAppWebhookSecret"]}}),u=a.config,c=a.logger;e.b=a},function(t,e){t.exports=require("sequelize")},function(t,e,r){"use strict";var n=r(21),i=r.n(n),o=r(169),s=r.n(o),a=r(0),u=r(5),c=r(22),l=r(60),h=r.n(l),p=r(61),f=r.n(p),d=r(172),m=r.n(d),y=r(173),g=r.n(y),D=r(10),v=r(38),b=r.n(v),E=r(6);const x=/^(?<prefix>!)(?<commandName>[\da-z]+)(?<afterCommandName>\s*(?<commandArguments>.*))?/i,w=r(245);class A extends i.a{constructor(){super(),this.commands=w.keys().reduce((t,e)=>(t[e.match(/\.\/(?<key>[\da-z]+)\//i).groups.key]=w(e).default,t),{}),this.commandUsages=[];for(const[t,e]of Object.entries(this.commands)){const n=r(309)(`./${t}/help.yml`);if(Object(E.isEmpty)(n))continue;const i=b()(n);for(const r of i){const n={command:t,description:r.description};if(r.param){const e=b()(r.param);n.params=e,n.usage=`!${t} ${e.join(" ")}`}else n.usage=`!${t}`;r.example&&(n.example=b()(r.example)),Object.assign(n,h()(e,"permission","needsDesktopClient","requiredArguments")),this.commandUsages.push(n)}}}handleMessage(t){var e;const r=x.exec(t.text);if(null===r)return;const n=r.groups.commandName.toLowerCase();let i,o;var s,u;r.groups.commandArguments&&(u=r.groups.commandArguments,s=m()(u),o=(i=g()(s))._);const c=this.commands[n];if(c){if(!t.sender.isBroadcaster){if("subOrVip"===c.permission&&!t.sender.isVip&&!t.sender.isSub&&!t.sender.isMod)return void C.say(`${t.sender.displayName}, für diesen Befehl musst du Moderator, Subscriber oder VIP sein!`);if("mod"===c.permission&&!t.sender.hasElevatedPermission)return void C.say(`${t.sender.displayName}, für diesen Befehl musst du Moderator sein!`)}if(!c.needsDesktopClient||D.default.hasClient()){if(c.requiredArguments){if(!i)return void C.say(`${t.sender.displayName}, dieser Befehl kann nicht ohne Arguments verwendet werden!`);const e=o.length;if(c.requiredArguments>e)return void C.say(`${t.sender.displayName}, dieser Befehl benötigt ${c.requiredArguments} Arguments!`)}c.handle({...t,commandArguments:i,positionalArguments:o||[],combinedArguments:null==r?void 0:null===(e=r.groups)||void 0===e?void 0:e.commandArguments}).then(t=>{var e;e=t,f()(e)&&C.say(t)}).catch(e=>{a.c.error('Error at execution of "%s": %s',t.text,e),C.say(`Oh, ${t.sender.displayName}, da hat irgendetwas nicht geklappt. Muss sich ${C.streamerUser.getDisplayName()} drum kümmern.`)})}else C.say(`Es besteht gerade keine Verbindung zum Computer von ${C.streamerUser.getDisplayName()}. ResidentSleeper`)}else C.say(`Verstehe ich jetzt nicht, ${t.sender.displayName}! Alle Befehle sind in den Panels unter dem Stream beschrieben.`)}}var C=e.a=new class extends i.a{constructor(...t){super(...t),this.ready=!1}async init(){const[t,e]=await Promise.all([c.default.getByTwitchLogin(a.a.twitchStreamerLogin),c.default.getByTwitchLogin(a.a.twitchBotLogin)]);if(this.streamerUser=t,this.botUser=e,!(null==t?void 0:t.accessToken))return a.c.warn("No user auth found for requested streamer user %s",a.a.twitchStreamerLogin),!1;if(!(null==e?void 0:e.accessToken))return a.c.warn("No user auth found for requested bot user %s",a.a.twitchBotLogin),!1;const[r,n]=await Promise.all([t.toTwitchClient(),e.toTwitchClient()]);this.streamerClient=r,this.botClient=n;const i=await s.a.forTwitchClient(n);this.chatClient=i,await i.connect(),await i.waitForRegistration(),await i.join(this.streamerUser.getDisplayName()),a.c.info("Connected bot"),this.chatBot=new A,i.onPrivmsg((t,e,r,n)=>{const i={text:r.trim(),bits:n.totalBits||0,sender:{id:n.userInfo.userId,name:n.userInfo.userName,isBroadcaster:"1"===n.userInfo.badges.get("broadcaster"),isVip:"1"===n.userInfo.badges.get("vip"),isMod:n.userInfo.isMod,isSub:n.userInfo.isSubscriber,color:n.userInfo.color}};i.sender.displayName=n.userInfo.displayName||i.sender.name,i.sender.hasElevatedPermission=Boolean(n.userInfo.userType)||i.sender.isBroadcaster,n.userInfo._userData.has("tmi-sent-ts")&&(i.sentDate=new Date(Number(n.userInfo._userData.get("tmi-sent-ts")))),a.c.debug(`${i.sender.displayName}: ${i.text}`),this.emit("chat",i),this.chatBot.handleMessage(i)}),this.ready=!0}async userNameToDisplayName(t){const e=await this.streamerClient.helix.users.getUserByName(t);return(null==e?void 0:e.displayName)||(null==e?void 0:e.name)||t}async getFollowMoment(t){const e=await this.streamerClient.helix.users.getUserByName(t),r=await e.getFollowTo(this.streamerUser.twitchId);return null!==r&&Object(u.a)(r.followDate)}async getMyStream(){return this.streamerClient.kraken.streams.getStreamByChannel(this.streamerUser.twitchId)}async setCategory(t){await this.streamerClient.kraken.channels.updateChannel(this.streamerUser.twitchId,{game:t})}async getChannelInfo(t){return await this.streamerClient.helix.users.getUserById(t)}async setTitle(t){await this.streamerClient.kraken.channels.updateChannel(this.streamerUser.twitchId,{status:t.trim()})}say(t){this.chatClient?this.chatClient.say(this.streamerUser.loginName,t):a.c.warn('Tried to say "%s", but chatClient was %s',t,this.chatClient)}}},function(t,e,r){"use strict";r.r(e),r.d(e,"schema",(function(){return v})),r.d(e,"indexes",(function(){return b}));var n=r(60),i=r.n(n),o=r(61),s=r.n(o),a=r(1),u=r.n(a),c=r(0),l=r(10),h=r(174),p=r.n(h),f=r(5),d=r(22),m=r(43),y=r.n(m),g=r(2);class D extends u.a.Model{static associate(t){D.belongsTo(t.TwitchUser,{as:"Requester",foreignKey:"RequesterId"})}static start(){l.default.on("gotClient",t=>{c.c.debug("Received gotClient in Video model handler"),t.on("videoDownloaded",D.handleVideoDownloaded),t.on("vlcState",D.handleVlcState),t.on("setInfoFile",D.handleSetInfoFile),t.on("getDownloadJobs",t=>D.handleGetDownloadJobs(t))})}static setCurrentVideo(t){D.currentVideoHeartbeatTimestamp=Date.now(),D.currentVideo=t}static async handleVideoDownloaded({videoId:t,bytes:e,videoFile:r,infoFile:n}){try{await D.update({bytes:e,videoFile:r,infoFile:n,downloadedAt:new Date},{where:{id:t}})}catch(t){c.c.error("Error at videoDownloaded handler: %s",t)}}static async handleVlcState(t){try{var e;D.currentVideoHeartbeatTimestamp=Date.now();const r=(null===(e=D.currentVideo)||void 0===e?void 0:e.videoFile)!==t.file;if(!r&&D.currentVideo.hasBeenWatched())return;await c.b.database.transaction(async e=>{if(r){const r=await D.findOne({transaction:e,where:{videoFile:t.file}});if(!r)return c.c.info("Current video unset"),void(D.currentVideo=null);if(c.c.info(`Current video set to #${r.id}`),D.currentVideo=r,r.hasBeenWatched())return void c.c.debug("Not applying any changes on video, because it has already been watched")}const n=D.currentVideo,i=["timestamp"];n.vlcDuration||(n.vlcDuration=t.durationMs,i.push("vlcDuration")),n.timestamp=t.timestampMs;const o=t.durationMs-t.timestampMs;1e4>o&&(n.watchedAt=Object(f.a)().add(o,"ms").toDate(),i.push("watchedAt"),c.c.debug("Video #%s will be marked as watched",n.id)),await n.save({transaction:e,fields:i})})}catch(t){c.c.error("Error at vlcState handler: %s",t)}}static async handleSetInfoFile({videoId:t,infoFile:e}){try{await D.update({infoFile:e},{where:{id:t}}),c.c.debug("Got info file path for video #%s",t)}catch(t){c.c.error("Error at setInfoFile handler: %s",t)}}static async handleGetDownloadJobs(t){try{return void t(await D.findAll({where:{videoFile:{[a.Op.eq]:null}},raw:!0,attributes:["id","downloadFormat","info"]}))}catch(e){return c.c.error("Error at getDownloadJobs handler: %s",e),void t(!1)}}static async queueByUrl(t,e){let r,n;try{var i;i=(r=await p()(c.a.youtubeDlPath,["--no-color","--ignore-config","--abort-on-error","--netrc","--format",c.a.youtubeDlFormat,"--cookies",c.a.youtubeDlCookieFile,"--dump-single-json",t])).stdout,n=JSON.parse(i)}catch(e){var o,s;c.c.error("Could not use youtube-dl to fetch media information of url %s: %s\ncommand: %s\nstd: %s",t,e,(null===(o=r)||void 0===o?void 0:o.command)||(null==e?void 0:e.command),(null===(s=r)||void 0===s?void 0:s.all)||(null==e?void 0:e.all))}if(!n&&l.default.hasClient()&&(c.c.warn("Could not fetch info for %s, trying on Desktop instead",t),n=await y.a.withDefaultTimeout(l.default.client,"fetchVideoInfo",t)),n)return D.queueByInfo(n,{requestUrl:t,...e});throw new Error(`Could not fetch info for video URL ${t}`)}static async queueByInfo(t,e){var r;const n=t.release_date||t.upload_date;let i;r=n,s()(r)&&(i=Object(f.a)(n,"YYYYMMDD").toDate());const o={title:t.title||t.webpage_url,duration:1e3*t.duration,views:t.view_count,likes:t.like_count,dislikes:t.dislike_count,publishedAt:i,format:t.format,extractor:t.extractor||t.extractor_key,width:t.width,height:t.height,webUrl:t.webpage_url||t.channel_url||t.uploader_url,audioCodec:t.acodec,videoCodec:t.vcodec,formatId:t.format_id,fileExtension:t.ext,description:t.description,thumbnailUrl:t.thumbnail,channelUrl:t.channel_url||t.uploader_url,audioBitrate:t.abr,videoBitrate:t.vbr,mediaId:t.id,ageLimit:t.age_limit,publisher:t.uploader||t.uploader_id,publisherId:t.uploader_id,info:t,downloadFormat:c.a.youtubeDlFormat};if(void 0!==e.priority&&(o.priority=e.priority),e.requesterTwitchId){const t=await d.default.getByTwitchId(e.requesterTwitchId);o.RequesterId=t.id}e.requestUrl&&(o.requestUrl=e.requestUrl);const[a,u]=await D.findOrCreate({where:{extractor:o.extractor,mediaId:o.mediaId},defaults:o});return u?(c.c.info('Requested video #%s "%s" with priority %s',a.id,a.title,a.priority),l.default.hasClient()&&l.default.client.emit("queueInfo",{videoInfo:t,videoId:a.id,downloadFormat:a.downloadFormat})):(await a.update({...o,priority:a.priority+10}),c.c.info('Video #%s "%s" got requested again, increased priority from %s to %s',a.id,a.title,a.priority-10,a.priority)),a}static getCurrentVideo(t=1e4){return D.currentVideo?Date.now()-D.currentVideoHeartbeatTimestamp>t?null:D.currentVideo:null}static getCurrentYoutubeVideo(t){const e=this.getCurrentVideo(t);return e?"youtube"===e.extractor?e:void g.a.say("Beim abgespielten Video scheint es sich nicht um ein YouTube-Video zu handeln."):null}static async getVlcState(){if(!l.default.hasClient())return void g.a.say("Ich habe keine Verbindung zum Computer von Jaidchen und kann somit auch das Kino nicht kontaktieren!");const t=await y.a.withDefaultTimeout(l.default.client,"getVlcState");if("noVlc"!==t)return t;g.a.say("Kein Lebenszeichen aus dem Kino, sorry!")}static async sendVlcCommand(t,e){if(!l.default.hasClient())return void g.a.say("Ich habe keine Verbindung zum Computer von Jaidchen und kann somit auch das Kino nicht kontaktieren!");const r={command:t,...e},n=await y.a.withDefaultTimeout(l.default.client,"sendVlcCommand",r);if("noVlc"!==n){if("commandFailed"!==n)return n;g.a.say("Die Anweisung ans Kino hat jetzt nicht so richtig geklappt.")}else g.a.say("Kein Lebenszeichen aus dem Kino, sorry!")}hasBeenWatched(){return null!==this.watchedAt}async play(){return l.default.hasClient()?this.videoFile?y.a.withDefaultTimeout(l.default.client,"playVideo",i()(this.get(),"videoFile","timestamp")):(c.c.warn("Tried to play video #%s on desktop, but videoFile is not defined",this.id),!1):(c.c.warn("Couldn't play video #%s, not connected to desktop",this.id),!1)}getDurationMs(){return this.vlcDuration||this.duration}getDurationSeconds(){return Math.floor(this.getDurationMs()/1e3)}}D.currentVideo=null,D.currentVideoHeartbeatTimestamp=null;const v={title:{allowNull:!1,type:u.a.STRING},duration:u.a.INTEGER,views:u.a.BIGINT,likes:u.a.INTEGER,dislikes:u.a.INTEGER,publishedAt:u.a.DATE,format:u.a.STRING,extractor:u.a.STRING,width:u.a.SMALLINT,height:u.a.SMALLINT,webUrl:u.a.TEXT,audioCodec:u.a.STRING,videoCodec:u.a.STRING,formatId:u.a.STRING,fileExtension:u.a.STRING,description:u.a.TEXT,thumbnailUrl:u.a.TEXT,channelUrl:u.a.TEXT,audioBitrate:u.a.SMALLINT,videoBitrate:u.a.INTEGER,mediaId:u.a.STRING,ageLimit:u.a.SMALLINT,publisher:u.a.STRING,publisherId:u.a.STRING,info:u.a.JSONB,priority:{allowNull:!1,type:u.a.SMALLINT,defaultValue:100},timestamp:u.a.INTEGER,watchedAt:u.a.DATE,skipped:{allowNull:!1,type:u.a.BOOLEAN,defaultValue:!1},liked:u.a.BOOLEAN,requestUrl:u.a.TEXT,infoFile:u.a.STRING,videoFile:u.a.STRING,bytes:u.a.BIGINT,downloadedAt:u.a.DATE,vlcDuration:u.a.INTEGER,downloadFormat:u.a.STRING},b=[{unique:!0,fields:["extractor","mediaId"]}];e.default=D},function(t,e){t.exports=require("path")},function(t,e,r){"use strict";var n=r(67),i=r.n(n),o=r(170);r.n(o)()(i.a),i.a.locale("de"),e.a=i.a},function(t,e){t.exports=require("has-content")},function(t,e,r){var n,i,o=r(13),s=r(343),a=r(345),u=r(346),c=r(20);"function"==typeof Symbol&&"function"==typeof Symbol.for?(n=Symbol.for("graceful-fs.queue"),i=Symbol.for("graceful-fs.previous")):(n="___graceful-fs.queue",i="___graceful-fs.previous");var l=function(){};if(c.debuglog?l=c.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(l=function(){var t=c.format.apply(c,arguments);t="GFS4: "+t.split(/\n/).join("\nGFS4: "),console.error(t)}),!global[n]){var h=[];Object.defineProperty(global,n,{get:function(){return h}}),o.close=function(t){function e(e,r){return t.call(o,e,(function(t){t||d(),"function"==typeof r&&r.apply(this,arguments)}))}return Object.defineProperty(e,i,{value:t}),e}(o.close),o.closeSync=function(t){function e(e){t.apply(o,arguments),d()}return Object.defineProperty(e,i,{value:t}),e}(o.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",(function(){l(global[n]),r(27).equal(global[n].length,0)}))}function p(t){s(t),t.gracefulify=p,t.createReadStream=function(e,r){return new t.ReadStream(e,r)},t.createWriteStream=function(e,r){return new t.WriteStream(e,r)};var e=t.readFile;t.readFile=function(t,r,n){return"function"==typeof r&&(n=r,r=null),function t(r,n,i){return e(r,n,(function(e){!e||"EMFILE"!==e.code&&"ENFILE"!==e.code?("function"==typeof i&&i.apply(this,arguments),d()):f([t,[r,n,i]])}))}(t,r,n)};var r=t.writeFile;t.writeFile=function(t,e,n,i){return"function"==typeof n&&(i=n,n=null),function t(e,n,i,o){return r(e,n,i,(function(r){!r||"EMFILE"!==r.code&&"ENFILE"!==r.code?("function"==typeof o&&o.apply(this,arguments),d()):f([t,[e,n,i,o]])}))}(t,e,n,i)};var n=t.appendFile;n&&(t.appendFile=function(t,e,r,i){return"function"==typeof r&&(i=r,r=null),function t(e,r,i,o){return n(e,r,i,(function(n){!n||"EMFILE"!==n.code&&"ENFILE"!==n.code?("function"==typeof o&&o.apply(this,arguments),d()):f([t,[e,r,i,o]])}))}(t,e,r,i)});var i=t.readdir;function o(e){return i.apply(t,e)}if(t.readdir=function(t,e,r){var n=[t];return"function"!=typeof e?n.push(e):r=e,n.push((function(t,e){e&&e.sort&&e.sort(),!t||"EMFILE"!==t.code&&"ENFILE"!==t.code?("function"==typeof r&&r.apply(this,arguments),d()):f([o,[n]])})),o(n)},"v0.8"===process.version.substr(0,4)){var u=a(t);h=u.ReadStream,m=u.WriteStream}var c=t.ReadStream;c&&(h.prototype=Object.create(c.prototype),h.prototype.open=function(){var t=this;g(t.path,t.flags,t.mode,(function(e,r){e?(t.autoClose&&t.destroy(),t.emit("error",e)):(t.fd=r,t.emit("open",r),t.read())}))});var l=t.WriteStream;function h(t,e){return this instanceof h?(c.apply(this,arguments),this):h.apply(Object.create(h.prototype),arguments)}function m(t,e){return this instanceof m?(l.apply(this,arguments),this):m.apply(Object.create(m.prototype),arguments)}l&&(m.prototype=Object.create(l.prototype),m.prototype.open=function(){var t=this;g(t.path,t.flags,t.mode,(function(e,r){e?(t.destroy(),t.emit("error",e)):(t.fd=r,t.emit("open",r))}))}),Object.defineProperty(t,"ReadStream",{get:function(){return h},set:function(t){h=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return m},set:function(t){m=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FileReadStream",{get:function(){return h},set:function(t){h=t},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FileWriteStream",{get:function(){return m},set:function(t){m=t},enumerable:!0,configurable:!0});var y=t.open;function g(t,e,r,n){return"function"==typeof r&&(n=r,r=null),function t(e,r,n,i){return y(e,r,n,(function(o,s){!o||"EMFILE"!==o.code&&"ENFILE"!==o.code?("function"==typeof i&&i.apply(this,arguments),d()):f([t,[e,r,n,i]])}))}(t,e,r,n)}return t.open=g,t}function f(t){l("ENQUEUE",t[0].name,t[1]),global[n].push(t)}function d(){var t=global[n].shift();t&&(l("RETRY",t[0].name,t[1]),t[0].apply(null,t[1]))}t.exports=p(u(o)),process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!o.__patched&&(t.exports=p(o),o.__patched=!0)},function(t,e){(function(){t.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}).call(this)},function(t,e,r){"use strict";var n=r(39),i=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],o=["scalar","sequence","mapping"];t.exports=function(t,e){var r,s;if(e=e||{},Object.keys(e).forEach((function(e){if(-1===i.indexOf(e))throw new n('Unknown option "'+e+'" is met in definition of "'+t+'" YAML type.')})),this.tag=t,this.kind=e.kind||null,this.resolve=e.resolve||function(){return!0},this.construct=e.construct||function(t){return t},this.instanceOf=e.instanceOf||null,this.predicate=e.predicate||null,this.represent=e.represent||null,this.defaultStyle=e.defaultStyle||null,this.styleAliases=(r=e.styleAliases||null,s={},null!==r&&Object.keys(r).forEach((function(t){r[t].forEach((function(e){s[String(e)]=t}))})),s),-1===o.indexOf(this.kind))throw new n('Unknown kind "'+this.kind+'" is specified for "'+t+'" YAML type.')}},function(t,e,r){"use strict";r.r(e);var n=r(21),i=r.n(n),o=r(0),s=r(2),a=r(183),u=new(r.n(a).a)({logger:o.c}),c=r(184),l=r.n(c);e.default=new class extends i.a{async init(){this.socketServer=l()(o.b.insecureServer),this.socketServer.on("connection",t=>t.handshake.query.password!==o.a.serverPassword?(o.c.warn("Received wrong password from client %s, disconnecting",t.handshake.address),void t.disconnect()):this.hasClient()?(o.c.warn("Client %s tried to connect, but another client is already here",t.handshake.address),void t.disconnect()):(this.client=t,t.on("disconnect",()=>{delete this.client,o.c.info("Client %s has disconnected",t.handshake.address),s.a.say("Uff, ich habe die Verbindung zum Computer von Jaidchen verloren.")}),this.emit("gotClient",t),void s.a.say("Ich bin jetzt mit dem Computer von Jaidchen verbunden!"))),u.enhanceServer(this.socketServer)}hasClient(){return Boolean(this.client)}}},function(t,e,r){"use strict";r.r(e);var n=r(2),i=r(0);e.default=new class{constructor(){this.currentProject=null,this.currentProjectRepo=null,this.projectSetDate=null}setProject(t,e=null){this.currentProject=t,this.currentProjectRepo=e,this.projectSetDate=Date.now()}clearProject(){this.currentProject=null}async init(){await n.a.init(),n.a.ready||i.c.warn("Twitch has not been loaded")}ready(){n.a.ready&&n.a.say("TBAngel Da bin ich!")}collectModels(){const t={},e=r(267);for(const r of e.keys())t[r.match(/\.\/(?<key>[\da-z]+)\./i).groups.key]=e(r);return t}}},function(t,e,r){"use strict";e.fromCallback=function(t){return Object.defineProperty((function(){if("function"!=typeof arguments[arguments.length-1])return new Promise((e,r)=>{arguments[arguments.length]=(t,n)=>{if(t)return r(t);e(n)},arguments.length++,t.apply(this,arguments)});t.apply(this,arguments)}),"name",{value:t.name})},e.fromPromise=function(t){return Object.defineProperty((function(){const e=arguments[arguments.length-1];if("function"!=typeof e)return t.apply(this,arguments);t.apply(this,arguments).then(t=>e(null,t),e)}),"name",{value:t.name})}},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";const n=(0,r(12).fromCallback)(r(348)),i=r(349);t.exports={mkdirs:n,mkdirsSync:i,mkdirp:n,mkdirpSync:i,ensureDir:n,ensureDirSync:i}},function(t,e,r){(function(){var e,n,i,o,s,a,u,c,l,h,p,f,d,m,y,g,D,v={}.hasOwnProperty;D=r(24),g=D.isObject,y=D.isFunction,m=D.isEmpty,d=D.getValue,c=null,i=null,o=null,s=null,a=null,p=null,f=null,h=null,u=null,n=null,l=null,e=null,t.exports=function(){function t(t){this.parent=t,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),this.value=null,this.children=[],this.baseURI=null,c||(c=r(81),i=r(83),o=r(84),s=r(85),a=r(86),p=r(91),f=r(92),h=r(93),u=r(144),n=r(8),l=r(404),r(82),e=r(405))}return Object.defineProperty(t.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(t.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(t.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(t.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(t.prototype,"childNodes",{get:function(){return this.childNodeList&&this.childNodeList.nodes||(this.childNodeList=new l(this.children)),this.childNodeList}}),Object.defineProperty(t.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(t.prototype,"previousSibling",{get:function(){var t;return t=this.parent.children.indexOf(this),this.parent.children[t-1]||null}}),Object.defineProperty(t.prototype,"nextSibling",{get:function(){var t;return t=this.parent.children.indexOf(this),this.parent.children[t+1]||null}}),Object.defineProperty(t.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(t.prototype,"textContent",{get:function(){var t,e,r,i,o;if(this.nodeType===n.Element||this.nodeType===n.DocumentFragment){for(o="",e=0,r=(i=this.children).length;r>e;e++)(t=i[e]).textContent&&(o+=t.textContent);return o}return null},set:function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),t.prototype.setParent=function(t){var e,r,n,i,o;for(this.parent=t,t&&(this.options=t.options,this.stringify=t.stringify),o=[],r=0,n=(i=this.children).length;n>r;r++)e=i[r],o.push(e.setParent(this));return o},t.prototype.element=function(t,e,r){var n,i,o,s,a,u,c,l,h,p,f;if(u=null,null===e&&null==r&&(e=(h=[{},null])[0],r=h[1]),null==e&&(e={}),e=d(e),g(e)||(r=(p=[e,r])[0],e=p[1]),null!=t&&(t=d(t)),Array.isArray(t))for(o=0,c=t.length;c>o;o++)i=t[o],u=this.element(i);else if(y(t))u=this.element(t.apply());else if(g(t)){for(a in t)if(v.call(t,a))if(f=t[a],y(f)&&(f=f.apply()),!this.options.ignoreDecorators&&this.stringify.convertAttKey&&0===a.indexOf(this.stringify.convertAttKey))u=this.attribute(a.substr(this.stringify.convertAttKey.length),f);else if(!this.options.separateArrayItems&&Array.isArray(f)&&m(f))u=this.dummy();else if(g(f)&&m(f))u=this.element(a);else if(this.options.keepNullNodes||null!=f)if(!this.options.separateArrayItems&&Array.isArray(f))for(s=0,l=f.length;l>s;s++)i=f[s],(n={})[a]=i,u=this.element(n);else g(f)?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===a.indexOf(this.stringify.convertTextKey)?u=this.element(f):(u=this.element(a)).element(f):u=this.element(a,f);else u=this.dummy()}else u=this.options.keepNullNodes||null!==r?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&0===t.indexOf(this.stringify.convertTextKey)?this.text(r):!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&0===t.indexOf(this.stringify.convertCDataKey)?this.cdata(r):!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&0===t.indexOf(this.stringify.convertCommentKey)?this.comment(r):!this.options.ignoreDecorators&&this.stringify.convertRawKey&&0===t.indexOf(this.stringify.convertRawKey)?this.raw(r):!this.options.ignoreDecorators&&this.stringify.convertPIKey&&0===t.indexOf(this.stringify.convertPIKey)?this.instruction(t.substr(this.stringify.convertPIKey.length),r):this.node(t,e,r):this.dummy();if(null==u)throw new Error("Could not create any elements with: "+t+". "+this.debugInfo());return u},t.prototype.insertBefore=function(t,e,r){var n,i,o,s,a;if(null!=t?t.type:void 0)return s=e,(o=t).setParent(this),s?(i=children.indexOf(s),a=children.splice(i),children.push(o),Array.prototype.push.apply(children,a)):children.push(o),o;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(t));return i=this.parent.children.indexOf(this),a=this.parent.children.splice(i),n=this.parent.element(t,e,r),Array.prototype.push.apply(this.parent.children,a),n},t.prototype.insertAfter=function(t,e,r){var n,i,o;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(t));return i=this.parent.children.indexOf(this),o=this.parent.children.splice(i+1),n=this.parent.element(t,e,r),Array.prototype.push.apply(this.parent.children,o),n},t.prototype.remove=function(){var t;if(this.isRoot)throw new Error("Cannot remove the root element. "+this.debugInfo());return t=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[t,t-t+1].concat([])),this.parent},t.prototype.node=function(t,e,r){var n,i;return null!=t&&(t=d(t)),e||(e={}),e=d(e),g(e)||(r=(i=[e,r])[0],e=i[1]),n=new c(this,t,e),null!=r&&n.text(r),this.children.push(n),n},t.prototype.text=function(t){var e;return g(t)&&this.element(t),e=new f(this,t),this.children.push(e),this},t.prototype.cdata=function(t){var e;return e=new i(this,t),this.children.push(e),this},t.prototype.comment=function(t){var e;return e=new o(this,t),this.children.push(e),this},t.prototype.commentBefore=function(t){var e,r;return e=this.parent.children.indexOf(this),r=this.parent.children.splice(e),this.parent.comment(t),Array.prototype.push.apply(this.parent.children,r),this},t.prototype.commentAfter=function(t){var e,r;return e=this.parent.children.indexOf(this),r=this.parent.children.splice(e+1),this.parent.comment(t),Array.prototype.push.apply(this.parent.children,r),this},t.prototype.raw=function(t){var e;return e=new p(this,t),this.children.push(e),this},t.prototype.dummy=function(){return new u(this)},t.prototype.instruction=function(t,e){var r,n,i,o,s;if(null!=t&&(t=d(t)),null!=e&&(e=d(e)),Array.isArray(t))for(o=0,s=t.length;s>o;o++)r=t[o],this.instruction(r);else if(g(t))for(r in t)v.call(t,r)&&(n=t[r],this.instruction(r,n));else y(e)&&(e=e.apply()),i=new h(this,t,e),this.children.push(i);return this},t.prototype.instructionBefore=function(t,e){var r,n;return r=this.parent.children.indexOf(this),n=this.parent.children.splice(r),this.parent.instruction(t,e),Array.prototype.push.apply(this.parent.children,n),this},t.prototype.instructionAfter=function(t,e){var r,n;return r=this.parent.children.indexOf(this),n=this.parent.children.splice(r+1),this.parent.instruction(t,e),Array.prototype.push.apply(this.parent.children,n),this},t.prototype.declaration=function(t,e,r){var i,o;return i=this.document(),o=new s(i,t,e,r),0===i.children.length?i.children.unshift(o):i.children[0].type===n.Declaration?i.children[0]=o:i.children.unshift(o),i.root()||i},t.prototype.dtd=function(t,e){var r,i,o,s,u,c,l,h,p;for(r=this.document(),i=new a(r,t,e),o=s=0,c=(h=r.children).length;c>s;o=++s)if(h[o].type===n.DocType)return r.children[o]=i,i;for(o=u=0,l=(p=r.children).length;l>u;o=++u)if(p[o].isRoot)return r.children.splice(o,0,i),i;return r.children.push(i),i},t.prototype.up=function(){if(this.isRoot)throw new Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},t.prototype.root=function(){var t;for(t=this;t;){if(t.type===n.Document)return t.rootObject;if(t.isRoot)return t;t=t.parent}},t.prototype.document=function(){var t;for(t=this;t;){if(t.type===n.Document)return t;t=t.parent}},t.prototype.end=function(t){return this.document().end(t)},t.prototype.prev=function(){var t;if(1>(t=this.parent.children.indexOf(this)))throw new Error("Already at the first node. "+this.debugInfo());return this.parent.children[t-1]},t.prototype.next=function(){var t;if(-1===(t=this.parent.children.indexOf(this))||t===this.parent.children.length-1)throw new Error("Already at the last node. "+this.debugInfo());return this.parent.children[t+1]},t.prototype.importDocument=function(t){var e;return(e=t.root().clone()).parent=this,e.isRoot=!1,this.children.push(e),this},t.prototype.debugInfo=function(t){var e,r;return null!=(t=t||this.name)||(null!=(e=this.parent)?e.name:void 0)?null==t?"parent: <"+this.parent.name+">":(null!=(r=this.parent)?r.name:void 0)?"node: <"+t+">, parent: <"+this.parent.name+">":"node: <"+t+">":""},t.prototype.ele=function(t,e,r){return this.element(t,e,r)},t.prototype.nod=function(t,e,r){return this.node(t,e,r)},t.prototype.txt=function(t){return this.text(t)},t.prototype.dat=function(t){return this.cdata(t)},t.prototype.com=function(t){return this.comment(t)},t.prototype.ins=function(t,e){return this.instruction(t,e)},t.prototype.doc=function(){return this.document()},t.prototype.dec=function(t,e,r){return this.declaration(t,e,r)},t.prototype.e=function(t,e,r){return this.element(t,e,r)},t.prototype.n=function(t,e,r){return this.node(t,e,r)},t.prototype.t=function(t){return this.text(t)},t.prototype.d=function(t){return this.cdata(t)},t.prototype.c=function(t){return this.comment(t)},t.prototype.r=function(t){return this.raw(t)},t.prototype.i=function(t,e){return this.instruction(t,e)},t.prototype.u=function(){return this.up()},t.prototype.importXMLBuilder=function(t){return this.importDocument(t)},t.prototype.replaceChild=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.removeChild=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.appendChild=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.hasChildNodes=function(){return 0!==this.children.length},t.prototype.cloneNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.normalize=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.isSupported=function(t,e){return!0},t.prototype.hasAttributes=function(){return 0!==this.attribs.length},t.prototype.compareDocumentPosition=function(t){var r;return this===t?0:this.document()!==t.document()?(r=e.Disconnected|e.ImplementationSpecific,.5>Math.random()?r|=e.Preceding:r|=e.Following,r):this.isAncestor(t)?e.Contains|e.Preceding:this.isDescendant(t)?e.Contains|e.Following:this.isPreceding(t)?e.Preceding:e.Following},t.prototype.isSameNode=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.lookupPrefix=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.isDefaultNamespace=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.lookupNamespaceURI=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.isEqualNode=function(t){var e,r,n;if(t.nodeType!==this.nodeType)return!1;if(t.children.length!==this.children.length)return!1;for(e=r=0,n=this.children.length-1;0>n?r>=n:n>=r;e=0>n?--r:++r)if(!this.children[e].isEqualNode(t.children[e]))return!1;return!0},t.prototype.getFeature=function(t,e){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.setUserData=function(t,e,r){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.getUserData=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},t.prototype.contains=function(t){return!!t&&(t===this||this.isDescendant(t))},t.prototype.isDescendant=function(t){var e,r,n,i;for(r=0,n=(i=this.children).length;n>r;r++){if(t===(e=i[r]))return!0;if(e.isDescendant(t))return!0}return!1},t.prototype.isAncestor=function(t){return t.isDescendant(this)},t.prototype.isPreceding=function(t){var e,r;return e=this.treePosition(t),r=this.treePosition(this),-1!==e&&-1!==r&&r>e},t.prototype.isFollowing=function(t){var e,r;return e=this.treePosition(t),r=this.treePosition(this),-1!==e&&-1!==r&&e>r},t.prototype.treePosition=function(t){var e,r;return r=0,e=!1,this.foreachTreeNode(this.document(),(function(n){if(r++,!e&&n===t)return e=!0})),e?r:-1},t.prototype.foreachTreeNode=function(t,e){var r,n,i,o,s;for(t||(t=this.document()),n=0,i=(o=t.children).length;i>n;n++){if(s=e(r=o[n]))return s;if(s=this.foreachTreeNode(r,e))return s}},t}()}).call(this)},function(t,e){t.exports=require("zahl")},function(t,e){var r=Array.isArray;t.exports=r},function(t,e,r){"use strict";var n=r(21),i=r.n(n),o=r(0),s=r(5),a=r(19),u=r(2);e.a=new class extends i.a{constructor(){super(),this.afkMessage=null,this.afkStart=null,this.afkEnd=null,this.title=null,setInterval(()=>{this.isAfk()&&this.setTitle()},3e4)}isAfk(){return null!==this.afkMessage}getRemainingTime(){return this.afkEnd-Date.now()}getTitlePrefix(){if(!this.isAfk())return"";const t=this.getRemainingTime();return t>6e4?`[Noch ${s.a.duration(t,"ms").format("h[h] m[m]")} weg] `:"[Im Verspätungsmodus] "}async setTitle(t){if(!u.a)return;if(t&&(this.title=t),!this.title){var e;const t=await u.a.getMyStream();(null==t?void 0:null===(e=t.channel)||void 0===e?void 0:e.status)&&(this.title=function(t){return t.replace(/^\s*\[.*]\s*/,"")}(t.channel.status))}const r=`${this.getTitlePrefix()}${this.title}`;o.c.info("New title: %s",r),await u.a.setTitle(r)}async activate(t,e){var r;this.afkStart=Date.now(),this.afkEnd=this.afkStart+1e3*t,this.afkMessage=e,await this.setTitle(),u.a.say(`Jaidchen geht jetzt mal weg für etwa ${r=1e3*t,Object(a.a)(r)}. Als Nachricht hat er lediglich ein "${e}" hinterlassen.`)}async deactivate(){const t=this.getRemainingTime(),e=(()=>{var e,r,n;return t>12e4?`Oh, der ist ja schon wieder da, ${e=t,Object(a.a)(e)} früher als angekündigt! KomodoHype`:t>-12e4?"Da ist er ja wieder! TPFufun":`"${this.afkMessage}", ja ja. Du wolltest doch eigentlich schon seit ${n=t,r=Math.abs(n),Object(a.a)(r)} wieder da sein. Jaidchen, wo bist du gewesen? PunOko`})();this.afkStart=null,this.afkEnd=null,this.afkMessage=null,await this.setTitle(),u.a.say(e)}}},function(t,e,r){"use strict";r.d(e,"b",(function(){return o}));var n=r(101),i=r.n(n);const o=i.a.humanizer({language:"de",conjunction:" und ",serialComma:!1,maxDecimalPoints:0,units:["h","m"]});e.a=i.a.humanizer({language:"de",conjunction:" und dann noch mal ",serialComma:!1,maxDecimalPoints:0})},function(t,e){t.exports=require("util")},function(t,e){t.exports=require("events")},function(t,e,r){"use strict";r.r(e),r.d(e,"schema",(function(){return h}));var n=r(1),i=r.n(n),o=r(171),s=r.n(o),a=r(2),u=r(0),c=r(41);class l extends i.a.Model{static associate(t){l.hasMany(t.ChatMessage,{foreignKey:{allowNull:!1}}),l.hasMany(t.Video,{as:"RequestedVideos",foreignKey:"RequesterId"})}static async getByTwitchId(t){return await l.findOne({where:{twitchId:t}})}static async getByTwitchLogin(t){return await l.findOne({where:{loginName:t.toLowerCase()}})}static async prepareByTwitchId(t,{attributes:e,defaults:r}){const n=await l.findOne({where:{twitchId:t},attributes:e});if(n)return n;const i=await a.a.getChannelInfo(t),o=i.displayName||i.name;return u.c.info("New Twitch user %s",o),await l.create({twitchId:t,displayName:o,description:i.description,loginName:i.name,offlineImageUrl:i.offlinePlaceholderUrl,avatarUrl:i.profilePictureUrl,viewCount:i.views,broadcasterType:i.broadcasterType,...r})}async toTwitchClient(){const t=await s.a.withCredentials(u.a.twitchClientId,this.accessToken,c.a,{clientSecret:u.a.twitchClientSecret,refreshToken:this.refreshToken,onRefresh:t=>this.updateToken(t),expiry:this.tokenExpiryDate},{preAuth:!0,initialScopes:c.a});return this.tokenExpiryDate||(u.c.info("Initial expiry date not set for user %s. Forcing access token refresh.",this.loginName),await t.refreshAccessToken()),u.c.info("Created client for user %s",this.loginName),t}async updateToken(t){u.c.info("Refresh token of user %s",this.loginName),this.accessToken=t.accessToken,this.refreshToken=t.refreshToken,this.tokenExpiryDate=t.expiryDate,await this.save({fields:["accessToken","refreshToken","tokenExpiryDate"]})}getDisplayName(){return this.displayName||this.loginName||this.twitchId}}const h={broadcasterType:i.a.STRING(16),description:i.a.STRING,twitchId:{type:i.a.STRING(16),unique:!0,allowNull:!1},nameColor:i.a.STRING,displayName:i.a.STRING(64),loginName:{allowNull:!1,type:i.a.STRING(64)},offlineImageUrl:i.a.TEXT,avatarUrl:i.a.TEXT,viewCount:{allowNull:!1,type:i.a.INTEGER},accessToken:i.a.STRING,refreshToken:i.a.STRING,followDate:i.a.DATE,tokenExpiryDate:i.a.DATE,offlineTimeMinutes:{type:i.a.INTEGER,defaultValue:0,allowNull:!1},liveWatchTimeMinutes:{type:i.a.INTEGER,defaultValue:0,allowNull:!1},vodcastWatchTimeMinutes:{type:i.a.INTEGER,defaultValue:0,allowNull:!1}};e.default=l},function(t,e,r){"use strict";const n=r(12).fromPromise,i=r(130);t.exports={pathExists:n((function(t){return i.access(t).then(()=>!0).catch(()=>!1)})),pathExistsSync:i.existsSync}},function(t,e){(function(){var e,r,n,i,o,s,a,u=[].slice,c={}.hasOwnProperty;e=function(){var t,e,r,n,i,s;if(s=arguments[0],i=2>arguments.length?[]:u.call(arguments,1),o(Object.assign))Object.assign.apply(null,arguments);else for(t=0,r=i.length;r>t;t++)if(null!=(n=i[t]))for(e in n)c.call(n,e)&&(s[e]=n[e]);return s},o=function(t){return!!t&&"[object Function]"===Object.prototype.toString.call(t)},s=function(t){var e;return!!t&&("function"==(e=typeof t)||"object"===e)},n=function(t){return o(Array.isArray)?Array.isArray(t):"[object Array]"===Object.prototype.toString.call(t)},i=function(t){var e;if(n(t))return!t.length;for(e in t)if(c.call(t,e))return!1;return!0},a=function(t){var e,r;return s(t)&&(r=Object.getPrototypeOf(t))&&(e=r.constructor)&&"function"==typeof e&&e instanceof e&&Function.prototype.toString.call(e)===Function.prototype.toString.call(Object)},r=function(t){return o(t.valueOf)?t.valueOf():t},t.exports.assign=e,t.exports.isFunction=o,t.exports.isObject=s,t.exports.isArray=n,t.exports.isEmpty=i,t.exports.isPlainObject=a,t.exports.getValue=r}).call(this)},function(t,e,r){var n=r(47),i=r(202),o=r(203),s=n?n.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":s&&s in Object(t)?i(t):o(t)}},function(t,e){t.exports=function(t){return null!=t&&"object"==typeof t}},function(t,e){t.exports=require("assert")},function(t,e,r){"use strict";var n,i=Object.getOwnPropertyDescriptor?function(){return Object.getOwnPropertyDescriptor(arguments,"callee").get}():function(){throw new TypeError},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator,s=Object.getPrototypeOf||function(t){return t.__proto__},a=n,u="undefined"==typeof Uint8Array?n:s(Uint8Array),c={"$ %Array%":Array,"$ %ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"$ %ArrayBufferPrototype%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer.prototype,"$ %ArrayIteratorPrototype%":o?s([][Symbol.iterator]()):n,"$ %ArrayPrototype%":Array.prototype,"$ %ArrayProto_entries%":Array.prototype.entries,"$ %ArrayProto_forEach%":Array.prototype.forEach,"$ %ArrayProto_keys%":Array.prototype.keys,"$ %ArrayProto_values%":Array.prototype.values,"$ %AsyncFromSyncIteratorPrototype%":n,"$ %AsyncFunction%":n,"$ %AsyncFunctionPrototype%":n,"$ %AsyncGenerator%":n,"$ %AsyncGeneratorFunction%":n,"$ %AsyncGeneratorPrototype%":n,"$ %AsyncIteratorPrototype%":a&&o&&Symbol.asyncIterator?a[Symbol.asyncIterator]():n,"$ %Atomics%":"undefined"==typeof Atomics?n:Atomics,"$ %Boolean%":Boolean,"$ %BooleanPrototype%":Boolean.prototype,"$ %DataView%":"undefined"==typeof DataView?n:DataView,"$ %DataViewPrototype%":"undefined"==typeof DataView?n:DataView.prototype,"$ %Date%":Date,"$ %DatePrototype%":Date.prototype,"$ %decodeURI%":decodeURI,"$ %decodeURIComponent%":decodeURIComponent,"$ %encodeURI%":encodeURI,"$ %encodeURIComponent%":encodeURIComponent,"$ %Error%":Error,"$ %ErrorPrototype%":Error.prototype,"$ %eval%":eval,"$ %EvalError%":EvalError,"$ %EvalErrorPrototype%":EvalError.prototype,"$ %Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"$ %Float32ArrayPrototype%":"undefined"==typeof Float32Array?n:Float32Array.prototype,"$ %Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"$ %Float64ArrayPrototype%":"undefined"==typeof Float64Array?n:Float64Array.prototype,"$ %Function%":Function,"$ %FunctionPrototype%":Function.prototype,"$ %Generator%":n,"$ %GeneratorFunction%":n,"$ %GeneratorPrototype%":n,"$ %Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"$ %Int8ArrayPrototype%":"undefined"==typeof Int8Array?n:Int8Array.prototype,"$ %Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"$ %Int16ArrayPrototype%":"undefined"==typeof Int16Array?n:Int8Array.prototype,"$ %Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"$ %Int32ArrayPrototype%":"undefined"==typeof Int32Array?n:Int32Array.prototype,"$ %isFinite%":isFinite,"$ %isNaN%":isNaN,"$ %IteratorPrototype%":o?s(s([][Symbol.iterator]())):n,"$ %JSON%":JSON,"$ %JSONParse%":JSON.parse,"$ %Map%":"undefined"==typeof Map?n:Map,"$ %MapIteratorPrototype%":"undefined"!=typeof Map&&o?s((new Map)[Symbol.iterator]()):n,"$ %MapPrototype%":"undefined"==typeof Map?n:Map.prototype,"$ %Math%":Math,"$ %Number%":Number,"$ %NumberPrototype%":Number.prototype,"$ %Object%":Object,"$ %ObjectPrototype%":Object.prototype,"$ %ObjProto_toString%":Object.prototype.toString,"$ %ObjProto_valueOf%":Object.prototype.valueOf,"$ %parseFloat%":parseFloat,"$ %parseInt%":parseInt,"$ %Promise%":"undefined"==typeof Promise?n:Promise,"$ %PromisePrototype%":"undefined"==typeof Promise?n:Promise.prototype,"$ %PromiseProto_then%":"undefined"==typeof Promise?n:Promise.prototype.then,"$ %Promise_all%":"undefined"==typeof Promise?n:Promise.all,"$ %Promise_reject%":"undefined"==typeof Promise?n:Promise.reject,"$ %Promise_resolve%":"undefined"==typeof Promise?n:Promise.resolve,"$ %Proxy%":"undefined"==typeof Proxy?n:Proxy,"$ %RangeError%":RangeError,"$ %RangeErrorPrototype%":RangeError.prototype,"$ %ReferenceError%":ReferenceError,"$ %ReferenceErrorPrototype%":ReferenceError.prototype,"$ %Reflect%":"undefined"==typeof Reflect?n:Reflect,"$ %RegExp%":RegExp,"$ %RegExpPrototype%":RegExp.prototype,"$ %Set%":"undefined"==typeof Set?n:Set,"$ %SetIteratorPrototype%":"undefined"!=typeof Set&&o?s((new Set)[Symbol.iterator]()):n,"$ %SetPrototype%":"undefined"==typeof Set?n:Set.prototype,"$ %SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"$ %SharedArrayBufferPrototype%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer.prototype,"$ %String%":String,"$ %StringIteratorPrototype%":o?s(""[Symbol.iterator]()):n,"$ %StringPrototype%":String.prototype,"$ %Symbol%":o?Symbol:n,"$ %SymbolPrototype%":o?Symbol.prototype:n,"$ %SyntaxError%":SyntaxError,"$ %SyntaxErrorPrototype%":SyntaxError.prototype,"$ %ThrowTypeError%":i,"$ %TypedArray%":u,"$ %TypedArrayPrototype%":u?u.prototype:n,"$ %TypeError%":TypeError,"$ %TypeErrorPrototype%":TypeError.prototype,"$ %Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"$ %Uint8ArrayPrototype%":"undefined"==typeof Uint8Array?n:Uint8Array.prototype,"$ %Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"$ %Uint8ClampedArrayPrototype%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray.prototype,"$ %Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"$ %Uint16ArrayPrototype%":"undefined"==typeof Uint16Array?n:Uint16Array.prototype,"$ %Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"$ %Uint32ArrayPrototype%":"undefined"==typeof Uint32Array?n:Uint32Array.prototype,"$ %URIError%":URIError,"$ %URIErrorPrototype%":URIError.prototype,"$ %WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"$ %WeakMapPrototype%":"undefined"==typeof WeakMap?n:WeakMap.prototype,"$ %WeakSet%":"undefined"==typeof WeakSet?n:WeakSet,"$ %WeakSetPrototype%":"undefined"==typeof WeakSet?n:WeakSet.prototype};t.exports=function(t,e){if(arguments.length>1&&"boolean"!=typeof e)throw new TypeError('"allowMissing" argument must be a boolean');var r="$ "+t;if(!(r in c))throw new SyntaxError("intrinsic "+t+" does not exist!");if(n===c[r]&&!e)throw new TypeError("intrinsic "+t+" exists, but is not available. Please file an issue!");return c[r]}},function(t,e){t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},function(module,exports,__webpack_require__){module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=4)}([function(t,e,r){"use strict";var n=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=n(r(1)),o=r(8),s=r(2),a=r(17);e.validatorSymbol=Symbol("validators"),e.Predicate=class{constructor(t,e={}){this.type=t,this.options=e,this.context={validators:[]},this.context=Object.assign({},this.context,this.options);const r=this.type[0].toLowerCase()+this.type.slice(1);this.addValidator({message:(t,e)=>`Expected ${e&&e.substring(this.type.length+1)||"argument"} to be of type \`${this.type}\` but received type \`${i.default(t)}\``,validator:t=>i.default[r](t)})}[s.testSymbol](t,e,r){for(const{validator:n,message:i}of this.context.validators){if(!0===this.options.optional&&void 0===t)continue;const s=n(t);if(!0===s)continue;let a=r;throw"function"==typeof r&&(a=r()),a=a?`${this.type} \`${a}\``:this.type,new o.ArgumentError(i(t,a,s),e)}}get[e.validatorSymbol](){return this.context.validators}get not(){return a.not(this)}is(t){return this.addValidator({message:(t,e,r)=>r?`(${e}) ${r}`:`Expected ${e} \`${t}\` to pass custom validation function`,validator:t})}addValidator(t){return this.context.validators.push(t),this}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n="undefined"==typeof URL?r(16).URL:URL,i=Object.prototype.toString,o=t=>e=>typeof e===t,s=t=>!c.nullOrUndefined(t)&&!c.nullOrUndefined(t.constructor)&&c.function_(t.constructor.isBuffer)&&t.constructor.isBuffer(t),a=t=>i.call(t).slice(8,-1)||null,u=t=>e=>a(e)===t;function c(t){switch(t){case null:return"null";case!0:case!1:return"boolean"}switch(typeof t){case"undefined":return"undefined";case"string":return"string";case"number":return"number";case"symbol":return"symbol"}if(c.function_(t))return"Function";if(c.observable(t))return"Observable";if(Array.isArray(t))return"Array";if(s(t))return"Buffer";const e=a(t);if(e)return e;if(t instanceof String||t instanceof Boolean||t instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}!function(t){const e=t=>"object"==typeof t;t.undefined=o("undefined"),t.string=o("string"),t.number=o("number"),t.function_=o("function"),t.null_=t=>null===t,t.class_=e=>t.function_(e)&&e.toString().startsWith("class "),t.boolean=t=>!0===t||!1===t,t.symbol=o("symbol"),t.numericString=e=>t.string(e)&&e.length>0&&!Number.isNaN(Number(e)),t.array=Array.isArray,t.buffer=s,t.nullOrUndefined=e=>t.null_(e)||t.undefined(e),t.object=r=>!t.nullOrUndefined(r)&&(t.function_(r)||e(r)),t.iterable=e=>!t.nullOrUndefined(e)&&t.function_(e[Symbol.iterator]),t.asyncIterable=e=>!t.nullOrUndefined(e)&&t.function_(e[Symbol.asyncIterator]),t.generator=e=>t.iterable(e)&&t.function_(e.next)&&t.function_(e.throw),t.nativePromise=t=>u("Promise")(t),t.promise=r=>t.nativePromise(r)||(r=>!t.null_(r)&&e(r)&&t.function_(r.then)&&t.function_(r.catch))(r),t.generatorFunction=u("GeneratorFunction"),t.asyncFunction=u("AsyncFunction"),t.boundFunction=e=>t.function_(e)&&!e.hasOwnProperty("prototype"),t.regExp=u("RegExp"),t.date=u("Date"),t.error=u("Error"),t.map=t=>u("Map")(t),t.set=t=>u("Set")(t),t.weakMap=t=>u("WeakMap")(t),t.weakSet=t=>u("WeakSet")(t),t.int8Array=u("Int8Array"),t.uint8Array=u("Uint8Array"),t.uint8ClampedArray=u("Uint8ClampedArray"),