!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ReporterPb=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=Array(t);i=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==i.return||i.return()}finally{if(s)throw o}}}}function s(e,t,i){return(t=f(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function u(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function l(e){for(var t=1;t=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),l=r.call(a,"finallyLoc");if(u&&l){if(this.prev=0;--i){var n=this.tryEntries[i];if(n.tryLoc<=this.prev&&r.call(n,"finallyLoc")&&this.prev=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),O(i),b}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var r=i.completion;if("throw"===r.type){var n=r.arg;O(i)}return n}}throw Error("illegal catch attempt")},delegateYield:function(t,i,r){return this.delegate={iterator:M(t),resultName:i,nextLoc:r},"next"===this.method&&(this.arg=e),b}},t}function d(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||v(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function p(e){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},p(e)}function v(t,i){if(t){if("string"==typeof t)return e(t,i);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,i):void 0}}function h(e){var t=this.constructor;return this.then((function(i){return t.resolve(e()).then((function(){return i}))}),(function(i){return t.resolve(e()).then((function(){return t.reject(i)}))}))}function w(e){return new this((function(t,i){if(!e||void 0===e.length)return i(new TypeError(p(e)+" "+e+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var r=Array.prototype.slice.call(e);if(0===r.length)return t([]);var n=r.length;function o(e,i){if(i&&("object"===p(i)||"function"==typeof i)){var a=i.then;if("function"==typeof a)return void a.call(i,(function(t){o(e,t)}),(function(i){r[e]={status:"rejected",reason:i},0==--n&&t(r)}))}r[e]={status:"fulfilled",value:i},0==--n&&t(r)}for(var a=0;a=this.options.batchSize?this.flush():0===this.timeout&&(this.timeout=window.setTimeout((function(){return e.flush()}),this.options.batchTime))}}]);var e}(),M=function(){return o((function e(){r(this,e),s(this,"current",0),s(this,"currentTime",Date.now())}),[{key:"get",value:function(){return this.current+=1,this.currentTime=Date.now(),{sn:this.current,time:this.currentTime}}}])}(),q=function(e){var t=function(t){var i,r=null==t||null===(i=t.match)||void 0===i?void 0:i.call(t,new RegExp("(^|&)"+e+"=([^&]*)(&|$)"));return null!=r&&r[2]?decodeURIComponent(r[2]):null},i=window.location.search.slice(1),r=window.location.hash.split("?")[1]||"";if(i){var n=t(i);if(n)return n}if(r){var o=t(r);if(o)return o}return null},A=function(e,t){var i=e.indexOf("?"),r=[];for(var n in t)r.push("".concat(encodeURIComponent(n),"=").concat(encodeURIComponent(t[n])));var o="".concat(i>0?"&":"?").concat(r.join("&")),a=e.indexOf("#");return a>0?e.slice(0,a)+o+e.slice(a):e+o},N=function(e){var t=new RegExp("(^| )"+e+"=([^;]*)(;|$)"),i=document.cookie.match(t);return null!=i&&i[2]?decodeURIComponent(i[2]):null},I=function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"same-domain",n=new Date;n.setTime(n.getTime()+1e3*i);var o=i>0?";expires="+n.toUTCString():"";return"same-domain"===r&&(r="."+document.domain.split(".").slice(-2).join(".")),document.cookie=e+"="+encodeURIComponent(t)+o+(r?";domain=".concat(r,";path=/"):""),t},B=function(e){for(var t=document.getElementsByTagName("meta"),i=0;i1?t-1:0),r=1;r0?2===u.length?p(u[1])==n?this[u[0]]=u[1].call(this,c):this[u[0]]=u[1]:3===u.length?p(u[1])!==n||u[1].exec&&u[1].test?this[u[0]]=c?c.replace(u[1],u[2]):r:this[u[0]]=c?u[1].call(this,c,u[2]):r:4===u.length&&(this[u[0]]=c?u[3].call(this,c.replace(u[1],u[2])):r):this[u]=c||r;d+=2}},X=function(e,t){for(var i in t)if(p(t[i])===a&&t[i].length>0){for(var n=0;n2&&(e[l]="iPad",e[d]=m),e},this.getEngine=function(){var e={};return e[c]=r,e[v]=r,Z.call(e,g,_.engine),e},this.getOS=function(){var e={};return e[c]=r,e[v]=r,Z.call(e,g,_.os),k&&!e[c]&&y&&y.platform&&"Unknown"!=y.platform&&(e[c]=y.platform.replace(/chrome os/i,D).replace(/macos/i,z)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return g},this.setUA=function(e){return g=p(e)===s&&e.length>500?W(e,500):e,this},this.setUA(g),this};J.VERSION="1.0.40",J.BROWSER=G([c,v,u]),J.CPU=G([h]),J.DEVICE=G([l,f,d,w,b,g,m,y,_]),J.ENGINE=J.OS=G([c,v]),e.exports&&(t=e.exports=J),t.UAParser=J;var K=p(i)!==o&&(i.jQuery||i.Zepto);if(K&&!K.ua){var ee=new J;K.ua=ee.getResult(),K.ua.get=function(){return ee.getUA()},K.ua.set=function(e){ee.setUA(e);var t=ee.getResult();for(var i in t)K.ua[i]=t[i]}}}("object"===("undefined"==typeof window?"undefined":p(window))?window:Y)}(J,J.exports);var K=J.exports,ee=null,te=function(){return ee||(ee=new K.UAParser)},ie=function(){var e,t=te().getDevice().type;if(!t)return"pc";return null!==(e={mobile:"phone",tablet:"pad",smarttv:"tv",embedded:"embedded",wearable:"ware",console:"console"}[t])&&void 0!==e?e:"pc"},re=function(){var e,t,i=te(),r=i.getDevice(),n=i.getOS(),o=n.name?"".concat(n.name).concat(n.version?" "+n.version:""):"",a=navigator.userAgent;!o&&/OpenHarmony/.test(a)&&(o=null!==(e=null===(t=a.match(/(OpenHarmony ?[\d.]*)/))||void 0===t?void 0:t[1])&&void 0!==e?e:"");return{brand:r.vendor||"",model:r.model||"",system:o}},ne=function(e){var t,i;return{app_id:null!==(t=null==e?void 0:e.appId)&&void 0!==t?t:100,platform:(null!==(i=null==e?void 0:e.platform)&&void 0!==i?i:/AppleWebKit.*Mobile.*/i.test(navigator.userAgent))?6:5,cbuvid:N("buvid3")||"",cmid:parseInt(N("DedeUserID")||"0"),fts:N("b_nut")||"",screen_resolution:"".concat(window.screen.width,"*").concat(window.screen.height),timezone:(new Date).getTimezoneOffset().toString(),bilifp:N("buvid_fp")||"",device_type:ie()}},oe=function(e){var t,i,r,n;return{network_info:null!==(t=null!==(i=null==e?void 0:e.networkInfo)&&void 0!==i?i:null===(r=navigator.connection)||void 0===r?void 0:r.effectiveType)&&void 0!==t?t:"4g",url:window.location.href,refer_url:document.referrer,logver:O,abtest:JSON.stringify(null!==(n=window.abtest)&&void 0!==n?n:{}),ptype:$(),window_size:"".concat(window.innerWidth,"*").concat(window.innerHeight),bsource:X().bsource,bsource_origin:q("bsource")||"",share_source_origin:q("share_source")||"",share_session_id:q("unique_k")||"",session_id:Z()}},ae=function(){var e,t,i,r,n,o=null===(e=window.performance)||void 0===e||null===(t=e.getEntriesByType)||void 0===t||null===(t=t.call(e,"navigation"))||void 0===t?void 0:t[0];if(o){var a;return null!==(a={navigate:0,reload:1,back_forward:2,prerender:3}[o.type])&&void 0!==a?a:0}return null!==(i=window.performance)&&void 0!==i&&i.navigation&&null!==(r=null===(n=window.performance)||void 0===n||null===(n=n.navigation)||void 0===n?void 0:n.type)&&void 0!==r?r:0},se={enabled:!0,value:{batchSize:32,batchTime:1e3}},ue={enabled:!0,value:{maxCount:5,retryInterval:3e3,maxInterval:6e4}},le=function(e){var t=e.url,i=e.method,r=e.body,n=e.headers,o=e.credentials,a=new XMLHttpRequest;return new Promise((function(e,s){if(a.open(i.toUpperCase(),t),o&&"omit"===o||(a.withCredentials=!0),a.responseType="text",n)for(var u in n)a.setRequestHeader(u,n[u]);a.onreadystatechange=function(){if(a.readyState===XMLHttpRequest.DONE){var t=a.status;if(t>=200&&t<300){var i=null==a?void 0:a.responseText;e(i||"")}else s({code:t})}},a.onerror=function(e){return s(e)},a.ontimeout=function(){return s("timeout")},a.send(r)}))},ce=function(){var e=i(c().mark((function e(t){var i,r,n,o,a,s,u;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=t.url,r=t.method,n=t.body,o=t.headers,a=t.credentials,s=t.keepalive,e.next=3,fetch(i,{method:r,headers:o,body:n,credentials:null!=a?a:"include",priority:"high",keepalive:null==s||s});case 3:if(!((u=e.sent).status<200&&u.status>=300)){e.next=6;break}throw new Error("".concat(u.status," ").concat(u.statusText));case 6:return e.abrupt("return",u.text());case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),de=function(){var e=i(c().mark((function e(t){var i;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="function"==typeof window.fetch?ce:le,e.abrupt("return",i(t));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),fe="undefined"!=typeof window,pe=fe&&"function"==typeof window.fetch,ve=fe&&pe&&window.Request&&"keepalive"in Request.prototype,he=fe&&"function"==typeof navigator.sendBeacon,we=function(){var e=i(c().mark((function e(t,i){var r,n,o,a,s,u,d,f,p,v,h,w,b;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=null!==(r=null==i?void 0:i.url)&&void 0!==r?r:"//data.bilibili.com/v2/log/web",n=A(n,{content_type:"pbrequest",logid:i.logId,disable_compression:"true"}),o={url:n,method:"post",body:t,headers:{"Content-Type":"text/plain"}},a=t.length>=65536,s=a?function(){return pe?ce(l(l({},o),{},{keepalive:!1})):le(o)}:ve?function(){return ce(o)}:he?function(){if(!navigator.sendBeacon(n,new Blob([t],{type:"text/plain"})))return pe?ce(l(l({},o),{},{keepalive:!1})):le(o)}:function(){return le(o)},e.prev=5,e.next=8,s();case 8:return e.abrupt("return",e.sent);case 11:if(e.prev=11,e.t0=e.catch(5),!(u=D(ue,null==i?void 0:i.retry)).enabled){e.next=28;break}d=u.value,f=d.retryInterval,p=d.maxInterval,v=d.maxCount,h=1,w=c().mark((function e(){var t,i;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=Math.random()*f,i=Math.min(1e3*Math.pow(f/1e3,h),p)+t,e.next=4,new Promise((function(e){return setTimeout(e,i)}));case 4:return e.prev=4,e.next=7,s();case 7:return e.t0=e.sent,e.abrupt("return",{v:e.t0});case 11:e.prev=11,e.t1=e.catch(4),h+=1;case 14:case"end":return e.stop()}}),e,null,[[4,11]])}));case 18:if(!(h<=v)){e.next=25;break}return e.delegateYield(w(),"t1",20);case 20:if(!(b=e.t1)){e.next=23;break}return e.abrupt("return",b.v);case 23:e.next=18;break;case 25:console.error("[reporter-pb]: max retries exceeded",e.t0,o.body),e.next=29;break;case 28:console.error("[reporter-pb]: request error",e.t0,o.body);case 29:case"end":return e.stop()}}),e,null,[[5,11]])})));return function(t,i){return e.apply(this,arguments)}}(),be=function(e){return/^\w{8,}-\w{4,}-\w{4,}-\w{4,}/.test(e)},me=function(e){return/^\w{8,}-\w{4,}-\w{4,}-\w{4,}-\w{17,}infoc$/.test(e)},ge=function(){var e=N("buvid3")||"",t=N("buvid4")||"";return me(e)&&be(t)},ye=function(){var e=i(c().mark((function e(){var t,i,r,n,o;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!ge()){e.next=2;break}return e.abrupt("return");case 2:return r=null,e.prev=3,e.t0=JSON,e.next=7,de({url:"https://api.bilibili.com/x/frontend/finger/spi",method:"get"});case 7:e.t1=e.sent,r=e.t0.parse.call(e.t0,e.t1),e.next=14;break;case 11:e.prev=11,e.t2=e.catch(3),console.error("[reporter-pb]: init buvid error ",e.t2);case 14:if(!ge()){e.next=16;break}return e.abrupt("return");case 16:n=be((null===(t=r)||void 0===t||null===(t=t.data)||void 0===t?void 0:t.b_3)||"")?r.data.b_3:(a=void 0,s=void 0,a=C,s=("00000"+(Date.now()%1e5).toString()).slice(-5),"".concat(a(8),"-").concat(a(4),"-").concat(a(4),"-").concat(a(4),"-").concat(a(12)).concat(s,"infoc")),me(N("buvid3")||"")||(I("buvid3",n,94608e3,"same-domain"),I("b_nut",Math.floor(Date.now()/1e3).toString(),94608e3,"same-domain")),o=(null===(i=r)||void 0===i||null===(i=i.data)||void 0===i?void 0:i.b_4)||"",!be(N("buvid4")||"")&&be(o)&&I("buvid4",o,94608e3,"same-domain");case 20:case"end":return e.stop()}var a,s}),e,null,[[3,11]])})));return function(){return e.apply(this,arguments)}}(),_e=4294967296,ke=1/_e,Fe="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8"),xe=function(){return o((function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array(16);r(this,e),this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}),[{key:"readFields",value:function(e,t){for(var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.length;this.pos>3,o=this.pos;this.type=7&r,e(n,t,this),this.pos===o&&this.skip(r)}return t}},{key:"readMessage",value:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}},{key:"readFixed32",value:function(){var e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}},{key:"readSFixed32",value:function(){var e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}},{key:"readFixed64",value:function(){var e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*_e;return this.pos+=8,e}},{key:"readSFixed64",value:function(){var e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*_e;return this.pos+=8,e}},{key:"readFloat",value:function(){var e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}},{key:"readDouble",value:function(){var e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}},{key:"readVarint",value:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,n,o=i.buf;if(n=o[i.pos++],r=(112&n)>>4,n<128)return Se(e,r,t);if(n=o[i.pos++],r|=(127&n)<<3,n<128)return Se(e,r,t);if(n=o[i.pos++],r|=(127&n)<<10,n<128)return Se(e,r,t);if(n=o[i.pos++],r|=(127&n)<<17,n<128)return Se(e,r,t);if(n=o[i.pos++],r|=(127&n)<<24,n<128)return Se(e,r,t);if(n=o[i.pos++],r|=(1&n)<<31,n<128)return Se(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[this.pos]))<<28,e,this))))}},{key:"readVarint64",value:function(){return this.readVarint(!0)}},{key:"readSVarint",value:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2}},{key:"readBoolean",value:function(){return Boolean(this.readVarint())}},{key:"readString",value:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Fe?Fe.decode(this.buf.subarray(t,e)):function(e,t,i){var r="",n=t;for(;n239?4:o>223?3:o>191?2:1;if(n+s>i)break;var u=void 0,l=void 0,c=void 0;1===s?o<128&&(a=o):2===s?128==(192&(u=e[n+1]))&&(a=(31&o)<<6|63&u)<=127&&(a=null):3===s?(u=e[n+1],l=e[n+2],128==(192&u)&&128==(192&l)&&((a=(15&o)<<12|(63&u)<<6|63&l)<=2047||a>=55296&&a<=57343)&&(a=null)):4===s&&(u=e[n+1],l=e[n+2],c=e[n+3],128==(192&u)&&128==(192&l)&&128==(192&c)&&((a=(15&o)<<18|(63&u)<<12|(63&l)<<6|63&c)<=65535||a>=1114112)&&(a=null)),null===a?(a=65533,s=1):a>65535&&(a-=65536,r+=String.fromCharCode(a>>>10&1023|55296),a=56320|1023&a),r+=String.fromCharCode(a),n+=s}return r}(this.buf,t,e)}},{key:"readBytes",value:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}},{key:"readPackedVarint",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1?arguments[1]:void 0,i=this.readPackedEnd();this.pos0&&void 0!==arguments[0]?arguments[0]:[],t=this.readPackedEnd();this.pos0&&void 0!==arguments[0]?arguments[0]:[],t=this.readPackedEnd();this.pos0&&void 0!==arguments[0]?arguments[0]:[],t=this.readPackedEnd();this.pos0&&void 0!==arguments[0]?arguments[0]:[],t=this.readPackedEnd();this.pos0&&void 0!==arguments[0]?arguments[0]:[],t=this.readPackedEnd();this.pos0&&void 0!==arguments[0]?arguments[0]:[],t=this.readPackedEnd();this.pos0&&void 0!==arguments[0]?arguments[0]:[],t=this.readPackedEnd();this.pos0&&void 0!==arguments[0]?arguments[0]:[],t=this.readPackedEnd();this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error("Unimplemented type: ".concat(t));this.pos+=8}}},{key:"writeTag",value:function(e,t){this.writeVarint(e<<3|t)}},{key:"realloc",value:function(e){for(var t=this.length||16;t268435455||e<0?function(e,t){var i,r;e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0));if(e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos]=127&e}(i,0,t),function(e,t){var i=(7&e)<<4;if(t.buf[t.pos++]|=i|((e>>>=3)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;t.buf[t.pos++]=127&e}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}},{key:"writeSVarint",value:function(e){this.writeVarint(e<0?2*-e-1:2*e)}},{key:"writeBoolean",value:function(e){this.writeVarint(+e)}},{key:"writeString",value:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var r,n,o=0;o55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&Ee(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}},{key:"writeFloat",value:function(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}},{key:"writeDouble",value:function(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}},{key:"writeBytes",value:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i=128&&Ee(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}},{key:"writeMessage",value:function(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}},{key:"writePackedVarint",value:function(e,t){t.length&&this.writeMessage(e,Ve,t)}},{key:"writePackedSVarint",value:function(e,t){t.length&&this.writeMessage(e,Pe,t)}},{key:"writePackedBoolean",value:function(e,t){t.length&&this.writeMessage(e,je,t)}},{key:"writePackedFloat",value:function(e,t){t.length&&this.writeMessage(e,Te,t)}},{key:"writePackedDouble",value:function(e,t){t.length&&this.writeMessage(e,Oe,t)}},{key:"writePackedFixed32",value:function(e,t){t.length&&this.writeMessage(e,Me,t)}},{key:"writePackedSFixed32",value:function(e,t){t.length&&this.writeMessage(e,qe,t)}},{key:"writePackedFixed64",value:function(e,t){t.length&&this.writeMessage(e,Ae,t)}},{key:"writePackedSFixed64",value:function(e,t){t.length&&this.writeMessage(e,Ne,t)}},{key:"writeBytesField",value:function(e,t){this.writeTag(e,2),this.writeBytes(t)}},{key:"writeFixed32Field",value:function(e,t){this.writeTag(e,5),this.writeFixed32(t)}},{key:"writeSFixed32Field",value:function(e,t){this.writeTag(e,5),this.writeSFixed32(t)}},{key:"writeFixed64Field",value:function(e,t){this.writeTag(e,1),this.writeFixed64(t)}},{key:"writeSFixed64Field",value:function(e,t){this.writeTag(e,1),this.writeSFixed64(t)}},{key:"writeVarintField",value:function(e,t){this.writeTag(e,0),this.writeVarint(t)}},{key:"writeSVarintField",value:function(e,t){this.writeTag(e,0),this.writeSVarint(t)}},{key:"writeStringField",value:function(e,t){this.writeTag(e,2),this.writeString(t)}},{key:"writeFloatField",value:function(e,t){this.writeTag(e,5),this.writeFloat(t)}},{key:"writeDoubleField",value:function(e,t){this.writeTag(e,1),this.writeDouble(t)}},{key:"writeBooleanField",value:function(e,t){this.writeVarintField(e,+t)}}])}();function Se(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Ee(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var n=i.pos-1;n>=e;n--)i.buf[n+r]=i.buf[n]}function Ve(e,t){for(var i=0;i=1&&console.log("%c".concat(e.type," ").concat(e.spm,"\n"),"color: #30A46C",p),{log_id:(null==f?void 0:f.logId)||(null!==(n=t.reporter.options)&&void 0!==n&&n.DEBUG_TEST_CHANNEL?"025219":"021436"),event_id:e.spm,body:h,meta:{}}},et=function(e){var t={events:e},i=new xe;return function(e,t){if(e.events){var i,r=a(e.events);try{for(r.s();!(i=r.n()).done;){var n=i.value;t.writeMessage(1,Be,n)}}catch(e){r.e(e)}finally{r.f()}}}(t,i),i.finish()},tt=null,it=function(){var e;tt||(tt=null!==(e=window.__BMG_AF__)&&void 0!==e?e:null);return tt},rt=function(){var e=i(c().mark((function e(){var t,i,r,n,o;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=(null===(t=it())||void 0===t?void 0:t.defDomain)||"i0.hdslb.com",r=/^uat-/.test(location.hostname)?location.hostname.slice(0,4):"",e.prev=2,e.next=5,de({method:"get",url:"//".concat(r).concat(i,"/bfs/polaris_web_conf/polaris/webcnf/event.cnf"),credentials:"omit"});case 5:(n=e.sent)&&(null===(o=window.localStorage)||void 0===o||o.setItem("__reporter-pb-sample-config",n),W("sampleRateConfig",JSON.parse(n))),e.next=12;break;case 9:e.prev=9,e.t0=e.catch(2),console.warn("[reporter-pb] fetch sample rate config failed");case 12:case"end":return e.stop()}}),e,null,[[2,9]])})));return function(){return e.apply(this,arguments)}}(),nt=function(e){if(!ot.plugins[e])throw new Error("[reporter-pb] 未加载 ".concat(e," 插件"))},ot=function(){function e(t){var n,o,a,u,f=this;r(this,e),s(this,"version",O),s(this,"techEventReporter",null),s(this,"fpPromise",null),this.miss=Math.random()>(null!==(n=null===(o=this.options)||void 0===o?void 0:o.sampleRate)&&void 0!==n?n:1);var p="undefined"!=typeof window,v=p&&/\bDEBUG_TEST_CHANNEL=1\b/.test(window.location.search+window.location.hash),h=p&&!!N("DEBUG_TEST_CHANNEL");v&&I("DEBUG_TEST_CHANNEL","1",0,"same-domain"),this.options=l(l({},t),{},{DEBUG_TEST_CHANNEL:(null==t?void 0:t.DEBUG_TEST_CHANNEL)||v||h});var w=e.plugins.native;this.initBuvidPromise=Promise.all([ye()].concat(d(w?[w.initBuvid()]:[]))).then((function(){f.buvidInit=!0}));var b=X(),m={bsource:b.bsource,bsourceFrom:b.bsourceFrom,uaSource:function(){var e=navigator.userAgent.toLowerCase(),t=function(){return/chrome/i.test(e)||/\b(?:crmo|crios)\/([\w\.]+)/i.test(e)},i={qq:function(){return/QQ\/([\d\.]+)/i.test(e)},wechat:["MicroMessenger","wechat"],douban:["com.douban.frodo","doubanapp"],baidubox:"baiduboxapp",baiduinput:"baiduinput",zhihu:["com.zhihu.android","zhihuhybrid"],haokan:"haokan",iqiyi:["IqiyiApp","iqiyi IqiyiVersion"],NGA:"Nga",weibo:"Weibo",xigua:"NewsArticle",qqlive:"QQLiveBrowser",hupu:"shence.hupu.com",letv:"LetvMobileClient",zuiyou:"Zuiyou",cloudmusic:["CloudMusic","NeteaseMusic"],tieba:"tieba",sogousearch:"SogouSearch",ucbrowser:"UCBrowser",baidubrowser:"baidubrowser",sogoumobilebrowser:"SogouMobileBrowser",huaweibrowser:"HuaweiBrowser",vivobrowser:"VivoBrowser",miuibrowser:"MiuiBrowser",oppobrowser:"oppobrowser",quark:"Quark",mqqbrowser:"MQQBrowser",chromebrowser:t,"360browser":function(){return/\bqihu|(qi?ho?o?|360)browser/i.test(e)||t()&&!window.navigator.webkitPersistentStorage||Object.keys(window).some((function(e){return/qihoo/.test(e)}))}};for(var r in i){var n=i[r];if(Array.isArray(n)){for(var o=0;o=0)return r}else if("string"==typeof n){if(e.indexOf(n.toLocaleLowerCase())>=0)return r}else if("function"==typeof n&&n())return r}return""}()};Object.keys(m).forEach((function(e){e&&(window[e]=m[e])})),this.sequencer=new M;var g,y=D(se,null===(a=this.options)||void 0===a?void 0:a.batch);this.scheduler=new j(l(l({},y.enabled?y.value:{batchSize:1,batchTime:0}),{},{run:(g=i(c().mark((function e(t){var i,r,n,o,a,s,u,l;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,s=(null===(i=f.options)||void 0===i||null===(i=i.base)||void 0===i?void 0:i.logId)||(null!==(r=f.options)&&void 0!==r&&r.DEBUG_TEST_CHANNEL?"025219":"021436"),u=et(t),(null===(n=f.options)||void 0===n?void 0:n.logLevel)>=2&&(l=d(u).map((function(e){return"0".concat(e.toString(16)).slice(-2)})).join(" "),console.log("log_id: %c".concat(s,"\n%crequest size: %c").concat(u.length," bytes\n%crequest body:\n%c").concat(l),"color: #0090FF","","color: #0090FF","","background-color: #004744; color: #A8F5E5")),e.next=6,we(u,{url:null===(o=f.options)||void 0===o||null===(o=o.base)||void 0===o?void 0:o.url,retry:null===(a=f.options)||void 0===a?void 0:a.retry,logId:s});case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(0),console.error("scheduler_run",e.t0);case 11:case"end":return e.stop()}}),e,null,[[0,8]])}))),function(e){return g.apply(this,arguments)})}));var _=null;this.spmPrefix&&!1!==(null==t?void 0:t.autoPv)&&p&&!Q("autoPvReported")&&(_=this.pv(),e.plugins.native&&this.reportNative({event:"".concat(this.spmPrefix,".0.0.pv"),type:1}),this.flush(),W("autoPvReported",!0)),function(){var e=Q("fetchSampleRateTimer");if(!e){try{var t,i=null===(t=window.localStorage)||void 0===t?void 0:t.getItem("__reporter-pb-sample-config");i&&W("sampleRateConfig",JSON.parse(i))}catch(e){}rt(),e=window.setInterval(rt,12e4),W("fetchSampleRateTimer",e)}}();var k=function(){var e;null!==_&&!1!==(null==t||null===(e=t.autoPv)||void 0===e?void 0:e.unload)&&(_(),_=null),f.flush()};window.addEventListener("beforeunload",k),window.addEventListener("pagehide",k);var F,x=function(){var t=i(c().mark((function t(){var i;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(i=e.plugins.fp)){t.next=4;break}return t.next=4,i.init(f);case 4:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();null!=t&&null!==(u=t.feature)&&void 0!==u&&u.fingerPrint&&!e.plugins.fp?this.fpPromise=(F="".concat("https://s1.hdslb.com/bfs/seed/jinkela/short/reporter-pb","/fingerPrint.js"),new Promise((function(e){var t=document.createElement("script");t.crossOrigin="anonymous",t.type="text/javascript",t.src=F,t.onload=function(){return e()},document.body.appendChild(t)}))).then((function(){var t=window.ReporterPbFingerPrint;if(t)return e.use({fp:t}),x()})):this.fpPromise=x()}return o(e,[{key:"spmPrefix",get:function(){var e;return(null===(e=this.options)||void 0===e?void 0:e.spmPrefix)||B("spm_prefix")}},{key:"_handleSpmId",value:function(e){if(!e)return"";if("string"==typeof e)return e;var t=e.prefix||this.spmPrefix||"",i=e.e?".".concat(e.e):"";return t?"".concat(t,".").concat(e.c,".").concat(e.d).concat(i):""}},{key:"report",value:function(e,t,i,r){var n=this,o=this._handleSpmId(t);if(o){if(!this.miss&&function(e){var t=Q("sampleRateConfig");return!t||!t[e]||"number"!=typeof t[e]||Math.ceil(100*Math.random())<=t[e]}(o))if("tech"!==e){var a=Date.now(),s=function(){n.scheduler.add(Ke({type:e,spm:o,data:i,ts:a,options:r},{reporter:n})),null!=r&&r.flush&&n.scheduler.flush()};if(this.buvidInit?s():this.initBuvidPromise.then(s),"pv"===e){var u=o.split(".").slice(0,4).concat("unload").join(".");return function(e){return n.report("pv_unload",u,l({pvStart:a},null!=e?e:{}),r)}}}else this._techReport(o,i,r)}else console.warn("[reporter-pb]: spmId not set",{type:e,spm:t,data:i,options:r})}},{key:"pv",value:function(e,t,i){if(!e){var r=this.spmPrefix;e=r?"".concat(r,".0.0"):""}return this.report("pv",e,null!=t?t:{},i)}},{key:"click",value:function(e,t,i){this.report("click",e,t,i)}},{key:"exposure",value:function(e,t,i){this.report("exposure",e,t,i)}},{key:"player",value:function(e,t,i){this.report("player",e,t,i)}},{key:"custom",value:function(e,t,i){this.report("custom",e,t,i)}},{key:"tech",value:function(e,t,i){this.report("tech",e,t,i)}},{key:"flush",value:function(){var e;this.scheduler.flush(),null===(e=this.techEventReporter)||void 0===e||e.flush()}},{key:"fpReport",value:(a=i(c().mark((function t(i){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.fpPromise;case 2:nt("fp"),e.plugins.fp.fpReport(this,i);case 4:case"end":return t.stop()}}),t,this)}))),function(e){return a.apply(this,arguments)})},{key:"_techReport",value:(n=i(c().mark((function t(i,r,n){var o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this.techEventReporter||(nt("tech"),this.techEventReporter=new e.plugins.tech(this.options,this.initBuvidPromise,this.sequencer)),o=["performance","error","player","custom"].some((function(e){return e===(null==r?void 0:r.type)}))?r.type:"custom",null==r||delete r.type,this.techEventReporter.report(o,i,r,n);case 4:case"end":return t.stop()}}),t,this)}))),function(e,t,i){return n.apply(this,arguments)})},{key:"reportNative",value:(t=i(c().mark((function t(){var i,r=arguments;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return nt("native"),t.abrupt("return",(i=e.plugins.native).reportNative.apply(i,r));case 2:case"end":return t.stop()}}),t)}))),function(){return t.apply(this,arguments)})},{key:"getActionID",value:function(){var t;return nt("native"),(t=e.plugins.native).getActionID.apply(t,arguments)}}],[{key:"use",value:function(e){this.plugins=l(l({},this.plugins),e)}}]);var t,n,a}();function at(e,t){if(e.log_id&&t.writeStringField(1,e.log_id),e.event_id&&t.writeStringField(2,e.event_id),null!=e.body&&t.writeBytesField(3,e.body),e.meta)for(var i=0,r=Object.keys(e.meta);i=1&&console.log("%c".concat(e.type," ").concat(e.spm,"\n"),"color: #30A46C",f),{log_id:gt(t.reporter.options),event_id:e.spm,body:v,meta:{metaEventId:e.spm,metaEventCategory:e.type}}},_t=function(e){var t={events:e},i=new xe;return function(e,t){if(e.events){var i,r=a(e.events);try{for(r.s();!(i=r.n()).done;){var n=i.value;t.writeMessage(1,at,n)}}catch(e){r.e(e)}finally{r.f()}}}(t,i),i.finish()},kt=function(){return o((function e(t,n,o){var a,s=this;r(this,e),this.options=t,this.initBuvidPromise=(n||ye()).then((function(){s.buvidInit=!0})),this.sequencer=o||new M;var u,f=D(se,null===(a=this.options)||void 0===a?void 0:a.batch);this.scheduler=new j(l(l({},f.enabled?f.value:{batchSize:1,batchTime:0}),{},{run:(u=i(c().mark((function e(i){var r,n,o,a,u;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=_t(i),a=gt(s.options),(null===(r=s.options)||void 0===r?void 0:r.logLevel)>=2&&(u=d(o).map((function(e){return"0".concat(e.toString(16)).slice(-2)})).join(" "),console.log("log_id: %c".concat(a,"\n%crequest size: %c").concat(o.length," bytes\n%crequest body:\n%c").concat(u),"color: #0090FF","","color: #0090FF","","background-color: #004744; color: #A8F5E5")),we(o,{url:null===(n=s.options)||void 0===n||null===(n=n.base)||void 0===n?void 0:n.url,retry:null==t?void 0:t.retry,logId:a});case 4:case"end":return e.stop()}}),e)}))),function(e){return u.apply(this,arguments)})}))}),[{key:"report",value:function(e,t,i,r){var n=this,o=function(){var o=Date.now();n.scheduler.add(yt({type:e,spm:t,data:i,ts:o,options:r},{reporter:n}))};this.buvidInit?o():this.initBuvidPromise.then(o)}},{key:"flush",value:function(){this.scheduler.flush()}}])}();return ot.use({tech:kt}),ot}));