fishpi 0.1.23 → 0.1.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/fishpi.min.js CHANGED
@@ -1 +1,26 @@
1
- var FishPi=(function(e,t,n,r,i){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e},f=(e,t,n)=>(n=e==null?{}:a(l(e)),d(t||!e||!e.__esModule?o(n,`default`,{value:e,enumerable:!0}):n,e));t=f(t),n=f(n),i=f(i),globalThis.FormData||import(`form-data`).then(e=>{globalThis.FormData=e.default}).catch(e=>{console.error(`Failed to load form-data module:`,e)});let p=`fishpi.cn`;function ee(e){p=e}async function m(e){let{url:t,method:n=`get`,headers:r={},data:i}=e;_||(r[`User-Agent`]=`Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36`,r.Referer=`https://${p}/`);let a;a=i instanceof FormData?i:JSON.stringify(i);let o={method:n,headers:r,body:a},s;try{return s=fetch(`https://${p}/${t}`,o).then(e=>e.text()).then(e=>{try{return JSON.parse(e)}catch{return e}}),s}catch(e){if(e.response.status===401)return e.response;throw e}}function te(e){if(!e||typeof e.attr!=`string`)return e;let t=e.attr.split(`&`);return e.attr={src:e.attr},t.forEach(t=>e.attr[t.split(`=`)[0]]=t.split(`=`)[1]),e.url=`https://${p}/gen?txt=${e.description}&url=${e.attr.src}`,e.icon=`https://${p}/gen?txt=&${e.attr.src}`,e}function h(e){try{let t=JSON.parse(e);return t.list.forEach((e,t,n)=>{n[t]=te(e)}),t.list}catch{return[]}}function g(e){if(!e)return;let t=e.split(`/`);return{client:t[0],version:t[1]}}let _=typeof window<`u`,v=_?window.WebSocket:n.default.WebSocket,ne=_?class{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),this}off(e,t){let n=this.listeners.get(e);if(n){let e=n.indexOf(t);e>-1&&n.splice(e,1)}return this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n),this}emit(e,...t){let n=this.listeners.get(e);return n&&n.forEach(e=>e(...t)),this}removeAllListeners(e){return e?this.listeners.delete(e):this.listeners.clear(),this}}:r.EventEmitter;var y=class e{title=``;content=``;tags=``;commentable=!0;isNotifyFollowers=!1;type=x.Normal;isShowInList=!0;rewardContent;rewardPoint;isAnonymous;offerPoint;static from(t){return Object.assign(new e,t)}toJson(){return{articleTitle:this.title,articleContent:this.content,articleTags:this.tags,articleCommentable:this.commentable,articleNotifyFollowers:this.isNotifyFollowers,articleType:this.type,articleShowInList:this.isShowInList?1:0,articleRewardContent:this.rewardContent,articleRewardPoint:this.rewardPoint,articleAnonymous:this.isAnonymous,articleQnAOfferPoint:this.offerPoint}}},b=class e{articleId=``;isAnonymous=!1;isVisible=!0;content=``;originalId;static from(t){return Object.assign(new e,t)}toJson(){return{articleId:this.articleId,commentAnonymous:this.isAnonymous?1:0,commentVisible:this.isVisible?1:0,commentContent:this.content,commentOriginalCommentId:this.originalId}}};let x=function(e){return e[e.Normal=0]=`Normal`,e[e.Private=1]=`Private`,e[e.Broadcast=2]=`Broadcast`,e[e.Thought=3]=`Thought`,e[e.Question=5]=`Question`,e}({}),re=function(e){return e[e.Public=0]=`Public`,e[e.Private=1]=`Private`,e}({}),S=function(e){return e[e.normal=-1]=`normal`,e[e.up=0]=`up`,e[e.down=1]=`down`,e}({}),C=function(e){return e[e.Yes=0]=`Yes`,e[e.No=1]=`No`,e}({}),w=function(e){return e[e.Normal=0]=`Normal`,e[e.Ban=1]=`Ban`,e[e.Lock=2]=`Lock`,e}({}),ie=function(e){return e.Recent=``,e.Hot=`/hot`,e.Good=`/good`,e.Reply=`/reply`,e.Perfect=`/perfact`,e}({}),ae=function(e){return e[e.Voted=0]=`Voted`,e[e.Unvote=-1]=`Unvote`,e}({});var T=class e{oId=``;title=``;description=``;iconPath=``;URI=``;CSS=``;badCnt=0;commentCount=0;followerCount=0;goodCnt=0;referenceCount=0;linkCount=0;seoDesc=``;seoKeywords=``;seoTitle=``;ad=``;isShowSideAd=!0;status=1;static from(t){let n=new e;return n.oId=t.oId,n.title=t.tagTitle,n.description=t.tagDescription,n.iconPath=t.tagIconPath,n.URI=t.tagURI,n.CSS=t.tagCSS,n.badCnt=t.tagBadCnt,n.commentCount=t.tagCommentCount,n.followerCount=t.tagFollowerCount,n.goodCnt=t.tagGoodCnt,n.referenceCount=t.tagReferenceCount,n.linkCount=t.tagLinkCount,n.seoDesc=t.tagSeoDesc,n.seoKeywords=t.tagSeoKeywords,n.seoTitle=t.tagSeoTitle,n.ad=t.tagAd,n.isShowSideAd=t.tagShowSideAd==1,n.status=t.tagStatus,n}},E=class e{online=!1;onlineMinute=0;tags=``;timezone=``;URL=``;latestArticleTime=0;nickname=``;appRole=0;status=0;province=``;currentCheckinStreak=0;userNo=0;avatarURL=``;language=``;usedPoint=0;points=0;commentCount=0;intro=``;oId=``;userName=``;articleCount=0;role=``;sysMetal;mbti=``;static from(t){let n=new e;return n.online=t.userOnlineFlag,n.onlineMinute=t.onlineMinute,n.tags=t.userTags,n.timezone=t.userTimezone,n.URL=t.userURL,n.latestArticleTime=t.userLatestArticleTime,n.nickname=t.userNickname,n.appRole=t.userAppRole,n.status=t.userStatus,n.province=t.userProvince,n.currentCheckinStreak=t.userCurrentCheckinStreak,n.userNo=t.userNo,n.avatarURL=t.userAvatarURL,n.language=t.userLanguage,n.usedPoint=t.userUsedPoint,n.points=t.userPoint,n.commentCount=t.userCommentCount,n.intro=t.userIntro,n.oId=t.oId,n.userName=t.userName,n.articleCount=t.userArticleCount,n.role=t.userRole,t.sysMetal&&(n.sysMetal=t.sysMetal),n.mbti=t.mbti,n}},D=class e{isShowInList=!0;authorId=``;badCnt=0;latestCmtTime=``;goodCnt=0;offerPoint=0;thumbnailURL=``;stickRemains=0;timeAgo=``;updateTime=``;authorName=``;type=x.Normal;isOffered=!1;createTime=``;viewCount=0;authorThumbnail20=``;watchCnt=0;previewContent=``;titleEmoj=``;titleEmojUnicode=``;title=``;authorThumbnail48=``;collectCnt=0;latestCmter=``;tagsContent=``;oId=``;cmtTimeAgo=``;stick=0;tags=[];isAnonymous=!1;thankCnt=0;status=w.Normal;heat=0;isPerfect=!1;authorThumbnail210=``;permalink=``;author=new E;thankedCnt=0;anonymousView=0;viewCntDisplay=``;commentable=!0;isRewarded=!1;rewardedCnt=0;rewardPoint=0;isFollowing=!1;isWatching=!1;isMyArticle=!1;isThanked=!1;audioURL=``;tableOfContents=``;content=``;originalContent=``;img1URL=``;vote=S.normal;authorIntro=``;city=``;authorURL=``;rewardContent=``;pagination;discussionViewable=!0;revisionCount=0;comments;niceComments;static from(t){var n;let r=new e;return r.isShowInList=t.articleShowInList,r.authorId=t.articleAuthorId,r.badCnt=t.articleBadCnt,r.goodCnt=t.articleGoodCnt,r.offerPoint=t.articleQnAOfferPoint,r.thumbnailURL=t.articleThumbnailURL,r.stickRemains=t.articleStickRemains,r.timeAgo=t.timeAgo,r.updateTime=t.articleUpdateTimeStr,r.authorName=t.articleAuthorName,r.type=t.articleType,r.isOffered=t.articleQnAOfferPoint>0,r.createTime=t.articleCreateTimeStr,r.viewCount=t.articleViewCount,r.authorThumbnail20=t.articleAuthorThumbnailURL20,r.watchCnt=t.articleWatchCnt,r.previewContent=t.articlePreviewContent,r.titleEmoj=t.articleTitleEmoj,r.titleEmojUnicode=t.articleTitleEmojUnicode,r.title=t.articleTitle,r.authorThumbnail48=t.articleAuthorThumbnailURL48,r.collectCnt=t.articleCollectCnt,r.latestCmter=t.articleLatestCmterName,r.tagsContent=t.articleTags,r.oId=t.oId,r.cmtTimeAgo=t.cmtTimeAgo,r.stick=t.articleStick,r.tags=((n=t.articleTagObjs)==null?void 0:n.map(e=>T.from(e)))||[],r.latestCmtTime=t.articleLatestCmtTimeStr,r.isAnonymous=t.articleAnonymous,r.thankCnt=t.articleThankCnt,r.status=t.articleStatus,r.heat=t.articleHeat,r.isPerfect=t.articlePerfect,r.authorThumbnail210=t.articleAuthorThumbnailURL210,r.permalink=t.articlePermalink,t.articleAuthor&&(r.author=E.from(t.articleAuthor)),r.thankedCnt=t.thankedCnt,r.anonymousView=t.articleAnonymousView,r.viewCntDisplay=t.articleViewCntDisplayFormat,r.commentable=t.articleCommentable,r.isRewarded=t.rewarded,r.rewardedCnt=t.rewardedCnt,r.rewardPoint=t.articleRewardPoint,r.isFollowing=t.isFollowing,r.isWatching=t.isWatching,r.isMyArticle=t.isMyArticle,r.isThanked=t.thanked,r.audioURL=t.articleAudioURL,r.tableOfContents=t.articleToC,r.content=t.articleContent,r.originalContent=t.articleOriginalContent,r.img1URL=t.articleImg1URL,r.vote=t.articleVote,r.authorIntro=t.articleAuthorIntro,r.city=t.articleCity,r.authorURL=t.articleAuthorURL,r.rewardContent=t.articleRewardContent,t.pagination&&(r.pagination=H.from(t.pagination)),r.discussionViewable=t.discussionViewable,r.revisionCount=t.articleRevisionCount,r.comments=t.articleComments?t.articleComments.map(e=>O.from(e)):void 0,r.niceComments=t.articleNiceComments?t.articleNiceComments.map(e=>O.from(e)):void 0,r}},O=class e{isNice=!1;createTime=``;authorId=``;score=0;authorURL=``;vote=S.normal;revisionCount=0;timeAgo=``;originalId=``;sysMetal=[];goodCnt=0;visible=C.Yes;articleId=``;rewardedCnt=0;sharpURL=``;isAnonymous=!1;replyCnt=0;oId=``;content=``;status=w.Normal;commenter=new E;authorName=``;thankCnt=0;badCnt=0;rewarded=!1;authorThumbnailURL=``;audioURL=``;isOffered=!1;static from(t){let n=new e;return n.isNice=t.commentNice,n.createTime=t.commentCreateTimeStr,n.authorId=t.commentAuthorId,n.score=t.commentScore,n.authorURL=t.commentAuthorURL,n.vote=t.commentVote,n.revisionCount=t.commentRevisionCount,n.timeAgo=t.timeAgo,n.originalId=t.commentOriginalCommentId,t.sysMetal&&(n.sysMetal=t.sysMetal),n.goodCnt=t.commentGoodCnt,n.visible=t.commentVisible,n.articleId=t.commentOnArticleId,n.rewardedCnt=t.rewardedCnt,n.sharpURL=t.commentSharpURL,n.isAnonymous=t.commentAnonymous,n.replyCnt=t.commentReplyCnt,n.oId=t.oId,n.content=t.commentContent,n.status=t.commentStatus,t.commenter&&(n.commenter=E.from(t.commenter)),n.authorName=t.commentAuthorName,n.thankCnt=t.commentThankCnt,n.badCnt=t.commentBadCnt,n.rewarded=t.rewarded,n.authorThumbnailURL=t.commentAuthorThumbnailURL,n.audioURL=t.commentAudioURL,n.isOffered=t.commentQnAOffered==1,n}},k=class e{articles=[];pagination=new H;tag;static from(t){let n=new e;return n.articles=t.articles.map(e=>D.from(e)),n.pagination=H.from(t.pagination),t.tag&&(n.tag=T.from(t.tag)),n}},A=class e{authorName=``;updatedAt=``;oId=``;createAt=``;authorThumbnail=``;timeAgo=``;content=``;city=``;static from(t){let n=new e;return n.authorName=t.breezemoonAuthorName,n.updatedAt=t.breezemoonUpdated,n.oId=t.oId,n.createAt=t.breezemoonCreated,n.authorThumbnail=t.breezemoonAuthorThumbnailURL48,n.timeAgo=t.timeAgo,n.content=t.breezemoonContent,n.city=t.breezemoonCity,n}},j=class e{pagination=new H;breezemoons=[];static from(t){let n=new e;return n.pagination=t.pagination,n.breezemoons=t.breezemoons.map(e=>A.from(e)),n}};let M=function(e){return e.Web=`Web`,e.PC=`PC`,e.Mobile=`Mobile`,e.Windows=`Windows`,e.macOS=`macOS`,e.Linux=`Linux`,e.iOS=`iOS`,e.Android=`Android`,e.IDEA=`IDEA`,e.Chrome=`Chrome`,e.Edge=`Edge`,e.VSCode=`VSCode`,e.Python=`Python`,e.Golang=`Golang`,e.Rust=`Rust`,e.Harmony=`Harmony`,e.CLI=`CLI`,e.Bird=`Bird`,e.IceNet=`IceNet`,e.ElvesOnline=`ElvesOnline`,e.Other=`Other`,e}({});var oe=class{client=M.Other;version=`latest`};let N=function(e){return e.Markdown=`md`,e.HTML=`html`,e}({}),P=function(e){return e[e.Context=0]=`Context`,e[e.Before=1]=`Before`,e[e.After=2]=`After`,e}({}),se=function(e){return e.online=`online`,e.discussChanged=`discussChanged`,e.revoke=`revoke`,e.msg=`msg`,e.redPacket=`redPacket`,e.redPacketStatus=`redPacketStatus`,e.barrager=`barrager`,e.custom=`customMessage`,e}({}),ce=function(e){return e[e.Rock=0]=`Rock`,e[e.Scissors=1]=`Scissors`,e[e.Paper=2]=`Paper`,e}({}),F=function(e){return e.Random=`random`,e.Average=`average`,e.Specify=`specify`,e.Heartbeat=`heartbeat`,e.RockPaperScissors=`rockPaperScissors`,e}({});var le=class{type=F.Random;money=32;count=1;msg=`摸鱼者,事竟成`;recivers;gesture},I=class e{oId=``;userNo=``;userName=``;userNickname=``;URL=``;city=``;intro=``;online=!1;points=0;role=``;appRole=z.Hack;avatar=``;cardBg=``;following=0;follower=0;onlineMinute=0;canFollow=`hide`;ownedMetal=[];sysMetal=[];mbti=``;get name(){return this.userNickname?`${this.userNickname}(${this.userName})`:this.userName}static from(t){let n=new e;return n.oId=t.oId,n.userNo=t.userNo,n.userName=t.userName,n.userNickname=t.userNickname,n.URL=t.userURL,n.city=t.userCity,n.intro=t.userIntro,n.online=t.userOnlineFlag,n.points=t.userPoint,n.role=t.userRole,n.appRole=t.userAppRole,n.avatar=t.userAvatarURL,n.cardBg=t.cardBg,n.following=t.followingUserCount,n.follower=t.followerCount,n.onlineMinute=t.onlineMinute,n.canFollow=t.canFollow,n.ownedMetal=h(t.allMetalOwned),n.sysMetal=h(t.sysMetal),n.mbti=t.mbti,n}},L=class{url=``;backcolor=``;fontcolor=``;ver=.1;scale=.79;toString(){return`url=${this.url}&backcolor=${this.backcolor}&fontcolor=${this.fontcolor}&ver=${this.ver}&scale=${this.scale}`}},R=class{attr=new L;name=``;description=``;data=``;constructor(e){e&&(this.attr=Object.assign(new L,e.attr),this.name=e.name,this.description=e.description,this.data=e.data)}toUrl(e=!0){let t=`https://${p}/gen?txt=${this.name}&${this.attr.toString()}`;return e||(t=`https://${p}/gen?txt=&${this.attr.toString()}`),t}},ue=class extends R{url;icon;enable=!0},de=class{userName=``;userAvatarURL=``;userNameLowerCase=``},fe=class{userName=``;stage=``;time=0};let pe=function(e){return e[e.checkin1day=0]=`checkin1day`,e[e.checkin2days=1]=`checkin2days`,e[e.patchCheckinCard=2]=`patchCheckinCard`,e[e.metalTicket=3]=`metalTicket`,e}({}),me=function(e){return e.Point=`point`,e.Comment=`commented`,e.Reply=`reply`,e.At=`at`,e.Following=`following`,e.Broadcast=`broadcast`,e.System=`sys-announce`,e}({}),he=function(e){return e.RefreshNotification=`refreshNotification`,e.ChatUnreadCountRefresh=`chatUnreadCountRefresh`,e.NewIdleChatMessage=`newIdleChatMessage`,e.WarnBroadcast=`warnBroadcast`,e.bzUpdate=`bzUpdate`,e}({}),ge=function(e){return e[e.article=0]=`article`,e[e.comment=1]=`comment`,e[e.at=2]=`at`,e[e.commented=3]=`commented`,e[e.followingUser=4]=`followingUser`,e[e.pointCharge=5]=`pointCharge`,e[e.pointTransfer=6]=`pointTransfer`,e[e.pointArticleReward=7]=`pointArticleReward`,e[e.pointCommentThank=8]=`pointCommentThank`,e[e.broadcast=9]=`broadcast`,e[e.pointExchange=10]=`pointExchange`,e[e.abusePointDeduct=11]=`abusePointDeduct`,e[e.pointArticleThank=12]=`pointArticleThank`,e[e.reply=13]=`reply`,e[e.invitecodeUsed=14]=`invitecodeUsed`,e[e.sysAnnounceArticle=15]=`sysAnnounceArticle`,e[e.sysAnnounceNewUser=16]=`sysAnnounceNewUser`,e[e.newFollower=17]=`newFollower`,e[e.invitationLinkUsed=18]=`invitationLinkUsed`,e[e.sysAnnounceRoleChanged=19]=`sysAnnounceRoleChanged`,e[e.followingArticleUpdate=20]=`followingArticleUpdate`,e[e.followingArticleComment=21]=`followingArticleComment`,e[e.pointPerfectArticle=22]=`pointPerfectArticle`,e[e.articleNewFollower=23]=`articleNewFollower`,e[e.articleNewWatcher=24]=`articleNewWatcher`,e[e.commentVoteUp=25]=`commentVoteUp`,e[e.commentVoteDown=26]=`commentVoteDown`,e[e.articleVoteUp=27]=`articleVoteUp`,e[e.articleVoteDown=28]=`articleVoteDown`,e[e.pointCommentAccept=33]=`pointCommentAccept`,e[e.pointReportHandled=36]=`pointReportHandled`,e[e.chatRoomAt=38]=`chatRoomAt`,e[e.redPacket=39]=`redPacket`,e}({}),z=function(e){return e[e.Hack=0]=`Hack`,e[e.Artist=1]=`Artist`,e}({}),B=function(e){return e[e.article=0]=`article`,e[e.comment=1]=`comment`,e[e.user=2]=`user`,e[e.chatroom=3]=`chatroom`,e}({}),_e=function(e){return e[e.advertise=0]=`advertise`,e[e.porn=1]=`porn`,e[e.violate=2]=`violate`,e[e.infringement=3]=`infringement`,e[e.attacks=4]=`attacks`,e[e.impersonate=5]=`impersonate`,e[e.advertisingAccount=6]=`advertisingAccount`,e[e.leakPrivacy=7]=`leakPrivacy`,e[e.other=8]=`other`,e}({});var ve=class{username=``;passwd=``;mfaCode=``},ye=class{username=``;phone=``;invitecode;captcha=``},be=class{role=``;passwd=``;userId=``;r},xe=class{reportDataId=``;reportDataType=B.article;reportType=_e.advertise;reportMemo=``},V=class e{oId=``;state=0;userId=``;jointVip=!1;color=``;underline=!1;metal=!1;autoCheckin=0;bold=!1;lvCode=``;expiresAt=0;createdAt=0;updatedAt=0;get isVip(){return this.state===1&&this.expiresAt*1e3>=Date.now()}get vipName(){return this.isVip?this.lvCode.replace(/_YEAR/,`(包年)`).replace(/_MONTH/,`(包月)`):`非会员`}get expireDate(){return new Date(this.expiresAt)}get createDate(){return new Date(this.createdAt)}get updateDate(){return new Date(this.updatedAt)}static from(t){var n,r,i,a,o,s;let c=new e;return c.oId=t.oId||``,c.state=t.state||0,c.userId=t.userId||``,c.jointVip=((n=t.config)==null?void 0:n.jointVip)||!1,c.color=((r=t.config)==null?void 0:r.color)||``,c.underline=((i=t.config)==null?void 0:i.underline)||!1,c.metal=((a=t.config)==null?void 0:a.metal)||!1,c.autoCheckin=((o=t.config)==null?void 0:o.autoCheckin)||0,c.bold=((s=t.config)==null?void 0:s.bold)||!1,c.lvCode=t.lvCode||``,c.expiresAt=t.expiresAt||0,c.createdAt=t.createdAt||0,c.updatedAt=t.updatedAt||0,c}},H=class e{pageCount=0;pageNums=[];static from(t){let n=new e;return n.pageCount=t.paginationPageCount,n.pageNums=t.paginationPageNums,n}},U=class{emitter=new ne;ws=null;rwsOptions={minReconnectionDelay:1e4,maxReconnectionDelay:6e5,reconnectionDelayGrowFactor:1.3,maxRetries:100,connectionTimeout:1e4};constructor(){}reconnect(){return this.ws?new Promise(e=>{!this.ws||this.ws.readyState===v.CONNECTING||(this.ws.reconnect(),this.ws.onopen=t=>{e(this.ws)})}):this.connect()}connect(e=!1){return new Promise(async(t,n)=>this.ws&&!e?t(this.ws):(this.ws&&this.ws.close(),n(Error(`请在子类中实现 connect 方法`))))}on(e,t){return(this.ws==null||this.ws.readyState!==v.OPEN)&&this.connect(),this.emitter.on(e,t)}off(e,t){return e?t?this.emitter.off(e,t):this.emitter.removeAllListeners(e):this.emitter.removeAllListeners()}once(e,t){return this.emitter.once(e,t)}clearListener(e){this.emitter.removeAllListeners(e)}removeListener(e,t){return this.off(e,t)}addListener(e,t){return this.on(e,t)}},W=class extends U{apiKey=``;_discusse=``;_onlines=[];wsTimer=null;client=M.Other;version=`Latest`;constructor(e=``){super(),e&&(this.apiKey=e)}get onlines(){return this._onlines}get discusse(){return this._discusse}set discusse(e){this.send(`[setdiscuss]${e}[/setdiscuss]`).catch(()=>{})}setToken(e){this.apiKey=e,this.redpacket.setToken(e)}setVia(e,t){this.client=e,this.version=t}async history(e=1,t=N.HTML){try{let n=await m({url:`chat-room/more?page=${e}&type=${t}&apiKey=${this.apiKey}`});if(n.code!=0)throw Error(n.msg);return n.data?(n.data.forEach((e,t,n)=>{try{n[t].type=`msg`,n[t].md=n[t].content,n[t].via=g(n[t].client),n[t].sysMetal=h(n[t].sysMetal),n[t].content=JSON.parse(e.content),n[t].content.recivers&&(n[t].content.recivers=JSON.parse(n[t].content.recivers)),n[t].type=n[t].content.msgType}catch{}}),n.data):n}catch(e){throw e}}async get({oId:e,mode:t=P.Context,size:n=25,type:r=N.HTML}){try{let i=await m({url:`chat-room/getMessage?oId=${e}&mode=${t}&size=${n}&type=${r}&apiKey=${this.apiKey}`});if(i.code!=0)throw Error(i.msg);if(!i.data)return i;let a;return i.data.forEach((e,t,n)=>{try{if(n[t].via=g(n[t].client),n[t].sysMetal=h(n[t].sysMetal),a=JSON.parse(e.content),a.msgType!==`redPacket`)return i;a.recivers&&(a.recivers=JSON.parse(a.recivers)),n[t].content=a}catch{}}),i.data}catch(e){throw e}}async revoke(e){let t;try{if(t=await m({url:`chat-room/revoke/${e}`,method:`delete`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async send(e,t,n){let r;try{if(r=await m({url:`chat-room/send`,method:`post`,data:{content:e,client:`${t||this.client}/${n||this.version}`,apiKey:this.apiKey}}),r.code)throw Error(r.msg)}catch(e){throw e}}async barrage(e,t=`#ffffff`){let n;try{if(n=await m({url:`chat-room/send`,method:`post`,data:{content:`[barrager]{\"color\":\"${t}\",\"content\":\"${e}\"}[/barrager]`,apiKey:this.apiKey}}),n.code)throw Error(n.msg)}catch(e){throw e}}async barragePay(){let e;try{if(e=await m({url:`chat-room/barrager/get?apiKey=${this.apiKey}`,method:`get`}),e.code!=0)throw Error(e.msg);let t=e.data.match(/([-0-9]+)(.+)/);return t?{cost:parseInt(t[1]),unit:t[2]}:{cost:20,unit:`积分`}}catch(e){throw e}}async mutes(){let e;try{if(e=await m({url:`chat-room/si-guo-list`,method:`get`}),e.code)throw Error(e.msg);return e.data}catch(e){throw e}}async raw(e){let t;try{if(t=await m({url:`cr/raw/${e}`}),t.code)throw Error(t.msg);return t.replace(/<!--.*?-->/g,``)}catch(e){throw e}}redpacket=new Se(this,this.apiKey);async getNode(){let e;try{var t;if(e=await m({url:`chat-room/node/get?apiKey=${this.apiKey}`,method:`get`}),e.code!=0)throw Error(`获取节点失败:`+e.msg);return{recommend:{node:e.data,name:e.msg,online:((t=e.avaliable.find(t=>t.node===e.data))==null?void 0:t.online)||0},avaliable:e.avaliable}}catch(e){throw e}}async connect(e,t=10){return new Promise(async n=>{let r=``;if(r=e===void 0||e===``||e===!0?await this.getNode().then(e=>e.recommend.node).catch(()=>`wss://${p}/chat-room-channel?apiKey=${this.apiKey}`):e,r.includes(`apiKey=`)||(r+=`${r.includes(`?`)?`&`:`?`}apiKey=${this.apiKey}`),this.ws)return n(this.reconnect());this.ws=new i.default(r,[],{WebSocket:v,...this.rwsOptions,connectionTimeout:1e3*t}),this.ws.onopen=e=>{this.wsTimer&&clearInterval(this.wsTimer),this.wsTimer=setInterval(()=>{var e;(e=this.ws)==null||e.send(`-hb-`)},1e3*60*3),n(e),this.emitter.emit(`open`,e)},this.ws.onmessage=async e=>{let t=JSON.parse(e.data),n=null;switch(t.type){case`online`:this._onlines=t.users,this._discusse=t.discussing,n=this._onlines;break;case`discussChanged`:n=t.newDiscuss,t.type=`discuss`;break;case`revoke`:n=t.oId;break;case`barrager`:{let{barragerContent:e,userAvatarURL:r,userAvatarURL20:i,userNickname:a,barragerColor:o,userName:s,userAvatarURL210:c,userAvatarURL48:l}=t;n={barragerContent:e,userAvatarURL:r,userAvatarURL20:i,userNickname:a,barragerColor:o,userName:s,userAvatarURL210:c,userAvatarURL48:l};break}case`msg`:{let{userOId:e,oId:r,time:i,userName:a,userNickname:o,userAvatarURL:s,content:c,md:l,client:u}=t;try{let e=JSON.parse(c);[`redPacket`,`music`,`weather`].includes(e.msgType)&&(c=e,t.type=e.msgType)}catch{}n={type:t.type,userOId:e,oId:r,time:i,userName:a,userNickname:o,userAvatarURL:s,content:c,md:l,client:u,via:g(u)};break}case`redPacketStatus`:{let{oId:e,count:r,got:i,whoGive:a,whoGot:o}=t;n={oId:e,count:r,got:i,whoGive:a,whoGot:o};break}case`customMessage`:n=t.message,t.type=`custom`;break}this.emitter.emit(t.type,n),this.emitter.emit(`all`,n)},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)}})}},Se=class{chatroom;apiKey=``;constructor(e,t){this.chatroom=e,this.apiKey=t}setToken(e){this.apiKey=e}async open(e,t){let n;try{if(n=await m({url:`chat-room/red-packet/open`,method:`post`,data:{oId:e,gesture:t,apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n}catch(e){throw e}}async send(e){return await this.chatroom.send(`[redpacket]${JSON.stringify(e)}[/redpacket]`)}},G=class extends U{apiKey=``;constructor(e=``){super(),e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async count(){let e;try{if(e=await m({url:`notifications/unread/count?apiKey=${this.apiKey}`}),e.code!==0)throw Error(e.msg);return e.userNotifyStatus&&(e.userNotifyStatus=e.userNotifyStatus!=0),e}catch(e){throw e}}async list(e){let t;try{if(t=await m({url:`api/getNotifications?apiKey=${this.apiKey}&type=${e}`}),t.code!==0)throw Error(t.msg);return t.data.forEach(e=>(!e.description&&e.content&&(e.description=e.content),e)),t.data}catch(e){throw e}}async makeRead(e){let t;try{if(t=await m({url:`notifications/make-read/${e}?apiKey=${this.apiKey}`}),t.code!==0)throw Error(t.msg)}catch(e){throw e}}async readAll(){let e;try{if(e=await m({url:`notifications/all-read?apiKey=${this.apiKey}`}),e.code!==0)throw Error(e.msg)}catch(e){throw e}}reconnect(){return this.ws?new Promise(e=>{this.ws&&(this.ws.reconnect(),this.ws.onopen=t=>{e(this.ws)})}):this.connect()}connect(e=!1){return new Promise(async(t,n)=>{if(this.ws&&!e)return t(this.ws);if(this.ws&&this.ws.close(),!this.apiKey)return n(Error(`请先设置 API Key`));this.ws=new i.default(`wss://${p}/user-channel?apiKey=${this.apiKey}`,[],{WebSocket:v,connectionTimeout:1e4,maxRetries:10}),this.ws.onopen=e=>{t(this.ws)},this.ws.onmessage=async e=>{let t=JSON.parse(e.data);t.command==`bz-update`&&(t={...t.bz,command:`bzUpdate`}),t.command&&this.emitter.emit(t.command,t)},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)}})}},K=class{apiKey=``;emojis=[];constructor(e=``){e&&this.setToken(e)}setToken(e){this.apiKey=e,e&&this.get().then(e=>this.emojis=e).catch(()=>{})}get default(){return{doge:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/doge.png`,trollface:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/trollface.png`,huaji:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/huaji.gif`,octocat:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/octocat.png`,wulian:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/wulian.png`,smile:`https://file.${p}/emoji/graphics/smile.png`,laughing:`https://file.${p}/emoji/graphics/laughing.png`,blush:`https://file.${p}/emoji/graphics/blush.png`,smiley:`https://file.${p}/emoji/graphics/smiley.png`,relaxed:`https://file.${p}/emoji/graphics/relaxed.png`,smirk:`https://file.${p}/emoji/graphics/smirk.png`,heart_eyes:`https://file.${p}/emoji/graphics/heart_eyes.png`,kissing_heart:`https://file.${p}/emoji/graphics/kissing_heart.png`,kissing_closed_eyes:`https://file.${p}/emoji/graphics/kissing_closed_eyes.png`,flushed:`https://file.${p}/emoji/graphics/flushed.png`,relieved:`https://file.${p}/emoji/graphics/relieved.png`,satisfied:`https://file.${p}/emoji/graphics/satisfied.png`,grin:`https://file.${p}/emoji/graphics/grin.png`,wink:`https://file.${p}/emoji/graphics/wink.png`,stuck_out_tongue_winking_eye:`https://file.${p}/emoji/graphics/stuck_out_tongue_winking_eye.png`,stuck_out_tongue_closed_eyes:`https://file.${p}/emoji/graphics/stuck_out_tongue_closed_eyes.png`,grinning:`https://file.${p}/emoji/graphics/grinning.png`,kissing:`https://file.${p}/emoji/graphics/kissing.png`,kissing_smiling_eyes:`https://file.${p}/emoji/graphics/kissing_smiling_eyes.png`,stuck_out_tongue:`https://file.${p}/emoji/graphics/stuck_out_tongue.png`,sleeping:`https://file.${p}/emoji/graphics/sleeping.png`,worried:`https://file.${p}/emoji/graphics/worried.png`,frowning:`https://file.${p}/emoji/graphics/frowning.png`,anguished:`https://file.${p}/emoji/graphics/anguished.png`,open_mouth:`https://file.${p}/emoji/graphics/open_mouth.png`,grimacing:`https://file.${p}/emoji/graphics/grimacing.png`,confused:`https://file.${p}/emoji/graphics/confused.png`,hushed:`https://file.${p}/emoji/graphics/hushed.png`,expressionless:`https://file.${p}/emoji/graphics/expressionless.png`,unamused:`https://file.${p}/emoji/graphics/unamused.png`,sweat_smile:`https://file.${p}/emoji/graphics/sweat_smile.png`,sweat:`https://file.${p}/emoji/graphics/sweat.png`,disappointed_relieved:`https://file.${p}/emoji/graphics/disappointed_relieved.png`,weary:`https://file.${p}/emoji/graphics/weary.png`,pensive:`https://file.${p}/emoji/graphics/pensive.png`,disappointed:`https://file.${p}/emoji/graphics/disappointed.png`,confounded:`https://file.${p}/emoji/graphics/confounded.png`,fearful:`https://file.${p}/emoji/graphics/fearful.png`,cold_sweat:`https://file.${p}/emoji/graphics/cold_sweat.png`,persevere:`https://file.${p}/emoji/graphics/persevere.png`,cry:`https://file.${p}/emoji/graphics/cry.png`,sob:`https://file.${p}/emoji/graphics/sob.png`,joy:`https://file.${p}/emoji/graphics/joy.png`,astonished:`https://file.${p}/emoji/graphics/astonished.png`,scream:`https://file.${p}/emoji/graphics/scream.png`,tired_face:`https://file.${p}/emoji/graphics/tired_face.png`,angry:`https://file.${p}/emoji/graphics/angry.png`,rage:`https://file.${p}/emoji/graphics/rage.png`,triumph:`https://file.${p}/emoji/graphics/triumph.png`,sleepy:`https://file.${p}/emoji/graphics/sleepy.png`,yum:`https://file.${p}/emoji/graphics/yum.png`,mask:`https://file.${p}/emoji/graphics/mask.png`,sunglasses:`https://file.${p}/emoji/graphics/sunglasses.png`,dizzy_face:`https://file.${p}/emoji/graphics/dizzy_face.png`,imp:`https://file.${p}/emoji/graphics/imp.png`,smiling_imp:`https://file.${p}/emoji/graphics/smiling_imp.png`,neutral_face:`https://file.${p}/emoji/graphics/neutral_face.png`,no_mouth:`https://file.${p}/emoji/graphics/no_mouth.png`,innocent:`https://file.${p}/emoji/graphics/innocent.png`,alien:`https://file.${p}/emoji/graphics/alien.png`,yellow_heart:`https://file.${p}/emoji/graphics/yellow_heart.png`,blue_heart:`https://file.${p}/emoji/graphics/blue_heart.png`,purple_heart:`https://file.${p}/emoji/graphics/purple_heart.png`,heart:`https://file.${p}/emoji/graphics/heart.png`,green_heart:`https://file.${p}/emoji/graphics/green_heart.png`,broken_heart:`https://file.${p}/emoji/graphics/broken_heart.png`,heartbeat:`https://file.${p}/emoji/graphics/heartbeat.png`,heartpulse:`https://file.${p}/emoji/graphics/heartpulse.png`,two_hearts:`https://file.${p}/emoji/graphics/two_hearts.png`,revolving_hearts:`https://file.${p}/emoji/graphics/revolving_hearts.png`,cupid:`https://file.${p}/emoji/graphics/cupid.png`,sparkling_heart:`https://file.${p}/emoji/graphics/sparkling_heart.png`,sparkles:`https://file.${p}/emoji/graphics/sparkles.png`,star:`https://file.${p}/emoji/graphics/star.png`,star2:`https://file.${p}/emoji/graphics/star2.png`,dizzy:`https://file.${p}/emoji/graphics/dizzy.png`,boom:`https://file.${p}/emoji/graphics/boom.png`,collision:`https://file.${p}/emoji/graphics/collision.png`,anger:`https://file.${p}/emoji/graphics/anger.png`,exclamation:`https://file.${p}/emoji/graphics/exclamation.png`,question:`https://file.${p}/emoji/graphics/question.png`,grey_exclamation:`https://file.${p}/emoji/graphics/grey_exclamation.png`,grey_question:`https://file.${p}/emoji/graphics/grey_question.png`,zzz:`https://file.${p}/emoji/graphics/zzz.png`,dash:`https://file.${p}/emoji/graphics/dash.png`,sweat_drops:`https://file.${p}/emoji/graphics/sweat_drops.png`,notes:`https://file.${p}/emoji/graphics/notes.png`,musical_note:`https://file.${p}/emoji/graphics/musical_note.png`,fire:`https://file.${p}/emoji/graphics/fire.png`,poop:`https://file.${p}/emoji/graphics/poop.png`,"+1":`https://file.${p}/emoji/graphics/%2B1.png`,thumbsup:`https://file.${p}/emoji/graphics/thumbsup.png`,"-1":`https://file.${p}/emoji/graphics/-1.png`,thumbsdown:`https://file.${p}/emoji/graphics/thumbsdown.png`,ok_hand:`https://file.${p}/emoji/graphics/ok_hand.png`,punch:`https://file.${p}/emoji/graphics/punch.png`,facepunch:`https://file.${p}/emoji/graphics/facepunch.png`,fist:`https://file.${p}/emoji/graphics/fist.png`,v:`https://file.${p}/emoji/graphics/v.png`,wave:`https://file.${p}/emoji/graphics/wave.png`,hand:`https://file.${p}/emoji/graphics/hand.png`,raised_hand:`https://file.${p}/emoji/graphics/raised_hand.png`,open_hands:`https://file.${p}/emoji/graphics/open_hands.png`,point_up:`https://file.${p}/emoji/graphics/point_up.png`,point_down:`https://file.${p}/emoji/graphics/point_down.png`,point_left:`https://file.${p}/emoji/graphics/point_left.png`,point_right:`https://file.${p}/emoji/graphics/point_right.png`,raised_hands:`https://file.${p}/emoji/graphics/raised_hands.png`,pray:`https://file.${p}/emoji/graphics/pray.png`,point_up_2:`https://file.${p}/emoji/graphics/point_up_2.png`,clap:`https://file.${p}/emoji/graphics/clap.png`,muscle:`https://file.${p}/emoji/graphics/muscle.png`,couple:`https://file.${p}/emoji/graphics/couple.png`,family:`https://file.${p}/emoji/graphics/family.png`,two_men_holding_hands:`https://file.${p}/emoji/graphics/two_men_holding_hands.png`,two_women_holding_hands:`https://file.${p}/emoji/graphics/two_women_holding_hands.png`,dancer:`https://file.${p}/emoji/graphics/dancer.png`,dancers:`https://file.${p}/emoji/graphics/dancers.png`,ok_woman:`https://file.${p}/emoji/graphics/ok_woman.png`,no_good:`https://file.${p}/emoji/graphics/no_good.png`,information_desk_person:`https://file.${p}/emoji/graphics/information_desk_person.png`,raising_hand:`https://file.${p}/emoji/graphics/raising_hand.png`,bride_with_veil:`https://file.${p}/emoji/graphics/bride_with_veil.png`,person_with_pouting_face:`https://file.${p}/emoji/graphics/person_with_pouting_face.png`,person_frowning:`https://file.${p}/emoji/graphics/person_frowning.png`,bow:`https://file.${p}/emoji/graphics/bow.png`,couplekiss:`https://file.${p}/emoji/graphics/couplekiss.png`,couple_with_heart:`https://file.${p}/emoji/graphics/couple_with_heart.png`,massage:`https://file.${p}/emoji/graphics/massage.png`,haircut:`https://file.${p}/emoji/graphics/haircut.png`,nail_care:`https://file.${p}/emoji/graphics/nail_care.png`,boy:`https://file.${p}/emoji/graphics/boy.png`,girl:`https://file.${p}/emoji/graphics/girl.png`,woman:`https://file.${p}/emoji/graphics/woman.png`,man:`https://file.${p}/emoji/graphics/man.png`,baby:`https://file.${p}/emoji/graphics/baby.png`,older_woman:`https://file.${p}/emoji/graphics/older_woman.png`,older_man:`https://file.${p}/emoji/graphics/older_man.png`,person_with_blond_hair:`https://file.${p}/emoji/graphics/person_with_blond_hair.png`,man_with_gua_pi_mao:`https://file.${p}/emoji/graphics/man_with_gua_pi_mao.png`,man_with_turban:`https://file.${p}/emoji/graphics/man_with_turban.png`,construction_worker:`https://file.${p}/emoji/graphics/construction_worker.png`,cop:`https://file.${p}/emoji/graphics/cop.png`,angel:`https://file.${p}/emoji/graphics/angel.png`,princess:`https://file.${p}/emoji/graphics/princess.png`,smiley_cat:`https://file.${p}/emoji/graphics/smiley_cat.png`,smile_cat:`https://file.${p}/emoji/graphics/smile_cat.png`,heart_eyes_cat:`https://file.${p}/emoji/graphics/heart_eyes_cat.png`,kissing_cat:`https://file.${p}/emoji/graphics/kissing_cat.png`,smirk_cat:`https://file.${p}/emoji/graphics/smirk_cat.png`,scream_cat:`https://file.${p}/emoji/graphics/scream_cat.png`,crying_cat_face:`https://file.${p}/emoji/graphics/crying_cat_face.png`,joy_cat:`https://file.${p}/emoji/graphics/joy_cat.png`,pouting_cat:`https://file.${p}/emoji/graphics/pouting_cat.png`,japanese_ogre:`https://file.${p}/emoji/graphics/japanese_ogre.png`,japanese_goblin:`https://file.${p}/emoji/graphics/japanese_goblin.png`,see_no_evil:`https://file.${p}/emoji/graphics/see_no_evil.png`,hear_no_evil:`https://file.${p}/emoji/graphics/hear_no_evil.png`,speak_no_evil:`https://file.${p}/emoji/graphics/speak_no_evil.png`,guardsman:`https://file.${p}/emoji/graphics/guardsman.png`,skull:`https://file.${p}/emoji/graphics/skull.png`,feet:`https://file.${p}/emoji/graphics/feet.png`,lips:`https://file.${p}/emoji/graphics/lips.png`,kiss:`https://file.${p}/emoji/graphics/kiss.png`,droplet:`https://file.${p}/emoji/graphics/droplet.png`,ear:`https://file.${p}/emoji/graphics/ear.png`,eyes:`https://file.${p}/emoji/graphics/eyes.png`,nose:`https://file.${p}/emoji/graphics/nose.png`,tongue:`https://file.${p}/emoji/graphics/tongue.png`,love_letter:`https://file.${p}/emoji/graphics/love_letter.png`,bust_in_silhouette:`https://file.${p}/emoji/graphics/bust_in_silhouette.png`,busts_in_silhouette:`https://file.${p}/emoji/graphics/busts_in_silhouette.png`,speech_balloon:`https://file.${p}/emoji/graphics/speech_balloon.png`,thought_balloon:`https://file.${p}/emoji/graphics/thought_balloon.png`}}async get(){let e;try{if(e=await m({url:`api/cloud/get`,method:`post`,data:{gameId:`emojis`,apiKey:this.apiKey}}),e.code)throw Error(e.msg);return this.emojis=JSON.parse(e.data),this.emojis.concat([])}catch(e){throw e}}async set(e){let t;try{if(t=await m({url:`api/cloud/sync`,method:`post`,data:{gameId:`emojis`,data:JSON.stringify(e),apiKey:this.apiKey}}),t.code)throw Error(t.msg);return t}catch(e){throw e}}async append(e){let t=this.emojis.length>0?this.emojis:await this.get();if(t.indexOf(e)>=0)throw Error(`表情包已存在`);return t.push(e),await this.set(t),this.emojis=t,t.concat([])}async remove(e){let t=this.emojis.length>0?this.emojis:await this.get();return t.indexOf(e)<0?t:(t.splice(t.indexOf(e),1),await this.set(t),this.emojis=t,t.concat([]))}async exists(e){return(this.emojis.length>0?this.emojis:await this.get()).indexOf(e)>=0}},q=class{apiKey=``;constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async info(){try{let e=await m({url:`api/user?apiKey=${this.apiKey}`});if(e.code!=0)throw Error(e.msg);return e.data&&(e.data.sysMetal=h(e.data.sysMetal)),I.from(e.data)}catch(e){throw e}}async emotions(){let e;try{if(e=await m({url:`users/emotions?apiKey=${this.apiKey}`}),e.code!=0)throw Error(e.msg);return e.data=Object.keys(e.data),e.data}catch(e){throw e}}async liveness(){if(!this.apiKey)return 0;try{let e=await m({url:`user/liveness?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.liveness||0}catch(e){throw e}}async isCheckIn(){if(!this.apiKey)return!1;try{let e=await m({url:`user/checkedIn?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.checkedIn||!1}catch(e){throw e}}async isCollectedLiveness(){if(!this.apiKey)return!1;try{let e=await m({url:`api/activity/is-collected-liveness?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.isCollectedYesterdayLivenessReward||!1}catch(e){throw e}}async rewardLiveness(){if(!this.apiKey)return 0;try{let e=await m({url:`activity/yesterday-liveness-reward-api?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.sum||0}catch(e){throw e}}async transfer(e,t,n){try{let r=await m({method:`POST`,url:`point/transfer`,data:{apiKey:this.apiKey,userName:e,amount:t,memo:n}});if(r.code)throw Error(r.msg)}catch(e){throw e}}async follow(e){let t;try{if(t=await m({url:`follow/user`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async unfollow(e){let t;try{if(t=await m({url:`unfollow/user`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async updateUserAvatar(e){let t;try{if(t=await m({url:`api/settings/avatar`,method:`post`,data:{apiKey:this.apiKey,userAvatarURL:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async updateUserInfo(e){let t;try{if(t=await m({url:`api/settings/profiles`,method:`post`,data:{apiKey:this.apiKey,...e}}),t.code)throw Error(t.msg)}catch(e){throw e}}},J=class{apiKey=``;channels={};constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async post(e){let t;try{if(t=await m({url:`article`,method:`post`,data:{...y.from(e).toJson(),apiKey:this.apiKey}}),t.code)throw Error(t.msg);return t.articleId}catch(e){throw e}}async update(e,t){let n;try{if(n=await m({url:`article/${e}`,method:`put`,data:{...y.from(t).toJson(),apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.articleId}catch(e){throw e}}async list({type:e,page:t=1,size:n=20,tag:r}){let i;try{if(i=await m({url:`api/articles/${r?`tag/${r}`:`recent`}${e}?p=${t}&size=${n}&${this.apiKey?`apiKey=${this.apiKey}`:``}`}),i.code)throw Error(i.msg);return k.from(i.data)}catch(e){throw e}}async userArticles({userName:e,page:t=1,size:n=20}){let r;try{if(r=await m({url:`api/user/${e}/articles?p=${t}&size=${n}&${this.apiKey?`apiKey=${this.apiKey}`:``}`}),r.code)throw Error(r.msg);return k.from(r.data)}catch(e){throw e}}async detail(e,t=1){let n;try{if(n=await m({url:`api/article/${e}?apiKey=${this.apiKey}&p=${t}`}),n.code)throw Error(n.msg);return D.from(n.data.article)}catch(e){throw e}}async vote(e,t){let n;try{if(n=await m({url:`vote/${t}/article`,method:`post`,data:{dataId:e,apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.type}catch(e){throw e}}async thank(e){let t;try{if(t=await m({url:`article/thank?articleId=${e}`,method:`post`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async follow(e){let t;try{if(t=await m({url:`follow/article`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async unfollow(e){let t;try{if(t=await m({url:`unfollow/article`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async watch(e){let t;try{if(t=await m({url:`follow/article-watch`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async unwatch(e){let t;try{if(t=await m({url:`unfollow/article-watch`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async reward(e){let t;try{if(t=await m({url:`article/reward?articleId=${e}`,method:`post`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async heat(e){let t;try{if(t=await m({url:`api/article/heat/${e}?apiKey=${this.apiKey}`,method:`get`}),t.code)throw Error(t.msg);return t.articleHeat}catch(e){throw e}}async md(e){let t;try{if(t=await m({url:`api/article/md/${e}?apiKey=${this.apiKey}`}),t.code)throw Error(t.msg);return t}catch(e){throw e}}channel(e,t){return this.channels[e]||(this.channels[e]=new Y(this.apiKey,e,t)),this.channels[e]}},Y=class extends U{apiKey=``;id=``;type=x.Normal;constructor(e,t,n){super(),e&&(this.apiKey=e)}async connect(e){return new Promise(async(t,n)=>this.ws&&!e?t(this.ws):(this.ws&&this.ws.close(),this.apiKey?(this.ws=new i.default(`wss://${p}/article-channel?articleId=${this.id}&articleType=${this.type}&apiKey=${this.apiKey}`,[],{WebSocket:v,connectionTimeout:1e4}),this.ws.onopen=e=>{this.emitter.emit(`open`,e)},this.ws.onmessage=e=>{let t=JSON.parse(e.data);t.type===`articleHeat`?this.emitter.emit(`heat`,t.data):this.emitter.emit(t.type,O.from(t.data))},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)},this.ws):n(Error(`请先设置 API Key`))))}},X=class{apiKey=``;constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async send(e){let t;try{if(t=await m({url:`comment`,method:`post`,data:{...b.from(e).toJson(),apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async update(e,t){let n;try{if(n=await m({url:`comment/${e}`,method:`put`,data:{...b.from(t).toJson(),apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.commentContent}catch(e){throw e}}async vote(e,t){let n;try{if(n=await m({url:`vote/${t}/comment`,method:`post`,data:{dataId:e,apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.type}catch(e){throw e}}async thank(e){let t;try{if(t=await m({url:`comment/thank`,method:`post`,data:{apiKey:this.apiKey,commentId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async remove(e){let t;try{if(t=await m({url:`comment/${e}/remove`,method:`post`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg);return t.commentId}catch(e){throw e}}},Ce=class extends U{apiKey=``;user=``;constructor(e,t){super(),this.apiKey=t,this.user=e}setToken(e){this.apiKey=e,this.connect(!0)}connect(e=!1){return new Promise(async(t,n)=>{if(this.ws&&!e)return t(this.ws);if(this.ws&&this.ws.close(),!this.user)return n(Error(`请先设置私聊用户名`));if(!this.apiKey)return n(Error(`请先设置 API Key`));this.ws=new i.default(`wss://${p}/chat-channel?apiKey=${this.apiKey}&toUser=${this.user}`,[],{WebSocket:v,connectionTimeout:1e4}),this.ws.onopen=e=>{t(this.ws)},this.ws.onmessage=async e=>{let t=JSON.parse(e.data),n=`data`;t.type==`revoke`&&(n=`revoke`,t=t.data),this.emitter.emit(n,t)},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)}})}async send(e){var t;this.ws==null&&await this.connect(),this.user&&((t=this.ws)==null||t.send(e))}close(){var e;(e=this.ws)==null||e.close()}async get({page:e=1,size:t=20,autoRead:n=!0}){if(!this.user)return[];try{let r=await m({url:`chat/get-message?apiKey=${this.apiKey}&toUser=${this.user}&page=${e}&pageSize=${t}`});if(r.code)throw Error(r.msg);return n&&this.markRead(),r.data}catch(e){throw e}}async markRead(){if(this.user)try{let e=await m({url:`chat/mark-as-read?apiKey=${this.apiKey}&fromUser=${this.user}`});if(e.code)throw Error(e.msg)}catch(e){throw e}}},Z=class{apiKey=``;chats={};constructor(e=``){e&&(this.apiKey=e)}channel(e){return this.chats[e]||(this.chats[e]=new Ce(e,this.apiKey)),this.chats[e]}close(e=``){if(e){var t;(t=this.chats[e])==null||t.close(),delete this.chats[e];return}Object.values(this.chats).forEach(e=>e.close()),this.chats={}}setToken(e){this.apiKey=e,Object.values(this.chats).forEach(t=>t.setToken(e))}async list(){try{let e=await m({url:`chat/get-list?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.data}catch(e){throw e}}async unread(){try{let e=await m({url:`chat/has-unread?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.data}catch(e){throw e}}async revoke(e){try{let t=await m({url:`chat/revoke?apiKey=${this.apiKey}&oId=${e}`});if(t.code)throw Error(t.msg);return t.result}catch(e){throw e}}},Q=class{apiKey=``;constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async list(e=1,t=20){try{let n=await m({url:`api/breezemoons?p=${e}&size=${t}`});if(n.code)throw Error(n.msg);return n.breezemoons.map(e=>A.from(e))}catch(e){throw e}}async listByUser(e,t=1,n=20){try{let r=await m({url:`api/user/${e}/breezemoons?p=${t}&size=${n}&apiKey=${this.apiKey}`});if(r.code)throw Error(r.msg);return j.from(r.data)}catch(e){throw e}}async send(e){try{let t=await m({url:`breezemoon`,method:`post`,data:{apiKey:this.apiKey,breezemoonContent:e}});if(t.code)throw Error(t.msg)}catch(e){throw e}}},we=class{goldFingerKey=``;constructor(e){e&&(this.goldFingerKey=e)}setFinger(e){this.goldFingerKey=e}async addMofishScore({userName:e,stage:t,time:n=new Date().getTime()}){let r;try{if(r=await m({url:`api/games/mofish/score`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,stage:t,time:n}}),r.code)throw Error(r.msg)}catch(e){throw e}}async queryLatestLoginIP(e){let t;try{if(t=await m({url:`user/query/latest-login-iP`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.code)throw Error(t.msg);return t.data}catch(e){throw e}}async addMetal(e,t){let n;t=new R(t);try{if(n=await m({url:`user/edit/give-metal`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,...t,attr:t.attr.toString()}}),n.code)throw Error(n.msg)}catch(e){throw e}}async deleteMetal(e,t){let n;try{if(n=await m({url:`user/edit/remove-metal`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,name:t}}),n.code)throw Error(n.msg)}catch(e){throw e}}async deleteMetalByUserId(e,t){let n;try{if(n=await m({url:`user/edit/remove-metal-by-user-id`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userId:e,name:t}}),n.code)throw Error(n.msg)}catch(e){throw e}}async queryUserBag(e){let t;try{if(t=await m({url:`user/query/items`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.code)throw Error(t.msg);return t.data}catch(e){throw e}}async editUserBag(e,t,n){let r;try{if(r=await m({url:`user/edit/items`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,item:t,sum:n}}),r.code)throw Error(r.msg)}catch(e){throw e}}async editUserPoints(e,t,n){let r;try{if(r=await m({url:`user/edit/points`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,point:t,memo:n}}),r.code)throw Error(r.msg)}catch(e){throw e}}async getLiveness(e){let t;try{if(t=await m({url:`user/liveness`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.code!==0)throw Error(t.msg);return t.liveness}catch(e){throw e}}async getYesterDayLivenessReward(e){let t;try{return t=await m({url:`activity/yesterday-liveness-reward-api`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.sum}catch(e){throw e}}},$=class{apiKey=``;chatroom=new W;notice=new G;emoji=new K;account=new q;article=new J;comment=new X;breezemoon=new Q;chat=new Z;constructor(e=``){e&&this.setToken(e)}async setToken(e){this.apiKey=e,this.chatroom.setToken(this.apiKey),this.notice.setToken(this.apiKey),this.emoji.setToken(this.apiKey),this.account.setToken(this.apiKey),this.article.setToken(this.apiKey),this.comment.setToken(this.apiKey),this.breezemoon.setToken(this.apiKey),this.chat.setToken(this.apiKey)}async setDomain(e){ee(e)}async login(e){try{let n=await m({url:`api/getKey`,method:`post`,data:{nameOrEmail:e.username,userPassword:(0,t.default)(e.passwd),mfaCode:e.mfaCode}});if(n.code!=0)throw Error(n.msg);return this.setToken(n.Key),n.Key}catch(e){throw e}}async preRegister(e){try{let t=await m({url:`register`,method:`post`,data:{userName:e.username,userPhone:e.phone,invitecode:e.invitecode,captcha:e.captcha}});if(t.code!=0)throw Error(t.msg)}catch(e){throw e}}async verify(e){try{let t=await m({url:`verify?code=`+e,method:`get`});if(t.code!=0)throw Error(t.msg);return t.userId}catch(e){throw e}}async register(e){try{let n=await m({url:`register2${e.r?`?r=${e.r}`:``}`,method:`post`,data:{userAppRole:e.role,userPassword:(0,t.default)(e.passwd),userId:e.userId}});if(n.code!=0)throw Error(n.msg)}catch(e){throw e}}async user(e){try{let t=await m({url:`user/${e}${this.apiKey?`?apiKey=${this.apiKey}`:``}`});return t.code&&t.code!==0?void 0:I.from(t)}catch(e){throw e}}async userPoints(e){try{let t=await m({url:`user/${e}/point`});return t.code&&t.code!==0?0:t.data.userPoint}catch(e){throw e}}async userByoId(e){try{let t=await m({url:`api/user/getInfoById?userId=${e}`});return t.code&&t.code!==0?void 0:{...t.data,oId:e}}catch(e){throw e}}async names(e){let t;try{return t=await m({url:`users/names`,method:`post`,data:{name:e}}),t.data||[]}catch(e){throw e}}async recentRegister(){let e;try{return e=await m({url:`api/user/recentReg`,method:`get`}),e.data||[]}catch(e){throw e}}async vipInfo(e){let t;try{if(t=await m({url:`api/membership/${e}`,method:`get`}),t.code!=0)throw Error(t.msg);return t.data.config&&(t.data.config=JSON.parse(t.data.config)),V.from(t.data)}catch(e){throw e}}async report(e){try{let t=await m({url:`report`,method:`post`,data:{apiKey:this.apiKey,...e}});if(t.code!=0)throw Error(t.msg);return t}catch(e){throw e}}async log({page:e=1,pageSize:t=30}){try{let n=await m({url:`/logs/more?page=${e}&pageSize=${t}`,method:`get`});if(n.code!=0)throw Error(n.msg);return n.data}catch(e){throw e}}async upload(e){let t;if(_)t=new FormData,e.forEach(e=>t.append(`file[]`,e));else{let n=await import(`form-data`).then(e=>e.default),r=await import(`fs`),i=await import(`path`);t=new n,e.forEach(e=>t.append(`file[]`,r.readFileSync(e.toString()),i.basename(e.toString())))}t.append(`apiKey`,this.apiKey);let n;try{if(n=await m({url:`upload`,method:`post`,data:t,headers:_?void 0:t.getHeaders()}),n.code!=0)throw Error(n.msg);return n.data}catch(e){throw e}}generateAuthURL(e){let t=new URL(e).origin;return`https://${p}/openid/login?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.return_to=${encodeURIComponent(e)}&openid.realm=${encodeURIComponent(t)}&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select`}async authVerify(e){let t={"openid.ns":`http://specs.openid.net/auth/2.0`,"openid.mode":`check_authentication`,"openid.op_endpoint":e[`openid.op_endpoint`],"openid.return_to":e[`openid.return_to`],"openid.identity":e[`openid.identity`],"openid.claimed_id":e[`openid.claimed_id`],"openid.response_nonce":e[`openid.response_nonce`],"openid.assoc_handle":e[`openid.assoc_handle`],"openid.sig":e[`openid.sig`]},n;try{if(n=await m({url:`openid/verify`,method:`post`,data:t}),n.includes(`is_valid:true`)){var r;let t=(r=e[`openid.claimed_id`])==null?void 0:r.split(`/`).pop();return t?await this.userByoId(t):void 0}else return}catch(e){throw e}}};function Te(e){return new we(e)}return e.Account=ve,e.Article=J,e.ArticleChannel=Y,e.ArticleComment=O,e.ArticleDetail=D,e.ArticleList=k,e.ArticleListType=ie,e.ArticlePost=y,e.ArticleStatus=w,e.ArticleTag=T,e.ArticleType=x,e.AtUser=de,e.Author=E,e.Breezemoon=Q,e.BreezemoonContent=A,e.BreezemoonList=j,e.Chat=Z,e.ChatContentType=N,e.ChatMessageType=P,e.ChatRoom=W,e.ChatRoomMessageType=se,e.ChatRoomSource=oe,e.ClientType=M,e.Comment=X,e.CommentPost=b,e.DataType=ge,e.Emoji=K,e.Finger=we,e.FingerTo=Te,e.FishPi=$,e.default=$,e.GestureType=ce,e.Metal=ue,e.MetalAttr=L,e.MetalBase=R,e.MoFishGame=fe,e.Notice=G,e.NoticeCommandType=he,e.NoticeType=me,e.Pagination=H,e.PreRegisterInfo=ye,e.PublicStatus=re,e.RedPacketType=F,e.Redpacket=le,e.RegisterInfo=be,e.Report=xe,e.ReportDataType=B,e.ReportType=_e,e.User=q,e.UserAppRole=z,e.UserBagType=pe,e.UserInfo=I,e.UserVIP=V,e.VoteStatus=S,e.VoteType=ae,e.YesNoStatus=C,e})({},js_md5,ws,events,reconnecting_websocket);
1
+ var FishPi=(function(exports){Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__commonJSMin=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),__copyProps=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=__getOwnPropNames(t),a=0,o=i.length,s;a<o;a++)s=i[a],!__hasOwnProp.call(e,s)&&s!==n&&__defProp(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=__getOwnPropDesc(t,s))||r.enumerable});return e},__toESM=(e,t,n)=>(n=e==null?{}:__create(__getProtoOf(e)),__copyProps(t||!e||!e.__esModule?__defProp(n,`default`,{value:e,enumerable:!0}):n,e)),require_md5=__commonJSMin(((exports,module)=>{
2
+ /**
3
+ * [js-md5]{@link https://github.com/emn178/js-md5}
4
+ *
5
+ * @namespace md5
6
+ * @version 0.7.3
7
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
8
+ * @copyright Chen, Yi-Cyuan 2014-2017
9
+ * @license MIT
10
+ */
11
+ (function(){"use strict";var ERROR=`input is invalid type`,WINDOW=typeof window==`object`,root=WINDOW?window:{};root.JS_MD5_NO_WINDOW&&(WINDOW=!1);var WEB_WORKER=!WINDOW&&typeof self==`object`,NODE_JS=!root.JS_MD5_NO_NODE_JS&&typeof process==`object`&&process.versions&&process.versions.node;NODE_JS?root=global:WEB_WORKER&&(root=self);var COMMON_JS=!root.JS_MD5_NO_COMMON_JS&&typeof module==`object`&&module.exports,AMD=typeof define==`function`&&define.amd,ARRAY_BUFFER=!root.JS_MD5_NO_ARRAY_BUFFER&&typeof ArrayBuffer<`u`,HEX_CHARS=`0123456789abcdef`.split(``),EXTRA=[128,32768,8388608,-2147483648],SHIFT=[0,8,16,24],OUTPUT_TYPES=[`hex`,`array`,`digest`,`buffer`,`arrayBuffer`,`base64`],BASE64_ENCODE_CHAR=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),blocks=[],buffer8;if(ARRAY_BUFFER){var buffer=new ArrayBuffer(68);buffer8=new Uint8Array(buffer),blocks=new Uint32Array(buffer)}(root.JS_MD5_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(e){return Object.prototype.toString.call(e)===`[object Array]`}),ARRAY_BUFFER&&(root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(e){return typeof e==`object`&&e.buffer&&e.buffer.constructor===ArrayBuffer});var createOutputMethod=function(e){return function(t){return new Md5(!0).update(t)[e]()}},createMethod=function(){var e=createOutputMethod(`hex`);NODE_JS&&(e=nodeWrap(e)),e.create=function(){return new Md5},e.update=function(t){return e.create().update(t)};for(var t=0;t<OUTPUT_TYPES.length;++t){var n=OUTPUT_TYPES[t];e[n]=createOutputMethod(n)}return e},nodeWrap=function(method){var crypto=eval(`require('crypto')`),Buffer=eval(`require('buffer').Buffer`),nodeMethod=function(e){if(typeof e==`string`)return crypto.createHash(`md5`).update(e,`utf8`).digest(`hex`);if(e==null)throw ERROR;return e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),Array.isArray(e)||ArrayBuffer.isView(e)||e.constructor===Buffer?crypto.createHash(`md5`).update(new Buffer(e)).digest(`hex`):method(e)};return nodeMethod};function Md5(e){if(e)blocks[0]=blocks[16]=blocks[1]=blocks[2]=blocks[3]=blocks[4]=blocks[5]=blocks[6]=blocks[7]=blocks[8]=blocks[9]=blocks[10]=blocks[11]=blocks[12]=blocks[13]=blocks[14]=blocks[15]=0,this.blocks=blocks,this.buffer8=buffer8;else if(ARRAY_BUFFER){var t=new ArrayBuffer(68);this.buffer8=new Uint8Array(t),this.blocks=new Uint32Array(t)}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=this.h1=this.h2=this.h3=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}Md5.prototype.update=function(e){if(!this.finalized){var t,n=typeof e;if(n!==`string`){if(n===`object`){if(e===null)throw ERROR;if(ARRAY_BUFFER&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!ARRAY_BUFFER||!ArrayBuffer.isView(e)))throw ERROR}else throw ERROR;t=!0}for(var r,i=0,a,o=e.length,s=this.blocks,c=this.buffer8;i<o;){if(this.hashed&&(this.hashed=!1,s[0]=s[16],s[16]=s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=0),t)if(ARRAY_BUFFER)for(a=this.start;i<o&&a<64;++i)c[a++]=e[i];else for(a=this.start;i<o&&a<64;++i)s[a>>2]|=e[i]<<SHIFT[a++&3];else if(ARRAY_BUFFER)for(a=this.start;i<o&&a<64;++i)r=e.charCodeAt(i),r<128?c[a++]=r:r<2048?(c[a++]=192|r>>6,c[a++]=128|r&63):r<55296||r>=57344?(c[a++]=224|r>>12,c[a++]=128|r>>6&63,c[a++]=128|r&63):(r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023),c[a++]=240|r>>18,c[a++]=128|r>>12&63,c[a++]=128|r>>6&63,c[a++]=128|r&63);else for(a=this.start;i<o&&a<64;++i)r=e.charCodeAt(i),r<128?s[a>>2]|=r<<SHIFT[a++&3]:r<2048?(s[a>>2]|=(192|r>>6)<<SHIFT[a++&3],s[a>>2]|=(128|r&63)<<SHIFT[a++&3]):r<55296||r>=57344?(s[a>>2]|=(224|r>>12)<<SHIFT[a++&3],s[a>>2]|=(128|r>>6&63)<<SHIFT[a++&3],s[a>>2]|=(128|r&63)<<SHIFT[a++&3]):(r=65536+((r&1023)<<10|e.charCodeAt(++i)&1023),s[a>>2]|=(240|r>>18)<<SHIFT[a++&3],s[a>>2]|=(128|r>>12&63)<<SHIFT[a++&3],s[a>>2]|=(128|r>>6&63)<<SHIFT[a++&3],s[a>>2]|=(128|r&63)<<SHIFT[a++&3]);this.lastByteIndex=a,this.bytes+=a-this.start,a>=64?(this.start=a-64,this.hash(),this.hashed=!0):this.start=a}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes%=4294967296),this}},Md5.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex;e[t>>2]|=EXTRA[t&3],t>=56&&(this.hashed||this.hash(),e[0]=e[16],e[16]=e[1]=e[2]=e[3]=e[4]=e[5]=e[6]=e[7]=e[8]=e[9]=e[10]=e[11]=e[12]=e[13]=e[14]=e[15]=0),e[14]=this.bytes<<3,e[15]=this.hBytes<<3|this.bytes>>>29,this.hash()}},Md5.prototype.hash=function(){var e,t,n,r,i,a,o=this.blocks;this.first?(e=o[0]-680876937,e=(e<<7|e>>>25)-271733879<<0,r=(-1732584194^e&2004318071)+o[1]-117830708,r=(r<<12|r>>>20)+e<<0,n=(-271733879^r&(e^-271733879))+o[2]-1126478375,n=(n<<17|n>>>15)+r<<0,t=(e^n&(r^e))+o[3]-1316259209,t=(t<<22|t>>>10)+n<<0):(e=this.h0,t=this.h1,n=this.h2,r=this.h3,e+=(r^t&(n^r))+o[0]-680876936,e=(e<<7|e>>>25)+t<<0,r+=(n^e&(t^n))+o[1]-389564586,r=(r<<12|r>>>20)+e<<0,n+=(t^r&(e^t))+o[2]+606105819,n=(n<<17|n>>>15)+r<<0,t+=(e^n&(r^e))+o[3]-1044525330,t=(t<<22|t>>>10)+n<<0),e+=(r^t&(n^r))+o[4]-176418897,e=(e<<7|e>>>25)+t<<0,r+=(n^e&(t^n))+o[5]+1200080426,r=(r<<12|r>>>20)+e<<0,n+=(t^r&(e^t))+o[6]-1473231341,n=(n<<17|n>>>15)+r<<0,t+=(e^n&(r^e))+o[7]-45705983,t=(t<<22|t>>>10)+n<<0,e+=(r^t&(n^r))+o[8]+1770035416,e=(e<<7|e>>>25)+t<<0,r+=(n^e&(t^n))+o[9]-1958414417,r=(r<<12|r>>>20)+e<<0,n+=(t^r&(e^t))+o[10]-42063,n=(n<<17|n>>>15)+r<<0,t+=(e^n&(r^e))+o[11]-1990404162,t=(t<<22|t>>>10)+n<<0,e+=(r^t&(n^r))+o[12]+1804603682,e=(e<<7|e>>>25)+t<<0,r+=(n^e&(t^n))+o[13]-40341101,r=(r<<12|r>>>20)+e<<0,n+=(t^r&(e^t))+o[14]-1502002290,n=(n<<17|n>>>15)+r<<0,t+=(e^n&(r^e))+o[15]+1236535329,t=(t<<22|t>>>10)+n<<0,e+=(n^r&(t^n))+o[1]-165796510,e=(e<<5|e>>>27)+t<<0,r+=(t^n&(e^t))+o[6]-1069501632,r=(r<<9|r>>>23)+e<<0,n+=(e^t&(r^e))+o[11]+643717713,n=(n<<14|n>>>18)+r<<0,t+=(r^e&(n^r))+o[0]-373897302,t=(t<<20|t>>>12)+n<<0,e+=(n^r&(t^n))+o[5]-701558691,e=(e<<5|e>>>27)+t<<0,r+=(t^n&(e^t))+o[10]+38016083,r=(r<<9|r>>>23)+e<<0,n+=(e^t&(r^e))+o[15]-660478335,n=(n<<14|n>>>18)+r<<0,t+=(r^e&(n^r))+o[4]-405537848,t=(t<<20|t>>>12)+n<<0,e+=(n^r&(t^n))+o[9]+568446438,e=(e<<5|e>>>27)+t<<0,r+=(t^n&(e^t))+o[14]-1019803690,r=(r<<9|r>>>23)+e<<0,n+=(e^t&(r^e))+o[3]-187363961,n=(n<<14|n>>>18)+r<<0,t+=(r^e&(n^r))+o[8]+1163531501,t=(t<<20|t>>>12)+n<<0,e+=(n^r&(t^n))+o[13]-1444681467,e=(e<<5|e>>>27)+t<<0,r+=(t^n&(e^t))+o[2]-51403784,r=(r<<9|r>>>23)+e<<0,n+=(e^t&(r^e))+o[7]+1735328473,n=(n<<14|n>>>18)+r<<0,t+=(r^e&(n^r))+o[12]-1926607734,t=(t<<20|t>>>12)+n<<0,i=t^n,e+=(i^r)+o[5]-378558,e=(e<<4|e>>>28)+t<<0,r+=(i^e)+o[8]-2022574463,r=(r<<11|r>>>21)+e<<0,a=r^e,n+=(a^t)+o[11]+1839030562,n=(n<<16|n>>>16)+r<<0,t+=(a^n)+o[14]-35309556,t=(t<<23|t>>>9)+n<<0,i=t^n,e+=(i^r)+o[1]-1530992060,e=(e<<4|e>>>28)+t<<0,r+=(i^e)+o[4]+1272893353,r=(r<<11|r>>>21)+e<<0,a=r^e,n+=(a^t)+o[7]-155497632,n=(n<<16|n>>>16)+r<<0,t+=(a^n)+o[10]-1094730640,t=(t<<23|t>>>9)+n<<0,i=t^n,e+=(i^r)+o[13]+681279174,e=(e<<4|e>>>28)+t<<0,r+=(i^e)+o[0]-358537222,r=(r<<11|r>>>21)+e<<0,a=r^e,n+=(a^t)+o[3]-722521979,n=(n<<16|n>>>16)+r<<0,t+=(a^n)+o[6]+76029189,t=(t<<23|t>>>9)+n<<0,i=t^n,e+=(i^r)+o[9]-640364487,e=(e<<4|e>>>28)+t<<0,r+=(i^e)+o[12]-421815835,r=(r<<11|r>>>21)+e<<0,a=r^e,n+=(a^t)+o[15]+530742520,n=(n<<16|n>>>16)+r<<0,t+=(a^n)+o[2]-995338651,t=(t<<23|t>>>9)+n<<0,e+=(n^(t|~r))+o[0]-198630844,e=(e<<6|e>>>26)+t<<0,r+=(t^(e|~n))+o[7]+1126891415,r=(r<<10|r>>>22)+e<<0,n+=(e^(r|~t))+o[14]-1416354905,n=(n<<15|n>>>17)+r<<0,t+=(r^(n|~e))+o[5]-57434055,t=(t<<21|t>>>11)+n<<0,e+=(n^(t|~r))+o[12]+1700485571,e=(e<<6|e>>>26)+t<<0,r+=(t^(e|~n))+o[3]-1894986606,r=(r<<10|r>>>22)+e<<0,n+=(e^(r|~t))+o[10]-1051523,n=(n<<15|n>>>17)+r<<0,t+=(r^(n|~e))+o[1]-2054922799,t=(t<<21|t>>>11)+n<<0,e+=(n^(t|~r))+o[8]+1873313359,e=(e<<6|e>>>26)+t<<0,r+=(t^(e|~n))+o[15]-30611744,r=(r<<10|r>>>22)+e<<0,n+=(e^(r|~t))+o[6]-1560198380,n=(n<<15|n>>>17)+r<<0,t+=(r^(n|~e))+o[13]+1309151649,t=(t<<21|t>>>11)+n<<0,e+=(n^(t|~r))+o[4]-145523070,e=(e<<6|e>>>26)+t<<0,r+=(t^(e|~n))+o[11]-1120210379,r=(r<<10|r>>>22)+e<<0,n+=(e^(r|~t))+o[2]+718787259,n=(n<<15|n>>>17)+r<<0,t+=(r^(n|~e))+o[9]-343485551,t=(t<<21|t>>>11)+n<<0,this.first?(this.h0=e+1732584193<<0,this.h1=t-271733879<<0,this.h2=n-1732584194<<0,this.h3=r+271733878<<0,this.first=!1):(this.h0=this.h0+e<<0,this.h1=this.h1+t<<0,this.h2=this.h2+n<<0,this.h3=this.h3+r<<0)},Md5.prototype.hex=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3;return HEX_CHARS[e>>4&15]+HEX_CHARS[e&15]+HEX_CHARS[e>>12&15]+HEX_CHARS[e>>8&15]+HEX_CHARS[e>>20&15]+HEX_CHARS[e>>16&15]+HEX_CHARS[e>>28&15]+HEX_CHARS[e>>24&15]+HEX_CHARS[t>>4&15]+HEX_CHARS[t&15]+HEX_CHARS[t>>12&15]+HEX_CHARS[t>>8&15]+HEX_CHARS[t>>20&15]+HEX_CHARS[t>>16&15]+HEX_CHARS[t>>28&15]+HEX_CHARS[t>>24&15]+HEX_CHARS[n>>4&15]+HEX_CHARS[n&15]+HEX_CHARS[n>>12&15]+HEX_CHARS[n>>8&15]+HEX_CHARS[n>>20&15]+HEX_CHARS[n>>16&15]+HEX_CHARS[n>>28&15]+HEX_CHARS[n>>24&15]+HEX_CHARS[r>>4&15]+HEX_CHARS[r&15]+HEX_CHARS[r>>12&15]+HEX_CHARS[r>>8&15]+HEX_CHARS[r>>20&15]+HEX_CHARS[r>>16&15]+HEX_CHARS[r>>28&15]+HEX_CHARS[r>>24&15]},Md5.prototype.toString=Md5.prototype.hex,Md5.prototype.digest=function(){this.finalize();var e=this.h0,t=this.h1,n=this.h2,r=this.h3;return[e&255,e>>8&255,e>>16&255,e>>24&255,t&255,t>>8&255,t>>16&255,t>>24&255,n&255,n>>8&255,n>>16&255,n>>24&255,r&255,r>>8&255,r>>16&255,r>>24&255]},Md5.prototype.array=Md5.prototype.digest,Md5.prototype.arrayBuffer=function(){this.finalize();var e=new ArrayBuffer(16),t=new Uint32Array(e);return t[0]=this.h0,t[1]=this.h1,t[2]=this.h2,t[3]=this.h3,e},Md5.prototype.buffer=Md5.prototype.arrayBuffer,Md5.prototype.base64=function(){for(var e,t,n,r=``,i=this.array(),a=0;a<15;)e=i[a++],t=i[a++],n=i[a++],r+=BASE64_ENCODE_CHAR[e>>>2]+BASE64_ENCODE_CHAR[(e<<4|t>>>4)&63]+BASE64_ENCODE_CHAR[(t<<2|n>>>6)&63]+BASE64_ENCODE_CHAR[n&63];return e=i[a],r+=BASE64_ENCODE_CHAR[e>>>2]+BASE64_ENCODE_CHAR[e<<4&63]+`==`,r};var exports$1=createMethod();COMMON_JS?module.exports=exports$1:(root.md5=exports$1,AMD&&define(function(){return exports$1}))})()})),import_md5=__toESM(require_md5(),1);globalThis.FormData||(globalThis.FormData=require(`form-data`));let domain=`fishpi.cn`;function setDomain(e){domain=e}async function request(e){let{url:t,method:n=`get`,headers:r={},data:i}=e;isBrowse||(r[`User-Agent`]=`Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36`,r.Referer=`https://${domain}/`);let a;a=i instanceof FormData?i:JSON.stringify(i);let o={method:n,headers:r,body:a},s;try{return s=fetch(`https://${domain}/${t}`,o).then(e=>e.text()).then(e=>{try{return JSON.parse(e)}catch{return e}}),s}catch(e){if(e.response.status===401)return e.response;throw e}}function analyzeMetalAttr(e){if(!e||typeof e.attr!=`string`)return e;let t=e.attr.split(`&`);return e.attr={src:e.attr},t.forEach(t=>e.attr[t.split(`=`)[0]]=t.split(`=`)[1]),e.url=`https://${domain}/gen?txt=${e.description}&url=${e.attr.src}`,e.icon=`https://${domain}/gen?txt=&${e.attr.src}`,e}function toMetal(e){try{let t=JSON.parse(e);return t.list.forEach((e,t,n)=>{n[t]=analyzeMetalAttr(e)}),t.list}catch{return[]}}function clientToVia(e){if(!e)return;let t=e.split(`/`);return{client:t[0],version:t[1]}}const isBrowse=typeof window<`u`;let WebSocket$1=isBrowse?window.WebSocket:require(`ws`).WebSocket;var BrowserEventEmitter=class{listeners=new Map;on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),this}off(e,t){let n=this.listeners.get(e);if(n){let e=n.indexOf(t);e>-1&&n.splice(e,1)}return this}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n),this}emit(e,...t){let n=this.listeners.get(e);return n&&n.forEach(e=>e(...t)),this}removeAllListeners(e){return e?this.listeners.delete(e):this.listeners.clear(),this}};let EventEmitter=BrowserEventEmitter;isBrowse||import(`events`).then(e=>{EventEmitter=e.EventEmitter});var ArticlePost=class e{title=``;content=``;tags=``;commentable=!0;isNotifyFollowers=!1;type=ArticleType.Normal;isShowInList=!0;rewardContent;rewardPoint;isAnonymous;offerPoint;static from(t){return Object.assign(new e,t)}toJson(){return{articleTitle:this.title,articleContent:this.content,articleTags:this.tags,articleCommentable:this.commentable,articleNotifyFollowers:this.isNotifyFollowers,articleType:this.type,articleShowInList:this.isShowInList?1:0,articleRewardContent:this.rewardContent,articleRewardPoint:this.rewardPoint,articleAnonymous:this.isAnonymous,articleQnAOfferPoint:this.offerPoint}}},CommentPost=class e{articleId=``;isAnonymous=!1;isVisible=!0;content=``;originalId;static from(t){return Object.assign(new e,t)}toJson(){return{articleId:this.articleId,commentAnonymous:this.isAnonymous?1:0,commentVisible:this.isVisible?1:0,commentContent:this.content,commentOriginalCommentId:this.originalId}}};let ArticleType=function(e){return e[e.Normal=0]=`Normal`,e[e.Private=1]=`Private`,e[e.Broadcast=2]=`Broadcast`,e[e.Thought=3]=`Thought`,e[e.Question=5]=`Question`,e}({}),PublicStatus=function(e){return e[e.Public=0]=`Public`,e[e.Private=1]=`Private`,e}({}),VoteStatus=function(e){return e[e.normal=-1]=`normal`,e[e.up=0]=`up`,e[e.down=1]=`down`,e}({}),YesNoStatus=function(e){return e[e.Yes=0]=`Yes`,e[e.No=1]=`No`,e}({}),ArticleStatus=function(e){return e[e.Normal=0]=`Normal`,e[e.Ban=1]=`Ban`,e[e.Lock=2]=`Lock`,e}({}),ArticleListType=function(e){return e.Recent=``,e.Hot=`/hot`,e.Good=`/good`,e.Reply=`/reply`,e.Perfect=`/perfact`,e}({}),VoteType=function(e){return e[e.Voted=0]=`Voted`,e[e.Unvote=-1]=`Unvote`,e}({});var ArticleTag=class e{oId=``;title=``;description=``;iconPath=``;URI=``;CSS=``;badCnt=0;commentCount=0;followerCount=0;goodCnt=0;referenceCount=0;linkCount=0;seoDesc=``;seoKeywords=``;seoTitle=``;ad=``;isShowSideAd=!0;status=1;static from(t){let n=new e;return n.oId=t.oId,n.title=t.tagTitle,n.description=t.tagDescription,n.iconPath=t.tagIconPath,n.URI=t.tagURI,n.CSS=t.tagCSS,n.badCnt=t.tagBadCnt,n.commentCount=t.tagCommentCount,n.followerCount=t.tagFollowerCount,n.goodCnt=t.tagGoodCnt,n.referenceCount=t.tagReferenceCount,n.linkCount=t.tagLinkCount,n.seoDesc=t.tagSeoDesc,n.seoKeywords=t.tagSeoKeywords,n.seoTitle=t.tagSeoTitle,n.ad=t.tagAd,n.isShowSideAd=t.tagShowSideAd==1,n.status=t.tagStatus,n}},Author=class e{online=!1;onlineMinute=0;tags=``;timezone=``;URL=``;latestArticleTime=0;nickname=``;appRole=0;status=0;province=``;currentCheckinStreak=0;userNo=0;avatarURL=``;language=``;usedPoint=0;points=0;commentCount=0;intro=``;oId=``;userName=``;articleCount=0;role=``;sysMetal;mbti=``;static from(t){let n=new e;return n.online=t.userOnlineFlag,n.onlineMinute=t.onlineMinute,n.tags=t.userTags,n.timezone=t.userTimezone,n.URL=t.userURL,n.latestArticleTime=t.userLatestArticleTime,n.nickname=t.userNickname,n.appRole=t.userAppRole,n.status=t.userStatus,n.province=t.userProvince,n.currentCheckinStreak=t.userCurrentCheckinStreak,n.userNo=t.userNo,n.avatarURL=t.userAvatarURL,n.language=t.userLanguage,n.usedPoint=t.userUsedPoint,n.points=t.userPoint,n.commentCount=t.userCommentCount,n.intro=t.userIntro,n.oId=t.oId,n.userName=t.userName,n.articleCount=t.userArticleCount,n.role=t.userRole,t.sysMetal&&(n.sysMetal=t.sysMetal),n.mbti=t.mbti,n}},ArticleDetail=class e{isShowInList=!0;authorId=``;badCnt=0;latestCmtTime=``;goodCnt=0;offerPoint=0;thumbnailURL=``;stickRemains=0;timeAgo=``;updateTime=``;authorName=``;type=ArticleType.Normal;isOffered=!1;createTime=``;viewCount=0;authorThumbnail20=``;watchCnt=0;previewContent=``;titleEmoj=``;titleEmojUnicode=``;title=``;authorThumbnail48=``;collectCnt=0;latestCmter=``;tagsContent=``;oId=``;cmtTimeAgo=``;stick=0;tags=[];isAnonymous=!1;thankCnt=0;status=ArticleStatus.Normal;heat=0;isPerfect=!1;authorThumbnail210=``;permalink=``;author=new Author;thankedCnt=0;anonymousView=0;viewCntDisplay=``;commentable=!0;isRewarded=!1;rewardedCnt=0;rewardPoint=0;isFollowing=!1;isWatching=!1;isMyArticle=!1;isThanked=!1;audioURL=``;tableOfContents=``;content=``;originalContent=``;img1URL=``;vote=VoteStatus.normal;authorIntro=``;city=``;authorURL=``;rewardContent=``;pagination;discussionViewable=!0;revisionCount=0;comments;niceComments;static from(t){var n;let r=new e;return r.isShowInList=t.articleShowInList,r.authorId=t.articleAuthorId,r.badCnt=t.articleBadCnt,r.goodCnt=t.articleGoodCnt,r.offerPoint=t.articleQnAOfferPoint,r.thumbnailURL=t.articleThumbnailURL,r.stickRemains=t.articleStickRemains,r.timeAgo=t.timeAgo,r.updateTime=t.articleUpdateTimeStr,r.authorName=t.articleAuthorName,r.type=t.articleType,r.isOffered=t.articleQnAOfferPoint>0,r.createTime=t.articleCreateTimeStr,r.viewCount=t.articleViewCount,r.authorThumbnail20=t.articleAuthorThumbnailURL20,r.watchCnt=t.articleWatchCnt,r.previewContent=t.articlePreviewContent,r.titleEmoj=t.articleTitleEmoj,r.titleEmojUnicode=t.articleTitleEmojUnicode,r.title=t.articleTitle,r.authorThumbnail48=t.articleAuthorThumbnailURL48,r.collectCnt=t.articleCollectCnt,r.latestCmter=t.articleLatestCmterName,r.tagsContent=t.articleTags,r.oId=t.oId,r.cmtTimeAgo=t.cmtTimeAgo,r.stick=t.articleStick,r.tags=((n=t.articleTagObjs)==null?void 0:n.map(e=>ArticleTag.from(e)))||[],r.latestCmtTime=t.articleLatestCmtTimeStr,r.isAnonymous=t.articleAnonymous,r.thankCnt=t.articleThankCnt,r.status=t.articleStatus,r.heat=t.articleHeat,r.isPerfect=t.articlePerfect,r.authorThumbnail210=t.articleAuthorThumbnailURL210,r.permalink=t.articlePermalink,t.articleAuthor&&(r.author=Author.from(t.articleAuthor)),r.thankedCnt=t.thankedCnt,r.anonymousView=t.articleAnonymousView,r.viewCntDisplay=t.articleViewCntDisplayFormat,r.commentable=t.articleCommentable,r.isRewarded=t.rewarded,r.rewardedCnt=t.rewardedCnt,r.rewardPoint=t.articleRewardPoint,r.isFollowing=t.isFollowing,r.isWatching=t.isWatching,r.isMyArticle=t.isMyArticle,r.isThanked=t.thanked,r.audioURL=t.articleAudioURL,r.tableOfContents=t.articleToC,r.content=t.articleContent,r.originalContent=t.articleOriginalContent,r.img1URL=t.articleImg1URL,r.vote=t.articleVote,r.authorIntro=t.articleAuthorIntro,r.city=t.articleCity,r.authorURL=t.articleAuthorURL,r.rewardContent=t.articleRewardContent,t.pagination&&(r.pagination=Pagination.from(t.pagination)),r.discussionViewable=t.discussionViewable,r.revisionCount=t.articleRevisionCount,r.comments=t.articleComments?t.articleComments.map(e=>ArticleComment.from(e)):void 0,r.niceComments=t.articleNiceComments?t.articleNiceComments.map(e=>ArticleComment.from(e)):void 0,r}},ArticleComment=class e{isNice=!1;createTime=``;authorId=``;score=0;authorURL=``;vote=VoteStatus.normal;revisionCount=0;timeAgo=``;originalId=``;sysMetal=[];goodCnt=0;visible=YesNoStatus.Yes;articleId=``;rewardedCnt=0;sharpURL=``;isAnonymous=!1;replyCnt=0;oId=``;content=``;status=ArticleStatus.Normal;commenter=new Author;authorName=``;thankCnt=0;badCnt=0;rewarded=!1;authorThumbnailURL=``;audioURL=``;isOffered=!1;static from(t){let n=new e;return n.isNice=t.commentNice,n.createTime=t.commentCreateTimeStr,n.authorId=t.commentAuthorId,n.score=t.commentScore,n.authorURL=t.commentAuthorURL,n.vote=t.commentVote,n.revisionCount=t.commentRevisionCount,n.timeAgo=t.timeAgo,n.originalId=t.commentOriginalCommentId,t.sysMetal&&(n.sysMetal=t.sysMetal),n.goodCnt=t.commentGoodCnt,n.visible=t.commentVisible,n.articleId=t.commentOnArticleId,n.rewardedCnt=t.rewardedCnt,n.sharpURL=t.commentSharpURL,n.isAnonymous=t.commentAnonymous,n.replyCnt=t.commentReplyCnt,n.oId=t.oId,n.content=t.commentContent,n.status=t.commentStatus,t.commenter&&(n.commenter=Author.from(t.commenter)),n.authorName=t.commentAuthorName,n.thankCnt=t.commentThankCnt,n.badCnt=t.commentBadCnt,n.rewarded=t.rewarded,n.authorThumbnailURL=t.commentAuthorThumbnailURL,n.audioURL=t.commentAudioURL,n.isOffered=t.commentQnAOffered==1,n}},ArticleList=class e{articles=[];pagination=new Pagination;tag;static from(t){let n=new e;return n.articles=t.articles.map(e=>ArticleDetail.from(e)),n.pagination=Pagination.from(t.pagination),t.tag&&(n.tag=ArticleTag.from(t.tag)),n}},BreezemoonContent=class e{authorName=``;updatedAt=``;oId=``;createAt=``;authorThumbnail=``;timeAgo=``;content=``;city=``;static from(t){let n=new e;return n.authorName=t.breezemoonAuthorName,n.updatedAt=t.breezemoonUpdated,n.oId=t.oId,n.createAt=t.breezemoonCreated,n.authorThumbnail=t.breezemoonAuthorThumbnailURL48,n.timeAgo=t.timeAgo,n.content=t.breezemoonContent,n.city=t.breezemoonCity,n}},BreezemoonList=class e{pagination=new Pagination;breezemoons=[];static from(t){let n=new e;return n.pagination=t.pagination,n.breezemoons=t.breezemoons.map(e=>BreezemoonContent.from(e)),n}};let ClientType=function(e){return e.Web=`Web`,e.PC=`PC`,e.Mobile=`Mobile`,e.Windows=`Windows`,e.macOS=`macOS`,e.Linux=`Linux`,e.iOS=`iOS`,e.Android=`Android`,e.IDEA=`IDEA`,e.Chrome=`Chrome`,e.Edge=`Edge`,e.VSCode=`VSCode`,e.Python=`Python`,e.Golang=`Golang`,e.Rust=`Rust`,e.Harmony=`Harmony`,e.CLI=`CLI`,e.Bird=`Bird`,e.IceNet=`IceNet`,e.ElvesOnline=`ElvesOnline`,e.Other=`Other`,e}({});var ChatRoomSource=class{client=ClientType.Other;version=`latest`};let ChatContentType=function(e){return e.Markdown=`md`,e.HTML=`html`,e}({}),ChatMessageType=function(e){return e[e.Context=0]=`Context`,e[e.Before=1]=`Before`,e[e.After=2]=`After`,e}({}),ChatRoomMessageType=function(e){return e.online=`online`,e.discussChanged=`discussChanged`,e.revoke=`revoke`,e.msg=`msg`,e.redPacket=`redPacket`,e.redPacketStatus=`redPacketStatus`,e.barrager=`barrager`,e.custom=`customMessage`,e}({}),GestureType=function(e){return e[e.Rock=0]=`Rock`,e[e.Scissors=1]=`Scissors`,e[e.Paper=2]=`Paper`,e}({}),RedPacketType=function(e){return e.Random=`random`,e.Average=`average`,e.Specify=`specify`,e.Heartbeat=`heartbeat`,e.RockPaperScissors=`rockPaperScissors`,e}({});var Redpacket=class{type=RedPacketType.Random;money=32;count=1;msg=`摸鱼者,事竟成`;recivers;gesture},UserInfo=class e{oId=``;userNo=``;userName=``;userNickname=``;URL=``;city=``;intro=``;online=!1;points=0;role=``;appRole=UserAppRole.Hack;avatar=``;cardBg=``;following=0;follower=0;onlineMinute=0;canFollow=`hide`;ownedMetal=[];sysMetal=[];mbti=``;get name(){return this.userNickname?`${this.userNickname}(${this.userName})`:this.userName}static from(t){let n=new e;return n.oId=t.oId,n.userNo=t.userNo,n.userName=t.userName,n.userNickname=t.userNickname,n.URL=t.userURL,n.city=t.userCity,n.intro=t.userIntro,n.online=t.userOnlineFlag,n.points=t.userPoint,n.role=t.userRole,n.appRole=t.userAppRole,n.avatar=t.userAvatarURL,n.cardBg=t.cardBg,n.following=t.followingUserCount,n.follower=t.followerCount,n.onlineMinute=t.onlineMinute,n.canFollow=t.canFollow,n.ownedMetal=toMetal(t.allMetalOwned),n.sysMetal=toMetal(t.sysMetal),n.mbti=t.mbti,n}},MetalAttr=class{url=``;backcolor=``;fontcolor=``;ver=.1;scale=.79;toString(){return`url=${this.url}&backcolor=${this.backcolor}&fontcolor=${this.fontcolor}&ver=${this.ver}&scale=${this.scale}`}},MetalBase=class{attr=new MetalAttr;name=``;description=``;data=``;constructor(e){e&&(this.attr=Object.assign(new MetalAttr,e.attr),this.name=e.name,this.description=e.description,this.data=e.data)}toUrl(e=!0){let t=`https://${domain}/gen?txt=${this.name}&${this.attr.toString()}`;return e||(t=`https://${domain}/gen?txt=&${this.attr.toString()}`),t}},Metal=class extends MetalBase{url;icon;enable=!0},AtUser=class{userName=``;userAvatarURL=``;userNameLowerCase=``},MoFishGame=class{userName=``;stage=``;time=0};let UserBagType=function(e){return e[e.checkin1day=0]=`checkin1day`,e[e.checkin2days=1]=`checkin2days`,e[e.patchCheckinCard=2]=`patchCheckinCard`,e[e.metalTicket=3]=`metalTicket`,e}({}),NoticeType=function(e){return e.Point=`point`,e.Comment=`commented`,e.Reply=`reply`,e.At=`at`,e.Following=`following`,e.Broadcast=`broadcast`,e.System=`sys-announce`,e}({}),NoticeCommandType=function(e){return e.RefreshNotification=`refreshNotification`,e.ChatUnreadCountRefresh=`chatUnreadCountRefresh`,e.NewIdleChatMessage=`newIdleChatMessage`,e.WarnBroadcast=`warnBroadcast`,e.bzUpdate=`bzUpdate`,e}({}),DataType=function(e){return e[e.article=0]=`article`,e[e.comment=1]=`comment`,e[e.at=2]=`at`,e[e.commented=3]=`commented`,e[e.followingUser=4]=`followingUser`,e[e.pointCharge=5]=`pointCharge`,e[e.pointTransfer=6]=`pointTransfer`,e[e.pointArticleReward=7]=`pointArticleReward`,e[e.pointCommentThank=8]=`pointCommentThank`,e[e.broadcast=9]=`broadcast`,e[e.pointExchange=10]=`pointExchange`,e[e.abusePointDeduct=11]=`abusePointDeduct`,e[e.pointArticleThank=12]=`pointArticleThank`,e[e.reply=13]=`reply`,e[e.invitecodeUsed=14]=`invitecodeUsed`,e[e.sysAnnounceArticle=15]=`sysAnnounceArticle`,e[e.sysAnnounceNewUser=16]=`sysAnnounceNewUser`,e[e.newFollower=17]=`newFollower`,e[e.invitationLinkUsed=18]=`invitationLinkUsed`,e[e.sysAnnounceRoleChanged=19]=`sysAnnounceRoleChanged`,e[e.followingArticleUpdate=20]=`followingArticleUpdate`,e[e.followingArticleComment=21]=`followingArticleComment`,e[e.pointPerfectArticle=22]=`pointPerfectArticle`,e[e.articleNewFollower=23]=`articleNewFollower`,e[e.articleNewWatcher=24]=`articleNewWatcher`,e[e.commentVoteUp=25]=`commentVoteUp`,e[e.commentVoteDown=26]=`commentVoteDown`,e[e.articleVoteUp=27]=`articleVoteUp`,e[e.articleVoteDown=28]=`articleVoteDown`,e[e.pointCommentAccept=33]=`pointCommentAccept`,e[e.pointReportHandled=36]=`pointReportHandled`,e[e.chatRoomAt=38]=`chatRoomAt`,e[e.redPacket=39]=`redPacket`,e}({}),UserAppRole=function(e){return e[e.Hack=0]=`Hack`,e[e.Artist=1]=`Artist`,e}({}),ReportDataType=function(e){return e[e.article=0]=`article`,e[e.comment=1]=`comment`,e[e.user=2]=`user`,e[e.chatroom=3]=`chatroom`,e}({}),ReportType=function(e){return e[e.advertise=0]=`advertise`,e[e.porn=1]=`porn`,e[e.violate=2]=`violate`,e[e.infringement=3]=`infringement`,e[e.attacks=4]=`attacks`,e[e.impersonate=5]=`impersonate`,e[e.advertisingAccount=6]=`advertisingAccount`,e[e.leakPrivacy=7]=`leakPrivacy`,e[e.other=8]=`other`,e}({});var Account=class{username=``;passwd=``;mfaCode=``},PreRegisterInfo=class{username=``;phone=``;invitecode;captcha=``},RegisterInfo=class{role=``;passwd=``;userId=``;r},Report=class{reportDataId=``;reportDataType=ReportDataType.article;reportType=ReportType.advertise;reportMemo=``},UserVIP=class e{oId=``;state=0;userId=``;jointVip=!1;color=``;underline=!1;metal=!1;autoCheckin=0;bold=!1;lvCode=``;expiresAt=0;createdAt=0;updatedAt=0;get isVip(){return this.state===1&&this.expiresAt*1e3>=Date.now()}get vipName(){return this.isVip?this.lvCode.replace(/_YEAR/,`(包年)`).replace(/_MONTH/,`(包月)`):`非会员`}get expireDate(){return new Date(this.expiresAt)}get createDate(){return new Date(this.createdAt)}get updateDate(){return new Date(this.updatedAt)}static from(t){var n,r,i,a,o,s;let c=new e;return c.oId=t.oId||``,c.state=t.state||0,c.userId=t.userId||``,c.jointVip=((n=t.config)==null?void 0:n.jointVip)||!1,c.color=((r=t.config)==null?void 0:r.color)||``,c.underline=((i=t.config)==null?void 0:i.underline)||!1,c.metal=((a=t.config)==null?void 0:a.metal)||!1,c.autoCheckin=((o=t.config)==null?void 0:o.autoCheckin)||0,c.bold=((s=t.config)==null?void 0:s.bold)||!1,c.lvCode=t.lvCode||``,c.expiresAt=t.expiresAt||0,c.createdAt=t.createdAt||0,c.updatedAt=t.updatedAt||0,c}},Pagination=class e{pageCount=0;pageNums=[];static from(t){let n=new e;return n.pageCount=t.paginationPageCount,n.pageNums=t.paginationPageNums,n}},require_reconnecting_websocket_cjs=__commonJSMin(((e,t)=>{
12
+ /*! *****************************************************************************
13
+ Copyright (c) Microsoft Corporation. All rights reserved.
14
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
15
+ this file except in compliance with the License. You may obtain a copy of the
16
+ License at http://www.apache.org/licenses/LICENSE-2.0
17
+
18
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
20
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
21
+ MERCHANTABLITY OR NON-INFRINGEMENT.
22
+
23
+ See the Apache Version 2.0 License for specific language governing permissions
24
+ and limitations under the License.
25
+ ***************************************************************************** */
26
+ var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},n(e,t)};function r(e,t){n(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function i(e){var t=typeof Symbol==`function`&&e[Symbol.iterator],n=0;return t?t.call(e):{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}}}function a(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function o(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(a(arguments[t]));return e}var s=function(){function e(e,t){this.target=t,this.type=e}return e}(),c=function(e){r(t,e);function t(t,n){var r=e.call(this,`error`,n)||this;return r.message=t.message,r.error=t,r}return t}(s),l=function(e){r(t,e);function t(t,n,r){t===void 0&&(t=1e3),n===void 0&&(n=``);var i=e.call(this,`close`,r)||this;return i.wasClean=!0,i.code=t,i.reason=n,i}return t}(s),u=function(){if(typeof WebSocket<`u`)return WebSocket},d=function(e){return e!==void 0&&!!e&&e.CLOSING===2},f={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0,startClosed:!1,debug:!1};t.exports=function(){function e(e,t,n){var r=this;n===void 0&&(n={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType=`blob`,this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(e){r._debug(`open event`);var t=r._options.minUptime,n=t===void 0?f.minUptime:t;clearTimeout(r._connectTimeout),r._uptimeTimeout=setTimeout(function(){return r._acceptOpen()},n),r._ws.binaryType=r._binaryType,r._messageQueue.forEach(function(e){return r._ws.send(e)}),r._messageQueue=[],r.onopen&&r.onopen(e),r._listeners.open.forEach(function(t){return r._callEventListener(e,t)})},this._handleMessage=function(e){r._debug(`message event`),r.onmessage&&r.onmessage(e),r._listeners.message.forEach(function(t){return r._callEventListener(e,t)})},this._handleError=function(e){r._debug(`error event`,e.message),r._disconnect(void 0,e.message===`TIMEOUT`?`timeout`:void 0),r.onerror&&r.onerror(e),r._debug(`exec error listeners`),r._listeners.error.forEach(function(t){return r._callEventListener(e,t)}),r._connect()},this._handleClose=function(e){r._debug(`close event`),r._clearTimeouts(),r._shouldReconnect&&r._connect(),r.onclose&&r.onclose(e),r._listeners.close.forEach(function(t){return r._callEventListener(e,t)})},this._url=e,this._protocols=t,this._options=n,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,`CONNECTING`,{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,`OPEN`,{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,`CLOSING`,{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,`CLOSED`,{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`CONNECTING`,{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`OPEN`,{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`CLOSING`,{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`CLOSED`,{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`binaryType`,{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(e){this._binaryType=e,this._ws&&(this._ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`retryCount`,{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`bufferedAmount`,{get:function(){return this._messageQueue.reduce(function(e,t){return typeof t==`string`?e+=t.length:t instanceof Blob?e+=t.size:e+=t.byteLength,e},0)+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`extensions`,{get:function(){return this._ws?this._ws.extensions:``},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`protocol`,{get:function(){return this._ws?this._ws.protocol:``},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`readyState`,{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,`url`,{get:function(){return this._ws?this._ws.url:``},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){if(e===void 0&&(e=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug(`close enqueued: no ws instance`);return}if(this._ws.readyState===this.CLOSED){this._debug(`close: already closed`);return}this._ws.close(e,t)},e.prototype.reconnect=function(e,t){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED||this._disconnect(e,t),this._connect()},e.prototype.send=function(e){if(this._ws&&this._ws.readyState===this.OPEN)this._debug(`send`,e),this._ws.send(e);else{var t=this._options.maxEnqueuedMessages,n=t===void 0?f.maxEnqueuedMessages:t;this._messageQueue.length<n&&(this._debug(`enqueue`,e),this._messageQueue.push(e))}},e.prototype.addEventListener=function(e,t){this._listeners[e]&&this._listeners[e].push(t)},e.prototype.dispatchEvent=function(e){var t,n,r=this._listeners[e.type];if(r)try{for(var a=i(r),o=a.next();!o.done;o=a.next()){var s=o.value;this._callEventListener(e,s)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return!0},e.prototype.removeEventListener=function(e,t){this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter(function(e){return e!==t}))},e.prototype._debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._options.debug&&console.log.apply(console,o([`RWS>`],e))},e.prototype._getNextDelay=function(){var e=this._options,t=e.reconnectionDelayGrowFactor,n=t===void 0?f.reconnectionDelayGrowFactor:t,r=e.minReconnectionDelay,i=r===void 0?f.minReconnectionDelay:r,a=e.maxReconnectionDelay,o=a===void 0?f.maxReconnectionDelay:a,s=0;return this._retryCount>0&&(s=i*n**(this._retryCount-1),s>o&&(s=o)),this._debug(`next delay`,s),s},e.prototype._wait=function(){var e=this;return new Promise(function(t){setTimeout(t,e._getNextDelay())})},e.prototype._getNextUrl=function(e){if(typeof e==`string`)return Promise.resolve(e);if(typeof e==`function`){var t=e();if(typeof t==`string`)return Promise.resolve(t);if(t.then)return t}throw Error(`Invalid URL`)},e.prototype._connect=function(){var e=this;if(!(this._connectLock||!this._shouldReconnect)){this._connectLock=!0;var t=this._options,n=t.maxRetries,r=n===void 0?f.maxRetries:n,i=t.connectionTimeout,a=i===void 0?f.connectionTimeout:i,o=t.WebSocket,s=o===void 0?u():o;if(this._retryCount>=r){this._debug(`max retries reached`,this._retryCount,`>=`,r);return}if(this._retryCount++,this._debug(`connect`,this._retryCount),this._removeListeners(),!d(s))throw Error(`No valid WebSocket class provided`);this._wait().then(function(){return e._getNextUrl(e._url)}).then(function(t){e._closeCalled||(e._debug(`connect`,{url:t,protocols:e._protocols}),e._ws=e._protocols?new s(t,e._protocols):new s(t),e._ws.binaryType=e._binaryType,e._connectLock=!1,e._addListeners(),e._connectTimeout=setTimeout(function(){return e._handleTimeout()},a))})}},e.prototype._handleTimeout=function(){this._debug(`timeout event`),this._handleError(new c(Error(`TIMEOUT`),this))},e.prototype._disconnect=function(e,t){if(e===void 0&&(e=1e3),this._clearTimeouts(),this._ws){this._removeListeners();try{this._ws.close(e,t),this._handleClose(new l(e,t,this))}catch{}}},e.prototype._acceptOpen=function(){this._debug(`accept open`),this._retryCount=0},e.prototype._callEventListener=function(e,t){`handleEvent`in t?t.handleEvent(e):t(e)},e.prototype._removeListeners=function(){this._ws&&(this._debug(`removeListeners`),this._ws.removeEventListener(`open`,this._handleOpen),this._ws.removeEventListener(`close`,this._handleClose),this._ws.removeEventListener(`message`,this._handleMessage),this._ws.removeEventListener(`error`,this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug(`addListeners`),this._ws.addEventListener(`open`,this._handleOpen),this._ws.addEventListener(`close`,this._handleClose),this._ws.addEventListener(`message`,this._handleMessage),this._ws.addEventListener(`error`,this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}()})),import_reconnecting_websocket_cjs=__toESM(require_reconnecting_websocket_cjs(),1),WsEventBase=class{emitter=new EventEmitter;ws=null;rwsOptions={minReconnectionDelay:1e4,maxReconnectionDelay:6e5,reconnectionDelayGrowFactor:1.3,maxRetries:100,connectionTimeout:1e4};constructor(){}reconnect(){return this.ws?new Promise(e=>{!this.ws||this.ws.readyState===WebSocket$1.CONNECTING||(this.ws.reconnect(),this.ws.onopen=t=>{e(this.ws)})}):this.connect()}connect(e=!1){return new Promise(async(t,n)=>this.ws&&!e?t(this.ws):(this.ws&&this.ws.close(),n(Error(`请在子类中实现 connect 方法`))))}on(e,t){return(this.ws==null||this.ws.readyState!==WebSocket$1.OPEN)&&this.connect(),this.emitter.on(e,t)}off(e,t){return e?t?this.emitter.off(e,t):this.emitter.removeAllListeners(e):this.emitter.removeAllListeners()}once(e,t){return this.emitter.once(e,t)}clearListener(e){this.emitter.removeAllListeners(e)}removeListener(e,t){return this.off(e,t)}addListener(e,t){return this.on(e,t)}},ChatRoom=class extends WsEventBase{apiKey=``;_discusse=``;_onlines=[];wsTimer=null;client=ClientType.Other;version=`Latest`;constructor(e=``){super(),e&&(this.apiKey=e)}get onlines(){return this._onlines}get discusse(){return this._discusse}set discusse(e){this.send(`[setdiscuss]${e}[/setdiscuss]`).catch(()=>{})}setToken(e){this.apiKey=e,this.redpacket.setToken(e)}setVia(e,t){this.client=e,this.version=t}async history(e=1,t=ChatContentType.HTML){try{let n=await request({url:`chat-room/more?page=${e}&type=${t}&apiKey=${this.apiKey}`});if(n.code!=0)throw Error(n.msg);return n.data?(n.data.forEach((e,t,n)=>{try{n[t].type=`msg`,n[t].md=n[t].content,n[t].via=clientToVia(n[t].client),n[t].sysMetal=toMetal(n[t].sysMetal),n[t].content=JSON.parse(e.content),n[t].content.recivers&&(n[t].content.recivers=JSON.parse(n[t].content.recivers)),n[t].type=n[t].content.msgType}catch{}}),n.data):n}catch(e){throw e}}async get({oId:e,mode:t=ChatMessageType.Context,size:n=25,type:r=ChatContentType.HTML}){try{let i=await request({url:`chat-room/getMessage?oId=${e}&mode=${t}&size=${n}&type=${r}&apiKey=${this.apiKey}`});if(i.code!=0)throw Error(i.msg);if(!i.data)return i;let a;return i.data.forEach((e,t,n)=>{try{if(n[t].via=clientToVia(n[t].client),n[t].sysMetal=toMetal(n[t].sysMetal),a=JSON.parse(e.content),a.msgType!==`redPacket`)return i;a.recivers&&(a.recivers=JSON.parse(a.recivers)),n[t].content=a}catch{}}),i.data}catch(e){throw e}}async revoke(e){let t;try{if(t=await request({url:`chat-room/revoke/${e}`,method:`delete`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async send(e,t,n){let r;try{if(r=await request({url:`chat-room/send`,method:`post`,data:{content:e,client:`${t||this.client}/${n||this.version}`,apiKey:this.apiKey}}),r.code)throw Error(r.msg)}catch(e){throw e}}async barrage(e,t=`#ffffff`){let n;try{if(n=await request({url:`chat-room/send`,method:`post`,data:{content:`[barrager]{\"color\":\"${t}\",\"content\":\"${e}\"}[/barrager]`,apiKey:this.apiKey}}),n.code)throw Error(n.msg)}catch(e){throw e}}async barragePay(){let e;try{if(e=await request({url:`chat-room/barrager/get?apiKey=${this.apiKey}`,method:`get`}),e.code!=0)throw Error(e.msg);let t=e.data.match(/([-0-9]+)(.+)/);return t?{cost:parseInt(t[1]),unit:t[2]}:{cost:20,unit:`积分`}}catch(e){throw e}}async mutes(){let e;try{if(e=await request({url:`chat-room/si-guo-list`,method:`get`}),e.code)throw Error(e.msg);return e.data}catch(e){throw e}}async raw(e){let t;try{if(t=await request({url:`cr/raw/${e}`}),t.code)throw Error(t.msg);return t.replace(/<!--.*?-->/g,``)}catch(e){throw e}}redpacket=new RedPacket(this,this.apiKey);async getNode(){let e;try{var t;if(e=await request({url:`chat-room/node/get?apiKey=${this.apiKey}`,method:`get`}),e.code!=0)throw Error(`获取节点失败:`+e.msg);return{recommend:{node:e.data,name:e.msg,online:((t=e.avaliable.find(t=>t.node===e.data))==null?void 0:t.online)||0},avaliable:e.avaliable}}catch(e){throw e}}async connect(e,t=10){return new Promise(async n=>{let r=``;if(r=e===void 0||e===``||e===!0?await this.getNode().then(e=>e.recommend.node).catch(()=>`wss://${domain}/chat-room-channel?apiKey=${this.apiKey}`):e,r.includes(`apiKey=`)||(r+=`${r.includes(`?`)?`&`:`?`}apiKey=${this.apiKey}`),this.ws)return n(this.reconnect());this.ws=new import_reconnecting_websocket_cjs.default(r,[],{WebSocket:WebSocket$1,...this.rwsOptions,connectionTimeout:1e3*t}),this.ws.onopen=e=>{this.wsTimer&&clearInterval(this.wsTimer),this.wsTimer=setInterval(()=>{var e;(e=this.ws)==null||e.send(`-hb-`)},1e3*60*3),n(e),this.emitter.emit(`open`,e)},this.ws.onmessage=async e=>{let t=JSON.parse(e.data),n=null;switch(t.type){case`online`:this._onlines=t.users,this._discusse=t.discussing,n=this._onlines;break;case`discussChanged`:n=t.newDiscuss,t.type=`discuss`;break;case`revoke`:n=t.oId;break;case`barrager`:{let{barragerContent:e,userAvatarURL:r,userAvatarURL20:i,userNickname:a,barragerColor:o,userName:s,userAvatarURL210:c,userAvatarURL48:l}=t;n={barragerContent:e,userAvatarURL:r,userAvatarURL20:i,userNickname:a,barragerColor:o,userName:s,userAvatarURL210:c,userAvatarURL48:l};break}case`msg`:{let{userOId:e,oId:r,time:i,userName:a,userNickname:o,userAvatarURL:s,content:c,md:l,client:u}=t;try{let e=JSON.parse(c);[`redPacket`,`music`,`weather`].includes(e.msgType)&&(c=e,t.type=e.msgType)}catch{}n={type:t.type,userOId:e,oId:r,time:i,userName:a,userNickname:o,userAvatarURL:s,content:c,md:l,client:u,via:clientToVia(u)};break}case`redPacketStatus`:{let{oId:e,count:r,got:i,whoGive:a,whoGot:o}=t;n={oId:e,count:r,got:i,whoGive:a,whoGot:o};break}case`customMessage`:n=t.message,t.type=`custom`;break}this.emitter.emit(t.type,n),this.emitter.emit(`all`,n)},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)}})}},RedPacket=class{chatroom;apiKey=``;constructor(e,t){this.chatroom=e,this.apiKey=t}setToken(e){this.apiKey=e}async open(e,t){let n;try{if(n=await request({url:`chat-room/red-packet/open`,method:`post`,data:{oId:e,gesture:t,apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n}catch(e){throw e}}async send(e){return await this.chatroom.send(`[redpacket]${JSON.stringify(e)}[/redpacket]`)}},Notice=class extends WsEventBase{apiKey=``;constructor(e=``){super(),e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async count(){let e;try{if(e=await request({url:`notifications/unread/count?apiKey=${this.apiKey}`}),e.code!==0)throw Error(e.msg);return e.userNotifyStatus&&(e.userNotifyStatus=e.userNotifyStatus!=0),e}catch(e){throw e}}async list(e){let t;try{if(t=await request({url:`api/getNotifications?apiKey=${this.apiKey}&type=${e}`}),t.code!==0)throw Error(t.msg);return t.data.forEach(e=>(!e.description&&e.content&&(e.description=e.content),e)),t.data}catch(e){throw e}}async makeRead(e){let t;try{if(t=await request({url:`notifications/make-read/${e}?apiKey=${this.apiKey}`}),t.code!==0)throw Error(t.msg)}catch(e){throw e}}async readAll(){let e;try{if(e=await request({url:`notifications/all-read?apiKey=${this.apiKey}`}),e.code!==0)throw Error(e.msg)}catch(e){throw e}}reconnect(){return this.ws?new Promise(e=>{this.ws&&(this.ws.reconnect(),this.ws.onopen=t=>{e(this.ws)})}):this.connect()}connect(e=!1){return new Promise(async(t,n)=>{if(this.ws&&!e)return t(this.ws);if(this.ws&&this.ws.close(),!this.apiKey)return n(Error(`请先设置 API Key`));this.ws=new import_reconnecting_websocket_cjs.default(`wss://${domain}/user-channel?apiKey=${this.apiKey}`,[],{WebSocket:WebSocket$1,connectionTimeout:1e4,maxRetries:10}),this.ws.onopen=e=>{t(this.ws)},this.ws.onmessage=async e=>{let t=JSON.parse(e.data);t.command==`bz-update`&&(t={...t.bz,command:`bzUpdate`}),t.command&&this.emitter.emit(t.command,t)},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)}})}},Emoji=class{apiKey=``;emojis=[];constructor(e=``){e&&this.setToken(e)}setToken(e){this.apiKey=e,e&&this.get().then(e=>this.emojis=e).catch(()=>{})}get default(){return{doge:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/doge.png`,trollface:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/trollface.png`,huaji:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/huaji.gif`,octocat:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/octocat.png`,wulian:`https://cdn.jsdelivr.net/npm/vditor@3.8.7/dist/images/emoji/wulian.png`,smile:`https://file.${domain}/emoji/graphics/smile.png`,laughing:`https://file.${domain}/emoji/graphics/laughing.png`,blush:`https://file.${domain}/emoji/graphics/blush.png`,smiley:`https://file.${domain}/emoji/graphics/smiley.png`,relaxed:`https://file.${domain}/emoji/graphics/relaxed.png`,smirk:`https://file.${domain}/emoji/graphics/smirk.png`,heart_eyes:`https://file.${domain}/emoji/graphics/heart_eyes.png`,kissing_heart:`https://file.${domain}/emoji/graphics/kissing_heart.png`,kissing_closed_eyes:`https://file.${domain}/emoji/graphics/kissing_closed_eyes.png`,flushed:`https://file.${domain}/emoji/graphics/flushed.png`,relieved:`https://file.${domain}/emoji/graphics/relieved.png`,satisfied:`https://file.${domain}/emoji/graphics/satisfied.png`,grin:`https://file.${domain}/emoji/graphics/grin.png`,wink:`https://file.${domain}/emoji/graphics/wink.png`,stuck_out_tongue_winking_eye:`https://file.${domain}/emoji/graphics/stuck_out_tongue_winking_eye.png`,stuck_out_tongue_closed_eyes:`https://file.${domain}/emoji/graphics/stuck_out_tongue_closed_eyes.png`,grinning:`https://file.${domain}/emoji/graphics/grinning.png`,kissing:`https://file.${domain}/emoji/graphics/kissing.png`,kissing_smiling_eyes:`https://file.${domain}/emoji/graphics/kissing_smiling_eyes.png`,stuck_out_tongue:`https://file.${domain}/emoji/graphics/stuck_out_tongue.png`,sleeping:`https://file.${domain}/emoji/graphics/sleeping.png`,worried:`https://file.${domain}/emoji/graphics/worried.png`,frowning:`https://file.${domain}/emoji/graphics/frowning.png`,anguished:`https://file.${domain}/emoji/graphics/anguished.png`,open_mouth:`https://file.${domain}/emoji/graphics/open_mouth.png`,grimacing:`https://file.${domain}/emoji/graphics/grimacing.png`,confused:`https://file.${domain}/emoji/graphics/confused.png`,hushed:`https://file.${domain}/emoji/graphics/hushed.png`,expressionless:`https://file.${domain}/emoji/graphics/expressionless.png`,unamused:`https://file.${domain}/emoji/graphics/unamused.png`,sweat_smile:`https://file.${domain}/emoji/graphics/sweat_smile.png`,sweat:`https://file.${domain}/emoji/graphics/sweat.png`,disappointed_relieved:`https://file.${domain}/emoji/graphics/disappointed_relieved.png`,weary:`https://file.${domain}/emoji/graphics/weary.png`,pensive:`https://file.${domain}/emoji/graphics/pensive.png`,disappointed:`https://file.${domain}/emoji/graphics/disappointed.png`,confounded:`https://file.${domain}/emoji/graphics/confounded.png`,fearful:`https://file.${domain}/emoji/graphics/fearful.png`,cold_sweat:`https://file.${domain}/emoji/graphics/cold_sweat.png`,persevere:`https://file.${domain}/emoji/graphics/persevere.png`,cry:`https://file.${domain}/emoji/graphics/cry.png`,sob:`https://file.${domain}/emoji/graphics/sob.png`,joy:`https://file.${domain}/emoji/graphics/joy.png`,astonished:`https://file.${domain}/emoji/graphics/astonished.png`,scream:`https://file.${domain}/emoji/graphics/scream.png`,tired_face:`https://file.${domain}/emoji/graphics/tired_face.png`,angry:`https://file.${domain}/emoji/graphics/angry.png`,rage:`https://file.${domain}/emoji/graphics/rage.png`,triumph:`https://file.${domain}/emoji/graphics/triumph.png`,sleepy:`https://file.${domain}/emoji/graphics/sleepy.png`,yum:`https://file.${domain}/emoji/graphics/yum.png`,mask:`https://file.${domain}/emoji/graphics/mask.png`,sunglasses:`https://file.${domain}/emoji/graphics/sunglasses.png`,dizzy_face:`https://file.${domain}/emoji/graphics/dizzy_face.png`,imp:`https://file.${domain}/emoji/graphics/imp.png`,smiling_imp:`https://file.${domain}/emoji/graphics/smiling_imp.png`,neutral_face:`https://file.${domain}/emoji/graphics/neutral_face.png`,no_mouth:`https://file.${domain}/emoji/graphics/no_mouth.png`,innocent:`https://file.${domain}/emoji/graphics/innocent.png`,alien:`https://file.${domain}/emoji/graphics/alien.png`,yellow_heart:`https://file.${domain}/emoji/graphics/yellow_heart.png`,blue_heart:`https://file.${domain}/emoji/graphics/blue_heart.png`,purple_heart:`https://file.${domain}/emoji/graphics/purple_heart.png`,heart:`https://file.${domain}/emoji/graphics/heart.png`,green_heart:`https://file.${domain}/emoji/graphics/green_heart.png`,broken_heart:`https://file.${domain}/emoji/graphics/broken_heart.png`,heartbeat:`https://file.${domain}/emoji/graphics/heartbeat.png`,heartpulse:`https://file.${domain}/emoji/graphics/heartpulse.png`,two_hearts:`https://file.${domain}/emoji/graphics/two_hearts.png`,revolving_hearts:`https://file.${domain}/emoji/graphics/revolving_hearts.png`,cupid:`https://file.${domain}/emoji/graphics/cupid.png`,sparkling_heart:`https://file.${domain}/emoji/graphics/sparkling_heart.png`,sparkles:`https://file.${domain}/emoji/graphics/sparkles.png`,star:`https://file.${domain}/emoji/graphics/star.png`,star2:`https://file.${domain}/emoji/graphics/star2.png`,dizzy:`https://file.${domain}/emoji/graphics/dizzy.png`,boom:`https://file.${domain}/emoji/graphics/boom.png`,collision:`https://file.${domain}/emoji/graphics/collision.png`,anger:`https://file.${domain}/emoji/graphics/anger.png`,exclamation:`https://file.${domain}/emoji/graphics/exclamation.png`,question:`https://file.${domain}/emoji/graphics/question.png`,grey_exclamation:`https://file.${domain}/emoji/graphics/grey_exclamation.png`,grey_question:`https://file.${domain}/emoji/graphics/grey_question.png`,zzz:`https://file.${domain}/emoji/graphics/zzz.png`,dash:`https://file.${domain}/emoji/graphics/dash.png`,sweat_drops:`https://file.${domain}/emoji/graphics/sweat_drops.png`,notes:`https://file.${domain}/emoji/graphics/notes.png`,musical_note:`https://file.${domain}/emoji/graphics/musical_note.png`,fire:`https://file.${domain}/emoji/graphics/fire.png`,poop:`https://file.${domain}/emoji/graphics/poop.png`,"+1":`https://file.${domain}/emoji/graphics/%2B1.png`,thumbsup:`https://file.${domain}/emoji/graphics/thumbsup.png`,"-1":`https://file.${domain}/emoji/graphics/-1.png`,thumbsdown:`https://file.${domain}/emoji/graphics/thumbsdown.png`,ok_hand:`https://file.${domain}/emoji/graphics/ok_hand.png`,punch:`https://file.${domain}/emoji/graphics/punch.png`,facepunch:`https://file.${domain}/emoji/graphics/facepunch.png`,fist:`https://file.${domain}/emoji/graphics/fist.png`,v:`https://file.${domain}/emoji/graphics/v.png`,wave:`https://file.${domain}/emoji/graphics/wave.png`,hand:`https://file.${domain}/emoji/graphics/hand.png`,raised_hand:`https://file.${domain}/emoji/graphics/raised_hand.png`,open_hands:`https://file.${domain}/emoji/graphics/open_hands.png`,point_up:`https://file.${domain}/emoji/graphics/point_up.png`,point_down:`https://file.${domain}/emoji/graphics/point_down.png`,point_left:`https://file.${domain}/emoji/graphics/point_left.png`,point_right:`https://file.${domain}/emoji/graphics/point_right.png`,raised_hands:`https://file.${domain}/emoji/graphics/raised_hands.png`,pray:`https://file.${domain}/emoji/graphics/pray.png`,point_up_2:`https://file.${domain}/emoji/graphics/point_up_2.png`,clap:`https://file.${domain}/emoji/graphics/clap.png`,muscle:`https://file.${domain}/emoji/graphics/muscle.png`,couple:`https://file.${domain}/emoji/graphics/couple.png`,family:`https://file.${domain}/emoji/graphics/family.png`,two_men_holding_hands:`https://file.${domain}/emoji/graphics/two_men_holding_hands.png`,two_women_holding_hands:`https://file.${domain}/emoji/graphics/two_women_holding_hands.png`,dancer:`https://file.${domain}/emoji/graphics/dancer.png`,dancers:`https://file.${domain}/emoji/graphics/dancers.png`,ok_woman:`https://file.${domain}/emoji/graphics/ok_woman.png`,no_good:`https://file.${domain}/emoji/graphics/no_good.png`,information_desk_person:`https://file.${domain}/emoji/graphics/information_desk_person.png`,raising_hand:`https://file.${domain}/emoji/graphics/raising_hand.png`,bride_with_veil:`https://file.${domain}/emoji/graphics/bride_with_veil.png`,person_with_pouting_face:`https://file.${domain}/emoji/graphics/person_with_pouting_face.png`,person_frowning:`https://file.${domain}/emoji/graphics/person_frowning.png`,bow:`https://file.${domain}/emoji/graphics/bow.png`,couplekiss:`https://file.${domain}/emoji/graphics/couplekiss.png`,couple_with_heart:`https://file.${domain}/emoji/graphics/couple_with_heart.png`,massage:`https://file.${domain}/emoji/graphics/massage.png`,haircut:`https://file.${domain}/emoji/graphics/haircut.png`,nail_care:`https://file.${domain}/emoji/graphics/nail_care.png`,boy:`https://file.${domain}/emoji/graphics/boy.png`,girl:`https://file.${domain}/emoji/graphics/girl.png`,woman:`https://file.${domain}/emoji/graphics/woman.png`,man:`https://file.${domain}/emoji/graphics/man.png`,baby:`https://file.${domain}/emoji/graphics/baby.png`,older_woman:`https://file.${domain}/emoji/graphics/older_woman.png`,older_man:`https://file.${domain}/emoji/graphics/older_man.png`,person_with_blond_hair:`https://file.${domain}/emoji/graphics/person_with_blond_hair.png`,man_with_gua_pi_mao:`https://file.${domain}/emoji/graphics/man_with_gua_pi_mao.png`,man_with_turban:`https://file.${domain}/emoji/graphics/man_with_turban.png`,construction_worker:`https://file.${domain}/emoji/graphics/construction_worker.png`,cop:`https://file.${domain}/emoji/graphics/cop.png`,angel:`https://file.${domain}/emoji/graphics/angel.png`,princess:`https://file.${domain}/emoji/graphics/princess.png`,smiley_cat:`https://file.${domain}/emoji/graphics/smiley_cat.png`,smile_cat:`https://file.${domain}/emoji/graphics/smile_cat.png`,heart_eyes_cat:`https://file.${domain}/emoji/graphics/heart_eyes_cat.png`,kissing_cat:`https://file.${domain}/emoji/graphics/kissing_cat.png`,smirk_cat:`https://file.${domain}/emoji/graphics/smirk_cat.png`,scream_cat:`https://file.${domain}/emoji/graphics/scream_cat.png`,crying_cat_face:`https://file.${domain}/emoji/graphics/crying_cat_face.png`,joy_cat:`https://file.${domain}/emoji/graphics/joy_cat.png`,pouting_cat:`https://file.${domain}/emoji/graphics/pouting_cat.png`,japanese_ogre:`https://file.${domain}/emoji/graphics/japanese_ogre.png`,japanese_goblin:`https://file.${domain}/emoji/graphics/japanese_goblin.png`,see_no_evil:`https://file.${domain}/emoji/graphics/see_no_evil.png`,hear_no_evil:`https://file.${domain}/emoji/graphics/hear_no_evil.png`,speak_no_evil:`https://file.${domain}/emoji/graphics/speak_no_evil.png`,guardsman:`https://file.${domain}/emoji/graphics/guardsman.png`,skull:`https://file.${domain}/emoji/graphics/skull.png`,feet:`https://file.${domain}/emoji/graphics/feet.png`,lips:`https://file.${domain}/emoji/graphics/lips.png`,kiss:`https://file.${domain}/emoji/graphics/kiss.png`,droplet:`https://file.${domain}/emoji/graphics/droplet.png`,ear:`https://file.${domain}/emoji/graphics/ear.png`,eyes:`https://file.${domain}/emoji/graphics/eyes.png`,nose:`https://file.${domain}/emoji/graphics/nose.png`,tongue:`https://file.${domain}/emoji/graphics/tongue.png`,love_letter:`https://file.${domain}/emoji/graphics/love_letter.png`,bust_in_silhouette:`https://file.${domain}/emoji/graphics/bust_in_silhouette.png`,busts_in_silhouette:`https://file.${domain}/emoji/graphics/busts_in_silhouette.png`,speech_balloon:`https://file.${domain}/emoji/graphics/speech_balloon.png`,thought_balloon:`https://file.${domain}/emoji/graphics/thought_balloon.png`}}async get(){let e;try{if(e=await request({url:`api/cloud/get`,method:`post`,data:{gameId:`emojis`,apiKey:this.apiKey}}),e.code)throw Error(e.msg);return this.emojis=JSON.parse(e.data),this.emojis.concat([])}catch(e){throw e}}async set(e){let t;try{if(t=await request({url:`api/cloud/sync`,method:`post`,data:{gameId:`emojis`,data:JSON.stringify(e),apiKey:this.apiKey}}),t.code)throw Error(t.msg);return t}catch(e){throw e}}async append(e){let t=this.emojis.length>0?this.emojis:await this.get();if(t.indexOf(e)>=0)throw Error(`表情包已存在`);return t.push(e),await this.set(t),this.emojis=t,t.concat([])}async remove(e){let t=this.emojis.length>0?this.emojis:await this.get();return t.indexOf(e)<0?t:(t.splice(t.indexOf(e),1),await this.set(t),this.emojis=t,t.concat([]))}async exists(e){return(this.emojis.length>0?this.emojis:await this.get()).indexOf(e)>=0}},User=class{apiKey=``;constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async info(){try{let e=await request({url:`api/user?apiKey=${this.apiKey}`});if(e.code!=0)throw Error(e.msg);return e.data&&(e.data.sysMetal=toMetal(e.data.sysMetal)),UserInfo.from(e.data)}catch(e){throw e}}async emotions(){let e;try{if(e=await request({url:`users/emotions?apiKey=${this.apiKey}`}),e.code!=0)throw Error(e.msg);return e.data=Object.keys(e.data),e.data}catch(e){throw e}}async liveness(){if(!this.apiKey)return 0;try{let e=await request({url:`user/liveness?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.liveness||0}catch(e){throw e}}async isCheckIn(){if(!this.apiKey)return!1;try{let e=await request({url:`user/checkedIn?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.checkedIn||!1}catch(e){throw e}}async isCollectedLiveness(){if(!this.apiKey)return!1;try{let e=await request({url:`api/activity/is-collected-liveness?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.isCollectedYesterdayLivenessReward||!1}catch(e){throw e}}async rewardLiveness(){if(!this.apiKey)return 0;try{let e=await request({url:`activity/yesterday-liveness-reward-api?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.sum||0}catch(e){throw e}}async transfer(e,t,n){try{let r=await request({method:`POST`,url:`point/transfer`,data:{apiKey:this.apiKey,userName:e,amount:t,memo:n}});if(r.code)throw Error(r.msg)}catch(e){throw e}}async follow(e){let t;try{if(t=await request({url:`follow/user`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async unfollow(e){let t;try{if(t=await request({url:`unfollow/user`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async updateUserAvatar(e){let t;try{if(t=await request({url:`api/settings/avatar`,method:`post`,data:{apiKey:this.apiKey,userAvatarURL:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async updateUserInfo(e){let t;try{if(t=await request({url:`api/settings/profiles`,method:`post`,data:{apiKey:this.apiKey,...e}}),t.code)throw Error(t.msg)}catch(e){throw e}}},Article=class{apiKey=``;channels={};constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async post(e){let t;try{if(t=await request({url:`article`,method:`post`,data:{...ArticlePost.from(e).toJson(),apiKey:this.apiKey}}),t.code)throw Error(t.msg);return t.articleId}catch(e){throw e}}async update(e,t){let n;try{if(n=await request({url:`article/${e}`,method:`put`,data:{...ArticlePost.from(t).toJson(),apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.articleId}catch(e){throw e}}async list({type:e,page:t=1,size:n=20,tag:r}){let i;try{if(i=await request({url:`api/articles/${r?`tag/${r}`:`recent`}${e}?p=${t}&size=${n}&${this.apiKey?`apiKey=${this.apiKey}`:``}`}),i.code)throw Error(i.msg);return ArticleList.from(i.data)}catch(e){throw e}}async userArticles({userName:e,page:t=1,size:n=20}){let r;try{if(r=await request({url:`api/user/${e}/articles?p=${t}&size=${n}&${this.apiKey?`apiKey=${this.apiKey}`:``}`}),r.code)throw Error(r.msg);return ArticleList.from(r.data)}catch(e){throw e}}async detail(e,t=1){let n;try{if(n=await request({url:`api/article/${e}?apiKey=${this.apiKey}&p=${t}`}),n.code)throw Error(n.msg);return ArticleDetail.from(n.data.article)}catch(e){throw e}}async vote(e,t){let n;try{if(n=await request({url:`vote/${t}/article`,method:`post`,data:{dataId:e,apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.type}catch(e){throw e}}async thank(e){let t;try{if(t=await request({url:`article/thank?articleId=${e}`,method:`post`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async follow(e){let t;try{if(t=await request({url:`follow/article`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async unfollow(e){let t;try{if(t=await request({url:`unfollow/article`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async watch(e){let t;try{if(t=await request({url:`follow/article-watch`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async unwatch(e){let t;try{if(t=await request({url:`unfollow/article-watch`,method:`post`,data:{apiKey:this.apiKey,followingId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async reward(e){let t;try{if(t=await request({url:`article/reward?articleId=${e}`,method:`post`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async heat(e){let t;try{if(t=await request({url:`api/article/heat/${e}?apiKey=${this.apiKey}`,method:`get`}),t.code)throw Error(t.msg);return t.articleHeat}catch(e){throw e}}async md(e){let t;try{if(t=await request({url:`api/article/md/${e}?apiKey=${this.apiKey}`}),t.code)throw Error(t.msg);return t}catch(e){throw e}}channel(e,t){return this.channels[e]||(this.channels[e]=new ArticleChannel(this.apiKey,e,t)),this.channels[e]}},ArticleChannel=class extends WsEventBase{apiKey=``;id=``;type=ArticleType.Normal;constructor(e,t,n){super(),e&&(this.apiKey=e)}async connect(e){return new Promise(async(t,n)=>this.ws&&!e?t(this.ws):(this.ws&&this.ws.close(),this.apiKey?(this.ws=new import_reconnecting_websocket_cjs.default(`wss://${domain}/article-channel?articleId=${this.id}&articleType=${this.type}&apiKey=${this.apiKey}`,[],{WebSocket:WebSocket$1,connectionTimeout:1e4}),this.ws.onopen=e=>{this.emitter.emit(`open`,e)},this.ws.onmessage=e=>{let t=JSON.parse(e.data);t.type===`articleHeat`?this.emitter.emit(`heat`,t.data):this.emitter.emit(t.type,ArticleComment.from(t.data))},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)},this.ws):n(Error(`请先设置 API Key`))))}},Comment=class{apiKey=``;constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async send(e){let t;try{if(t=await request({url:`comment`,method:`post`,data:{...CommentPost.from(e).toJson(),apiKey:this.apiKey}}),t.code)throw Error(t.msg)}catch(e){throw e}}async update(e,t){let n;try{if(n=await request({url:`comment/${e}`,method:`put`,data:{...CommentPost.from(t).toJson(),apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.commentContent}catch(e){throw e}}async vote(e,t){let n;try{if(n=await request({url:`vote/${t}/comment`,method:`post`,data:{dataId:e,apiKey:this.apiKey}}),n.code)throw Error(n.msg);return n.type}catch(e){throw e}}async thank(e){let t;try{if(t=await request({url:`comment/thank`,method:`post`,data:{apiKey:this.apiKey,commentId:e}}),t.code)throw Error(t.msg)}catch(e){throw e}}async remove(e){let t;try{if(t=await request({url:`comment/${e}/remove`,method:`post`,data:{apiKey:this.apiKey}}),t.code)throw Error(t.msg);return t.commentId}catch(e){throw e}}},ChatChannel=class extends WsEventBase{apiKey=``;user=``;constructor(e,t){super(),this.apiKey=t,this.user=e}setToken(e){this.apiKey=e,this.connect(!0)}connect(e=!1){return new Promise(async(t,n)=>{if(this.ws&&!e)return t(this.ws);if(this.ws&&this.ws.close(),!this.user)return n(Error(`请先设置私聊用户名`));if(!this.apiKey)return n(Error(`请先设置 API Key`));this.ws=new import_reconnecting_websocket_cjs.default(`wss://${domain}/chat-channel?apiKey=${this.apiKey}&toUser=${this.user}`,[],{WebSocket:WebSocket$1,connectionTimeout:1e4}),this.ws.onopen=e=>{t(this.ws)},this.ws.onmessage=async e=>{let t=JSON.parse(e.data),n=`data`;t.type==`revoke`&&(n=`revoke`,t=t.data),this.emitter.emit(n,t)},this.ws.onerror=e=>{this.emitter.emit(`error`,e)},this.ws.onclose=e=>{this.emitter.emit(`close`,e)}})}async send(e){var t;this.ws==null&&await this.connect(),this.user&&((t=this.ws)==null||t.send(e))}close(){var e;(e=this.ws)==null||e.close()}async get({page:e=1,size:t=20,autoRead:n=!0}){if(!this.user)return[];try{let r=await request({url:`chat/get-message?apiKey=${this.apiKey}&toUser=${this.user}&page=${e}&pageSize=${t}`});if(r.code)throw Error(r.msg);return n&&this.markRead(),r.data}catch(e){throw e}}async markRead(){if(this.user)try{let e=await request({url:`chat/mark-as-read?apiKey=${this.apiKey}&fromUser=${this.user}`});if(e.code)throw Error(e.msg)}catch(e){throw e}}},Chat=class{apiKey=``;chats={};constructor(e=``){e&&(this.apiKey=e)}channel(e){return this.chats[e]||(this.chats[e]=new ChatChannel(e,this.apiKey)),this.chats[e]}close(e=``){if(e){var t;(t=this.chats[e])==null||t.close(),delete this.chats[e];return}Object.values(this.chats).forEach(e=>e.close()),this.chats={}}setToken(e){this.apiKey=e,Object.values(this.chats).forEach(t=>t.setToken(e))}async list(){try{let e=await request({url:`chat/get-list?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.data}catch(e){throw e}}async unread(){try{let e=await request({url:`chat/has-unread?apiKey=${this.apiKey}`});if(e.code)throw Error(e.msg);return e.data}catch(e){throw e}}async revoke(e){try{let t=await request({url:`chat/revoke?apiKey=${this.apiKey}&oId=${e}`});if(t.code)throw Error(t.msg);return t.result}catch(e){throw e}}},Breezemoon=class{apiKey=``;constructor(e=``){e&&(this.apiKey=e)}setToken(e){this.apiKey=e}async list(e=1,t=20){try{let n=await request({url:`api/breezemoons?p=${e}&size=${t}`});if(n.code)throw Error(n.msg);return n.breezemoons.map(e=>BreezemoonContent.from(e))}catch(e){throw e}}async listByUser(e,t=1,n=20){try{let r=await request({url:`api/user/${e}/breezemoons?p=${t}&size=${n}&apiKey=${this.apiKey}`});if(r.code)throw Error(r.msg);return BreezemoonList.from(r.data)}catch(e){throw e}}async send(e){try{let t=await request({url:`breezemoon`,method:`post`,data:{apiKey:this.apiKey,breezemoonContent:e}});if(t.code)throw Error(t.msg)}catch(e){throw e}}},Finger=class{goldFingerKey=``;constructor(e){e&&(this.goldFingerKey=e)}setFinger(e){this.goldFingerKey=e}async addMofishScore({userName:e,stage:t,time:n=new Date().getTime()}){let r;try{if(r=await request({url:`api/games/mofish/score`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,stage:t,time:n}}),r.code)throw Error(r.msg)}catch(e){throw e}}async queryLatestLoginIP(e){let t;try{if(t=await request({url:`user/query/latest-login-iP`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.code)throw Error(t.msg);return t.data}catch(e){throw e}}async addMetal(e,t){let n;t=new MetalBase(t);try{if(n=await request({url:`user/edit/give-metal`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,...t,attr:t.attr.toString()}}),n.code)throw Error(n.msg)}catch(e){throw e}}async deleteMetal(e,t){let n;try{if(n=await request({url:`user/edit/remove-metal`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,name:t}}),n.code)throw Error(n.msg)}catch(e){throw e}}async deleteMetalByUserId(e,t){let n;try{if(n=await request({url:`user/edit/remove-metal-by-user-id`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userId:e,name:t}}),n.code)throw Error(n.msg)}catch(e){throw e}}async queryUserBag(e){let t;try{if(t=await request({url:`user/query/items`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.code)throw Error(t.msg);return t.data}catch(e){throw e}}async editUserBag(e,t,n){let r;try{if(r=await request({url:`user/edit/items`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,item:t,sum:n}}),r.code)throw Error(r.msg)}catch(e){throw e}}async editUserPoints(e,t,n){let r;try{if(r=await request({url:`user/edit/points`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e,point:t,memo:n}}),r.code)throw Error(r.msg)}catch(e){throw e}}async getLiveness(e){let t;try{if(t=await request({url:`user/liveness`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.code!==0)throw Error(t.msg);return t.liveness}catch(e){throw e}}async getYesterDayLivenessReward(e){let t;try{return t=await request({url:`activity/yesterday-liveness-reward-api`,method:`post`,data:{goldFingerKey:this.goldFingerKey,userName:e}}),t.sum}catch(e){throw e}}},FishPi=class{apiKey=``;chatroom=new ChatRoom;notice=new Notice;emoji=new Emoji;account=new User;article=new Article;comment=new Comment;breezemoon=new Breezemoon;chat=new Chat;constructor(e=``){e&&this.setToken(e)}async setToken(e){this.apiKey=e,this.chatroom.setToken(this.apiKey),this.notice.setToken(this.apiKey),this.emoji.setToken(this.apiKey),this.account.setToken(this.apiKey),this.article.setToken(this.apiKey),this.comment.setToken(this.apiKey),this.breezemoon.setToken(this.apiKey),this.chat.setToken(this.apiKey)}async setDomain(e){setDomain(e)}async login(e){try{let t=await request({url:`api/getKey`,method:`post`,data:{nameOrEmail:e.username,userPassword:(0,import_md5.default)(e.passwd),mfaCode:e.mfaCode}});if(t.code!=0)throw Error(t.msg);return this.setToken(t.Key),t.Key}catch(e){throw e}}async preRegister(e){try{let t=await request({url:`register`,method:`post`,data:{userName:e.username,userPhone:e.phone,invitecode:e.invitecode,captcha:e.captcha}});if(t.code!=0)throw Error(t.msg)}catch(e){throw e}}async verify(e){try{let t=await request({url:`verify?code=`+e,method:`get`});if(t.code!=0)throw Error(t.msg);return t.userId}catch(e){throw e}}async register(e){try{let t=await request({url:`register2${e.r?`?r=${e.r}`:``}`,method:`post`,data:{userAppRole:e.role,userPassword:(0,import_md5.default)(e.passwd),userId:e.userId}});if(t.code!=0)throw Error(t.msg)}catch(e){throw e}}async user(e){try{let t=await request({url:`user/${e}${this.apiKey?`?apiKey=${this.apiKey}`:``}`});return t.code&&t.code!==0?void 0:UserInfo.from(t)}catch(e){throw e}}async userPoints(e){try{let t=await request({url:`user/${e}/point`});return t.code&&t.code!==0?0:t.data.userPoint}catch(e){throw e}}async userByoId(e){try{let t=await request({url:`api/user/getInfoById?userId=${e}`});return t.code&&t.code!==0?void 0:{...t.data,oId:e}}catch(e){throw e}}async names(e){let t;try{return t=await request({url:`users/names`,method:`post`,data:{name:e}}),t.data||[]}catch(e){throw e}}async recentRegister(){let e;try{return e=await request({url:`api/user/recentReg`,method:`get`}),e.data||[]}catch(e){throw e}}async vipInfo(e){let t;try{if(t=await request({url:`api/membership/${e}`,method:`get`}),t.code!=0)throw Error(t.msg);return t.data.config&&(t.data.config=JSON.parse(t.data.config)),UserVIP.from(t.data)}catch(e){throw e}}async report(e){try{let t=await request({url:`report`,method:`post`,data:{apiKey:this.apiKey,...e}});if(t.code!=0)throw Error(t.msg);return t}catch(e){throw e}}async log({page:e=1,pageSize:t=30}){try{let n=await request({url:`/logs/more?page=${e}&pageSize=${t}`,method:`get`});if(n.code!=0)throw Error(n.msg);return n.data}catch(e){throw e}}async upload(e){let t;if(isBrowse)t=new FormData,e.forEach(e=>t.append(`file[]`,e));else{let n=await import(`form-data`).then(e=>e.default),r=await import(`fs`),i=await import(`path`);t=new n,e.forEach(e=>t.append(`file[]`,r.readFileSync(e.toString()),i.basename(e.toString())))}t.append(`apiKey`,this.apiKey);let n;try{if(n=await request({url:`upload`,method:`post`,data:t,headers:isBrowse?void 0:t.getHeaders()}),n.code!=0)throw Error(n.msg);return n.data}catch(e){throw e}}generateAuthURL(e){let t=new URL(e).origin;return`https://${domain}/openid/login?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.return_to=${encodeURIComponent(e)}&openid.realm=${encodeURIComponent(t)}&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select`}async authVerify(e){let t={"openid.ns":`http://specs.openid.net/auth/2.0`,"openid.mode":`check_authentication`,"openid.op_endpoint":e[`openid.op_endpoint`],"openid.return_to":e[`openid.return_to`],"openid.identity":e[`openid.identity`],"openid.claimed_id":e[`openid.claimed_id`],"openid.response_nonce":e[`openid.response_nonce`],"openid.assoc_handle":e[`openid.assoc_handle`],"openid.sig":e[`openid.sig`]},n;try{if(n=await request({url:`openid/verify`,method:`post`,data:t}),n.includes(`is_valid:true`)){var r;let t=(r=e[`openid.claimed_id`])==null?void 0:r.split(`/`).pop();return t?await this.userByoId(t):void 0}else return}catch(e){throw e}}};function FingerTo(e){return new Finger(e)}return exports.Account=Account,exports.Article=Article,exports.ArticleChannel=ArticleChannel,exports.ArticleComment=ArticleComment,exports.ArticleDetail=ArticleDetail,exports.ArticleList=ArticleList,exports.ArticleListType=ArticleListType,exports.ArticlePost=ArticlePost,exports.ArticleStatus=ArticleStatus,exports.ArticleTag=ArticleTag,exports.ArticleType=ArticleType,exports.AtUser=AtUser,exports.Author=Author,exports.Breezemoon=Breezemoon,exports.BreezemoonContent=BreezemoonContent,exports.BreezemoonList=BreezemoonList,exports.Chat=Chat,exports.ChatContentType=ChatContentType,exports.ChatMessageType=ChatMessageType,exports.ChatRoom=ChatRoom,exports.ChatRoomMessageType=ChatRoomMessageType,exports.ChatRoomSource=ChatRoomSource,exports.ClientType=ClientType,exports.Comment=Comment,exports.CommentPost=CommentPost,exports.DataType=DataType,exports.Emoji=Emoji,exports.Finger=Finger,exports.FingerTo=FingerTo,exports.FishPi=FishPi,exports.default=FishPi,exports.GestureType=GestureType,exports.Metal=Metal,exports.MetalAttr=MetalAttr,exports.MetalBase=MetalBase,exports.MoFishGame=MoFishGame,exports.Notice=Notice,exports.NoticeCommandType=NoticeCommandType,exports.NoticeType=NoticeType,exports.Pagination=Pagination,exports.PreRegisterInfo=PreRegisterInfo,exports.PublicStatus=PublicStatus,exports.RedPacketType=RedPacketType,exports.Redpacket=Redpacket,exports.RegisterInfo=RegisterInfo,exports.Report=Report,exports.ReportDataType=ReportDataType,exports.ReportType=ReportType,exports.User=User,exports.UserAppRole=UserAppRole,exports.UserBagType=UserBagType,exports.UserInfo=UserInfo,exports.UserVIP=UserVIP,exports.VoteStatus=VoteStatus,exports.VoteType=VoteType,exports.YesNoStatus=YesNoStatus,exports})({});
package/lib/index.cjs CHANGED
@@ -28,18 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  //#endregion
29
29
  let js_md5 = require("js-md5");
30
30
  js_md5 = __toESM(js_md5);
31
- let ws = require("ws");
32
- ws = __toESM(ws);
33
- let events = require("events");
34
31
  let reconnecting_websocket = require("reconnecting-websocket");
35
32
  reconnecting_websocket = __toESM(reconnecting_websocket);
36
33
 
37
34
  //#region src/utils.ts
38
- if (!globalThis.FormData) import("form-data").then((mod) => {
39
- globalThis.FormData = mod.default;
40
- }).catch((err) => {
41
- console.error("Failed to load form-data module:", err);
42
- });
35
+ if (!globalThis.FormData) globalThis.FormData = require("form-data");
43
36
  let domain = "fishpi.cn";
44
37
  function setDomain(d) {
45
38
  domain = d;
@@ -103,7 +96,7 @@ function clientToVia(client) {
103
96
  };
104
97
  }
105
98
  const isBrowse = typeof window !== "undefined";
106
- const WebSocket = isBrowse ? window.WebSocket : ws.default.WebSocket;
99
+ let WebSocket = isBrowse ? window.WebSocket : require("ws").WebSocket;
107
100
  var BrowserEventEmitter = class {
108
101
  listeners = /* @__PURE__ */ new Map();
109
102
  on(event, listener) {
@@ -138,7 +131,10 @@ var BrowserEventEmitter = class {
138
131
  return this;
139
132
  }
140
133
  };
141
- const EventEmitter = isBrowse ? BrowserEventEmitter : events.EventEmitter;
134
+ let EventEmitter = BrowserEventEmitter;
135
+ if (!isBrowse) import("events").then((mod) => {
136
+ EventEmitter = mod.EventEmitter;
137
+ });
142
138
 
143
139
  //#endregion
144
140
  //#region src/types/article.ts