@polyv/chat 2.1.0-rc-20251023.1 → 2.1.0-rc-20251023.2

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/index.cjs.js CHANGED
@@ -16,4 +16,4 @@
16
16
  *
17
17
  * @author Feross Aboukhadijeh <https://feross.org>
18
18
  * @license MIT
19
- */o.exports=function(e){return e!=null&&(t(e)||function(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&t(r.slice(0,0))}(e)||!!e._isBuffer)}},function(o,a,t){t.r(a),t.d(a,"ChatImageUpload",function(){return st}),t.d(a,"defaultConfig",function(){return ht}),t.d(a,"allowAccept",function(){return Et}),t.d(a,"allowFileExtension",function(){return vt}),t.d(a,"FailError",function(){return rt}),t.d(a,"FailCode",function(){return G}),t.d(a,"ChatImage",function(){return _t}),t.d(a,"ImageStatus",function(){return et}),t(127),t(92),t(63),t(35),t(67),t(135),t(136),t(73);var e=Object.prototype.hasOwnProperty;function r(T,w){return e.call(T,w)}function n(T){if(T==null)throw new TypeError("Cannot convert undefined or null to object");for(var w=0;w<(arguments.length<=1?0:arguments.length-1);w++){var O=w+1<1||arguments.length<=w+1?void 0:arguments[w+1];if(O!=null)for(var M in O)M!=="__proto__"&&r(O,M)&&(T[M]=O[M])}return T}var i=Object.prototype.toString;t(74),t(53),t(151),t(152),t(154);function s(T,w){var O,M,_=n({encode:encodeURIComponent},w),$=[];function L(Q,X){X==null&&(X=""),X===""&&_.ignoreEmpty||(typeof _.encode=="function"&&(Q=_.encode(Q),X=_.encode(String(X))),$.push(Q+"="+X))}function K(Q){L(O,Q)}for(O in T)r(T,O)&&(M=T[O],Array.isArray(M)?M.forEach(K):L(O,M));return $.join("&")}t(116),t(155);function u(T,w,O){if(T==null||w==null)return T;var M=(T=String(T)).indexOf("#"),_="";return M!==-1&&(_=T.substring(M,T.length),T=T.substring(0,M)),(T=T.replace(/[?&]$/,""))+((w=typeof w!="string"?s(w,O):w.replace(/^[?&]/,""))?(T.indexOf("?")!==-1?"&":"?")+w:"")+_}t(157),t(159),t(117),t(160),t(161),t(162),t(163),t(164),t(120),t(167),t(173),t(174),t(175),t(176),t(178),t(179);function f(T){return(f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w})(T)}function c(T,w){if(w&&(f(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(O){if(O===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O}(T)}function d(T){var w=typeof Map=="function"?new Map:void 0;return(d=function(O){if(O===null||(M=O,Function.toString.call(M).indexOf("[native code]")===-1))return O;var M;if(typeof O!="function")throw new TypeError("Super expression must either be null or a function");if(w!==void 0){if(w.has(O))return w.get(O);w.set(O,_)}function _(){return p(O,arguments,v(this).constructor)}return _.prototype=Object.create(O.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),h(_,O)})(T)}function p(T,w,O){return(p=l()?Reflect.construct:function(M,_,$){var L=[null];L.push.apply(L,_);var K=new(Function.bind.apply(M,L));return $&&h(K,$.prototype),K}).apply(null,arguments)}function l(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(T){return!1}}function h(T,w){return(h=Object.setPrototypeOf||function(O,M){return O.__proto__=M,O})(T,w)}function v(T){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(w){return w.__proto__||Object.getPrototypeOf(w)})(T)}var g=function(T){(function(L,K){if(typeof K!="function"&&K!==null)throw new TypeError("Super expression must either be null or a function");L.prototype=Object.create(K&&K.prototype,{constructor:{value:L,writable:!0,configurable:!0}}),Object.defineProperty(L,"prototype",{writable:!1}),K&&h(L,K)})($,T);var w,O,M,_=(w=$,O=l(),function(){var L,K=v(w);if(O){var Q=v(this).constructor;L=Reflect.construct(K,arguments,Q)}else L=K.apply(this,arguments);return c(this,L)});function $(L){var K;return function(Q,X){if(!(Q instanceof X))throw new TypeError("Cannot call a class as a function")}(this,$),(K=_.call(this,L)).name="AJAXError",K}return M=$,Object.defineProperty(M,"prototype",{writable:!1}),M}(d(Error)),y=/(?:^|;\s*)(?:application|text)\/([a-z]+)/i;t(180),t(182),t(183);function b(T,w,O,M){return function(){var _,$,L,K=(T.responseText||"").trim();switch(w.responseType||((L=T.getResponseHeader("Content-Type"))&&y.test(L)?RegExp.$1.toLowerCase():"")){case"json":if(K)try{_=JSON.parse(K)}catch(at){$="Invalid JSON structure"}break;case"xml":(_=T.responseXML)&&_.documentElement||($="Invalid XML format");break;default:_=K}var Q,X={xhr:T,options:w,data:_},N=T.status;(function(at){return!(at===void 0||at>=200&&at<300||at===1223||at===304)})(N)?(Q=new g("Error (HTTP status code: "+N+")")).code=N:$&&(Q=new g($)),Q?M(n(Q,X)):O(X)}}var m=Object.create(null),S=0;function x(T,w,O,M){T.onload=b(T,w,O,M),T.ontimeout=function(){var $;M((($=new g("Request timeout")).isTimeout=!0,$))},T.onerror=function(){M(new g("Network error"))},w.onDownloadProgress&&T.addEventListener("progress",w.onDownloadProgress),w.onUploadProgress&&T.upload&&T.upload.addEventListener("progress",w.onUploadProgress),S===Number.MAX_SAFE_INTEGER&&(S=0);var _=++S;return m[_]={xhr:T,options:w,resolve:O,reject:M},_}function I(T){delete m[T]}function E(T,w,O,M,_){return T&&/MSIE\s+(\d+)/.test(navigator.userAgent)&&parseInt(RegExp.$1)<10&&window.XDomainRequest&&(w==="get"||w==="post")&&!O&&!_&&function($){if($!=null){if(Array.isArray($))return!$.length;for(var L in $)if(r($,L))return!1}return!0}(M)?new window.XDomainRequest:new window.XMLHttpRequest}function C(T,w,O,M){var _,$,L;if(O!=null&&T!=="get")return M==="json"?(_=JSON.stringify(O),$="application/json; charset=utf-8"):(L=O,typeof(_=i.call(L)==="[object Object]"?s(O,{ignoreEmpty:!1}):O)=="string"&&($="application/x-www-form-urlencoded; charset=utf-8")),w["Content-Type"]=w["Content-Type"]||$,_}function k(T,w){var O=0;return new Promise(function(M,_){(w=n({},w)).method=w.method||"get",w.requestType=w.requestType||"",w.responseType=w.responseType||"json",w.timeout=w.timeout||0;var $=w.method.toLowerCase(),L=w.requestType.toLowerCase(),K=w.headers||{},Q=function(at){var R=document.createElement("div");R.innerHTML='<a href="'+at+'"></a>';var H=R.firstChild,W=H.host!==location.host;return R=null,H=null,W}(T=function(at,R,H){return R!=null&&(at=u(at,R,{ignoreEmpty:!1})),H&&(at=u(at,{_:Date.now()})),at}(T,w.params,w.preventCaching)),X=E(Q,$,L,K,w.withCredentials);O=x(X,w,function(at){I(O),M(at)},function(at){I(O),_(at)}),X.open($,T,!0,w.username,w.password);var N=C($,K,w.data,L);(function(at,R,H,W){R.timeout&&(at.timeout=R.timeout),H&&R.withCredentials!=null&&(at.withCredentials=!!R.withCredentials),H||W["X-Request-With"]!=null||(W["X-Request-With"]="XMLHttpRequest"),Object.keys(W).forEach(function(J){W[J]!=null&&at.setRequestHeader(J,String(W[J]))})})(X,w,Q,K),typeof w.beforeSend=="function"&&w.beforeSend.call(window,X),X.send(N||""),typeof w.receiveCancelId=="function"&&w.receiveCancelId(O)})}var A=t(82),U=t.n(A);function V(T){return T.name.toLowerCase().split(".").pop()||""}function F(T){var w=new FormData;for(var O in T)w.append(O,T[O]);return w}function z(T,w,O){O===void 0&&(O=!1);for(var M=T.split(","),_=/:(.*?);/.exec(M[0]),$=_?_[1]:"image/jpeg",L=window.atob(M[1]),K=L.length,Q=new Uint8Array(K);K--;)Q[K]=L.charCodeAt(K);return O?new Blob([Q],{type:$}):new File([Q],w,{type:$})}function B(T){return new Promise(function(w,O){var M=new Image;M.onload=function(){w({width:M.width,height:M.height,imageTarget:M})},M.onerror=function(){O(new Error("获取图片尺寸失败"))};var _="";_=typeof T=="string"?T:j(T),M.src=_})}function j(T){return(window.URL||window.webkitURL).createObjectURL(T)}var P,D,G,Z=(P=function(T,w){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(O,M){O.__proto__=M}||function(O,M){for(var _ in M)Object.prototype.hasOwnProperty.call(M,_)&&(O[_]=M[_])})(T,w)},function(T,w){if(typeof w!="function"&&w!==null)throw new TypeError("Class extends value "+String(w)+" is not a constructor or null");function O(){this.constructor=T}P(T,w),T.prototype=w===null?Object.create(w):(O.prototype=w.prototype,new O)});(function(T){T.EMPTY_FILE="empty file",T.FILE_SIZE_TOO_LARGE="file size too large",T.FILE_TYPE_NOT_ALLOW="file type not allow",T.FILE_EXTENSION_NOT_ALLOW="file extension not allow",T.GET_UPLOAD_TOKEN_ERROR="get upload token error",T.UPLOAD_IMAGE_ERROR="upload image error",T.PORN_IDENTIFY_ERROR="porn identify error"})(G||(G={}));var et,rt=function(T){function w(O){var M=T.call(this,O)||this,_=w.getFailErrorData(O);return M.failCode=_.failCode,M.failMessage=_.failMessage,M}return Z(w,T),w.getFailErrorData=function(O){return{failCode:O,failMessage:w.failMessageVal[O]}},w.failMessageVal=((D={})[G.EMPTY_FILE]="请勿上传空文件",D[G.FILE_SIZE_TOO_LARGE]="文件大小超出限制",D[G.FILE_TYPE_NOT_ALLOW]="该文件类型不支持",D[G.FILE_EXTENSION_NOT_ALLOW]="该文件扩展名不支持",D[G.GET_UPLOAD_TOKEN_ERROR]="获取上传图片 token 失败",D[G.UPLOAD_IMAGE_ERROR]="上传图片失败",D[G.PORN_IDENTIFY_ERROR]="图片鉴黄失败",D),w}(Error),tt=function(){return(tt=Object.assign||function(T){for(var w,O=1,M=arguments.length;O<M;O++)for(var _ in w=arguments[O])Object.prototype.hasOwnProperty.call(w,_)&&(T[_]=w[_]);return T}).apply(this,arguments)},Y=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},dt=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},pt=function(){function T(w){this.uploadCtx=w.uploadCtx}return T.prototype.getUploadToken=function(w){return Y(this,void 0,void 0,function(){var O,M,_,$,L;return dt(this,function(K){switch(K.label){case 0:return O=Date.now(),M=U()("upload_token_live"+w.channelId+O),_={channelId:w.channelId,ts:O,hash:M,bucket:w.bucket},w.userId&&(_.userId=w.userId),[4,k("https://"+this.uploadCtx.apiHost+"/live/upload/token/image/get-token",{params:_})];case 1:return($=K.sent()).data?(L=$.data).code!==200?[2,Promise.reject(new rt(G.GET_UPLOAD_TOKEN_ERROR))]:[2,L.data]:[2,Promise.reject(new rt(G.GET_UPLOAD_TOKEN_ERROR))]}})})},T.prototype.uploadImage=function(w){return Y(this,void 0,void 0,function(){var O,M,_,$,L,K;return dt(this,function(Q){switch(Q.label){case 0:O={key:""+w.dir+w.fileName,policy:w.policy,OSSAccessKeyId:w.accessid,signature:w.signature,success_action_status:200,callback:w.encodedCallback,file:w.file},Q.label=1;case 1:return Q.trys.push([1,3,,4]),[4,k("https://"+w.host,{method:"post",data:F(O),onUploadProgress:function(X){var N,at,R=w.onUploadProgress;typeof R=="function"&&R((N=X.loaded/X.total,at=2,Number(N.toFixed(at||0))))}})];case 2:return(M=Q.sent()).data?(_=M.data).code!==200?[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))]:[2,_.data]:[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))];case 3:return Q.sent(),$=w.currentReuploadTime,(L=$===void 0?0:$)&&L>=this.uploadCtx.reUploadTimes?[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))]:(L+=1,K=Object.assign({},w,{currentReuploadTime:L}),[2,this.uploadImage(K)]);case 4:return[2]}})})},T.prototype.createSign=function(w,O,M){var _=w;Object.keys(O).sort().forEach(function(L){O[L]&&(_+=L+String(O[L]))}),_+=w;var $=U()(_);return M==="lower"?$:$.toLocaleUpperCase()},T.prototype.pornIdentify=function(w){return Y(this,void 0,void 0,function(){var O,M,_;return dt(this,function($){switch($.label){case 0:O=tt(tt({},w),{timestamp:Date.now()}),$.label=1;case 1:return $.trys.push([1,3,,4]),[4,k("https://"+this.uploadCtx.apiHost+"/live/inner/v3/chat/image/porn-identify",{method:"post",data:tt(tt({},O),{sign:this.createSign("polyv_chat_api_innor",O)})})];case 2:return(M=$.sent()).data?M.data.code!==200?[2,Promise.reject(new rt(G.PORN_IDENTIFY_ERROR))]:[2,!0]:[2,Promise.reject(new rt(G.PORN_IDENTIFY_ERROR))];case 3:return _=$.sent(),[2,Promise.reject(_)];case 4:return[2]}})})},T}();(function(T){T.WAIT_UPLOAD="waitUpload",T.UPLOADING="uploading",T.UPLOAD_SUCCESS="uploadSuccess",T.UPLOAD_FAIL="uploadFail",T.UPLOAD_FORBID="forbid"})(et||(et={}));var yt=function(){return(yt=Object.assign||function(T){for(var w,O=1,M=arguments.length;O<M;O++)for(var _ in w=arguments[O])Object.prototype.hasOwnProperty.call(w,_)&&(T[_]=w[_]);return T}).apply(this,arguments)},mt=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},ut=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},ft={width:500,height:500},_t=function(){function T(w){var O=w.callbackChange,M=O===void 0||O;this.imageId=w.imageId,this.uploadCtx=w.uploadCtx,this.file=w.file,this._status=w.status||et.WAIT_UPLOAD,this.callbackChange=M,this.fileUrl=void 0,this.uploadProgress=void 0,this.previewSrc=j(this.file),this.uploadCtx.recordChatImage(this),this.triggerChange()}return T.prototype.upload=function(w){return w===void 0&&(w={}),mt(this,void 0,void 0,function(){var O,M,_,$,L,K,Q,X,N,at,R,H,W,J=this;return ut(this,function(it){switch(it.label){case 0:return O=this.uploadCtx,M=O.channelId,_=O.userId,$=O.bucket,this.status=et.UPLOADING,[4,O.uploadApi.getUploadToken({channelId:M,userId:_,bucket:$})];case 1:if(L=it.sent(),!((K=this.file).size>1024*O.compressSizeLimit))return[3,5];it.label=2;case 2:return it.trys.push([2,4,,5]),[4,this.compressImage({file:this.file,fileName:this.fileName})];case 3:return Q=it.sent(),K=Q,[3,5];case 4:return it.sent(),console.warn("图片压缩失败",K,this.imageId),[3,5];case 5:return it.trys.push([5,7,,8]),[4,B(K)];case 6:return X=it.sent(),N=X.width,at=X.height,this.size={width:N,height:at},[3,8];case 7:return it.sent(),console.warn("获取图片尺寸失败"),[3,8];case 8:this.size||(this.size=ft),this.uploadProgress=0,R="",it.label=9;case 9:return it.trys.push([9,13,,14]),[4,O.uploadApi.uploadImage(yt(yt({},L),{file:K,fileName:this.fileName,onUploadProgress:function(Ct){J.uploadProgress=Ct,J.triggerChange()}}))];case 10:return R=it.sent(),this.fileUrl=R,O.enablePornChecking?[4,O.uploadApi.pornIdentify({channelId:M,url:"https:"+R})]:[3,12];case 11:it.sent(),it.label=12;case 12:return this.status=et.UPLOAD_SUCCESS,[3,14];case 13:return H=it.sent(),this.status=H.failCode===G.PORN_IDENTIFY_ERROR?et.UPLOAD_FORBID:et.UPLOAD_FAIL,w.error,[2,Promise.reject(H)];case 14:return typeof(W=w.success)=="function"&&W(R),[2,R]}})})},T.prototype.compressImage=function(w){return mt(this,void 0,void 0,function(){var O,M,_,$,L,K,Q,X,N,at;return ut(this,function(R){switch(R.label){case 0:return O=w.file,M=w.fileName,_=w.quality,$=_===void 0?.7:_,[4,B(O)];case 1:return L=R.sent(),K=L.width,Q=L.height,X=L.imageTarget,(N=document.createElement("canvas")).setAttribute("width",""+K),N.setAttribute("height",""+Q),(at=N.getContext("2d"))?(at.drawImage(X,0,0,K,Q),[2,z(N.toDataURL("image/jpeg",$),M)]):[2,Promise.reject(new Error("create canvas error"))]}})})},T.prototype.triggerChange=function(){if(this.callbackChange){var w=this.uploadCtx.onChange;typeof w=="function"&&w(this)}},Object.defineProperty(T.prototype,"fileName",{get:function(){var w=V(this.file);return this.imageId+"."+(w||"png")},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"status",{get:function(){return this._status},set:function(w){this._status=w,this.triggerChange()},enumerable:!1,configurable:!0}),T}(),It=function(){function T(w){this.uploadCtx=w.uploadCtx,this.uploadingList=[],this.waitQueue=[]}return T.prototype.joinWaitQueue=function(w){this.isExistQueue(w,this.waitQueue)||(this.waitQueue.push(w),this.checkQueue())},T.prototype.checkQueue=function(){var w=this;if(!(this.uploadingList.length>=this.uploadCtx.maxUploadNumber)&&this.waitQueue.length!==0)for(var O=this.uploadCtx.maxUploadNumber-this.uploadingList.length,M=function(L){var K=_.waitQueue.shift();K&&(K.upload({success:function(){w.handleImageUploadSuccess(K)}}),_.uploadingList.push(K))},_=this,$=0;$<O;$++)M()},T.prototype.handleImageUploadSuccess=function(w){this.uploadingList=this.uploadingList.filter(function(O){return O.imageId!==w.imageId}),this.checkQueue()},T.prototype.isExistQueue=function(w,O){return O.findIndex(function(M){return M.imageId===w.imageId})!==-1},T}(),Et=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/tiff","image/tifa"],vt=["png","bmp","webp","tiff","tif","jpeg","jpg","gif"],ht={channelId:"",userId:"",sizeLimit:81920,compressSizeLimit:2048,limit:9,maxWidth:700,reUploadTimes:3,source:"chat_img",bucket:"liveimages",useBlobByCompress:!1,allowAccept:Et,allowFileExtension:vt,maxUploadNumber:3,enablePornChecking:!1,apiHost:"api.polyv.net"},xt=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},q=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},st=function(){function T(w){w===void 0&&(w={});var O=w.channelId,M=O===void 0?ht.channelId:O,_=w.userId,$=_===void 0?ht.userId:_,L=w.sizeLimit,K=L===void 0?ht.sizeLimit:L,Q=w.compressSizeLimit,X=Q===void 0?ht.compressSizeLimit:Q,N=w.limit,at=N===void 0?ht.limit:N,R=w.maxWidth,H=R===void 0?ht.maxWidth:R,W=w.reUploadTimes,J=W===void 0?ht.reUploadTimes:W,it=w.source,Ct=it===void 0?ht.source:it,kt=w.bucket,At=kt===void 0?ht.bucket:kt,Lt=w.useBlobByCompress,nt=Lt===void 0?ht.useBlobByCompress:Lt,ct=w.allowAccept,gt=ct===void 0?ht.allowAccept:ct,bt=w.allowFileExtension,Tt=bt===void 0?ht.allowFileExtension:bt,Gt=w.maxUploadNumber,Bt=Gt===void 0?ht.maxUploadNumber:Gt,Jt=w.apiHost,pe=Jt===void 0?ht.apiHost:Jt,de=w.onChange,he=w.beforeStart;this.channelId=M,this.userId=$,this.sizeLimit=K,this.compressSizeLimit=X,this.limit=at,this.maxWidth=H,this.reUploadTimes=J,this.source=Ct,this.bucket=At,this.useBlobByCompress=!!nt,this.allowAccept=gt,this.allowFileExtension=Tt,this.maxUploadNumber=Bt,this.onChange=de,this.beforeStart=he,this.enablePornChecking=w.enablePornChecking===!0,this.apiHost=pe,this.uploadQueue=new It({uploadCtx:this}),this.uploadApi=new pt({uploadCtx:this}),this.chatImageStore={}}return T.prototype.choiceImageFile=function(w){var O=this;w===void 0&&(w={});var M=this.getAccept(),_=document.createElement("input");return _.setAttribute("id","polyv-upload-chat-image-input-id"),_.setAttribute("type","file"),_.setAttribute("accept",M),_.setAttribute("style","visibility: hidden;position: fixed;bottom: -100%;z-index: -1;"),this.limit>1&&_.setAttribute("multiple","multiple"),_.addEventListener("change",function(){document.body.removeChild(_),w&&_.files&&_.files.length!==0&&O.handleFileList(w,_.files)}),document.body.appendChild(_),_.click(),this},T.prototype.handleFileList=function(w,O){this.beforeStart&&this.beforeStart();for(var M,_=w.fail,$=w.success,L=w.callbackChange,K=O.length<this.limit?O.length:this.limit,Q=0;Q<K;Q++){var X=O[Q],N=this.checkFile(X);if(N)return M=N,void(typeof _=="function"&&_(M))}var at=[];for(Q=0;Q<K;Q++){X=O[Q];var R=this.buildImageId(Q),H=new _t({imageId:R,uploadCtx:this,file:X,callbackChange:L});at.push(H)}typeof $=="function"&&$(at)},T.prototype.getAccept=function(){var w=[];return w.push.apply(w,this.allowFileExtension.map(function(O){return"."+O})),w.push.apply(w,this.allowAccept),w.join(",")},T.prototype.joinWaitQueue=function(w){var O=this;if(Array.isArray(w))return w.forEach(function(_){O.joinWaitQueue(_)}),this;var M=void 0;return typeof w=="string"?M=this.getChatImageById(w):w instanceof _t&&(M=w),M&&this.uploadQueue.joinWaitQueue(M),this},T.prototype.getUploadImageUrl=function(){var w=this;return new Promise(function(O,M){w.choiceImageFile({callbackChange:!1,success:function(_){return xt(w,void 0,void 0,function(){var $;return q(this,function(L){switch(L.label){case 0:return[4,($=_[0]).upload()];case 1:return L.sent(),$.fileUrl?O($):M(new rt(G.UPLOAD_IMAGE_ERROR)),[2]}})})},fail:function(_){M(_)}})})},T.prototype.callbackUploadImage=function(){var w=this;this.choiceImageFile({success:function(O){w.joinWaitQueue(O)}})},T.prototype.uploadImageFile=function(w){return xt(this,void 0,void 0,function(){var O;return q(this,function(M){switch(M.label){case 0:if(O=this.checkFile(w))throw new Error(O.failMessage);return[4,new _t({imageId:this.buildImageId(),file:w,uploadCtx:this,callbackChange:!1}).upload()];case 1:return[2,M.sent()]}})})},T.prototype.uploadImage=function(w,O){return xt(this,void 0,void 0,function(){var M,_;return q(this,function($){switch($.label){case 0:if(M=this.checkFile(w))throw new Error(M.failMessage);return[4,(_=new _t({imageId:this.buildImageId(),file:w,uploadCtx:this,callbackChange:O!==!1})).upload()];case 1:return $.sent(),[2,_]}})})},T.prototype.reUploadImage=function(w){return xt(this,void 0,void 0,function(){var O,M;return q(this,function(_){switch(_.label){case 0:if(!(O=this.getChatImageById(w)))return[2,Promise.reject(new Error("图片不存在"))];_.label=1;case 1:return _.trys.push([1,3,,4]),[4,O.upload()];case 2:return _.sent(),[2,O];case 3:return M=_.sent(),[2,Promise.reject(M)];case 4:return[2]}})})},T.prototype.getChatImageById=function(w){return this.chatImageStore[w]},T.prototype.recordChatImage=function(w){this.chatImageStore[w.imageId]=w},T.prototype.checkFile=function(w){if(!w.size)return rt.getFailErrorData(G.EMPTY_FILE);if(w.size>1024*this.sizeLimit)return rt.getFailErrorData(G.FILE_SIZE_TOO_LARGE);if(!this.allowAccept.includes(w.type))return rt.getFailErrorData(G.FILE_TYPE_NOT_ALLOW);var O=V(w);return this.allowFileExtension.includes(O)?void 0:rt.getFailErrorData(G.FILE_EXTENSION_NOT_ALLOW)},T.prototype.buildImageId=function(w){var O=[];this.source&&O.push(this.source),this.channelId&&O.push(this.channelId),this.userId&&O.push(this.userId);var M=w!==void 0?"_"+w:"";return O.join("_")+"_"+Date.now()+"_"+Math.random().toString().substring(2,10)+M},T}()}]);class De extends Nt{constructor(t){super(t);wt(this,"__uploadImgCtrl");wt(this,"__svgaMap",{coffee:"coffee.svga",like:"like.svga",handclap:"handclap.svga",666:"666.svga",star:"star.svga",diamond:"diamond.svga",car:"car.svga",rocket:"rocket.svga",bear:"bear.svga",crown:"crown.svga",cup:"cup.svga",microphone:"microphone.svga",villa:"villa.svga",house:"villa.svga"});this.__uploadImgCtrl=new Fe.ChatImageUpload({enablePornChecking:!0})}__setUploadImgChannelId(){return lt(this,null,function*(){const t=yield this._plvSocket.getChannelInfo();this.__uploadImgCtrl.channelId=t.channelId})}uploadMultiImage(t){return lt(this,null,function*(){yield this.__setUploadImgChannelId();const e=(t==null?void 0:t.maxLimit)||9,r=typeof(t==null?void 0:t.ready)=="function"?t.ready:()=>{},n=typeof(t==null?void 0:t.success)=="function"?t.success:()=>{},i=typeof(t==null?void 0:t.fail)=="function"?t.fail:()=>{},s=[],u=[];return new Promise((f,c)=>{this.__uploadImgCtrl.choiceImageFile({callbackChange:!1,success:d=>lt(this,null,function*(){d=d.slice(0,e),d.forEach(g=>{r({imageId:g.imageId,previewSrc:g.previewSrc||""})});try{for(var p=ee(d),l,h,v;l=!(h=yield p.next()).done;l=!1){const g=h.value;try{const y=yield g.upload();if(!y)throw new Error("upload Image Error");const b={imageId:g.imageId,imageUrl:y,size:g.size};s.push(b),n(b)}catch(y){const b=y,m={imageId:g.imageId,previewSrc:g.previewSrc||""};u.push(m),console.error("[util-module][uploadMultiImage] ",b.message,m),i(b,m)}}}catch(h){v=[h]}finally{try{l&&(h=p.return)&&(yield h.call(p))}finally{if(v)throw v[0]}}return f({successUploadImages:s,failUploadImages:u})}),fail:d=>{console.error("[util-module][uploadMultiImage] ",d),c(new Error(d.failMessage))}})})})}directUploadImage(t){return lt(this,null,function*(){if(!t)throw new Error("file is null");yield this.__setUploadImgChannelId();const e=yield this.__uploadImgCtrl.uploadImage(t);if(!e.fileUrl)throw new Error("upload fail");return{imageId:e.imageId,imageUrl:e.fileUrl,size:e.size}})}translateText(t){return lt(this,null,function*(){const e=this._plvSocket.getUserInfo(),r=yield this._plvSocket.polyvApi.getTokenFieldByUserType();return(yield this._plvSocket.polyvApi.post("/live/v4/channel/translate",{},{params:{query:t,viewerId:e.userId},tokenInfo:{tokenField:r}}))[0]})}__genResourceUrl(t){return`https://s1.videocc.net${t}`}getDefaultResource(){return{defaultViewerAvatar:this.__genResourceUrl("/default-img/avatar/viewer.png")}}getDefaultDonateSvgaUrl(t){return lt(this,null,function*(){const e=t.gimg,r=this.__svgaMap,n=document.createElement("a");n.href=e;const i=n.pathname.split("/"),s=i[i.length-1].split(".")[0];if(r[s])return this.__genResourceUrl(`/default-img/donate-svga/${r[s]}`)})}}function Be(o){return typeof o!="object"&&(o=new Date(o)),o}function ze(o,a){const t={Y:(o=Be(o)).getFullYear(),M:o.getMonth()+1,D:o.getDate(),h:o.getHours(),m:o.getMinutes(),s:o.getSeconds()};return a.replace(/([YMDhms])\1*/g,function(e){let r=t[e[0]].toString();const n=e.length;return n>r.length&&(r=new Array(n-r.length+1).join("0")+r),r})}class Ge extends Nt{constructor(){super(...arguments);wt(this,"__refId","")}setRefId(t){this.__refId=t}getRefId(){return this.__refId}exportAttendanceList(){return lt(this,null,function*(){const t=yield this._plvSocket.getChannelInfo(),e=this._plvSocket.getUserInfo(),r={channelId:t.channelId,userId:e.userId,timestamp:Date.now(),expectedArrivalType:"viewer_white",type:"whiteList"};r.sign=yield this._plvSocket.chatApi.getChatSign(r),yield this._plvSocket.chatApi.post("/front/channel/download-history/post",r,{appendChannelId:!1,appendUserId:!1})})}getAttendanceDownloadRecord(){return lt(this,arguments,function*(t={}){const{pageNumber:e=1,pageSize:r=10}=t,n=yield this._plvSocket.getChannelInfo(),i=yield this._plvSocket.chatApi.get("/front/channel/download-history-list/get",{timestamp:Date.now(),page:e,size:r,type:"whiteList"},{appendChatSign:!0}),s=[];return i.list.forEach(u=>{const f=["缺勤/到勤名单",n.channelId];u.sessionId&&f.push(u.sessionId),u.createTime&&f.push(ze(u.createTime,"YYYYMMDD hh:mm:ss"));let c="pending";u.isExpire?c="expired":u.status===1?c="failed":u.status===0?c="pending":u.status===2&&(c="success"),s.push({id:`${u.createTime}-${u.sessionId}`,downloadUrl:u.src,fileName:f.join("-")+".gz",fileSize:0,progress:c==="pending"?0:100,status:c,createTime:u.createTime})}),{pageNumber:i.page,pageSize:i.size,contents:s,totalItems:i.totalCount,totalPages:i.totalPage}})}exportOnlineList(){return lt(this,null,function*(){const t={businessType:"LIVE"},e=this.getRefId();e&&(t.refId=e),yield this._plvSocket.polyvApi.get("/live/v4/channel/chat-data/online-user/export",t)})}exportWhiteList(){return lt(this,null,function*(){this._plvSocket.polyvApi.open("/live/v3/channel/chat/export-whitelist-viewing",{})})}}class He{constructor(a,t={}){wt(this,"PolyvChatEvent",St);wt(this,"ChatMsgSource",ot);wt(this,"DonateType",Dt);wt(this,"RedpackType",Yt);wt(this,"SystemMsgType",qt);wt(this,"ChatRequestHistoryMode",Ut);wt(this,"ManageFailReason",Pt);wt(this,"TranslateLanguage",Xt);wt(this,"eventEmitter",new we);wt(this,"__socketFilter");wt(this,"__socketHandler");wt(this,"emotion");wt(this,"history");wt(this,"message");wt(this,"status");wt(this,"utils");wt(this,"sender");wt(this,"manage");wt(this,"online");wt(this,"download");wt(this,"setuped",!1);this.plvSocket=a,this.config=t,this.emotion=new Ce(this),this.history=new ke(this),this.message=new Re(this),this.status=new Ue(this),this.utils=new De(this),this.sender=new Ne(this),this.manage=new Me(this),this.online=new Pe(this),this.download=new Ge(this),this.__socketFilter=new Ee(this),this.__socketHandler=new Oe(this)}setup(){return lt(this,null,function*(){yield this.emotion.setupEmotionParser(),this.setuped=!0})}}exports.ChatMsgSource=ot;exports.ChatRequestHistoryMode=Ut;exports.DonateType=Dt;exports.ManageFailReason=Pt;exports.MotivationLikeType=Qt;exports.PolyvChat=He;exports.PolyvChatEvent=St;exports.RedpackType=Yt;exports.SystemMsgType=qt;exports.TranslateLanguage=Xt;exports.canQuoteMsgSource=le;exports.canTopMsgSource=fe;exports.isServiceMsgMap=ce;console.log("%c@polyv/chat","background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff","[version: 2.1.0-rc-20251023.1]","[buildTime: 2025-10-21 10:21:15]");
19
+ */o.exports=function(e){return e!=null&&(t(e)||function(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&t(r.slice(0,0))}(e)||!!e._isBuffer)}},function(o,a,t){t.r(a),t.d(a,"ChatImageUpload",function(){return st}),t.d(a,"defaultConfig",function(){return ht}),t.d(a,"allowAccept",function(){return Et}),t.d(a,"allowFileExtension",function(){return vt}),t.d(a,"FailError",function(){return rt}),t.d(a,"FailCode",function(){return G}),t.d(a,"ChatImage",function(){return _t}),t.d(a,"ImageStatus",function(){return et}),t(127),t(92),t(63),t(35),t(67),t(135),t(136),t(73);var e=Object.prototype.hasOwnProperty;function r(T,w){return e.call(T,w)}function n(T){if(T==null)throw new TypeError("Cannot convert undefined or null to object");for(var w=0;w<(arguments.length<=1?0:arguments.length-1);w++){var O=w+1<1||arguments.length<=w+1?void 0:arguments[w+1];if(O!=null)for(var M in O)M!=="__proto__"&&r(O,M)&&(T[M]=O[M])}return T}var i=Object.prototype.toString;t(74),t(53),t(151),t(152),t(154);function s(T,w){var O,M,_=n({encode:encodeURIComponent},w),$=[];function L(Q,X){X==null&&(X=""),X===""&&_.ignoreEmpty||(typeof _.encode=="function"&&(Q=_.encode(Q),X=_.encode(String(X))),$.push(Q+"="+X))}function K(Q){L(O,Q)}for(O in T)r(T,O)&&(M=T[O],Array.isArray(M)?M.forEach(K):L(O,M));return $.join("&")}t(116),t(155);function u(T,w,O){if(T==null||w==null)return T;var M=(T=String(T)).indexOf("#"),_="";return M!==-1&&(_=T.substring(M,T.length),T=T.substring(0,M)),(T=T.replace(/[?&]$/,""))+((w=typeof w!="string"?s(w,O):w.replace(/^[?&]/,""))?(T.indexOf("?")!==-1?"&":"?")+w:"")+_}t(157),t(159),t(117),t(160),t(161),t(162),t(163),t(164),t(120),t(167),t(173),t(174),t(175),t(176),t(178),t(179);function f(T){return(f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w})(T)}function c(T,w){if(w&&(f(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(O){if(O===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O}(T)}function d(T){var w=typeof Map=="function"?new Map:void 0;return(d=function(O){if(O===null||(M=O,Function.toString.call(M).indexOf("[native code]")===-1))return O;var M;if(typeof O!="function")throw new TypeError("Super expression must either be null or a function");if(w!==void 0){if(w.has(O))return w.get(O);w.set(O,_)}function _(){return p(O,arguments,v(this).constructor)}return _.prototype=Object.create(O.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),h(_,O)})(T)}function p(T,w,O){return(p=l()?Reflect.construct:function(M,_,$){var L=[null];L.push.apply(L,_);var K=new(Function.bind.apply(M,L));return $&&h(K,$.prototype),K}).apply(null,arguments)}function l(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(T){return!1}}function h(T,w){return(h=Object.setPrototypeOf||function(O,M){return O.__proto__=M,O})(T,w)}function v(T){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(w){return w.__proto__||Object.getPrototypeOf(w)})(T)}var g=function(T){(function(L,K){if(typeof K!="function"&&K!==null)throw new TypeError("Super expression must either be null or a function");L.prototype=Object.create(K&&K.prototype,{constructor:{value:L,writable:!0,configurable:!0}}),Object.defineProperty(L,"prototype",{writable:!1}),K&&h(L,K)})($,T);var w,O,M,_=(w=$,O=l(),function(){var L,K=v(w);if(O){var Q=v(this).constructor;L=Reflect.construct(K,arguments,Q)}else L=K.apply(this,arguments);return c(this,L)});function $(L){var K;return function(Q,X){if(!(Q instanceof X))throw new TypeError("Cannot call a class as a function")}(this,$),(K=_.call(this,L)).name="AJAXError",K}return M=$,Object.defineProperty(M,"prototype",{writable:!1}),M}(d(Error)),y=/(?:^|;\s*)(?:application|text)\/([a-z]+)/i;t(180),t(182),t(183);function b(T,w,O,M){return function(){var _,$,L,K=(T.responseText||"").trim();switch(w.responseType||((L=T.getResponseHeader("Content-Type"))&&y.test(L)?RegExp.$1.toLowerCase():"")){case"json":if(K)try{_=JSON.parse(K)}catch(at){$="Invalid JSON structure"}break;case"xml":(_=T.responseXML)&&_.documentElement||($="Invalid XML format");break;default:_=K}var Q,X={xhr:T,options:w,data:_},N=T.status;(function(at){return!(at===void 0||at>=200&&at<300||at===1223||at===304)})(N)?(Q=new g("Error (HTTP status code: "+N+")")).code=N:$&&(Q=new g($)),Q?M(n(Q,X)):O(X)}}var m=Object.create(null),S=0;function x(T,w,O,M){T.onload=b(T,w,O,M),T.ontimeout=function(){var $;M((($=new g("Request timeout")).isTimeout=!0,$))},T.onerror=function(){M(new g("Network error"))},w.onDownloadProgress&&T.addEventListener("progress",w.onDownloadProgress),w.onUploadProgress&&T.upload&&T.upload.addEventListener("progress",w.onUploadProgress),S===Number.MAX_SAFE_INTEGER&&(S=0);var _=++S;return m[_]={xhr:T,options:w,resolve:O,reject:M},_}function I(T){delete m[T]}function E(T,w,O,M,_){return T&&/MSIE\s+(\d+)/.test(navigator.userAgent)&&parseInt(RegExp.$1)<10&&window.XDomainRequest&&(w==="get"||w==="post")&&!O&&!_&&function($){if($!=null){if(Array.isArray($))return!$.length;for(var L in $)if(r($,L))return!1}return!0}(M)?new window.XDomainRequest:new window.XMLHttpRequest}function C(T,w,O,M){var _,$,L;if(O!=null&&T!=="get")return M==="json"?(_=JSON.stringify(O),$="application/json; charset=utf-8"):(L=O,typeof(_=i.call(L)==="[object Object]"?s(O,{ignoreEmpty:!1}):O)=="string"&&($="application/x-www-form-urlencoded; charset=utf-8")),w["Content-Type"]=w["Content-Type"]||$,_}function k(T,w){var O=0;return new Promise(function(M,_){(w=n({},w)).method=w.method||"get",w.requestType=w.requestType||"",w.responseType=w.responseType||"json",w.timeout=w.timeout||0;var $=w.method.toLowerCase(),L=w.requestType.toLowerCase(),K=w.headers||{},Q=function(at){var R=document.createElement("div");R.innerHTML='<a href="'+at+'"></a>';var H=R.firstChild,W=H.host!==location.host;return R=null,H=null,W}(T=function(at,R,H){return R!=null&&(at=u(at,R,{ignoreEmpty:!1})),H&&(at=u(at,{_:Date.now()})),at}(T,w.params,w.preventCaching)),X=E(Q,$,L,K,w.withCredentials);O=x(X,w,function(at){I(O),M(at)},function(at){I(O),_(at)}),X.open($,T,!0,w.username,w.password);var N=C($,K,w.data,L);(function(at,R,H,W){R.timeout&&(at.timeout=R.timeout),H&&R.withCredentials!=null&&(at.withCredentials=!!R.withCredentials),H||W["X-Request-With"]!=null||(W["X-Request-With"]="XMLHttpRequest"),Object.keys(W).forEach(function(J){W[J]!=null&&at.setRequestHeader(J,String(W[J]))})})(X,w,Q,K),typeof w.beforeSend=="function"&&w.beforeSend.call(window,X),X.send(N||""),typeof w.receiveCancelId=="function"&&w.receiveCancelId(O)})}var A=t(82),U=t.n(A);function V(T){return T.name.toLowerCase().split(".").pop()||""}function F(T){var w=new FormData;for(var O in T)w.append(O,T[O]);return w}function z(T,w,O){O===void 0&&(O=!1);for(var M=T.split(","),_=/:(.*?);/.exec(M[0]),$=_?_[1]:"image/jpeg",L=window.atob(M[1]),K=L.length,Q=new Uint8Array(K);K--;)Q[K]=L.charCodeAt(K);return O?new Blob([Q],{type:$}):new File([Q],w,{type:$})}function B(T){return new Promise(function(w,O){var M=new Image;M.onload=function(){w({width:M.width,height:M.height,imageTarget:M})},M.onerror=function(){O(new Error("获取图片尺寸失败"))};var _="";_=typeof T=="string"?T:j(T),M.src=_})}function j(T){return(window.URL||window.webkitURL).createObjectURL(T)}var P,D,G,Z=(P=function(T,w){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(O,M){O.__proto__=M}||function(O,M){for(var _ in M)Object.prototype.hasOwnProperty.call(M,_)&&(O[_]=M[_])})(T,w)},function(T,w){if(typeof w!="function"&&w!==null)throw new TypeError("Class extends value "+String(w)+" is not a constructor or null");function O(){this.constructor=T}P(T,w),T.prototype=w===null?Object.create(w):(O.prototype=w.prototype,new O)});(function(T){T.EMPTY_FILE="empty file",T.FILE_SIZE_TOO_LARGE="file size too large",T.FILE_TYPE_NOT_ALLOW="file type not allow",T.FILE_EXTENSION_NOT_ALLOW="file extension not allow",T.GET_UPLOAD_TOKEN_ERROR="get upload token error",T.UPLOAD_IMAGE_ERROR="upload image error",T.PORN_IDENTIFY_ERROR="porn identify error"})(G||(G={}));var et,rt=function(T){function w(O){var M=T.call(this,O)||this,_=w.getFailErrorData(O);return M.failCode=_.failCode,M.failMessage=_.failMessage,M}return Z(w,T),w.getFailErrorData=function(O){return{failCode:O,failMessage:w.failMessageVal[O]}},w.failMessageVal=((D={})[G.EMPTY_FILE]="请勿上传空文件",D[G.FILE_SIZE_TOO_LARGE]="文件大小超出限制",D[G.FILE_TYPE_NOT_ALLOW]="该文件类型不支持",D[G.FILE_EXTENSION_NOT_ALLOW]="该文件扩展名不支持",D[G.GET_UPLOAD_TOKEN_ERROR]="获取上传图片 token 失败",D[G.UPLOAD_IMAGE_ERROR]="上传图片失败",D[G.PORN_IDENTIFY_ERROR]="图片鉴黄失败",D),w}(Error),tt=function(){return(tt=Object.assign||function(T){for(var w,O=1,M=arguments.length;O<M;O++)for(var _ in w=arguments[O])Object.prototype.hasOwnProperty.call(w,_)&&(T[_]=w[_]);return T}).apply(this,arguments)},Y=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},dt=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},pt=function(){function T(w){this.uploadCtx=w.uploadCtx}return T.prototype.getUploadToken=function(w){return Y(this,void 0,void 0,function(){var O,M,_,$,L;return dt(this,function(K){switch(K.label){case 0:return O=Date.now(),M=U()("upload_token_live"+w.channelId+O),_={channelId:w.channelId,ts:O,hash:M,bucket:w.bucket},w.userId&&(_.userId=w.userId),[4,k("https://"+this.uploadCtx.apiHost+"/live/upload/token/image/get-token",{params:_})];case 1:return($=K.sent()).data?(L=$.data).code!==200?[2,Promise.reject(new rt(G.GET_UPLOAD_TOKEN_ERROR))]:[2,L.data]:[2,Promise.reject(new rt(G.GET_UPLOAD_TOKEN_ERROR))]}})})},T.prototype.uploadImage=function(w){return Y(this,void 0,void 0,function(){var O,M,_,$,L,K;return dt(this,function(Q){switch(Q.label){case 0:O={key:""+w.dir+w.fileName,policy:w.policy,OSSAccessKeyId:w.accessid,signature:w.signature,success_action_status:200,callback:w.encodedCallback,file:w.file},Q.label=1;case 1:return Q.trys.push([1,3,,4]),[4,k("https://"+w.host,{method:"post",data:F(O),onUploadProgress:function(X){var N,at,R=w.onUploadProgress;typeof R=="function"&&R((N=X.loaded/X.total,at=2,Number(N.toFixed(at||0))))}})];case 2:return(M=Q.sent()).data?(_=M.data).code!==200?[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))]:[2,_.data]:[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))];case 3:return Q.sent(),$=w.currentReuploadTime,(L=$===void 0?0:$)&&L>=this.uploadCtx.reUploadTimes?[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))]:(L+=1,K=Object.assign({},w,{currentReuploadTime:L}),[2,this.uploadImage(K)]);case 4:return[2]}})})},T.prototype.createSign=function(w,O,M){var _=w;Object.keys(O).sort().forEach(function(L){O[L]&&(_+=L+String(O[L]))}),_+=w;var $=U()(_);return M==="lower"?$:$.toLocaleUpperCase()},T.prototype.pornIdentify=function(w){return Y(this,void 0,void 0,function(){var O,M,_;return dt(this,function($){switch($.label){case 0:O=tt(tt({},w),{timestamp:Date.now()}),$.label=1;case 1:return $.trys.push([1,3,,4]),[4,k("https://"+this.uploadCtx.apiHost+"/live/inner/v3/chat/image/porn-identify",{method:"post",data:tt(tt({},O),{sign:this.createSign("polyv_chat_api_innor",O)})})];case 2:return(M=$.sent()).data?M.data.code!==200?[2,Promise.reject(new rt(G.PORN_IDENTIFY_ERROR))]:[2,!0]:[2,Promise.reject(new rt(G.PORN_IDENTIFY_ERROR))];case 3:return _=$.sent(),[2,Promise.reject(_)];case 4:return[2]}})})},T}();(function(T){T.WAIT_UPLOAD="waitUpload",T.UPLOADING="uploading",T.UPLOAD_SUCCESS="uploadSuccess",T.UPLOAD_FAIL="uploadFail",T.UPLOAD_FORBID="forbid"})(et||(et={}));var yt=function(){return(yt=Object.assign||function(T){for(var w,O=1,M=arguments.length;O<M;O++)for(var _ in w=arguments[O])Object.prototype.hasOwnProperty.call(w,_)&&(T[_]=w[_]);return T}).apply(this,arguments)},mt=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},ut=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},ft={width:500,height:500},_t=function(){function T(w){var O=w.callbackChange,M=O===void 0||O;this.imageId=w.imageId,this.uploadCtx=w.uploadCtx,this.file=w.file,this._status=w.status||et.WAIT_UPLOAD,this.callbackChange=M,this.fileUrl=void 0,this.uploadProgress=void 0,this.previewSrc=j(this.file),this.uploadCtx.recordChatImage(this),this.triggerChange()}return T.prototype.upload=function(w){return w===void 0&&(w={}),mt(this,void 0,void 0,function(){var O,M,_,$,L,K,Q,X,N,at,R,H,W,J=this;return ut(this,function(it){switch(it.label){case 0:return O=this.uploadCtx,M=O.channelId,_=O.userId,$=O.bucket,this.status=et.UPLOADING,[4,O.uploadApi.getUploadToken({channelId:M,userId:_,bucket:$})];case 1:if(L=it.sent(),!((K=this.file).size>1024*O.compressSizeLimit))return[3,5];it.label=2;case 2:return it.trys.push([2,4,,5]),[4,this.compressImage({file:this.file,fileName:this.fileName})];case 3:return Q=it.sent(),K=Q,[3,5];case 4:return it.sent(),console.warn("图片压缩失败",K,this.imageId),[3,5];case 5:return it.trys.push([5,7,,8]),[4,B(K)];case 6:return X=it.sent(),N=X.width,at=X.height,this.size={width:N,height:at},[3,8];case 7:return it.sent(),console.warn("获取图片尺寸失败"),[3,8];case 8:this.size||(this.size=ft),this.uploadProgress=0,R="",it.label=9;case 9:return it.trys.push([9,13,,14]),[4,O.uploadApi.uploadImage(yt(yt({},L),{file:K,fileName:this.fileName,onUploadProgress:function(Ct){J.uploadProgress=Ct,J.triggerChange()}}))];case 10:return R=it.sent(),this.fileUrl=R,O.enablePornChecking?[4,O.uploadApi.pornIdentify({channelId:M,url:"https:"+R})]:[3,12];case 11:it.sent(),it.label=12;case 12:return this.status=et.UPLOAD_SUCCESS,[3,14];case 13:return H=it.sent(),this.status=H.failCode===G.PORN_IDENTIFY_ERROR?et.UPLOAD_FORBID:et.UPLOAD_FAIL,w.error,[2,Promise.reject(H)];case 14:return typeof(W=w.success)=="function"&&W(R),[2,R]}})})},T.prototype.compressImage=function(w){return mt(this,void 0,void 0,function(){var O,M,_,$,L,K,Q,X,N,at;return ut(this,function(R){switch(R.label){case 0:return O=w.file,M=w.fileName,_=w.quality,$=_===void 0?.7:_,[4,B(O)];case 1:return L=R.sent(),K=L.width,Q=L.height,X=L.imageTarget,(N=document.createElement("canvas")).setAttribute("width",""+K),N.setAttribute("height",""+Q),(at=N.getContext("2d"))?(at.drawImage(X,0,0,K,Q),[2,z(N.toDataURL("image/jpeg",$),M)]):[2,Promise.reject(new Error("create canvas error"))]}})})},T.prototype.triggerChange=function(){if(this.callbackChange){var w=this.uploadCtx.onChange;typeof w=="function"&&w(this)}},Object.defineProperty(T.prototype,"fileName",{get:function(){var w=V(this.file);return this.imageId+"."+(w||"png")},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"status",{get:function(){return this._status},set:function(w){this._status=w,this.triggerChange()},enumerable:!1,configurable:!0}),T}(),It=function(){function T(w){this.uploadCtx=w.uploadCtx,this.uploadingList=[],this.waitQueue=[]}return T.prototype.joinWaitQueue=function(w){this.isExistQueue(w,this.waitQueue)||(this.waitQueue.push(w),this.checkQueue())},T.prototype.checkQueue=function(){var w=this;if(!(this.uploadingList.length>=this.uploadCtx.maxUploadNumber)&&this.waitQueue.length!==0)for(var O=this.uploadCtx.maxUploadNumber-this.uploadingList.length,M=function(L){var K=_.waitQueue.shift();K&&(K.upload({success:function(){w.handleImageUploadSuccess(K)}}),_.uploadingList.push(K))},_=this,$=0;$<O;$++)M()},T.prototype.handleImageUploadSuccess=function(w){this.uploadingList=this.uploadingList.filter(function(O){return O.imageId!==w.imageId}),this.checkQueue()},T.prototype.isExistQueue=function(w,O){return O.findIndex(function(M){return M.imageId===w.imageId})!==-1},T}(),Et=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/tiff","image/tifa"],vt=["png","bmp","webp","tiff","tif","jpeg","jpg","gif"],ht={channelId:"",userId:"",sizeLimit:81920,compressSizeLimit:2048,limit:9,maxWidth:700,reUploadTimes:3,source:"chat_img",bucket:"liveimages",useBlobByCompress:!1,allowAccept:Et,allowFileExtension:vt,maxUploadNumber:3,enablePornChecking:!1,apiHost:"api.polyv.net"},xt=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},q=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},st=function(){function T(w){w===void 0&&(w={});var O=w.channelId,M=O===void 0?ht.channelId:O,_=w.userId,$=_===void 0?ht.userId:_,L=w.sizeLimit,K=L===void 0?ht.sizeLimit:L,Q=w.compressSizeLimit,X=Q===void 0?ht.compressSizeLimit:Q,N=w.limit,at=N===void 0?ht.limit:N,R=w.maxWidth,H=R===void 0?ht.maxWidth:R,W=w.reUploadTimes,J=W===void 0?ht.reUploadTimes:W,it=w.source,Ct=it===void 0?ht.source:it,kt=w.bucket,At=kt===void 0?ht.bucket:kt,Lt=w.useBlobByCompress,nt=Lt===void 0?ht.useBlobByCompress:Lt,ct=w.allowAccept,gt=ct===void 0?ht.allowAccept:ct,bt=w.allowFileExtension,Tt=bt===void 0?ht.allowFileExtension:bt,Gt=w.maxUploadNumber,Bt=Gt===void 0?ht.maxUploadNumber:Gt,Jt=w.apiHost,pe=Jt===void 0?ht.apiHost:Jt,de=w.onChange,he=w.beforeStart;this.channelId=M,this.userId=$,this.sizeLimit=K,this.compressSizeLimit=X,this.limit=at,this.maxWidth=H,this.reUploadTimes=J,this.source=Ct,this.bucket=At,this.useBlobByCompress=!!nt,this.allowAccept=gt,this.allowFileExtension=Tt,this.maxUploadNumber=Bt,this.onChange=de,this.beforeStart=he,this.enablePornChecking=w.enablePornChecking===!0,this.apiHost=pe,this.uploadQueue=new It({uploadCtx:this}),this.uploadApi=new pt({uploadCtx:this}),this.chatImageStore={}}return T.prototype.choiceImageFile=function(w){var O=this;w===void 0&&(w={});var M=this.getAccept(),_=document.createElement("input");return _.setAttribute("id","polyv-upload-chat-image-input-id"),_.setAttribute("type","file"),_.setAttribute("accept",M),_.setAttribute("style","visibility: hidden;position: fixed;bottom: -100%;z-index: -1;"),this.limit>1&&_.setAttribute("multiple","multiple"),_.addEventListener("change",function(){document.body.removeChild(_),w&&_.files&&_.files.length!==0&&O.handleFileList(w,_.files)}),document.body.appendChild(_),_.click(),this},T.prototype.handleFileList=function(w,O){this.beforeStart&&this.beforeStart();for(var M,_=w.fail,$=w.success,L=w.callbackChange,K=O.length<this.limit?O.length:this.limit,Q=0;Q<K;Q++){var X=O[Q],N=this.checkFile(X);if(N)return M=N,void(typeof _=="function"&&_(M))}var at=[];for(Q=0;Q<K;Q++){X=O[Q];var R=this.buildImageId(Q),H=new _t({imageId:R,uploadCtx:this,file:X,callbackChange:L});at.push(H)}typeof $=="function"&&$(at)},T.prototype.getAccept=function(){var w=[];return w.push.apply(w,this.allowFileExtension.map(function(O){return"."+O})),w.push.apply(w,this.allowAccept),w.join(",")},T.prototype.joinWaitQueue=function(w){var O=this;if(Array.isArray(w))return w.forEach(function(_){O.joinWaitQueue(_)}),this;var M=void 0;return typeof w=="string"?M=this.getChatImageById(w):w instanceof _t&&(M=w),M&&this.uploadQueue.joinWaitQueue(M),this},T.prototype.getUploadImageUrl=function(){var w=this;return new Promise(function(O,M){w.choiceImageFile({callbackChange:!1,success:function(_){return xt(w,void 0,void 0,function(){var $;return q(this,function(L){switch(L.label){case 0:return[4,($=_[0]).upload()];case 1:return L.sent(),$.fileUrl?O($):M(new rt(G.UPLOAD_IMAGE_ERROR)),[2]}})})},fail:function(_){M(_)}})})},T.prototype.callbackUploadImage=function(){var w=this;this.choiceImageFile({success:function(O){w.joinWaitQueue(O)}})},T.prototype.uploadImageFile=function(w){return xt(this,void 0,void 0,function(){var O;return q(this,function(M){switch(M.label){case 0:if(O=this.checkFile(w))throw new Error(O.failMessage);return[4,new _t({imageId:this.buildImageId(),file:w,uploadCtx:this,callbackChange:!1}).upload()];case 1:return[2,M.sent()]}})})},T.prototype.uploadImage=function(w,O){return xt(this,void 0,void 0,function(){var M,_;return q(this,function($){switch($.label){case 0:if(M=this.checkFile(w))throw new Error(M.failMessage);return[4,(_=new _t({imageId:this.buildImageId(),file:w,uploadCtx:this,callbackChange:O!==!1})).upload()];case 1:return $.sent(),[2,_]}})})},T.prototype.reUploadImage=function(w){return xt(this,void 0,void 0,function(){var O,M;return q(this,function(_){switch(_.label){case 0:if(!(O=this.getChatImageById(w)))return[2,Promise.reject(new Error("图片不存在"))];_.label=1;case 1:return _.trys.push([1,3,,4]),[4,O.upload()];case 2:return _.sent(),[2,O];case 3:return M=_.sent(),[2,Promise.reject(M)];case 4:return[2]}})})},T.prototype.getChatImageById=function(w){return this.chatImageStore[w]},T.prototype.recordChatImage=function(w){this.chatImageStore[w.imageId]=w},T.prototype.checkFile=function(w){if(!w.size)return rt.getFailErrorData(G.EMPTY_FILE);if(w.size>1024*this.sizeLimit)return rt.getFailErrorData(G.FILE_SIZE_TOO_LARGE);if(!this.allowAccept.includes(w.type))return rt.getFailErrorData(G.FILE_TYPE_NOT_ALLOW);var O=V(w);return this.allowFileExtension.includes(O)?void 0:rt.getFailErrorData(G.FILE_EXTENSION_NOT_ALLOW)},T.prototype.buildImageId=function(w){var O=[];this.source&&O.push(this.source),this.channelId&&O.push(this.channelId),this.userId&&O.push(this.userId);var M=w!==void 0?"_"+w:"";return O.join("_")+"_"+Date.now()+"_"+Math.random().toString().substring(2,10)+M},T}()}]);class De extends Nt{constructor(t){super(t);wt(this,"__uploadImgCtrl");wt(this,"__svgaMap",{coffee:"coffee.svga",like:"like.svga",handclap:"handclap.svga",666:"666.svga",star:"star.svga",diamond:"diamond.svga",car:"car.svga",rocket:"rocket.svga",bear:"bear.svga",crown:"crown.svga",cup:"cup.svga",microphone:"microphone.svga",villa:"villa.svga",house:"villa.svga"});this.__uploadImgCtrl=new Fe.ChatImageUpload({enablePornChecking:!0})}__setUploadImgChannelId(){return lt(this,null,function*(){const t=yield this._plvSocket.getChannelInfo();this.__uploadImgCtrl.channelId=t.channelId})}uploadMultiImage(t){return lt(this,null,function*(){yield this.__setUploadImgChannelId();const e=(t==null?void 0:t.maxLimit)||9,r=typeof(t==null?void 0:t.ready)=="function"?t.ready:()=>{},n=typeof(t==null?void 0:t.success)=="function"?t.success:()=>{},i=typeof(t==null?void 0:t.fail)=="function"?t.fail:()=>{},s=[],u=[];return new Promise((f,c)=>{this.__uploadImgCtrl.choiceImageFile({callbackChange:!1,success:d=>lt(this,null,function*(){d=d.slice(0,e),d.forEach(g=>{r({imageId:g.imageId,previewSrc:g.previewSrc||""})});try{for(var p=ee(d),l,h,v;l=!(h=yield p.next()).done;l=!1){const g=h.value;try{const y=yield g.upload();if(!y)throw new Error("upload Image Error");const b={imageId:g.imageId,imageUrl:y,size:g.size};s.push(b),n(b)}catch(y){const b=y,m={imageId:g.imageId,previewSrc:g.previewSrc||""};u.push(m),console.error("[util-module][uploadMultiImage] ",b.message,m),i(b,m)}}}catch(h){v=[h]}finally{try{l&&(h=p.return)&&(yield h.call(p))}finally{if(v)throw v[0]}}return f({successUploadImages:s,failUploadImages:u})}),fail:d=>{console.error("[util-module][uploadMultiImage] ",d),c(new Error(d.failMessage))}})})})}directUploadImage(t){return lt(this,null,function*(){if(!t)throw new Error("file is null");yield this.__setUploadImgChannelId();const e=yield this.__uploadImgCtrl.uploadImage(t);if(!e.fileUrl)throw new Error("upload fail");return{imageId:e.imageId,imageUrl:e.fileUrl,size:e.size}})}translateText(t){return lt(this,null,function*(){const e=this._plvSocket.getUserInfo(),r=yield this._plvSocket.polyvApi.getTokenFieldByUserType();return(yield this._plvSocket.polyvApi.post("/live/v4/channel/translate",{},{params:{query:t,viewerId:e.userId},tokenInfo:{tokenField:r}}))[0]})}__genResourceUrl(t){return`https://s1.videocc.net${t}`}getDefaultResource(){return{defaultViewerAvatar:this.__genResourceUrl("/default-img/avatar/viewer.png")}}getDefaultDonateSvgaUrl(t){return lt(this,null,function*(){const e=t.gimg,r=this.__svgaMap,n=document.createElement("a");n.href=e;const i=n.pathname.split("/"),s=i[i.length-1].split(".")[0];if(r[s])return this.__genResourceUrl(`/default-img/donate-svga/${r[s]}`)})}}function Be(o){return typeof o!="object"&&(o=new Date(o)),o}function ze(o,a){const t={Y:(o=Be(o)).getFullYear(),M:o.getMonth()+1,D:o.getDate(),h:o.getHours(),m:o.getMinutes(),s:o.getSeconds()};return a.replace(/([YMDhms])\1*/g,function(e){let r=t[e[0]].toString();const n=e.length;return n>r.length&&(r=new Array(n-r.length+1).join("0")+r),r})}class Ge extends Nt{constructor(){super(...arguments);wt(this,"__refId","")}setRefId(t){this.__refId=t}getRefId(){return this.__refId}exportAttendanceList(){return lt(this,null,function*(){const t=yield this._plvSocket.getChannelInfo(),e=this._plvSocket.getUserInfo(),r={channelId:t.channelId,userId:e.userId,timestamp:Date.now(),expectedArrivalType:"viewer_white",type:"whiteList"};r.sign=yield this._plvSocket.chatApi.getChatSign(r),yield this._plvSocket.chatApi.post("/front/channel/download-history/post",r,{appendChannelId:!1,appendUserId:!1})})}getAttendanceDownloadRecord(){return lt(this,arguments,function*(t={}){const{pageNumber:e=1,pageSize:r=10}=t,n=yield this._plvSocket.getChannelInfo(),i=yield this._plvSocket.chatApi.get("/front/channel/download-history-list/get",{timestamp:Date.now(),page:e,size:r,type:"whiteList"},{appendChatSign:!0}),s=[];return i.list.forEach(u=>{const f=["缺勤/到勤名单",n.channelId];u.sessionId&&f.push(u.sessionId),u.createTime&&f.push(ze(u.createTime,"YYYYMMDD hh:mm:ss"));let c="pending";u.isExpire?c="expired":u.status===1?c="failed":u.status===0?c="pending":u.status===2&&(c="success"),s.push({id:`${u.createTime}-${u.sessionId}`,downloadUrl:u.src,fileName:f.join("-")+".gz",fileSize:0,progress:c==="pending"?0:100,status:c,createTime:u.createTime})}),{pageNumber:i.page,pageSize:i.size,contents:s,totalItems:i.totalCount,totalPages:i.totalPage}})}exportOnlineList(){return lt(this,null,function*(){const t={businessType:"LIVE"},e=this.getRefId();e&&(t.refId=e),yield this._plvSocket.polyvApi.get("/live/v4/channel/chat-data/online-user/export",t)})}exportWhiteList(){return lt(this,null,function*(){this._plvSocket.polyvApi.open("/live/v3/channel/chat/export-whitelist-viewing",{})})}}class He{constructor(a,t={}){wt(this,"PolyvChatEvent",St);wt(this,"ChatMsgSource",ot);wt(this,"DonateType",Dt);wt(this,"RedpackType",Yt);wt(this,"SystemMsgType",qt);wt(this,"ChatRequestHistoryMode",Ut);wt(this,"ManageFailReason",Pt);wt(this,"TranslateLanguage",Xt);wt(this,"eventEmitter",new we);wt(this,"__socketFilter");wt(this,"__socketHandler");wt(this,"emotion");wt(this,"history");wt(this,"message");wt(this,"status");wt(this,"utils");wt(this,"sender");wt(this,"manage");wt(this,"online");wt(this,"download");wt(this,"setuped",!1);this.plvSocket=a,this.config=t,this.emotion=new Ce(this),this.history=new ke(this),this.message=new Re(this),this.status=new Ue(this),this.utils=new De(this),this.sender=new Ne(this),this.manage=new Me(this),this.online=new Pe(this),this.download=new Ge(this),this.__socketFilter=new Ee(this),this.__socketHandler=new Oe(this)}setup(){return lt(this,null,function*(){yield this.emotion.setupEmotionParser(),this.setuped=!0})}}exports.ChatMsgSource=ot;exports.ChatRequestHistoryMode=Ut;exports.DonateType=Dt;exports.ManageFailReason=Pt;exports.MotivationLikeType=Qt;exports.PolyvChat=He;exports.PolyvChatEvent=St;exports.RedpackType=Yt;exports.SystemMsgType=qt;exports.TranslateLanguage=Xt;exports.canQuoteMsgSource=le;exports.canTopMsgSource=fe;exports.isServiceMsgMap=ce;console.log("%c@polyv/chat","background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff","[version: 2.1.0-rc-20251023.2]","[buildTime: 2025-10-22 01:22:17]");
package/index.es.js CHANGED
@@ -7040,8 +7040,8 @@ class Ve {
7040
7040
  console.log(
7041
7041
  "%c@polyv/chat",
7042
7042
  "background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff",
7043
- "[version: 2.1.0-rc-20251023.1]",
7044
- "[buildTime: 2025-10-21 10:21:15]"
7043
+ "[version: 2.1.0-rc-20251023.2]",
7044
+ "[buildTime: 2025-10-22 01:22:17]"
7045
7045
  );
7046
7046
  export {
7047
7047
  ot as ChatMsgSource,
package/index.umd.js CHANGED
@@ -16,4 +16,4 @@
16
16
  *
17
17
  * @author Feross Aboukhadijeh <https://feross.org>
18
18
  * @license MIT
19
- */o.exports=function(e){return e!=null&&(t(e)||function(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&t(r.slice(0,0))}(e)||!!e._isBuffer)}},function(o,u,t){t.r(u),t.d(u,"ChatImageUpload",function(){return ut}),t.d(u,"defaultConfig",function(){return vt}),t.d(u,"allowAccept",function(){return Ct}),t.d(u,"allowFileExtension",function(){return gt}),t.d(u,"FailError",function(){return rt}),t.d(u,"FailCode",function(){return G}),t.d(u,"ChatImage",function(){return Ot}),t.d(u,"ImageStatus",function(){return et}),t(127),t(92),t(63),t(35),t(67),t(135),t(136),t(73);var e=Object.prototype.hasOwnProperty;function r(T,w){return e.call(T,w)}function n(T){if(T==null)throw new TypeError("Cannot convert undefined or null to object");for(var w=0;w<(arguments.length<=1?0:arguments.length-1);w++){var O=w+1<1||arguments.length<=w+1?void 0:arguments[w+1];if(O!=null)for(var M in O)M!=="__proto__"&&r(O,M)&&(T[M]=O[M])}return T}var i=Object.prototype.toString;t(74),t(53),t(151),t(152),t(154);function a(T,w){var O,M,_=n({encode:encodeURIComponent},w),$=[];function L(Q,X){X==null&&(X=""),X===""&&_.ignoreEmpty||(typeof _.encode=="function"&&(Q=_.encode(Q),X=_.encode(String(X))),$.push(Q+"="+X))}function K(Q){L(O,Q)}for(O in T)r(T,O)&&(M=T[O],Array.isArray(M)?M.forEach(K):L(O,M));return $.join("&")}t(116),t(155);function s(T,w,O){if(T==null||w==null)return T;var M=(T=String(T)).indexOf("#"),_="";return M!==-1&&(_=T.substring(M,T.length),T=T.substring(0,M)),(T=T.replace(/[?&]$/,""))+((w=typeof w!="string"?a(w,O):w.replace(/^[?&]/,""))?(T.indexOf("?")!==-1?"&":"?")+w:"")+_}t(157),t(159),t(117),t(160),t(161),t(162),t(163),t(164),t(120),t(167),t(173),t(174),t(175),t(176),t(178),t(179);function f(T){return(f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w})(T)}function c(T,w){if(w&&(f(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(O){if(O===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O}(T)}function d(T){var w=typeof Map=="function"?new Map:void 0;return(d=function(O){if(O===null||(M=O,Function.toString.call(M).indexOf("[native code]")===-1))return O;var M;if(typeof O!="function")throw new TypeError("Super expression must either be null or a function");if(w!==void 0){if(w.has(O))return w.get(O);w.set(O,_)}function _(){return p(O,arguments,v(this).constructor)}return _.prototype=Object.create(O.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),h(_,O)})(T)}function p(T,w,O){return(p=l()?Reflect.construct:function(M,_,$){var L=[null];L.push.apply(L,_);var K=new(Function.bind.apply(M,L));return $&&h(K,$.prototype),K}).apply(null,arguments)}function l(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(T){return!1}}function h(T,w){return(h=Object.setPrototypeOf||function(O,M){return O.__proto__=M,O})(T,w)}function v(T){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(w){return w.__proto__||Object.getPrototypeOf(w)})(T)}var g=function(T){(function(L,K){if(typeof K!="function"&&K!==null)throw new TypeError("Super expression must either be null or a function");L.prototype=Object.create(K&&K.prototype,{constructor:{value:L,writable:!0,configurable:!0}}),Object.defineProperty(L,"prototype",{writable:!1}),K&&h(L,K)})($,T);var w,O,M,_=(w=$,O=l(),function(){var L,K=v(w);if(O){var Q=v(this).constructor;L=Reflect.construct(K,arguments,Q)}else L=K.apply(this,arguments);return c(this,L)});function $(L){var K;return function(Q,X){if(!(Q instanceof X))throw new TypeError("Cannot call a class as a function")}(this,$),(K=_.call(this,L)).name="AJAXError",K}return M=$,Object.defineProperty(M,"prototype",{writable:!1}),M}(d(Error)),y=/(?:^|;\s*)(?:application|text)\/([a-z]+)/i;t(180),t(182),t(183);function b(T,w,O,M){return function(){var _,$,L,K=(T.responseText||"").trim();switch(w.responseType||((L=T.getResponseHeader("Content-Type"))&&y.test(L)?RegExp.$1.toLowerCase():"")){case"json":if(K)try{_=JSON.parse(K)}catch(at){$="Invalid JSON structure"}break;case"xml":(_=T.responseXML)&&_.documentElement||($="Invalid XML format");break;default:_=K}var Q,X={xhr:T,options:w,data:_},N=T.status;(function(at){return!(at===void 0||at>=200&&at<300||at===1223||at===304)})(N)?(Q=new g("Error (HTTP status code: "+N+")")).code=N:$&&(Q=new g($)),Q?M(n(Q,X)):O(X)}}var m=Object.create(null),S=0;function x(T,w,O,M){T.onload=b(T,w,O,M),T.ontimeout=function(){var $;M((($=new g("Request timeout")).isTimeout=!0,$))},T.onerror=function(){M(new g("Network error"))},w.onDownloadProgress&&T.addEventListener("progress",w.onDownloadProgress),w.onUploadProgress&&T.upload&&T.upload.addEventListener("progress",w.onUploadProgress),S===Number.MAX_SAFE_INTEGER&&(S=0);var _=++S;return m[_]={xhr:T,options:w,resolve:O,reject:M},_}function I(T){delete m[T]}function E(T,w,O,M,_){return T&&/MSIE\s+(\d+)/.test(navigator.userAgent)&&parseInt(RegExp.$1)<10&&window.XDomainRequest&&(w==="get"||w==="post")&&!O&&!_&&function($){if($!=null){if(Array.isArray($))return!$.length;for(var L in $)if(r($,L))return!1}return!0}(M)?new window.XDomainRequest:new window.XMLHttpRequest}function C(T,w,O,M){var _,$,L;if(O!=null&&T!=="get")return M==="json"?(_=JSON.stringify(O),$="application/json; charset=utf-8"):(L=O,typeof(_=i.call(L)==="[object Object]"?a(O,{ignoreEmpty:!1}):O)=="string"&&($="application/x-www-form-urlencoded; charset=utf-8")),w["Content-Type"]=w["Content-Type"]||$,_}function k(T,w){var O=0;return new Promise(function(M,_){(w=n({},w)).method=w.method||"get",w.requestType=w.requestType||"",w.responseType=w.responseType||"json",w.timeout=w.timeout||0;var $=w.method.toLowerCase(),L=w.requestType.toLowerCase(),K=w.headers||{},Q=function(at){var R=document.createElement("div");R.innerHTML='<a href="'+at+'"></a>';var H=R.firstChild,W=H.host!==location.host;return R=null,H=null,W}(T=function(at,R,H){return R!=null&&(at=s(at,R,{ignoreEmpty:!1})),H&&(at=s(at,{_:Date.now()})),at}(T,w.params,w.preventCaching)),X=E(Q,$,L,K,w.withCredentials);O=x(X,w,function(at){I(O),M(at)},function(at){I(O),_(at)}),X.open($,T,!0,w.username,w.password);var N=C($,K,w.data,L);(function(at,R,H,W){R.timeout&&(at.timeout=R.timeout),H&&R.withCredentials!=null&&(at.withCredentials=!!R.withCredentials),H||W["X-Request-With"]!=null||(W["X-Request-With"]="XMLHttpRequest"),Object.keys(W).forEach(function(J){W[J]!=null&&at.setRequestHeader(J,String(W[J]))})})(X,w,Q,K),typeof w.beforeSend=="function"&&w.beforeSend.call(window,X),X.send(N||""),typeof w.receiveCancelId=="function"&&w.receiveCancelId(O)})}var A=t(82),U=t.n(A);function V(T){return T.name.toLowerCase().split(".").pop()||""}function F(T){var w=new FormData;for(var O in T)w.append(O,T[O]);return w}function z(T,w,O){O===void 0&&(O=!1);for(var M=T.split(","),_=/:(.*?);/.exec(M[0]),$=_?_[1]:"image/jpeg",L=window.atob(M[1]),K=L.length,Q=new Uint8Array(K);K--;)Q[K]=L.charCodeAt(K);return O?new Blob([Q],{type:$}):new File([Q],w,{type:$})}function B(T){return new Promise(function(w,O){var M=new Image;M.onload=function(){w({width:M.width,height:M.height,imageTarget:M})},M.onerror=function(){O(new Error("获取图片尺寸失败"))};var _="";_=typeof T=="string"?T:j(T),M.src=_})}function j(T){return(window.URL||window.webkitURL).createObjectURL(T)}var P,D,G,Z=(P=function(T,w){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(O,M){O.__proto__=M}||function(O,M){for(var _ in M)Object.prototype.hasOwnProperty.call(M,_)&&(O[_]=M[_])})(T,w)},function(T,w){if(typeof w!="function"&&w!==null)throw new TypeError("Class extends value "+String(w)+" is not a constructor or null");function O(){this.constructor=T}P(T,w),T.prototype=w===null?Object.create(w):(O.prototype=w.prototype,new O)});(function(T){T.EMPTY_FILE="empty file",T.FILE_SIZE_TOO_LARGE="file size too large",T.FILE_TYPE_NOT_ALLOW="file type not allow",T.FILE_EXTENSION_NOT_ALLOW="file extension not allow",T.GET_UPLOAD_TOKEN_ERROR="get upload token error",T.UPLOAD_IMAGE_ERROR="upload image error",T.PORN_IDENTIFY_ERROR="porn identify error"})(G||(G={}));var et,rt=function(T){function w(O){var M=T.call(this,O)||this,_=w.getFailErrorData(O);return M.failCode=_.failCode,M.failMessage=_.failMessage,M}return Z(w,T),w.getFailErrorData=function(O){return{failCode:O,failMessage:w.failMessageVal[O]}},w.failMessageVal=((D={})[G.EMPTY_FILE]="请勿上传空文件",D[G.FILE_SIZE_TOO_LARGE]="文件大小超出限制",D[G.FILE_TYPE_NOT_ALLOW]="该文件类型不支持",D[G.FILE_EXTENSION_NOT_ALLOW]="该文件扩展名不支持",D[G.GET_UPLOAD_TOKEN_ERROR]="获取上传图片 token 失败",D[G.UPLOAD_IMAGE_ERROR]="上传图片失败",D[G.PORN_IDENTIFY_ERROR]="图片鉴黄失败",D),w}(Error),tt=function(){return(tt=Object.assign||function(T){for(var w,O=1,M=arguments.length;O<M;O++)for(var _ in w=arguments[O])Object.prototype.hasOwnProperty.call(w,_)&&(T[_]=w[_]);return T}).apply(this,arguments)},Y=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},ht=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},dt=function(){function T(w){this.uploadCtx=w.uploadCtx}return T.prototype.getUploadToken=function(w){return Y(this,void 0,void 0,function(){var O,M,_,$,L;return ht(this,function(K){switch(K.label){case 0:return O=Date.now(),M=U()("upload_token_live"+w.channelId+O),_={channelId:w.channelId,ts:O,hash:M,bucket:w.bucket},w.userId&&(_.userId=w.userId),[4,k("https://"+this.uploadCtx.apiHost+"/live/upload/token/image/get-token",{params:_})];case 1:return($=K.sent()).data?(L=$.data).code!==200?[2,Promise.reject(new rt(G.GET_UPLOAD_TOKEN_ERROR))]:[2,L.data]:[2,Promise.reject(new rt(G.GET_UPLOAD_TOKEN_ERROR))]}})})},T.prototype.uploadImage=function(w){return Y(this,void 0,void 0,function(){var O,M,_,$,L,K;return ht(this,function(Q){switch(Q.label){case 0:O={key:""+w.dir+w.fileName,policy:w.policy,OSSAccessKeyId:w.accessid,signature:w.signature,success_action_status:200,callback:w.encodedCallback,file:w.file},Q.label=1;case 1:return Q.trys.push([1,3,,4]),[4,k("https://"+w.host,{method:"post",data:F(O),onUploadProgress:function(X){var N,at,R=w.onUploadProgress;typeof R=="function"&&R((N=X.loaded/X.total,at=2,Number(N.toFixed(at||0))))}})];case 2:return(M=Q.sent()).data?(_=M.data).code!==200?[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))]:[2,_.data]:[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))];case 3:return Q.sent(),$=w.currentReuploadTime,(L=$===void 0?0:$)&&L>=this.uploadCtx.reUploadTimes?[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))]:(L+=1,K=Object.assign({},w,{currentReuploadTime:L}),[2,this.uploadImage(K)]);case 4:return[2]}})})},T.prototype.createSign=function(w,O,M){var _=w;Object.keys(O).sort().forEach(function(L){O[L]&&(_+=L+String(O[L]))}),_+=w;var $=U()(_);return M==="lower"?$:$.toLocaleUpperCase()},T.prototype.pornIdentify=function(w){return Y(this,void 0,void 0,function(){var O,M,_;return ht(this,function($){switch($.label){case 0:O=tt(tt({},w),{timestamp:Date.now()}),$.label=1;case 1:return $.trys.push([1,3,,4]),[4,k("https://"+this.uploadCtx.apiHost+"/live/inner/v3/chat/image/porn-identify",{method:"post",data:tt(tt({},O),{sign:this.createSign("polyv_chat_api_innor",O)})})];case 2:return(M=$.sent()).data?M.data.code!==200?[2,Promise.reject(new rt(G.PORN_IDENTIFY_ERROR))]:[2,!0]:[2,Promise.reject(new rt(G.PORN_IDENTIFY_ERROR))];case 3:return _=$.sent(),[2,Promise.reject(_)];case 4:return[2]}})})},T}();(function(T){T.WAIT_UPLOAD="waitUpload",T.UPLOADING="uploading",T.UPLOAD_SUCCESS="uploadSuccess",T.UPLOAD_FAIL="uploadFail",T.UPLOAD_FORBID="forbid"})(et||(et={}));var wt=function(){return(wt=Object.assign||function(T){for(var w,O=1,M=arguments.length;O<M;O++)for(var _ in w=arguments[O])Object.prototype.hasOwnProperty.call(w,_)&&(T[_]=w[_]);return T}).apply(this,arguments)},bt=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},st=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},lt={width:500,height:500},Ot=function(){function T(w){var O=w.callbackChange,M=O===void 0||O;this.imageId=w.imageId,this.uploadCtx=w.uploadCtx,this.file=w.file,this._status=w.status||et.WAIT_UPLOAD,this.callbackChange=M,this.fileUrl=void 0,this.uploadProgress=void 0,this.previewSrc=j(this.file),this.uploadCtx.recordChatImage(this),this.triggerChange()}return T.prototype.upload=function(w){return w===void 0&&(w={}),bt(this,void 0,void 0,function(){var O,M,_,$,L,K,Q,X,N,at,R,H,W,J=this;return st(this,function(it){switch(it.label){case 0:return O=this.uploadCtx,M=O.channelId,_=O.userId,$=O.bucket,this.status=et.UPLOADING,[4,O.uploadApi.getUploadToken({channelId:M,userId:_,bucket:$})];case 1:if(L=it.sent(),!((K=this.file).size>1024*O.compressSizeLimit))return[3,5];it.label=2;case 2:return it.trys.push([2,4,,5]),[4,this.compressImage({file:this.file,fileName:this.fileName})];case 3:return Q=it.sent(),K=Q,[3,5];case 4:return it.sent(),console.warn("图片压缩失败",K,this.imageId),[3,5];case 5:return it.trys.push([5,7,,8]),[4,B(K)];case 6:return X=it.sent(),N=X.width,at=X.height,this.size={width:N,height:at},[3,8];case 7:return it.sent(),console.warn("获取图片尺寸失败"),[3,8];case 8:this.size||(this.size=lt),this.uploadProgress=0,R="",it.label=9;case 9:return it.trys.push([9,13,,14]),[4,O.uploadApi.uploadImage(wt(wt({},L),{file:K,fileName:this.fileName,onUploadProgress:function(kt){J.uploadProgress=kt,J.triggerChange()}}))];case 10:return R=it.sent(),this.fileUrl=R,O.enablePornChecking?[4,O.uploadApi.pornIdentify({channelId:M,url:"https:"+R})]:[3,12];case 11:it.sent(),it.label=12;case 12:return this.status=et.UPLOAD_SUCCESS,[3,14];case 13:return H=it.sent(),this.status=H.failCode===G.PORN_IDENTIFY_ERROR?et.UPLOAD_FORBID:et.UPLOAD_FAIL,w.error,[2,Promise.reject(H)];case 14:return typeof(W=w.success)=="function"&&W(R),[2,R]}})})},T.prototype.compressImage=function(w){return bt(this,void 0,void 0,function(){var O,M,_,$,L,K,Q,X,N,at;return st(this,function(R){switch(R.label){case 0:return O=w.file,M=w.fileName,_=w.quality,$=_===void 0?.7:_,[4,B(O)];case 1:return L=R.sent(),K=L.width,Q=L.height,X=L.imageTarget,(N=document.createElement("canvas")).setAttribute("width",""+K),N.setAttribute("height",""+Q),(at=N.getContext("2d"))?(at.drawImage(X,0,0,K,Q),[2,z(N.toDataURL("image/jpeg",$),M)]):[2,Promise.reject(new Error("create canvas error"))]}})})},T.prototype.triggerChange=function(){if(this.callbackChange){var w=this.uploadCtx.onChange;typeof w=="function"&&w(this)}},Object.defineProperty(T.prototype,"fileName",{get:function(){var w=V(this.file);return this.imageId+"."+(w||"png")},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"status",{get:function(){return this._status},set:function(w){this._status=w,this.triggerChange()},enumerable:!1,configurable:!0}),T}(),Et=function(){function T(w){this.uploadCtx=w.uploadCtx,this.uploadingList=[],this.waitQueue=[]}return T.prototype.joinWaitQueue=function(w){this.isExistQueue(w,this.waitQueue)||(this.waitQueue.push(w),this.checkQueue())},T.prototype.checkQueue=function(){var w=this;if(!(this.uploadingList.length>=this.uploadCtx.maxUploadNumber)&&this.waitQueue.length!==0)for(var O=this.uploadCtx.maxUploadNumber-this.uploadingList.length,M=function(L){var K=_.waitQueue.shift();K&&(K.upload({success:function(){w.handleImageUploadSuccess(K)}}),_.uploadingList.push(K))},_=this,$=0;$<O;$++)M()},T.prototype.handleImageUploadSuccess=function(w){this.uploadingList=this.uploadingList.filter(function(O){return O.imageId!==w.imageId}),this.checkQueue()},T.prototype.isExistQueue=function(w,O){return O.findIndex(function(M){return M.imageId===w.imageId})!==-1},T}(),Ct=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/tiff","image/tifa"],gt=["png","bmp","webp","tiff","tif","jpeg","jpg","gif"],vt={channelId:"",userId:"",sizeLimit:81920,compressSizeLimit:2048,limit:9,maxWidth:700,reUploadTimes:3,source:"chat_img",bucket:"liveimages",useBlobByCompress:!1,allowAccept:Ct,allowFileExtension:gt,maxUploadNumber:3,enablePornChecking:!1,apiHost:"api.polyv.net"},_t=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},q=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},ut=function(){function T(w){w===void 0&&(w={});var O=w.channelId,M=O===void 0?vt.channelId:O,_=w.userId,$=_===void 0?vt.userId:_,L=w.sizeLimit,K=L===void 0?vt.sizeLimit:L,Q=w.compressSizeLimit,X=Q===void 0?vt.compressSizeLimit:Q,N=w.limit,at=N===void 0?vt.limit:N,R=w.maxWidth,H=R===void 0?vt.maxWidth:R,W=w.reUploadTimes,J=W===void 0?vt.reUploadTimes:W,it=w.source,kt=it===void 0?vt.source:it,Rt=w.bucket,Lt=Rt===void 0?vt.bucket:Rt,Bt=w.useBlobByCompress,nt=Bt===void 0?vt.useBlobByCompress:Bt,ft=w.allowAccept,mt=ft===void 0?vt.allowAccept:ft,xt=w.allowFileExtension,At=xt===void 0?vt.allowFileExtension:xt,Qt=w.maxUploadNumber,Wt=Qt===void 0?vt.maxUploadNumber:Qt,le=w.apiHost,Ue=le===void 0?vt.apiHost:le,Fe=w.onChange,De=w.beforeStart;this.channelId=M,this.userId=$,this.sizeLimit=K,this.compressSizeLimit=X,this.limit=at,this.maxWidth=H,this.reUploadTimes=J,this.source=kt,this.bucket=Lt,this.useBlobByCompress=!!nt,this.allowAccept=mt,this.allowFileExtension=At,this.maxUploadNumber=Wt,this.onChange=Fe,this.beforeStart=De,this.enablePornChecking=w.enablePornChecking===!0,this.apiHost=Ue,this.uploadQueue=new Et({uploadCtx:this}),this.uploadApi=new dt({uploadCtx:this}),this.chatImageStore={}}return T.prototype.choiceImageFile=function(w){var O=this;w===void 0&&(w={});var M=this.getAccept(),_=document.createElement("input");return _.setAttribute("id","polyv-upload-chat-image-input-id"),_.setAttribute("type","file"),_.setAttribute("accept",M),_.setAttribute("style","visibility: hidden;position: fixed;bottom: -100%;z-index: -1;"),this.limit>1&&_.setAttribute("multiple","multiple"),_.addEventListener("change",function(){document.body.removeChild(_),w&&_.files&&_.files.length!==0&&O.handleFileList(w,_.files)}),document.body.appendChild(_),_.click(),this},T.prototype.handleFileList=function(w,O){this.beforeStart&&this.beforeStart();for(var M,_=w.fail,$=w.success,L=w.callbackChange,K=O.length<this.limit?O.length:this.limit,Q=0;Q<K;Q++){var X=O[Q],N=this.checkFile(X);if(N)return M=N,void(typeof _=="function"&&_(M))}var at=[];for(Q=0;Q<K;Q++){X=O[Q];var R=this.buildImageId(Q),H=new Ot({imageId:R,uploadCtx:this,file:X,callbackChange:L});at.push(H)}typeof $=="function"&&$(at)},T.prototype.getAccept=function(){var w=[];return w.push.apply(w,this.allowFileExtension.map(function(O){return"."+O})),w.push.apply(w,this.allowAccept),w.join(",")},T.prototype.joinWaitQueue=function(w){var O=this;if(Array.isArray(w))return w.forEach(function(_){O.joinWaitQueue(_)}),this;var M=void 0;return typeof w=="string"?M=this.getChatImageById(w):w instanceof Ot&&(M=w),M&&this.uploadQueue.joinWaitQueue(M),this},T.prototype.getUploadImageUrl=function(){var w=this;return new Promise(function(O,M){w.choiceImageFile({callbackChange:!1,success:function(_){return _t(w,void 0,void 0,function(){var $;return q(this,function(L){switch(L.label){case 0:return[4,($=_[0]).upload()];case 1:return L.sent(),$.fileUrl?O($):M(new rt(G.UPLOAD_IMAGE_ERROR)),[2]}})})},fail:function(_){M(_)}})})},T.prototype.callbackUploadImage=function(){var w=this;this.choiceImageFile({success:function(O){w.joinWaitQueue(O)}})},T.prototype.uploadImageFile=function(w){return _t(this,void 0,void 0,function(){var O;return q(this,function(M){switch(M.label){case 0:if(O=this.checkFile(w))throw new Error(O.failMessage);return[4,new Ot({imageId:this.buildImageId(),file:w,uploadCtx:this,callbackChange:!1}).upload()];case 1:return[2,M.sent()]}})})},T.prototype.uploadImage=function(w,O){return _t(this,void 0,void 0,function(){var M,_;return q(this,function($){switch($.label){case 0:if(M=this.checkFile(w))throw new Error(M.failMessage);return[4,(_=new Ot({imageId:this.buildImageId(),file:w,uploadCtx:this,callbackChange:O!==!1})).upload()];case 1:return $.sent(),[2,_]}})})},T.prototype.reUploadImage=function(w){return _t(this,void 0,void 0,function(){var O,M;return q(this,function(_){switch(_.label){case 0:if(!(O=this.getChatImageById(w)))return[2,Promise.reject(new Error("图片不存在"))];_.label=1;case 1:return _.trys.push([1,3,,4]),[4,O.upload()];case 2:return _.sent(),[2,O];case 3:return M=_.sent(),[2,Promise.reject(M)];case 4:return[2]}})})},T.prototype.getChatImageById=function(w){return this.chatImageStore[w]},T.prototype.recordChatImage=function(w){this.chatImageStore[w.imageId]=w},T.prototype.checkFile=function(w){if(!w.size)return rt.getFailErrorData(G.EMPTY_FILE);if(w.size>1024*this.sizeLimit)return rt.getFailErrorData(G.FILE_SIZE_TOO_LARGE);if(!this.allowAccept.includes(w.type))return rt.getFailErrorData(G.FILE_TYPE_NOT_ALLOW);var O=V(w);return this.allowFileExtension.includes(O)?void 0:rt.getFailErrorData(G.FILE_EXTENSION_NOT_ALLOW)},T.prototype.buildImageId=function(w){var O=[];this.source&&O.push(this.source),this.channelId&&O.push(this.channelId),this.userId&&O.push(this.userId);var M=w!==void 0?"_"+w:"";return O.join("_")+"_"+Date.now()+"_"+Math.random().toString().substring(2,10)+M},T}()}]);class Re extends Dt{constructor(t){super(t);It(this,"__uploadImgCtrl");It(this,"__svgaMap",{coffee:"coffee.svga",like:"like.svga",handclap:"handclap.svga",666:"666.svga",star:"star.svga",diamond:"diamond.svga",car:"car.svga",rocket:"rocket.svga",bear:"bear.svga",crown:"crown.svga",cup:"cup.svga",microphone:"microphone.svga",villa:"villa.svga",house:"villa.svga"});this.__uploadImgCtrl=new Ae.ChatImageUpload({enablePornChecking:!0})}__setUploadImgChannelId(){return pt(this,null,function*(){const t=yield this._plvSocket.getChannelInfo();this.__uploadImgCtrl.channelId=t.channelId})}uploadMultiImage(t){return pt(this,null,function*(){yield this.__setUploadImgChannelId();const e=(t==null?void 0:t.maxLimit)||9,r=typeof(t==null?void 0:t.ready)=="function"?t.ready:()=>{},n=typeof(t==null?void 0:t.success)=="function"?t.success:()=>{},i=typeof(t==null?void 0:t.fail)=="function"?t.fail:()=>{},a=[],s=[];return new Promise((f,c)=>{this.__uploadImgCtrl.choiceImageFile({callbackChange:!1,success:d=>pt(this,null,function*(){d=d.slice(0,e),d.forEach(g=>{r({imageId:g.imageId,previewSrc:g.previewSrc||""})});try{for(var p=he(d),l,h,v;l=!(h=yield p.next()).done;l=!1){const g=h.value;try{const y=yield g.upload();if(!y)throw new Error("upload Image Error");const b={imageId:g.imageId,imageUrl:y,size:g.size};a.push(b),n(b)}catch(y){const b=y,m={imageId:g.imageId,previewSrc:g.previewSrc||""};s.push(m),console.error("[util-module][uploadMultiImage] ",b.message,m),i(b,m)}}}catch(h){v=[h]}finally{try{l&&(h=p.return)&&(yield h.call(p))}finally{if(v)throw v[0]}}return f({successUploadImages:a,failUploadImages:s})}),fail:d=>{console.error("[util-module][uploadMultiImage] ",d),c(new Error(d.failMessage))}})})})}directUploadImage(t){return pt(this,null,function*(){if(!t)throw new Error("file is null");yield this.__setUploadImgChannelId();const e=yield this.__uploadImgCtrl.uploadImage(t);if(!e.fileUrl)throw new Error("upload fail");return{imageId:e.imageId,imageUrl:e.fileUrl,size:e.size}})}translateText(t){return pt(this,null,function*(){const e=this._plvSocket.getUserInfo(),r=yield this._plvSocket.polyvApi.getTokenFieldByUserType();return(yield this._plvSocket.polyvApi.post("/live/v4/channel/translate",{},{params:{query:t,viewerId:e.userId},tokenInfo:{tokenField:r}}))[0]})}__genResourceUrl(t){return`https://s1.videocc.net${t}`}getDefaultResource(){return{defaultViewerAvatar:this.__genResourceUrl("/default-img/avatar/viewer.png")}}getDefaultDonateSvgaUrl(t){return pt(this,null,function*(){const e=t.gimg,r=this.__svgaMap,n=document.createElement("a");n.href=e;const i=n.pathname.split("/"),a=i[i.length-1].split(".")[0];if(r[a])return this.__genResourceUrl(`/default-img/donate-svga/${r[a]}`)})}}function Pe(o){return typeof o!="object"&&(o=new Date(o)),o}function je(o,u){const t={Y:(o=Pe(o)).getFullYear(),M:o.getMonth()+1,D:o.getDate(),h:o.getHours(),m:o.getMinutes(),s:o.getSeconds()};return u.replace(/([YMDhms])\1*/g,function(e){let r=t[e[0]].toString();const n=e.length;return n>r.length&&(r=new Array(n-r.length+1).join("0")+r),r})}class Le extends Dt{constructor(){super(...arguments);It(this,"__refId","")}setRefId(t){this.__refId=t}getRefId(){return this.__refId}exportAttendanceList(){return pt(this,null,function*(){const t=yield this._plvSocket.getChannelInfo(),e=this._plvSocket.getUserInfo(),r={channelId:t.channelId,userId:e.userId,timestamp:Date.now(),expectedArrivalType:"viewer_white",type:"whiteList"};r.sign=yield this._plvSocket.chatApi.getChatSign(r),yield this._plvSocket.chatApi.post("/front/channel/download-history/post",r,{appendChannelId:!1,appendUserId:!1})})}getAttendanceDownloadRecord(){return pt(this,arguments,function*(t={}){const{pageNumber:e=1,pageSize:r=10}=t,n=yield this._plvSocket.getChannelInfo(),i=yield this._plvSocket.chatApi.get("/front/channel/download-history-list/get",{timestamp:Date.now(),page:e,size:r,type:"whiteList"},{appendChatSign:!0}),a=[];return i.list.forEach(s=>{const f=["缺勤/到勤名单",n.channelId];s.sessionId&&f.push(s.sessionId),s.createTime&&f.push(je(s.createTime,"YYYYMMDD hh:mm:ss"));let c="pending";s.isExpire?c="expired":s.status===1?c="failed":s.status===0?c="pending":s.status===2&&(c="success"),a.push({id:`${s.createTime}-${s.sessionId}`,downloadUrl:s.src,fileName:f.join("-")+".gz",fileSize:0,progress:c==="pending"?0:100,status:c,createTime:s.createTime})}),{pageNumber:i.page,pageSize:i.size,contents:a,totalItems:i.totalCount,totalPages:i.totalPage}})}exportOnlineList(){return pt(this,null,function*(){const t={businessType:"LIVE"},e=this.getRefId();e&&(t.refId=e),yield this._plvSocket.polyvApi.get("/live/v4/channel/chat-data/online-user/export",t)})}exportWhiteList(){return pt(this,null,function*(){this._plvSocket.polyvApi.open("/live/v3/channel/chat/export-whitelist-viewing",{})})}}class Ne{constructor(u,t={}){It(this,"PolyvChatEvent",ct);It(this,"ChatMsgSource",ot);It(this,"DonateType",Vt);It(this,"RedpackType",Jt);It(this,"SystemMsgType",Zt);It(this,"ChatRequestHistoryMode",Ht);It(this,"ManageFailReason",St);It(this,"TranslateLanguage",ee);It(this,"eventEmitter",new $t);It(this,"__socketFilter");It(this,"__socketHandler");It(this,"emotion");It(this,"history");It(this,"message");It(this,"status");It(this,"utils");It(this,"sender");It(this,"manage");It(this,"online");It(this,"download");It(this,"setuped",!1);this.plvSocket=u,this.config=t,this.emotion=new we(this),this.history=new Ie(this),this.message=new Ee(this),this.status=new Me(this),this.utils=new Re(this),this.sender=new ke(this),this.manage=new Se(this),this.online=new Oe(this),this.download=new Le(this),this.__socketFilter=new ye(this),this.__socketHandler=new be(this)}setup(){return pt(this,null,function*(){yield this.emotion.setupEmotionParser(),this.setuped=!0})}}yt.ChatMsgSource=ot,yt.ChatRequestHistoryMode=Ht,yt.DonateType=Vt,yt.ManageFailReason=St,yt.MotivationLikeType=te,yt.PolyvChat=Ne,yt.PolyvChatEvent=ct,yt.RedpackType=Jt,yt.SystemMsgType=Zt,yt.TranslateLanguage=ee,yt.canQuoteMsgSource=fe,yt.canTopMsgSource=ce,yt.isServiceMsgMap=se,Object.defineProperty(yt,Symbol.toStringTag,{value:"Module"})});console.log("%c@polyv/chat","background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff","[version: 2.1.0-rc-20251023.1]","[buildTime: 2025-10-21 10:21:12]");
19
+ */o.exports=function(e){return e!=null&&(t(e)||function(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&t(r.slice(0,0))}(e)||!!e._isBuffer)}},function(o,u,t){t.r(u),t.d(u,"ChatImageUpload",function(){return ut}),t.d(u,"defaultConfig",function(){return vt}),t.d(u,"allowAccept",function(){return Ct}),t.d(u,"allowFileExtension",function(){return gt}),t.d(u,"FailError",function(){return rt}),t.d(u,"FailCode",function(){return G}),t.d(u,"ChatImage",function(){return Ot}),t.d(u,"ImageStatus",function(){return et}),t(127),t(92),t(63),t(35),t(67),t(135),t(136),t(73);var e=Object.prototype.hasOwnProperty;function r(T,w){return e.call(T,w)}function n(T){if(T==null)throw new TypeError("Cannot convert undefined or null to object");for(var w=0;w<(arguments.length<=1?0:arguments.length-1);w++){var O=w+1<1||arguments.length<=w+1?void 0:arguments[w+1];if(O!=null)for(var M in O)M!=="__proto__"&&r(O,M)&&(T[M]=O[M])}return T}var i=Object.prototype.toString;t(74),t(53),t(151),t(152),t(154);function a(T,w){var O,M,_=n({encode:encodeURIComponent},w),$=[];function L(Q,X){X==null&&(X=""),X===""&&_.ignoreEmpty||(typeof _.encode=="function"&&(Q=_.encode(Q),X=_.encode(String(X))),$.push(Q+"="+X))}function K(Q){L(O,Q)}for(O in T)r(T,O)&&(M=T[O],Array.isArray(M)?M.forEach(K):L(O,M));return $.join("&")}t(116),t(155);function s(T,w,O){if(T==null||w==null)return T;var M=(T=String(T)).indexOf("#"),_="";return M!==-1&&(_=T.substring(M,T.length),T=T.substring(0,M)),(T=T.replace(/[?&]$/,""))+((w=typeof w!="string"?a(w,O):w.replace(/^[?&]/,""))?(T.indexOf("?")!==-1?"&":"?")+w:"")+_}t(157),t(159),t(117),t(160),t(161),t(162),t(163),t(164),t(120),t(167),t(173),t(174),t(175),t(176),t(178),t(179);function f(T){return(f=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w})(T)}function c(T,w){if(w&&(f(w)==="object"||typeof w=="function"))return w;if(w!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return function(O){if(O===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return O}(T)}function d(T){var w=typeof Map=="function"?new Map:void 0;return(d=function(O){if(O===null||(M=O,Function.toString.call(M).indexOf("[native code]")===-1))return O;var M;if(typeof O!="function")throw new TypeError("Super expression must either be null or a function");if(w!==void 0){if(w.has(O))return w.get(O);w.set(O,_)}function _(){return p(O,arguments,v(this).constructor)}return _.prototype=Object.create(O.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),h(_,O)})(T)}function p(T,w,O){return(p=l()?Reflect.construct:function(M,_,$){var L=[null];L.push.apply(L,_);var K=new(Function.bind.apply(M,L));return $&&h(K,$.prototype),K}).apply(null,arguments)}function l(){if(typeof Reflect=="undefined"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(T){return!1}}function h(T,w){return(h=Object.setPrototypeOf||function(O,M){return O.__proto__=M,O})(T,w)}function v(T){return(v=Object.setPrototypeOf?Object.getPrototypeOf:function(w){return w.__proto__||Object.getPrototypeOf(w)})(T)}var g=function(T){(function(L,K){if(typeof K!="function"&&K!==null)throw new TypeError("Super expression must either be null or a function");L.prototype=Object.create(K&&K.prototype,{constructor:{value:L,writable:!0,configurable:!0}}),Object.defineProperty(L,"prototype",{writable:!1}),K&&h(L,K)})($,T);var w,O,M,_=(w=$,O=l(),function(){var L,K=v(w);if(O){var Q=v(this).constructor;L=Reflect.construct(K,arguments,Q)}else L=K.apply(this,arguments);return c(this,L)});function $(L){var K;return function(Q,X){if(!(Q instanceof X))throw new TypeError("Cannot call a class as a function")}(this,$),(K=_.call(this,L)).name="AJAXError",K}return M=$,Object.defineProperty(M,"prototype",{writable:!1}),M}(d(Error)),y=/(?:^|;\s*)(?:application|text)\/([a-z]+)/i;t(180),t(182),t(183);function b(T,w,O,M){return function(){var _,$,L,K=(T.responseText||"").trim();switch(w.responseType||((L=T.getResponseHeader("Content-Type"))&&y.test(L)?RegExp.$1.toLowerCase():"")){case"json":if(K)try{_=JSON.parse(K)}catch(at){$="Invalid JSON structure"}break;case"xml":(_=T.responseXML)&&_.documentElement||($="Invalid XML format");break;default:_=K}var Q,X={xhr:T,options:w,data:_},N=T.status;(function(at){return!(at===void 0||at>=200&&at<300||at===1223||at===304)})(N)?(Q=new g("Error (HTTP status code: "+N+")")).code=N:$&&(Q=new g($)),Q?M(n(Q,X)):O(X)}}var m=Object.create(null),S=0;function x(T,w,O,M){T.onload=b(T,w,O,M),T.ontimeout=function(){var $;M((($=new g("Request timeout")).isTimeout=!0,$))},T.onerror=function(){M(new g("Network error"))},w.onDownloadProgress&&T.addEventListener("progress",w.onDownloadProgress),w.onUploadProgress&&T.upload&&T.upload.addEventListener("progress",w.onUploadProgress),S===Number.MAX_SAFE_INTEGER&&(S=0);var _=++S;return m[_]={xhr:T,options:w,resolve:O,reject:M},_}function I(T){delete m[T]}function E(T,w,O,M,_){return T&&/MSIE\s+(\d+)/.test(navigator.userAgent)&&parseInt(RegExp.$1)<10&&window.XDomainRequest&&(w==="get"||w==="post")&&!O&&!_&&function($){if($!=null){if(Array.isArray($))return!$.length;for(var L in $)if(r($,L))return!1}return!0}(M)?new window.XDomainRequest:new window.XMLHttpRequest}function C(T,w,O,M){var _,$,L;if(O!=null&&T!=="get")return M==="json"?(_=JSON.stringify(O),$="application/json; charset=utf-8"):(L=O,typeof(_=i.call(L)==="[object Object]"?a(O,{ignoreEmpty:!1}):O)=="string"&&($="application/x-www-form-urlencoded; charset=utf-8")),w["Content-Type"]=w["Content-Type"]||$,_}function k(T,w){var O=0;return new Promise(function(M,_){(w=n({},w)).method=w.method||"get",w.requestType=w.requestType||"",w.responseType=w.responseType||"json",w.timeout=w.timeout||0;var $=w.method.toLowerCase(),L=w.requestType.toLowerCase(),K=w.headers||{},Q=function(at){var R=document.createElement("div");R.innerHTML='<a href="'+at+'"></a>';var H=R.firstChild,W=H.host!==location.host;return R=null,H=null,W}(T=function(at,R,H){return R!=null&&(at=s(at,R,{ignoreEmpty:!1})),H&&(at=s(at,{_:Date.now()})),at}(T,w.params,w.preventCaching)),X=E(Q,$,L,K,w.withCredentials);O=x(X,w,function(at){I(O),M(at)},function(at){I(O),_(at)}),X.open($,T,!0,w.username,w.password);var N=C($,K,w.data,L);(function(at,R,H,W){R.timeout&&(at.timeout=R.timeout),H&&R.withCredentials!=null&&(at.withCredentials=!!R.withCredentials),H||W["X-Request-With"]!=null||(W["X-Request-With"]="XMLHttpRequest"),Object.keys(W).forEach(function(J){W[J]!=null&&at.setRequestHeader(J,String(W[J]))})})(X,w,Q,K),typeof w.beforeSend=="function"&&w.beforeSend.call(window,X),X.send(N||""),typeof w.receiveCancelId=="function"&&w.receiveCancelId(O)})}var A=t(82),U=t.n(A);function V(T){return T.name.toLowerCase().split(".").pop()||""}function F(T){var w=new FormData;for(var O in T)w.append(O,T[O]);return w}function z(T,w,O){O===void 0&&(O=!1);for(var M=T.split(","),_=/:(.*?);/.exec(M[0]),$=_?_[1]:"image/jpeg",L=window.atob(M[1]),K=L.length,Q=new Uint8Array(K);K--;)Q[K]=L.charCodeAt(K);return O?new Blob([Q],{type:$}):new File([Q],w,{type:$})}function B(T){return new Promise(function(w,O){var M=new Image;M.onload=function(){w({width:M.width,height:M.height,imageTarget:M})},M.onerror=function(){O(new Error("获取图片尺寸失败"))};var _="";_=typeof T=="string"?T:j(T),M.src=_})}function j(T){return(window.URL||window.webkitURL).createObjectURL(T)}var P,D,G,Z=(P=function(T,w){return(P=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(O,M){O.__proto__=M}||function(O,M){for(var _ in M)Object.prototype.hasOwnProperty.call(M,_)&&(O[_]=M[_])})(T,w)},function(T,w){if(typeof w!="function"&&w!==null)throw new TypeError("Class extends value "+String(w)+" is not a constructor or null");function O(){this.constructor=T}P(T,w),T.prototype=w===null?Object.create(w):(O.prototype=w.prototype,new O)});(function(T){T.EMPTY_FILE="empty file",T.FILE_SIZE_TOO_LARGE="file size too large",T.FILE_TYPE_NOT_ALLOW="file type not allow",T.FILE_EXTENSION_NOT_ALLOW="file extension not allow",T.GET_UPLOAD_TOKEN_ERROR="get upload token error",T.UPLOAD_IMAGE_ERROR="upload image error",T.PORN_IDENTIFY_ERROR="porn identify error"})(G||(G={}));var et,rt=function(T){function w(O){var M=T.call(this,O)||this,_=w.getFailErrorData(O);return M.failCode=_.failCode,M.failMessage=_.failMessage,M}return Z(w,T),w.getFailErrorData=function(O){return{failCode:O,failMessage:w.failMessageVal[O]}},w.failMessageVal=((D={})[G.EMPTY_FILE]="请勿上传空文件",D[G.FILE_SIZE_TOO_LARGE]="文件大小超出限制",D[G.FILE_TYPE_NOT_ALLOW]="该文件类型不支持",D[G.FILE_EXTENSION_NOT_ALLOW]="该文件扩展名不支持",D[G.GET_UPLOAD_TOKEN_ERROR]="获取上传图片 token 失败",D[G.UPLOAD_IMAGE_ERROR]="上传图片失败",D[G.PORN_IDENTIFY_ERROR]="图片鉴黄失败",D),w}(Error),tt=function(){return(tt=Object.assign||function(T){for(var w,O=1,M=arguments.length;O<M;O++)for(var _ in w=arguments[O])Object.prototype.hasOwnProperty.call(w,_)&&(T[_]=w[_]);return T}).apply(this,arguments)},Y=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},ht=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},dt=function(){function T(w){this.uploadCtx=w.uploadCtx}return T.prototype.getUploadToken=function(w){return Y(this,void 0,void 0,function(){var O,M,_,$,L;return ht(this,function(K){switch(K.label){case 0:return O=Date.now(),M=U()("upload_token_live"+w.channelId+O),_={channelId:w.channelId,ts:O,hash:M,bucket:w.bucket},w.userId&&(_.userId=w.userId),[4,k("https://"+this.uploadCtx.apiHost+"/live/upload/token/image/get-token",{params:_})];case 1:return($=K.sent()).data?(L=$.data).code!==200?[2,Promise.reject(new rt(G.GET_UPLOAD_TOKEN_ERROR))]:[2,L.data]:[2,Promise.reject(new rt(G.GET_UPLOAD_TOKEN_ERROR))]}})})},T.prototype.uploadImage=function(w){return Y(this,void 0,void 0,function(){var O,M,_,$,L,K;return ht(this,function(Q){switch(Q.label){case 0:O={key:""+w.dir+w.fileName,policy:w.policy,OSSAccessKeyId:w.accessid,signature:w.signature,success_action_status:200,callback:w.encodedCallback,file:w.file},Q.label=1;case 1:return Q.trys.push([1,3,,4]),[4,k("https://"+w.host,{method:"post",data:F(O),onUploadProgress:function(X){var N,at,R=w.onUploadProgress;typeof R=="function"&&R((N=X.loaded/X.total,at=2,Number(N.toFixed(at||0))))}})];case 2:return(M=Q.sent()).data?(_=M.data).code!==200?[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))]:[2,_.data]:[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))];case 3:return Q.sent(),$=w.currentReuploadTime,(L=$===void 0?0:$)&&L>=this.uploadCtx.reUploadTimes?[2,Promise.reject(new rt(G.UPLOAD_IMAGE_ERROR))]:(L+=1,K=Object.assign({},w,{currentReuploadTime:L}),[2,this.uploadImage(K)]);case 4:return[2]}})})},T.prototype.createSign=function(w,O,M){var _=w;Object.keys(O).sort().forEach(function(L){O[L]&&(_+=L+String(O[L]))}),_+=w;var $=U()(_);return M==="lower"?$:$.toLocaleUpperCase()},T.prototype.pornIdentify=function(w){return Y(this,void 0,void 0,function(){var O,M,_;return ht(this,function($){switch($.label){case 0:O=tt(tt({},w),{timestamp:Date.now()}),$.label=1;case 1:return $.trys.push([1,3,,4]),[4,k("https://"+this.uploadCtx.apiHost+"/live/inner/v3/chat/image/porn-identify",{method:"post",data:tt(tt({},O),{sign:this.createSign("polyv_chat_api_innor",O)})})];case 2:return(M=$.sent()).data?M.data.code!==200?[2,Promise.reject(new rt(G.PORN_IDENTIFY_ERROR))]:[2,!0]:[2,Promise.reject(new rt(G.PORN_IDENTIFY_ERROR))];case 3:return _=$.sent(),[2,Promise.reject(_)];case 4:return[2]}})})},T}();(function(T){T.WAIT_UPLOAD="waitUpload",T.UPLOADING="uploading",T.UPLOAD_SUCCESS="uploadSuccess",T.UPLOAD_FAIL="uploadFail",T.UPLOAD_FORBID="forbid"})(et||(et={}));var wt=function(){return(wt=Object.assign||function(T){for(var w,O=1,M=arguments.length;O<M;O++)for(var _ in w=arguments[O])Object.prototype.hasOwnProperty.call(w,_)&&(T[_]=w[_]);return T}).apply(this,arguments)},bt=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},st=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},lt={width:500,height:500},Ot=function(){function T(w){var O=w.callbackChange,M=O===void 0||O;this.imageId=w.imageId,this.uploadCtx=w.uploadCtx,this.file=w.file,this._status=w.status||et.WAIT_UPLOAD,this.callbackChange=M,this.fileUrl=void 0,this.uploadProgress=void 0,this.previewSrc=j(this.file),this.uploadCtx.recordChatImage(this),this.triggerChange()}return T.prototype.upload=function(w){return w===void 0&&(w={}),bt(this,void 0,void 0,function(){var O,M,_,$,L,K,Q,X,N,at,R,H,W,J=this;return st(this,function(it){switch(it.label){case 0:return O=this.uploadCtx,M=O.channelId,_=O.userId,$=O.bucket,this.status=et.UPLOADING,[4,O.uploadApi.getUploadToken({channelId:M,userId:_,bucket:$})];case 1:if(L=it.sent(),!((K=this.file).size>1024*O.compressSizeLimit))return[3,5];it.label=2;case 2:return it.trys.push([2,4,,5]),[4,this.compressImage({file:this.file,fileName:this.fileName})];case 3:return Q=it.sent(),K=Q,[3,5];case 4:return it.sent(),console.warn("图片压缩失败",K,this.imageId),[3,5];case 5:return it.trys.push([5,7,,8]),[4,B(K)];case 6:return X=it.sent(),N=X.width,at=X.height,this.size={width:N,height:at},[3,8];case 7:return it.sent(),console.warn("获取图片尺寸失败"),[3,8];case 8:this.size||(this.size=lt),this.uploadProgress=0,R="",it.label=9;case 9:return it.trys.push([9,13,,14]),[4,O.uploadApi.uploadImage(wt(wt({},L),{file:K,fileName:this.fileName,onUploadProgress:function(kt){J.uploadProgress=kt,J.triggerChange()}}))];case 10:return R=it.sent(),this.fileUrl=R,O.enablePornChecking?[4,O.uploadApi.pornIdentify({channelId:M,url:"https:"+R})]:[3,12];case 11:it.sent(),it.label=12;case 12:return this.status=et.UPLOAD_SUCCESS,[3,14];case 13:return H=it.sent(),this.status=H.failCode===G.PORN_IDENTIFY_ERROR?et.UPLOAD_FORBID:et.UPLOAD_FAIL,w.error,[2,Promise.reject(H)];case 14:return typeof(W=w.success)=="function"&&W(R),[2,R]}})})},T.prototype.compressImage=function(w){return bt(this,void 0,void 0,function(){var O,M,_,$,L,K,Q,X,N,at;return st(this,function(R){switch(R.label){case 0:return O=w.file,M=w.fileName,_=w.quality,$=_===void 0?.7:_,[4,B(O)];case 1:return L=R.sent(),K=L.width,Q=L.height,X=L.imageTarget,(N=document.createElement("canvas")).setAttribute("width",""+K),N.setAttribute("height",""+Q),(at=N.getContext("2d"))?(at.drawImage(X,0,0,K,Q),[2,z(N.toDataURL("image/jpeg",$),M)]):[2,Promise.reject(new Error("create canvas error"))]}})})},T.prototype.triggerChange=function(){if(this.callbackChange){var w=this.uploadCtx.onChange;typeof w=="function"&&w(this)}},Object.defineProperty(T.prototype,"fileName",{get:function(){var w=V(this.file);return this.imageId+"."+(w||"png")},enumerable:!1,configurable:!0}),Object.defineProperty(T.prototype,"status",{get:function(){return this._status},set:function(w){this._status=w,this.triggerChange()},enumerable:!1,configurable:!0}),T}(),Et=function(){function T(w){this.uploadCtx=w.uploadCtx,this.uploadingList=[],this.waitQueue=[]}return T.prototype.joinWaitQueue=function(w){this.isExistQueue(w,this.waitQueue)||(this.waitQueue.push(w),this.checkQueue())},T.prototype.checkQueue=function(){var w=this;if(!(this.uploadingList.length>=this.uploadCtx.maxUploadNumber)&&this.waitQueue.length!==0)for(var O=this.uploadCtx.maxUploadNumber-this.uploadingList.length,M=function(L){var K=_.waitQueue.shift();K&&(K.upload({success:function(){w.handleImageUploadSuccess(K)}}),_.uploadingList.push(K))},_=this,$=0;$<O;$++)M()},T.prototype.handleImageUploadSuccess=function(w){this.uploadingList=this.uploadingList.filter(function(O){return O.imageId!==w.imageId}),this.checkQueue()},T.prototype.isExistQueue=function(w,O){return O.findIndex(function(M){return M.imageId===w.imageId})!==-1},T}(),Ct=["image/jpeg","image/jpg","image/png","image/gif","image/webp","image/bmp","image/tiff","image/tifa"],gt=["png","bmp","webp","tiff","tif","jpeg","jpg","gif"],vt={channelId:"",userId:"",sizeLimit:81920,compressSizeLimit:2048,limit:9,maxWidth:700,reUploadTimes:3,source:"chat_img",bucket:"liveimages",useBlobByCompress:!1,allowAccept:Ct,allowFileExtension:gt,maxUploadNumber:3,enablePornChecking:!1,apiHost:"api.polyv.net"},_t=function(T,w,O,M){return new(O||(O=Promise))(function(_,$){function L(X){try{Q(M.next(X))}catch(N){$(N)}}function K(X){try{Q(M.throw(X))}catch(N){$(N)}}function Q(X){var N;X.done?_(X.value):(N=X.value,N instanceof O?N:new O(function(at){at(N)})).then(L,K)}Q((M=M.apply(T,[])).next())})},q=function(T,w){var O,M,_,$,L={label:0,sent:function(){if(1&_[0])throw _[1];return _[1]},trys:[],ops:[]};return $={next:K(0),throw:K(1),return:K(2)},typeof Symbol=="function"&&($[Symbol.iterator]=function(){return this}),$;function K(Q){return function(X){return function(N){if(O)throw new TypeError("Generator is already executing.");for(;L;)try{if(O=1,M&&(_=2&N[0]?M.return:N[0]?M.throw||((_=M.return)&&_.call(M),0):M.next)&&!(_=_.call(M,N[1])).done)return _;switch(M=0,_&&(N=[2&N[0],_.value]),N[0]){case 0:case 1:_=N;break;case 4:return L.label++,{value:N[1],done:!1};case 5:L.label++,M=N[1],N=[0];continue;case 7:N=L.ops.pop(),L.trys.pop();continue;default:if(_=L.trys,!((_=_.length>0&&_[_.length-1])||N[0]!==6&&N[0]!==2)){L=0;continue}if(N[0]===3&&(!_||N[1]>_[0]&&N[1]<_[3])){L.label=N[1];break}if(N[0]===6&&L.label<_[1]){L.label=_[1],_=N;break}if(_&&L.label<_[2]){L.label=_[2],L.ops.push(N);break}_[2]&&L.ops.pop(),L.trys.pop();continue}N=w.call(T,L)}catch(at){N=[6,at],M=0}finally{O=_=0}if(5&N[0])throw N[1];return{value:N[0]?N[1]:void 0,done:!0}}([Q,X])}}},ut=function(){function T(w){w===void 0&&(w={});var O=w.channelId,M=O===void 0?vt.channelId:O,_=w.userId,$=_===void 0?vt.userId:_,L=w.sizeLimit,K=L===void 0?vt.sizeLimit:L,Q=w.compressSizeLimit,X=Q===void 0?vt.compressSizeLimit:Q,N=w.limit,at=N===void 0?vt.limit:N,R=w.maxWidth,H=R===void 0?vt.maxWidth:R,W=w.reUploadTimes,J=W===void 0?vt.reUploadTimes:W,it=w.source,kt=it===void 0?vt.source:it,Rt=w.bucket,Lt=Rt===void 0?vt.bucket:Rt,Bt=w.useBlobByCompress,nt=Bt===void 0?vt.useBlobByCompress:Bt,ft=w.allowAccept,mt=ft===void 0?vt.allowAccept:ft,xt=w.allowFileExtension,At=xt===void 0?vt.allowFileExtension:xt,Qt=w.maxUploadNumber,Wt=Qt===void 0?vt.maxUploadNumber:Qt,le=w.apiHost,Ue=le===void 0?vt.apiHost:le,Fe=w.onChange,De=w.beforeStart;this.channelId=M,this.userId=$,this.sizeLimit=K,this.compressSizeLimit=X,this.limit=at,this.maxWidth=H,this.reUploadTimes=J,this.source=kt,this.bucket=Lt,this.useBlobByCompress=!!nt,this.allowAccept=mt,this.allowFileExtension=At,this.maxUploadNumber=Wt,this.onChange=Fe,this.beforeStart=De,this.enablePornChecking=w.enablePornChecking===!0,this.apiHost=Ue,this.uploadQueue=new Et({uploadCtx:this}),this.uploadApi=new dt({uploadCtx:this}),this.chatImageStore={}}return T.prototype.choiceImageFile=function(w){var O=this;w===void 0&&(w={});var M=this.getAccept(),_=document.createElement("input");return _.setAttribute("id","polyv-upload-chat-image-input-id"),_.setAttribute("type","file"),_.setAttribute("accept",M),_.setAttribute("style","visibility: hidden;position: fixed;bottom: -100%;z-index: -1;"),this.limit>1&&_.setAttribute("multiple","multiple"),_.addEventListener("change",function(){document.body.removeChild(_),w&&_.files&&_.files.length!==0&&O.handleFileList(w,_.files)}),document.body.appendChild(_),_.click(),this},T.prototype.handleFileList=function(w,O){this.beforeStart&&this.beforeStart();for(var M,_=w.fail,$=w.success,L=w.callbackChange,K=O.length<this.limit?O.length:this.limit,Q=0;Q<K;Q++){var X=O[Q],N=this.checkFile(X);if(N)return M=N,void(typeof _=="function"&&_(M))}var at=[];for(Q=0;Q<K;Q++){X=O[Q];var R=this.buildImageId(Q),H=new Ot({imageId:R,uploadCtx:this,file:X,callbackChange:L});at.push(H)}typeof $=="function"&&$(at)},T.prototype.getAccept=function(){var w=[];return w.push.apply(w,this.allowFileExtension.map(function(O){return"."+O})),w.push.apply(w,this.allowAccept),w.join(",")},T.prototype.joinWaitQueue=function(w){var O=this;if(Array.isArray(w))return w.forEach(function(_){O.joinWaitQueue(_)}),this;var M=void 0;return typeof w=="string"?M=this.getChatImageById(w):w instanceof Ot&&(M=w),M&&this.uploadQueue.joinWaitQueue(M),this},T.prototype.getUploadImageUrl=function(){var w=this;return new Promise(function(O,M){w.choiceImageFile({callbackChange:!1,success:function(_){return _t(w,void 0,void 0,function(){var $;return q(this,function(L){switch(L.label){case 0:return[4,($=_[0]).upload()];case 1:return L.sent(),$.fileUrl?O($):M(new rt(G.UPLOAD_IMAGE_ERROR)),[2]}})})},fail:function(_){M(_)}})})},T.prototype.callbackUploadImage=function(){var w=this;this.choiceImageFile({success:function(O){w.joinWaitQueue(O)}})},T.prototype.uploadImageFile=function(w){return _t(this,void 0,void 0,function(){var O;return q(this,function(M){switch(M.label){case 0:if(O=this.checkFile(w))throw new Error(O.failMessage);return[4,new Ot({imageId:this.buildImageId(),file:w,uploadCtx:this,callbackChange:!1}).upload()];case 1:return[2,M.sent()]}})})},T.prototype.uploadImage=function(w,O){return _t(this,void 0,void 0,function(){var M,_;return q(this,function($){switch($.label){case 0:if(M=this.checkFile(w))throw new Error(M.failMessage);return[4,(_=new Ot({imageId:this.buildImageId(),file:w,uploadCtx:this,callbackChange:O!==!1})).upload()];case 1:return $.sent(),[2,_]}})})},T.prototype.reUploadImage=function(w){return _t(this,void 0,void 0,function(){var O,M;return q(this,function(_){switch(_.label){case 0:if(!(O=this.getChatImageById(w)))return[2,Promise.reject(new Error("图片不存在"))];_.label=1;case 1:return _.trys.push([1,3,,4]),[4,O.upload()];case 2:return _.sent(),[2,O];case 3:return M=_.sent(),[2,Promise.reject(M)];case 4:return[2]}})})},T.prototype.getChatImageById=function(w){return this.chatImageStore[w]},T.prototype.recordChatImage=function(w){this.chatImageStore[w.imageId]=w},T.prototype.checkFile=function(w){if(!w.size)return rt.getFailErrorData(G.EMPTY_FILE);if(w.size>1024*this.sizeLimit)return rt.getFailErrorData(G.FILE_SIZE_TOO_LARGE);if(!this.allowAccept.includes(w.type))return rt.getFailErrorData(G.FILE_TYPE_NOT_ALLOW);var O=V(w);return this.allowFileExtension.includes(O)?void 0:rt.getFailErrorData(G.FILE_EXTENSION_NOT_ALLOW)},T.prototype.buildImageId=function(w){var O=[];this.source&&O.push(this.source),this.channelId&&O.push(this.channelId),this.userId&&O.push(this.userId);var M=w!==void 0?"_"+w:"";return O.join("_")+"_"+Date.now()+"_"+Math.random().toString().substring(2,10)+M},T}()}]);class Re extends Dt{constructor(t){super(t);It(this,"__uploadImgCtrl");It(this,"__svgaMap",{coffee:"coffee.svga",like:"like.svga",handclap:"handclap.svga",666:"666.svga",star:"star.svga",diamond:"diamond.svga",car:"car.svga",rocket:"rocket.svga",bear:"bear.svga",crown:"crown.svga",cup:"cup.svga",microphone:"microphone.svga",villa:"villa.svga",house:"villa.svga"});this.__uploadImgCtrl=new Ae.ChatImageUpload({enablePornChecking:!0})}__setUploadImgChannelId(){return pt(this,null,function*(){const t=yield this._plvSocket.getChannelInfo();this.__uploadImgCtrl.channelId=t.channelId})}uploadMultiImage(t){return pt(this,null,function*(){yield this.__setUploadImgChannelId();const e=(t==null?void 0:t.maxLimit)||9,r=typeof(t==null?void 0:t.ready)=="function"?t.ready:()=>{},n=typeof(t==null?void 0:t.success)=="function"?t.success:()=>{},i=typeof(t==null?void 0:t.fail)=="function"?t.fail:()=>{},a=[],s=[];return new Promise((f,c)=>{this.__uploadImgCtrl.choiceImageFile({callbackChange:!1,success:d=>pt(this,null,function*(){d=d.slice(0,e),d.forEach(g=>{r({imageId:g.imageId,previewSrc:g.previewSrc||""})});try{for(var p=he(d),l,h,v;l=!(h=yield p.next()).done;l=!1){const g=h.value;try{const y=yield g.upload();if(!y)throw new Error("upload Image Error");const b={imageId:g.imageId,imageUrl:y,size:g.size};a.push(b),n(b)}catch(y){const b=y,m={imageId:g.imageId,previewSrc:g.previewSrc||""};s.push(m),console.error("[util-module][uploadMultiImage] ",b.message,m),i(b,m)}}}catch(h){v=[h]}finally{try{l&&(h=p.return)&&(yield h.call(p))}finally{if(v)throw v[0]}}return f({successUploadImages:a,failUploadImages:s})}),fail:d=>{console.error("[util-module][uploadMultiImage] ",d),c(new Error(d.failMessage))}})})})}directUploadImage(t){return pt(this,null,function*(){if(!t)throw new Error("file is null");yield this.__setUploadImgChannelId();const e=yield this.__uploadImgCtrl.uploadImage(t);if(!e.fileUrl)throw new Error("upload fail");return{imageId:e.imageId,imageUrl:e.fileUrl,size:e.size}})}translateText(t){return pt(this,null,function*(){const e=this._plvSocket.getUserInfo(),r=yield this._plvSocket.polyvApi.getTokenFieldByUserType();return(yield this._plvSocket.polyvApi.post("/live/v4/channel/translate",{},{params:{query:t,viewerId:e.userId},tokenInfo:{tokenField:r}}))[0]})}__genResourceUrl(t){return`https://s1.videocc.net${t}`}getDefaultResource(){return{defaultViewerAvatar:this.__genResourceUrl("/default-img/avatar/viewer.png")}}getDefaultDonateSvgaUrl(t){return pt(this,null,function*(){const e=t.gimg,r=this.__svgaMap,n=document.createElement("a");n.href=e;const i=n.pathname.split("/"),a=i[i.length-1].split(".")[0];if(r[a])return this.__genResourceUrl(`/default-img/donate-svga/${r[a]}`)})}}function Pe(o){return typeof o!="object"&&(o=new Date(o)),o}function je(o,u){const t={Y:(o=Pe(o)).getFullYear(),M:o.getMonth()+1,D:o.getDate(),h:o.getHours(),m:o.getMinutes(),s:o.getSeconds()};return u.replace(/([YMDhms])\1*/g,function(e){let r=t[e[0]].toString();const n=e.length;return n>r.length&&(r=new Array(n-r.length+1).join("0")+r),r})}class Le extends Dt{constructor(){super(...arguments);It(this,"__refId","")}setRefId(t){this.__refId=t}getRefId(){return this.__refId}exportAttendanceList(){return pt(this,null,function*(){const t=yield this._plvSocket.getChannelInfo(),e=this._plvSocket.getUserInfo(),r={channelId:t.channelId,userId:e.userId,timestamp:Date.now(),expectedArrivalType:"viewer_white",type:"whiteList"};r.sign=yield this._plvSocket.chatApi.getChatSign(r),yield this._plvSocket.chatApi.post("/front/channel/download-history/post",r,{appendChannelId:!1,appendUserId:!1})})}getAttendanceDownloadRecord(){return pt(this,arguments,function*(t={}){const{pageNumber:e=1,pageSize:r=10}=t,n=yield this._plvSocket.getChannelInfo(),i=yield this._plvSocket.chatApi.get("/front/channel/download-history-list/get",{timestamp:Date.now(),page:e,size:r,type:"whiteList"},{appendChatSign:!0}),a=[];return i.list.forEach(s=>{const f=["缺勤/到勤名单",n.channelId];s.sessionId&&f.push(s.sessionId),s.createTime&&f.push(je(s.createTime,"YYYYMMDD hh:mm:ss"));let c="pending";s.isExpire?c="expired":s.status===1?c="failed":s.status===0?c="pending":s.status===2&&(c="success"),a.push({id:`${s.createTime}-${s.sessionId}`,downloadUrl:s.src,fileName:f.join("-")+".gz",fileSize:0,progress:c==="pending"?0:100,status:c,createTime:s.createTime})}),{pageNumber:i.page,pageSize:i.size,contents:a,totalItems:i.totalCount,totalPages:i.totalPage}})}exportOnlineList(){return pt(this,null,function*(){const t={businessType:"LIVE"},e=this.getRefId();e&&(t.refId=e),yield this._plvSocket.polyvApi.get("/live/v4/channel/chat-data/online-user/export",t)})}exportWhiteList(){return pt(this,null,function*(){this._plvSocket.polyvApi.open("/live/v3/channel/chat/export-whitelist-viewing",{})})}}class Ne{constructor(u,t={}){It(this,"PolyvChatEvent",ct);It(this,"ChatMsgSource",ot);It(this,"DonateType",Vt);It(this,"RedpackType",Jt);It(this,"SystemMsgType",Zt);It(this,"ChatRequestHistoryMode",Ht);It(this,"ManageFailReason",St);It(this,"TranslateLanguage",ee);It(this,"eventEmitter",new $t);It(this,"__socketFilter");It(this,"__socketHandler");It(this,"emotion");It(this,"history");It(this,"message");It(this,"status");It(this,"utils");It(this,"sender");It(this,"manage");It(this,"online");It(this,"download");It(this,"setuped",!1);this.plvSocket=u,this.config=t,this.emotion=new we(this),this.history=new Ie(this),this.message=new Ee(this),this.status=new Me(this),this.utils=new Re(this),this.sender=new ke(this),this.manage=new Se(this),this.online=new Oe(this),this.download=new Le(this),this.__socketFilter=new ye(this),this.__socketHandler=new be(this)}setup(){return pt(this,null,function*(){yield this.emotion.setupEmotionParser(),this.setuped=!0})}}yt.ChatMsgSource=ot,yt.ChatRequestHistoryMode=Ht,yt.DonateType=Vt,yt.ManageFailReason=St,yt.MotivationLikeType=te,yt.PolyvChat=Ne,yt.PolyvChatEvent=ct,yt.RedpackType=Jt,yt.SystemMsgType=Zt,yt.TranslateLanguage=ee,yt.canQuoteMsgSource=fe,yt.canTopMsgSource=ce,yt.isServiceMsgMap=se,Object.defineProperty(yt,Symbol.toStringTag,{value:"Module"})});console.log("%c@polyv/chat","background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff","[version: 2.1.0-rc-20251023.2]","[buildTime: 2025-10-22 01:22:13]");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polyv/chat",
3
- "version": "2.1.0-rc-20251023.1",
3
+ "version": "2.1.0-rc-20251023.2",
4
4
  "main": "./index.es.js",
5
5
  "dependencies": {
6
6
  "@polyv/socket": "*"