@forward-widget/danmu-universe 0.13.0 → 0.13.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/dist/danmu-universe.js +6 -6
- package/package.json +11 -8
package/dist/danmu-universe.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
let METADATA_SYMBOL;var compat_ZodFirstPartyTypeKind,__webpack_modules__={188:function(e){e.exports=t;function t(e,t){for(var n=Array(arguments.length-1),r=0,i=2,o=!0;i<arguments.length;)n[r++]=arguments[i++];return new Promise(function(i,a){n[r]=function(e){if(o)if(o=!1,e)a(e);else{for(var t=Array(arguments.length-1),n=0;n<t.length;)t[n++]=arguments[n];i.apply(null,t)}};try{e.apply(t||null,n)}catch(e){o&&(o=!1,a(e))}})}},4:function(e,t){var n=t;n.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};for(var r=Array(64),i=Array(123),o=0;o<64;)i[r[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;n.encode=function(e,t,n){for(var i,o=null,a=[],s=0,l=0;t<n;){var u=e[t++];switch(l){case 0:a[s++]=r[u>>2],i=(3&u)<<4,l=1;break;case 1:a[s++]=r[i|u>>4],i=(15&u)<<2,l=2;break;case 2:a[s++]=r[i|u>>6],a[s++]=r[63&u],l=0}s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,a)),s=0)}return(l&&(a[s++]=r[i],a[s++]=61,1===l&&(a[s++]=61)),o)?(s&&o.push(String.fromCharCode.apply(String,a.slice(0,s))),o.join("")):String.fromCharCode.apply(String,a.slice(0,s))};var a="invalid encoding";n.decode=function(e,t,n){for(var r,o=n,s=0,l=0;l<e.length;){var u=e.charCodeAt(l++);if(61===u&&s>1)break;if(void 0===(u=i[u]))throw Error(a);switch(s){case 0:r=u,s=1;break;case 1:t[n++]=r<<2|(48&u)>>4,r=u,s=2;break;case 2:t[n++]=(15&r)<<4|(60&u)>>2,r=u,s=3;break;case 3:t[n++]=(3&r)<<6|u,s=0}}if(1===s)throw Error(a);return n-o},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},730:function(e){function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var n=this._listeners[e],r=0;r<n.length;)n[r].fn===t?n.splice(r,1):++r;return this},t.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<t.length;)t[r].fn.apply(t[r++].ctx,n)}return this}},791:function(e){function t(e){return"undefined"!=typeof Float32Array?!function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),r=128===n[3];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3]}function o(e,r,i){t[0]=e,r[i]=n[3],r[i+1]=n[2],r[i+2]=n[1],r[i+3]=n[0]}function a(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],t[0]}function s(e,r){return n[3]=e[r],n[2]=e[r+1],n[1]=e[r+2],n[0]=e[r+3],t[0]}e.writeFloatLE=r?i:o,e.writeFloatBE=r?o:i,e.readFloatLE=r?a:s,e.readFloatBE=r?s:a}():!function(){function t(e,t,n,r){var i=+(t<0);if(i&&(t=-t),0===t)e(1/t>0?0:0x80000000,n,r);else if(isNaN(t))e(0x7fc00000,n,r);else if(t>34028234663852886e22)e((i<<31|0x7f800000)>>>0,n,r);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,n,r);else{var o=Math.floor(Math.log(t)/Math.LN2),a=8388607&Math.round(t*Math.pow(2,-o)*8388608);e((i<<31|o+127<<23|a)>>>0,n,r)}}function a(e,t,n){var r=e(t,n),i=(r>>31)*2+1,o=r>>>23&255,a=8388607&r;return 255===o?a?NaN:1/0*i:0===o?1401298464324817e-60*i*a:i*Math.pow(2,o-150)*(a+8388608)}e.writeFloatLE=t.bind(null,n),e.writeFloatBE=t.bind(null,r),e.readFloatLE=a.bind(null,i),e.readFloatBE=a.bind(null,o)}(),"undefined"!=typeof Float64Array?!function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),r=128===n[7];function i(e,r,i){t[0]=e,r[i]=n[0],r[i+1]=n[1],r[i+2]=n[2],r[i+3]=n[3],r[i+4]=n[4],r[i+5]=n[5],r[i+6]=n[6],r[i+7]=n[7]}function o(e,r,i){t[0]=e,r[i]=n[7],r[i+1]=n[6],r[i+2]=n[5],r[i+3]=n[4],r[i+4]=n[3],r[i+5]=n[2],r[i+6]=n[1],r[i+7]=n[0]}function a(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],n[4]=e[r+4],n[5]=e[r+5],n[6]=e[r+6],n[7]=e[r+7],t[0]}function s(e,r){return n[7]=e[r],n[6]=e[r+1],n[5]=e[r+2],n[4]=e[r+3],n[3]=e[r+4],n[2]=e[r+5],n[1]=e[r+6],n[0]=e[r+7],t[0]}e.writeDoubleLE=r?i:o,e.writeDoubleBE=r?o:i,e.readDoubleLE=r?a:s,e.readDoubleBE=r?s:a}():!function(){function t(e,t,n,r,i,o){var a,s=+(r<0);if(s&&(r=-r),0===r)e(0,i,o+t),e(1/r>0?0:0x80000000,i,o+n);else if(isNaN(r))e(0,i,o+t),e(0x7ff80000,i,o+n);else if(r>17976931348623157e292)e(0,i,o+t),e((s<<31|0x7ff00000)>>>0,i,o+n);else if(r<22250738585072014e-324)e((a=r/5e-324)>>>0,i,o+t),e((s<<31|a/0x100000000)>>>0,i,o+n);else{var l=Math.floor(Math.log(r)/Math.LN2);1024===l&&(l=1023),e(0x10000000000000*(a=r*Math.pow(2,-l))>>>0,i,o+t),e((s<<31|l+1023<<20|1048576*a&1048575)>>>0,i,o+n)}}function a(e,t,n,r,i){var o=e(r,i+t),a=e(r,i+n),s=(a>>31)*2+1,l=a>>>20&2047,u=0x100000000*(1048575&a)+o;return 2047===l?u?NaN:1/0*s:0===l?5e-324*s*u:s*Math.pow(2,l-1075)*(u+0x10000000000000)}e.writeDoubleLE=t.bind(null,n,0,4),e.writeDoubleBE=t.bind(null,r,4,0),e.readDoubleLE=a.bind(null,i,0,4),e.readDoubleBE=a.bind(null,o,4,0)}(),e}function n(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function r(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function o(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},706:function(module){module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}},338:function(e){e.exports=t;function t(e,t,n){var r=n||8192,i=r>>>1,o=null,a=r;return function(n){if(n<1||n>i)return e(n);a+n>r&&(o=e(r),a=0);var s=t.call(o,a,a+=n);return 7&a&&(a=(7|a)+1),s}}},322:function(e,t){var n=t;n.length=function(e){for(var t=0,n=0,r=0;r<e.length;++r)(n=e.charCodeAt(r))<128?t+=1:n<2048?t+=2:(64512&n)==55296&&(64512&e.charCodeAt(r+1))==56320?(++r,t+=4):t+=3;return t},n.read=function(e,t,n){if(n-t<1)return"";for(var r,i=null,o=[],a=0;t<n;)(r=e[t++])<128?o[a++]=r:r>191&&r<224?o[a++]=(31&r)<<6|63&e[t++]:r>239&&r<365?(r=((7&r)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[a++]=55296+(r>>10),o[a++]=56320+(1023&r)):o[a++]=(15&r)<<12|(63&e[t++])<<6|63&e[t++],a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0);return i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))},n.write=function(e,t,n){for(var r,i,o=n,a=0;a<e.length;++a)(r=e.charCodeAt(a))<128?t[n++]=r:(r<2048?t[n++]=r>>6|192:((64512&r)==55296&&(64512&(i=e.charCodeAt(a+1)))==56320?(r=65536+((1023&r)<<10)+(1023&i),++a,t[n++]=r>>18|240,t[n++]=r>>12&63|128):t[n++]=r>>12|224,t[n++]=r>>6&63|128),t[n++]=63&r|128);return n-o}},252:function(e,t,n){e=n.nmd(e),function(t,r){"function"==typeof define&&define.amd?define(["protobufjs/minimal"],r):e&&e.exports&&(e.exports=r(n(643)))}(0,function(e){"use strict";var t=e.Reader,n=e.Writer,r=e.util,i=e.roots.default||(e.roots.default={});return i.biliproto=function(){var o={};return o.community=function(){var o={};return o.service=function(){var o={};return o.dm=function(){var o={};return o.v1=function(){var o={};return o.DanmakuElem=function(){function o(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return o.prototype.id=r.Long?r.Long.fromBits(0,0,!1):0,o.prototype.progress=0,o.prototype.mode=0,o.prototype.fontsize=0,o.prototype.color=0,o.prototype.midHash="",o.prototype.content="",o.prototype.ctime=r.Long?r.Long.fromBits(0,0,!1):0,o.prototype.weight=0,o.prototype.action="",o.prototype.pool=0,o.prototype.idStr="",o.prototype.attr=0,o.prototype.animation="",o.prototype.likeNum=0,o.prototype.colorV2="",o.prototype.dmTypeV2=0,o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=n.create()),null!=e.id&&Object.hasOwnProperty.call(e,"id")&&t.uint32(8).int64(e.id),null!=e.progress&&Object.hasOwnProperty.call(e,"progress")&&t.uint32(16).int32(e.progress),null!=e.mode&&Object.hasOwnProperty.call(e,"mode")&&t.uint32(24).int32(e.mode),null!=e.fontsize&&Object.hasOwnProperty.call(e,"fontsize")&&t.uint32(32).int32(e.fontsize),null!=e.color&&Object.hasOwnProperty.call(e,"color")&&t.uint32(40).uint32(e.color),null!=e.midHash&&Object.hasOwnProperty.call(e,"midHash")&&t.uint32(50).string(e.midHash),null!=e.content&&Object.hasOwnProperty.call(e,"content")&&t.uint32(58).string(e.content),null!=e.ctime&&Object.hasOwnProperty.call(e,"ctime")&&t.uint32(64).int64(e.ctime),null!=e.weight&&Object.hasOwnProperty.call(e,"weight")&&t.uint32(72).int32(e.weight),null!=e.action&&Object.hasOwnProperty.call(e,"action")&&t.uint32(82).string(e.action),null!=e.pool&&Object.hasOwnProperty.call(e,"pool")&&t.uint32(88).int32(e.pool),null!=e.idStr&&Object.hasOwnProperty.call(e,"idStr")&&t.uint32(98).string(e.idStr),null!=e.attr&&Object.hasOwnProperty.call(e,"attr")&&t.uint32(104).int32(e.attr),null!=e.animation&&Object.hasOwnProperty.call(e,"animation")&&t.uint32(114).string(e.animation),null!=e.likeNum&&Object.hasOwnProperty.call(e,"likeNum")&&t.uint32(120).uint32(e.likeNum),null!=e.colorV2&&Object.hasOwnProperty.call(e,"colorV2")&&t.uint32(130).string(e.colorV2),null!=e.dmTypeV2&&Object.hasOwnProperty.call(e,"dmTypeV2")&&t.uint32(136).uint32(e.dmTypeV2),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,n,r){e instanceof t||(e=t.create(e));for(var o=void 0===n?e.len:e.pos+n,a=new i.biliproto.community.service.dm.v1.DanmakuElem;e.pos<o;){var s=e.uint32();if(s===r)break;switch(s>>>3){case 1:a.id=e.int64();break;case 2:a.progress=e.int32();break;case 3:a.mode=e.int32();break;case 4:a.fontsize=e.int32();break;case 5:a.color=e.uint32();break;case 6:a.midHash=e.string();break;case 7:a.content=e.string();break;case 8:a.ctime=e.int64();break;case 9:a.weight=e.int32();break;case 10:a.action=e.string();break;case 11:a.pool=e.int32();break;case 12:a.idStr=e.string();break;case 13:a.attr=e.int32();break;case 14:a.animation=e.string();break;case 15:a.likeNum=e.uint32();break;case 16:a.colorV2=e.string();break;case 17:a.dmTypeV2=e.uint32();break;default:e.skipType(7&s)}}return a},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.id&&e.hasOwnProperty("id")&&!r.isInteger(e.id)&&!(e.id&&r.isInteger(e.id.low)&&r.isInteger(e.id.high))?"id: integer|Long expected":null!=e.progress&&e.hasOwnProperty("progress")&&!r.isInteger(e.progress)?"progress: integer expected":null!=e.mode&&e.hasOwnProperty("mode")&&!r.isInteger(e.mode)?"mode: integer expected":null!=e.fontsize&&e.hasOwnProperty("fontsize")&&!r.isInteger(e.fontsize)?"fontsize: integer expected":null!=e.color&&e.hasOwnProperty("color")&&!r.isInteger(e.color)?"color: integer expected":null!=e.midHash&&e.hasOwnProperty("midHash")&&!r.isString(e.midHash)?"midHash: string expected":null!=e.content&&e.hasOwnProperty("content")&&!r.isString(e.content)?"content: string expected":null!=e.ctime&&e.hasOwnProperty("ctime")&&!r.isInteger(e.ctime)&&!(e.ctime&&r.isInteger(e.ctime.low)&&r.isInteger(e.ctime.high))?"ctime: integer|Long expected":null!=e.weight&&e.hasOwnProperty("weight")&&!r.isInteger(e.weight)?"weight: integer expected":null!=e.action&&e.hasOwnProperty("action")&&!r.isString(e.action)?"action: string expected":null!=e.pool&&e.hasOwnProperty("pool")&&!r.isInteger(e.pool)?"pool: integer expected":null!=e.idStr&&e.hasOwnProperty("idStr")&&!r.isString(e.idStr)?"idStr: string expected":null!=e.attr&&e.hasOwnProperty("attr")&&!r.isInteger(e.attr)?"attr: integer expected":null!=e.animation&&e.hasOwnProperty("animation")&&!r.isString(e.animation)?"animation: string expected":null!=e.likeNum&&e.hasOwnProperty("likeNum")&&!r.isInteger(e.likeNum)?"likeNum: integer expected":null!=e.colorV2&&e.hasOwnProperty("colorV2")&&!r.isString(e.colorV2)?"colorV2: string expected":null!=e.dmTypeV2&&e.hasOwnProperty("dmTypeV2")&&!r.isInteger(e.dmTypeV2)?"dmTypeV2: integer expected":null},o.fromObject=function(e){if(e instanceof i.biliproto.community.service.dm.v1.DanmakuElem)return e;var t=new i.biliproto.community.service.dm.v1.DanmakuElem;return null!=e.id&&(r.Long?(t.id=r.Long.fromValue(e.id)).unsigned=!1:"string"==typeof e.id?t.id=parseInt(e.id,10):"number"==typeof e.id?t.id=e.id:"object"==typeof e.id&&(t.id=new r.LongBits(e.id.low>>>0,e.id.high>>>0).toNumber())),null!=e.progress&&(t.progress=0|e.progress),null!=e.mode&&(t.mode=0|e.mode),null!=e.fontsize&&(t.fontsize=0|e.fontsize),null!=e.color&&(t.color=e.color>>>0),null!=e.midHash&&(t.midHash=String(e.midHash)),null!=e.content&&(t.content=String(e.content)),null!=e.ctime&&(r.Long?(t.ctime=r.Long.fromValue(e.ctime)).unsigned=!1:"string"==typeof e.ctime?t.ctime=parseInt(e.ctime,10):"number"==typeof e.ctime?t.ctime=e.ctime:"object"==typeof e.ctime&&(t.ctime=new r.LongBits(e.ctime.low>>>0,e.ctime.high>>>0).toNumber())),null!=e.weight&&(t.weight=0|e.weight),null!=e.action&&(t.action=String(e.action)),null!=e.pool&&(t.pool=0|e.pool),null!=e.idStr&&(t.idStr=String(e.idStr)),null!=e.attr&&(t.attr=0|e.attr),null!=e.animation&&(t.animation=String(e.animation)),null!=e.likeNum&&(t.likeNum=e.likeNum>>>0),null!=e.colorV2&&(t.colorV2=String(e.colorV2)),null!=e.dmTypeV2&&(t.dmTypeV2=e.dmTypeV2>>>0),t},o.toObject=function(e,t){t||(t={});var n={};if(t.defaults){if(r.Long){var i=new r.Long(0,0,!1);n.id=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else n.id=t.longs===String?"0":0;if(n.progress=0,n.mode=0,n.fontsize=0,n.color=0,n.midHash="",n.content="",r.Long){var i=new r.Long(0,0,!1);n.ctime=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else n.ctime=t.longs===String?"0":0;n.weight=0,n.action="",n.pool=0,n.idStr="",n.attr=0,n.animation="",n.likeNum=0,n.colorV2="",n.dmTypeV2=0}return null!=e.id&&e.hasOwnProperty("id")&&("number"==typeof e.id?n.id=t.longs===String?String(e.id):e.id:n.id=t.longs===String?r.Long.prototype.toString.call(e.id):t.longs===Number?new r.LongBits(e.id.low>>>0,e.id.high>>>0).toNumber():e.id),null!=e.progress&&e.hasOwnProperty("progress")&&(n.progress=e.progress),null!=e.mode&&e.hasOwnProperty("mode")&&(n.mode=e.mode),null!=e.fontsize&&e.hasOwnProperty("fontsize")&&(n.fontsize=e.fontsize),null!=e.color&&e.hasOwnProperty("color")&&(n.color=e.color),null!=e.midHash&&e.hasOwnProperty("midHash")&&(n.midHash=e.midHash),null!=e.content&&e.hasOwnProperty("content")&&(n.content=e.content),null!=e.ctime&&e.hasOwnProperty("ctime")&&("number"==typeof e.ctime?n.ctime=t.longs===String?String(e.ctime):e.ctime:n.ctime=t.longs===String?r.Long.prototype.toString.call(e.ctime):t.longs===Number?new r.LongBits(e.ctime.low>>>0,e.ctime.high>>>0).toNumber():e.ctime),null!=e.weight&&e.hasOwnProperty("weight")&&(n.weight=e.weight),null!=e.action&&e.hasOwnProperty("action")&&(n.action=e.action),null!=e.pool&&e.hasOwnProperty("pool")&&(n.pool=e.pool),null!=e.idStr&&e.hasOwnProperty("idStr")&&(n.idStr=e.idStr),null!=e.attr&&e.hasOwnProperty("attr")&&(n.attr=e.attr),null!=e.animation&&e.hasOwnProperty("animation")&&(n.animation=e.animation),null!=e.likeNum&&e.hasOwnProperty("likeNum")&&(n.likeNum=e.likeNum),null!=e.colorV2&&e.hasOwnProperty("colorV2")&&(n.colorV2=e.colorV2),null!=e.dmTypeV2&&e.hasOwnProperty("dmTypeV2")&&(n.dmTypeV2=e.dmTypeV2),n},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/biliproto.community.service.dm.v1.DanmakuElem"},o}(),o.Flag=function(){function o(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return o.prototype.value=0,o.prototype.description="",o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=n.create()),null!=e.value&&Object.hasOwnProperty.call(e,"value")&&t.uint32(8).int32(e.value),null!=e.description&&Object.hasOwnProperty.call(e,"description")&&t.uint32(18).string(e.description),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,n,r){e instanceof t||(e=t.create(e));for(var o=void 0===n?e.len:e.pos+n,a=new i.biliproto.community.service.dm.v1.Flag;e.pos<o;){var s=e.uint32();if(s===r)break;switch(s>>>3){case 1:a.value=e.int32();break;case 2:a.description=e.string();break;default:e.skipType(7&s)}}return a},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&!r.isInteger(e.value)?"value: integer expected":null!=e.description&&e.hasOwnProperty("description")&&!r.isString(e.description)?"description: string expected":null},o.fromObject=function(e){if(e instanceof i.biliproto.community.service.dm.v1.Flag)return e;var t=new i.biliproto.community.service.dm.v1.Flag;return null!=e.value&&(t.value=0|e.value),null!=e.description&&(t.description=String(e.description)),t},o.toObject=function(e,t){t||(t={});var n={};return t.defaults&&(n.value=0,n.description=""),null!=e.value&&e.hasOwnProperty("value")&&(n.value=e.value),null!=e.description&&e.hasOwnProperty("description")&&(n.description=e.description),n},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/biliproto.community.service.dm.v1.Flag"},o}(),o.DmSegMobileReply=function(){function o(e){if(this.elems=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return o.prototype.elems=r.emptyArray,o.prototype.state=0,o.prototype.aiFlagForSummary=null,o.create=function(e){return new o(e)},o.encode=function(e,t){if(t||(t=n.create()),null!=e.elems&&e.elems.length)for(var r=0;r<e.elems.length;++r)i.biliproto.community.service.dm.v1.DanmakuElem.encode(e.elems[r],t.uint32(10).fork()).ldelim();return null!=e.state&&Object.hasOwnProperty.call(e,"state")&&t.uint32(16).int32(e.state),null!=e.aiFlagForSummary&&Object.hasOwnProperty.call(e,"aiFlagForSummary")&&i.biliproto.community.service.dm.v1.Flag.encode(e.aiFlagForSummary,t.uint32(26).fork()).ldelim(),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,n,r){e instanceof t||(e=t.create(e));for(var o=void 0===n?e.len:e.pos+n,a=new i.biliproto.community.service.dm.v1.DmSegMobileReply;e.pos<o;){var s=e.uint32();if(s===r)break;switch(s>>>3){case 1:a.elems&&a.elems.length||(a.elems=[]),a.elems.push(i.biliproto.community.service.dm.v1.DanmakuElem.decode(e,e.uint32()));break;case 2:a.state=e.int32();break;case 3:a.aiFlagForSummary=i.biliproto.community.service.dm.v1.Flag.decode(e,e.uint32());break;default:e.skipType(7&s)}}return a},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.elems&&e.hasOwnProperty("elems")){if(!Array.isArray(e.elems))return"elems: array expected";for(var t=0;t<e.elems.length;++t){var n=i.biliproto.community.service.dm.v1.DanmakuElem.verify(e.elems[t]);if(n)return"elems."+n}}if(null!=e.state&&e.hasOwnProperty("state")&&!r.isInteger(e.state))return"state: integer expected";if(null!=e.aiFlagForSummary&&e.hasOwnProperty("aiFlagForSummary")){var n=i.biliproto.community.service.dm.v1.Flag.verify(e.aiFlagForSummary);if(n)return"aiFlagForSummary."+n}return null},o.fromObject=function(e){if(e instanceof i.biliproto.community.service.dm.v1.DmSegMobileReply)return e;var t=new i.biliproto.community.service.dm.v1.DmSegMobileReply;if(e.elems){if(!Array.isArray(e.elems))throw TypeError(".biliproto.community.service.dm.v1.DmSegMobileReply.elems: array expected");t.elems=[];for(var n=0;n<e.elems.length;++n){if("object"!=typeof e.elems[n])throw TypeError(".biliproto.community.service.dm.v1.DmSegMobileReply.elems: object expected");t.elems[n]=i.biliproto.community.service.dm.v1.DanmakuElem.fromObject(e.elems[n])}}if(null!=e.state&&(t.state=0|e.state),null!=e.aiFlagForSummary){if("object"!=typeof e.aiFlagForSummary)throw TypeError(".biliproto.community.service.dm.v1.DmSegMobileReply.aiFlagForSummary: object expected");t.aiFlagForSummary=i.biliproto.community.service.dm.v1.Flag.fromObject(e.aiFlagForSummary)}return t},o.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.elems=[]),t.defaults&&(n.state=0,n.aiFlagForSummary=null),e.elems&&e.elems.length){n.elems=[];for(var r=0;r<e.elems.length;++r)n.elems[r]=i.biliproto.community.service.dm.v1.DanmakuElem.toObject(e.elems[r],t)}return null!=e.state&&e.hasOwnProperty("state")&&(n.state=e.state),null!=e.aiFlagForSummary&&e.hasOwnProperty("aiFlagForSummary")&&(n.aiFlagForSummary=i.biliproto.community.service.dm.v1.Flag.toObject(e.aiFlagForSummary,t)),n},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/biliproto.community.service.dm.v1.DmSegMobileReply"},o}(),o}(),o}(),o}(),o}(),o}(),i})},129:function(e,t,n){!function(r,i,o){e.exports=t=i(n(95),n(716),n(478),n(516),n(947))}(0,function(e){return!function(){var t=e,n=t.lib.BlockCipher,r=t.algo,i=[],o=[],a=[],s=[],l=[],u=[],c=[],d=[],f=[],h=[];!function(){for(var e=[],t=0;t<256;t++)t<128?e[t]=t<<1:e[t]=t<<1^283;for(var n=0,r=0,t=0;t<256;t++){var p=r^r<<1^r<<2^r<<3^r<<4;p=p>>>8^255&p^99,i[n]=p,o[p]=n;var m=e[n],g=e[m],v=e[g],y=257*e[p]^0x1010100*p;a[n]=y<<24|y>>>8,s[n]=y<<16|y>>>16,l[n]=y<<8|y>>>24,u[n]=y;var y=0x1010101*v^65537*g^257*m^0x1010100*n;c[p]=y<<24|y>>>8,d[p]=y<<16|y>>>16,f[p]=y<<8|y>>>24,h[p]=y,n?(n=m^e[e[e[v^m]]],r^=e[e[r]]):n=r=1}}();var p=[0,1,2,4,8,16,32,64,128,27,54],m=r.AES=n.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e,t=this._keyPriorReset=this._key,n=t.words,r=t.sigBytes/4,o=this._nRounds=r+6,a=(o+1)*4,s=this._keySchedule=[],l=0;l<a;l++)l<r?s[l]=n[l]:(e=s[l-1],l%r?r>6&&l%r==4&&(e=i[e>>>24]<<24|i[e>>>16&255]<<16|i[e>>>8&255]<<8|i[255&e]):e=(i[(e=e<<8|e>>>24)>>>24]<<24|i[e>>>16&255]<<16|i[e>>>8&255]<<8|i[255&e])^p[l/r|0]<<24,s[l]=s[l-r]^e);for(var u=this._invKeySchedule=[],m=0;m<a;m++){var l=a-m;if(m%4)var e=s[l];else var e=s[l-4];m<4||l<=4?u[m]=e:u[m]=c[i[e>>>24]]^d[i[e>>>16&255]]^f[i[e>>>8&255]]^h[i[255&e]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,l,u,i)},decryptBlock:function(e,t){var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n,this._doCryptBlock(e,t,this._invKeySchedule,c,d,f,h,o);var n=e[t+1];e[t+1]=e[t+3],e[t+3]=n},_doCryptBlock:function(e,t,n,r,i,o,a,s){for(var l=this._nRounds,u=e[t]^n[0],c=e[t+1]^n[1],d=e[t+2]^n[2],f=e[t+3]^n[3],h=4,p=1;p<l;p++){var m=r[u>>>24]^i[c>>>16&255]^o[d>>>8&255]^a[255&f]^n[h++],g=r[c>>>24]^i[d>>>16&255]^o[f>>>8&255]^a[255&u]^n[h++],v=r[d>>>24]^i[f>>>16&255]^o[u>>>8&255]^a[255&c]^n[h++],y=r[f>>>24]^i[u>>>16&255]^o[c>>>8&255]^a[255&d]^n[h++];u=m,c=g,d=v,f=y}var m=(s[u>>>24]<<24|s[c>>>16&255]<<16|s[d>>>8&255]<<8|s[255&f])^n[h++],g=(s[c>>>24]<<24|s[d>>>16&255]<<16|s[f>>>8&255]<<8|s[255&u])^n[h++],v=(s[d>>>24]<<24|s[f>>>16&255]<<16|s[u>>>8&255]<<8|s[255&c])^n[h++],y=(s[f>>>24]<<24|s[u>>>16&255]<<16|s[c>>>8&255]<<8|s[255&d])^n[h++];e[t]=m,e[t+1]=g,e[t+2]=v,e[t+3]=y},keySize:8});t.AES=n._createHelper(m)}(),e.AES})},947:function(e,t,n){!function(r,i,o){e.exports=t=i(n(95),n(516))}(0,function(e){e.lib.Cipher||function(){var t=e,n=t.lib,r=n.Base,i=n.WordArray,o=n.BufferedBlockAlgorithm,a=t.enc;a.Utf8;var s=a.Base64,l=t.algo.EvpKDF,u=n.Cipher=o.extend({cfg:r.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,n){this.cfg=this.cfg.extend(n),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?y:g}return function(t){return{encrypt:function(n,r,i){return e(r).encrypt(t,n,r,i)},decrypt:function(n,r,i){return e(r).decrypt(t,n,r,i)}}}}()});n.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var c=t.mode={},d=n.BlockCipherMode=r.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),f=c.CBC=function(){var e=d.extend();function t(e,t,n){var r,i=this._iv;i?(r=i,this._iv=void 0):r=this._prevBlock;for(var o=0;o<n;o++)e[t+o]^=r[o]}return e.Encryptor=e.extend({processBlock:function(e,n){var r=this._cipher,i=r.blockSize;t.call(this,e,n,i),r.encryptBlock(e,n),this._prevBlock=e.slice(n,n+i)}}),e.Decryptor=e.extend({processBlock:function(e,n){var r=this._cipher,i=r.blockSize,o=e.slice(n,n+i);r.decryptBlock(e,n),t.call(this,e,n,i),this._prevBlock=o}}),e}(),h=(t.pad={}).Pkcs7={pad:function(e,t){for(var n=4*t,r=n-e.sigBytes%n,o=r<<24|r<<16|r<<8|r,a=[],s=0;s<r;s+=4)a.push(o);var l=i.create(a,r);e.concat(l)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};n.BlockCipher=u.extend({cfg:u.cfg.extend({mode:f,padding:h}),reset:function(){u.reset.call(this);var e,t=this.cfg,n=t.iv,r=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=r.createEncryptor:(e=r.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,n&&n.words):(this._mode=e.call(r,this,n&&n.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var p=n.CipherParams=r.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),m=(t.format={}).OpenSSL={stringify:function(e){var t,n=e.ciphertext,r=e.salt;return(t=r?i.create([0x53616c74,0x65645f5f]).concat(r).concat(n):n).toString(s)},parse:function(e){var t,n=s.parse(e),r=n.words;return 0x53616c74==r[0]&&0x65645f5f==r[1]&&(t=i.create(r.slice(2,4)),r.splice(0,4),n.sigBytes-=16),p.create({ciphertext:n,salt:t})}},g=n.SerializableCipher=r.extend({cfg:r.extend({format:m}),encrypt:function(e,t,n,r){r=this.cfg.extend(r);var i=e.createEncryptor(n,r),o=i.finalize(t),a=i.cfg;return p.create({ciphertext:o,key:n,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:r.format})},decrypt:function(e,t,n,r){return r=this.cfg.extend(r),t=this._parse(t,r.format),e.createDecryptor(n,r).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),v=(t.kdf={}).OpenSSL={execute:function(e,t,n,r,o){if(r||(r=i.random(8)),o)var a=l.create({keySize:t+n,hasher:o}).compute(e,r);else var a=l.create({keySize:t+n}).compute(e,r);var s=i.create(a.words.slice(t),4*n);return a.sigBytes=4*t,p.create({key:a,iv:s,salt:r})}},y=n.PasswordBasedCipher=g.extend({cfg:g.cfg.extend({kdf:v}),encrypt:function(e,t,n,r){var i=(r=this.cfg.extend(r)).kdf.execute(n,e.keySize,e.ivSize,r.salt,r.hasher);r.iv=i.iv;var o=g.encrypt.call(this,e,t,i.key,r);return o.mixIn(i),o},decrypt:function(e,t,n,r){r=this.cfg.extend(r),t=this._parse(t,r.format);var i=r.kdf.execute(n,e.keySize,e.ivSize,t.salt,r.hasher);return r.iv=i.iv,g.decrypt.call(this,e,t,i.key,r)}})}()})},95:function(e,t,n){!function(n,r){e.exports=t=r()}(0,function(){var e=e||function(e,t){if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&void 0!==n.g&&n.g.crypto&&(r=n.g.crypto),!r)try{r=n(602)}catch(e){}var r,i=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(e){}}throw Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),a={},s=a.lib={},l=s.Base=function(){return{extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),u=s.WordArray=l.extend({init:function(e,n){e=this.words=e||[],t!=n?this.sigBytes=n:this.sigBytes=4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,i=e.sigBytes;if(this.clamp(),r%4)for(var o=0;o<i;o++){var a=n[o>>>2]>>>24-o%4*8&255;t[r+o>>>2]|=a<<24-(r+o)%4*8}else for(var s=0;s<i;s+=4)t[r+s>>>2]=n[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=0xffffffff<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=l.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],n=0;n<e;n+=4)t.push(i());return new u.init(t,e)}}),c=a.enc={},d=c.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push((o>>>4).toString(16)),r.push((15&o).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r+=2)n[r>>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new u.init(n,t/2)}},f=c.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var o=t[i>>>2]>>>24-i%4*8&255;r.push(String.fromCharCode(o))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r<t;r++)n[r>>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new u.init(n,t)}},h=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},p=s.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n,r=this._data,i=r.words,o=r.sigBytes,a=this.blockSize,s=o/(4*a),l=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,c=e.min(4*l,o);if(l){for(var d=0;d<l;d+=a)this._doProcessBlock(i,d);n=i.splice(0,l),r.sigBytes-=c}return new u.init(n,c)},clone:function(){var e=l.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=p.extend({cfg:l.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new m.HMAC.init(e,n).finalize(t)}}});var m=a.algo={};return a}(Math);return e})},716:function(e,t,n){!function(r,i){e.exports=t=i(n(95))}(0,function(e){return!function(){var t=e,n=t.lib.WordArray;function r(e,t,r){for(var i=[],o=0,a=0;a<t;a++)if(a%4){var s=r[e.charCodeAt(a-1)]<<a%4*2|r[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return n.create(i,o)}t.enc.Base64={stringify:function(e){var t=e.words,n=e.sigBytes,r=this._map;e.clamp();for(var i=[],o=0;o<n;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<n;s++)i.push(r.charAt(a>>>6*(3-s)&63));var l=r.charAt(64);if(l)for(;i.length%4;)i.push(l);return i.join("")},parse:function(e){var t=e.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<n.length;o++)i[n.charCodeAt(o)]=o}var a=n.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return r(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64})},60:function(e,t,n){!function(r,i){e.exports=t=i(n(95))}(0,function(e){return e.enc.Utf8})},516:function(e,t,n){!function(r,i,o){e.exports=t=i(n(95),n(825),n(979))}(0,function(e){return!function(){var t=e,n=t.lib,r=n.Base,i=n.WordArray,o=t.algo,a=o.MD5,s=o.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:a,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var n,r=this.cfg,o=r.hasher.create(),a=i.create(),s=a.words,l=r.keySize,u=r.iterations;s.length<l;){n&&o.update(n),n=o.update(e).finalize(t),o.reset();for(var c=1;c<u;c++)n=o.finalize(n),o.reset();a.concat(n)}return a.sigBytes=4*l,a}});t.EvpKDF=function(e,t,n){return s.create(n).compute(e,t)}}(),e.EvpKDF})},939:function(e,t,n){!function(r,i,o){e.exports=t=i(n(95),n(331),n(979))}(0,function(e){return e.HmacSHA256})},979:function(e,t,n){!function(r,i){e.exports=t=i(n(95))}(0,function(e){!function(){var t=e,n=t.lib.Base,r=t.enc.Utf8;t.algo.HMAC=n.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=r.parse(t));var n=e.blockSize,i=4*n;t.sigBytes>i&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,l=a.words,u=0;u<n;u++)s[u]^=0x5c5c5c5c,l[u]^=0x36363636;o.sigBytes=a.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})}()})},478:function(e,t,n){!function(r,i){e.exports=t=i(n(95))}(0,function(e){return!function(t){var n=e,r=n.lib,i=r.WordArray,o=r.Hasher,a=n.algo,s=[];!function(){for(var e=0;e<64;e++)s[e]=0x100000000*t.abs(t.sin(e+1))|0}();var l=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([0x67452301,0xefcdab89,0x98badcfe,0x10325476])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var r=t+n,i=e[r];e[r]=(i<<8|i>>>24)&0xff00ff|(i<<24|i>>>8)&0xff00ff00}var o=this._hash.words,a=e[t+0],l=e[t+1],h=e[t+2],p=e[t+3],m=e[t+4],g=e[t+5],v=e[t+6],y=e[t+7],b=e[t+8],w=e[t+9],_=e[t+10],x=e[t+11],k=e[t+12],S=e[t+13],z=e[t+14],I=e[t+15],O=o[0],E=o[1],P=o[2],$=o[3];O=u(O,E,P,$,a,7,s[0]),$=u($,O,E,P,l,12,s[1]),P=u(P,$,O,E,h,17,s[2]),E=u(E,P,$,O,p,22,s[3]),O=u(O,E,P,$,m,7,s[4]),$=u($,O,E,P,g,12,s[5]),P=u(P,$,O,E,v,17,s[6]),E=u(E,P,$,O,y,22,s[7]),O=u(O,E,P,$,b,7,s[8]),$=u($,O,E,P,w,12,s[9]),P=u(P,$,O,E,_,17,s[10]),E=u(E,P,$,O,x,22,s[11]),O=u(O,E,P,$,k,7,s[12]),$=u($,O,E,P,S,12,s[13]),P=u(P,$,O,E,z,17,s[14]),E=u(E,P,$,O,I,22,s[15]),O=c(O,E,P,$,l,5,s[16]),$=c($,O,E,P,v,9,s[17]),P=c(P,$,O,E,x,14,s[18]),E=c(E,P,$,O,a,20,s[19]),O=c(O,E,P,$,g,5,s[20]),$=c($,O,E,P,_,9,s[21]),P=c(P,$,O,E,I,14,s[22]),E=c(E,P,$,O,m,20,s[23]),O=c(O,E,P,$,w,5,s[24]),$=c($,O,E,P,z,9,s[25]),P=c(P,$,O,E,p,14,s[26]),E=c(E,P,$,O,b,20,s[27]),O=c(O,E,P,$,S,5,s[28]),$=c($,O,E,P,h,9,s[29]),P=c(P,$,O,E,y,14,s[30]),E=c(E,P,$,O,k,20,s[31]),O=d(O,E,P,$,g,4,s[32]),$=d($,O,E,P,b,11,s[33]),P=d(P,$,O,E,x,16,s[34]),E=d(E,P,$,O,z,23,s[35]),O=d(O,E,P,$,l,4,s[36]),$=d($,O,E,P,m,11,s[37]),P=d(P,$,O,E,y,16,s[38]),E=d(E,P,$,O,_,23,s[39]),O=d(O,E,P,$,S,4,s[40]),$=d($,O,E,P,a,11,s[41]),P=d(P,$,O,E,p,16,s[42]),E=d(E,P,$,O,v,23,s[43]),O=d(O,E,P,$,w,4,s[44]),$=d($,O,E,P,k,11,s[45]),P=d(P,$,O,E,I,16,s[46]),E=d(E,P,$,O,h,23,s[47]),O=f(O,E,P,$,a,6,s[48]),$=f($,O,E,P,y,10,s[49]),P=f(P,$,O,E,z,15,s[50]),E=f(E,P,$,O,g,21,s[51]),O=f(O,E,P,$,k,6,s[52]),$=f($,O,E,P,p,10,s[53]),P=f(P,$,O,E,_,15,s[54]),E=f(E,P,$,O,l,21,s[55]),O=f(O,E,P,$,b,6,s[56]),$=f($,O,E,P,I,10,s[57]),P=f(P,$,O,E,v,15,s[58]),E=f(E,P,$,O,S,21,s[59]),O=f(O,E,P,$,m,6,s[60]),$=f($,O,E,P,x,10,s[61]),P=f(P,$,O,E,h,15,s[62]),E=f(E,P,$,O,w,21,s[63]),o[0]=o[0]+O|0,o[1]=o[1]+E|0,o[2]=o[2]+P|0,o[3]=o[3]+$|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;n[i>>>5]|=128<<24-i%32;var o=t.floor(r/0x100000000),a=r;n[(i+64>>>9<<4)+15]=(o<<8|o>>>24)&0xff00ff|(o<<24|o>>>8)&0xff00ff00,n[(i+64>>>9<<4)+14]=(a<<8|a>>>24)&0xff00ff|(a<<24|a>>>8)&0xff00ff00,e.sigBytes=(n.length+1)*4,this._process();for(var s=this._hash,l=s.words,u=0;u<4;u++){var c=l[u];l[u]=(c<<8|c>>>24)&0xff00ff|(c<<24|c>>>8)&0xff00ff00}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,r,i,o,a){var s=e+(t&n|~t&r)+i+a;return(s<<o|s>>>32-o)+t}function c(e,t,n,r,i,o,a){var s=e+(t&r|n&~r)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,n,r,i,o,a){var s=e+(t^n^r)+i+a;return(s<<o|s>>>32-o)+t}function f(e,t,n,r,i,o,a){var s=e+(n^(t|~r))+i+a;return(s<<o|s>>>32-o)+t}n.MD5=o._createHelper(l),n.HmacMD5=o._createHmacHelper(l)}(Math),e.MD5})},760:function(e,t,n){!function(r,i,o){e.exports=t=i(n(95),n(947))}(0,function(e){return e.mode.ECB=function(){var t=e.lib.BlockCipherMode.extend();return t.Encryptor=t.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),t.Decryptor=t.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),t}(),e.mode.ECB})},186:function(e,t,n){!function(r,i,o){e.exports=t=i(n(95),n(947))}(0,function(e){return e.pad.Pkcs7})},825:function(e,t,n){!function(r,i){e.exports=t=i(n(95))}(0,function(e){return!function(){var t=e,n=t.lib,r=n.WordArray,i=n.Hasher,o=t.algo,a=[],s=o.SHA1=i.extend({_doReset:function(){this._hash=new r.init([0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0])},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],s=n[3],l=n[4],u=0;u<80;u++){if(u<16)a[u]=0|e[t+u];else{var c=a[u-3]^a[u-8]^a[u-14]^a[u-16];a[u]=c<<1|c>>>31}var d=(r<<5|r>>>27)+l+a[u];u<20?d+=(i&o|~i&s)+0x5a827999:u<40?d+=(i^o^s)+0x6ed9eba1:u<60?d+=(i&o|i&s|o&s)-0x70e44324:d+=(i^o^s)-0x359d3e2a,l=s,s=o,o=i<<30|i>>>2,i=r,r=d}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+s|0,n[4]=n[4]+l|0},_doFinalize:function(){var e=this._data,t=e.words,n=8*this._nDataBytes,r=8*e.sigBytes;return t[r>>>5]|=128<<24-r%32,t[(r+64>>>9<<4)+14]=Math.floor(n/0x100000000),t[(r+64>>>9<<4)+15]=n,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA1=i._createHelper(s),t.HmacSHA1=i._createHmacHelper(s)}(),e.SHA1})},331:function(e,t,n){!function(r,i){e.exports=t=i(n(95))}(0,function(e){return!function(t){var n=e,r=n.lib,i=r.WordArray,o=r.Hasher,a=n.algo,s=[],l=[];!function(){function e(e){for(var n=t.sqrt(e),r=2;r<=n;r++)if(!(e%r))return!1;return!0}function n(e){return(e-(0|e))*0x100000000|0}for(var r=2,i=0;i<64;)e(r)&&(i<8&&(s[i]=n(t.pow(r,.5))),l[i]=n(t.pow(r,1/3)),i++),r++}();var u=[],c=a.SHA256=o.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var n=this._hash.words,r=n[0],i=n[1],o=n[2],a=n[3],s=n[4],c=n[5],d=n[6],f=n[7],h=0;h<64;h++){if(h<16)u[h]=0|e[t+h];else{var p=u[h-15],m=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,g=u[h-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[h]=m+u[h-7]+v+u[h-16]}var y=s&c^~s&d,b=r&i^r&o^i&o,w=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),_=f+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+y+l[h]+u[h],x=w+b;f=d,d=c,c=s,s=a+_|0,a=o,o=i,i=r,r=_+x|0}n[0]=n[0]+r|0,n[1]=n[1]+i|0,n[2]=n[2]+o|0,n[3]=n[3]+a|0,n[4]=n[4]+s|0,n[5]=n[5]+c|0,n[6]=n[6]+d|0,n[7]=n[7]+f|0},_doFinalize:function(){var e=this._data,n=e.words,r=8*this._nDataBytes,i=8*e.sigBytes;return n[i>>>5]|=128<<24-i%32,n[(i+64>>>9<<4)+14]=t.floor(r/0x100000000),n[(i+64>>>9<<4)+15]=r,e.sigBytes=4*n.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});n.SHA256=o._createHelper(c),n.HmacSHA256=o._createHmacHelper(c)}(Math),e.SHA256})},643:function(e,t,n){e.exports=n(447)},447:function(e,t,n){var r=t;function i(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=n(114),r.BufferWriter=n(491),r.Reader=n(762),r.BufferReader=n(171),r.util=n(837),r.rpc=n(366),r.roots=n(264),r.configure=i,i()},762:function(e,t,n){e.exports=l;var r,i=n(837),o=i.LongBits,a=i.utf8;function s(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function l(e){this.buf=e,this.pos=0,this.len=e.length}var u="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new l(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new l(e);throw Error("illegal buffer")},c=function(){return i.Buffer?function(e){return(l.create=function(e){return i.Buffer.isBuffer(e)?new r(e):u(e)})(e)}:u};function d(){var e=new o(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw s(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw s(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function f(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function h(){if(this.pos+8>this.len)throw s(this,8);return new o(f(this.buf,this.pos+=4),f(this.buf,this.pos+=4))}l.create=c(),l.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,l.prototype.uint32=function(){var e=0xffffffff;return function(){if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,s(this,10);return e}}(),l.prototype.int32=function(){return 0|this.uint32()},l.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},l.prototype.bool=function(){return 0!==this.uint32()},l.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return f(this.buf,this.pos+=4)},l.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return 0|f(this.buf,this.pos+=4)},l.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},l.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},l.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw s(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(t,n);if(t===n){var r=i.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,n)},l.prototype.string=function(){var e=this.bytes();return a.read(e,0,e.length)},l.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw s(this,e);this.pos+=e}else do if(this.pos>=this.len)throw s(this);while(128&this.buf[this.pos++]);return this},l.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},l._configure=function(e){r=e,l.create=c(),r._configure();var t=i.Long?"toLong":"toNumber";i.merge(l.prototype,{int64:function(){return d.call(this)[t](!1)},uint64:function(){return d.call(this)[t](!0)},sint64:function(){return d.call(this).zzDecode()[t](!1)},fixed64:function(){return h.call(this)[t](!0)},sfixed64:function(){return h.call(this)[t](!1)}})}},171:function(e,t,n){e.exports=o;var r=n(762);(o.prototype=Object.create(r.prototype)).constructor=o;var i=n(837);function o(e){r.call(this,e)}o._configure=function(){i.Buffer&&(o.prototype._slice=i.Buffer.prototype.slice)},o.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},o._configure()},264:function(e){e.exports={}},366:function(e,t,n){t.Service=n(286)},286:function(e,t,n){e.exports=i;var r=n(837);function i(e,t,n){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!n}(i.prototype=Object.create(r.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,n,i,o,a){if(!o)throw TypeError("request must be specified");var s=this;if(!a)return r.asPromise(e,s,t,n,i,o);if(!s.rpcImpl)return void setTimeout(function(){a(Error("already ended"))},0);try{return s.rpcImpl(t,n[s.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(e,n){if(e)return s.emit("error",e,t),a(e);if(null===n)return void s.end(!0);if(!(n instanceof i))try{n=i[s.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return s.emit("error",e,t),a(e)}return s.emit("data",n,t),a(null,n)})}catch(e){s.emit("error",e,t),setTimeout(function(){a(e)},0);return}},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},926:function(e,t,n){e.exports=i;var r=n(837);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var o=i.zero=new i(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var a=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return o;var t=e<0;t&&(e=-e);var n=e>>>0,r=(e-n)/0x100000000>>>0;return t&&(r=~r>>>0,n=~n>>>0,++n>0xffffffff&&(n=0,++r>0xffffffff&&(r=0))),new i(n,r)},i.from=function(e){if("number"==typeof e)return i.fromNumber(e);if(r.isString(e))if(!r.Long)return i.fromNumber(parseInt(e,10));else e=r.Long.fromString(e);return e.low||e.high?new i(e.low>>>0,e.high>>>0):o},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=~this.lo+1>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+0x100000000*n)}return this.lo+0x100000000*this.hi},i.prototype.toLong=function(e){return r.Long?new r.Long(0|this.lo,0|this.hi,!!e):{low:0|this.lo,high:0|this.hi,unsigned:!!e}};var s=String.prototype.charCodeAt;i.fromHash=function(e){return e===a?o:new i((s.call(e,0)|s.call(e,1)<<8|s.call(e,2)<<16|s.call(e,3)<<24)>>>0,(s.call(e,4)|s.call(e,5)<<8|s.call(e,6)<<16|s.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}},837:function(e,t,n){var r=t;function i(e,t,n){for(var r=Object.keys(t),i=0;i<r.length;++i)void 0!==e[r[i]]&&n||(e[r[i]]=t[r[i]]);return e}function o(e){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:Error().stack||""}),n&&i(this,n)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}r.asPromise=n(188),r.base64=n(4),r.EventEmitter=n(730),r.float=n(791),r.inquire=n(706),r.utf8=n(322),r.pool=n(338),r.LongBits=n(926),r.isNode=!!(void 0!==n.g&&n.g&&n.g.process&&n.g.process.versions&&n.g.process.versions.node),r.global=r.isNode&&n.g||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||this,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},r.isString=function(e){return"string"==typeof e||e instanceof String},r.isObject=function(e){return e&&"object"==typeof e},r.isset=r.isSet=function(e,t){var n=e[t];return!!(null!=n&&e.hasOwnProperty(t))&&("object"!=typeof n||(Array.isArray(n)?n.length:Object.keys(n).length)>0)},r.Buffer=function(){try{var e=r.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(e){return"number"==typeof e?r.Buffer?r._Buffer_allocUnsafe(e):new r.Array(e):r.Buffer?r._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},r.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(e){return e?r.LongBits.from(e).toHash():r.LongBits.zeroHash},r.longFromHash=function(e,t){var n=r.LongBits.fromHash(e);return r.Long?r.Long.fromBits(n.lo,n.hi,t):n.toNumber(!!t)},r.merge=i,r.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},r.newError=o,r.ProtocolError=o("ProtocolError"),r.oneOfGetter=function(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=1;return function(){for(var e=Object.keys(this),n=e.length-1;n>-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},r.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var e=r.Buffer;if(!e){r._Buffer_from=r._Buffer_allocUnsafe=null;return}r._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,n){return new e(t,n)},r._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}}},114:function(e,t,n){e.exports=d;var r,i=n(837),o=i.LongBits,a=i.base64,s=i.utf8;function l(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function u(){}function c(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function d(){this.len=0,this.head=new l(u,0,0),this.tail=this.head,this.states=null}var f=function(){return i.Buffer?function(){return(d.create=function(){return new r})()}:function(){return new d}};function h(e,t,n){t[n]=255&e}function p(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e}function m(e,t){this.len=e,this.next=void 0,this.val=t}function g(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function v(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}d.create=f(),d.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(d.alloc=i.pool(d.alloc,i.Array.prototype.subarray)),d.prototype._push=function(e,t,n){return this.tail=this.tail.next=new l(e,t,n),this.len+=t,this},m.prototype=Object.create(l.prototype),m.prototype.fn=p,d.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new m((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<0x10000000?4:5,e)).len,this},d.prototype.int32=function(e){return e<0?this._push(g,10,o.fromNumber(e)):this.uint32(e)},d.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},d.prototype.uint64=function(e){var t=o.from(e);return this._push(g,t.length(),t)},d.prototype.int64=d.prototype.uint64,d.prototype.sint64=function(e){var t=o.from(e).zzEncode();return this._push(g,t.length(),t)},d.prototype.bool=function(e){return this._push(h,1,+!!e)},d.prototype.fixed32=function(e){return this._push(v,4,e>>>0)},d.prototype.sfixed32=d.prototype.fixed32,d.prototype.fixed64=function(e){var t=o.from(e);return this._push(v,4,t.lo)._push(v,4,t.hi)},d.prototype.sfixed64=d.prototype.fixed64,d.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},d.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var y=i.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var r=0;r<e.length;++r)t[n+r]=e[r]};d.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(h,1,0);if(i.isString(e)){var n=d.alloc(t=a.length(e));a.decode(e,n,0),e=n}return this.uint32(t)._push(y,t,e)},d.prototype.string=function(e){var t=s.length(e);return t?this.uint32(t)._push(s.write,t,e):this._push(h,1,0)},d.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new l(u,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new l(u,0,0),this.len=0),this},d.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},d.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},d._configure=function(e){r=e,d.create=f(),r._configure()}},491:function(e,t,n){e.exports=o;var r=n(114);(o.prototype=Object.create(r.prototype)).constructor=o;var i=n(837);function o(){r.call(this)}function a(e,t,n){e.length<40?i.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}o._configure=function(){o.alloc=i._Buffer_allocUnsafe,o.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var r=0;r<e.length;)t[n++]=e[r++]}},o.prototype.bytes=function(e){i.isString(e)&&(e=i._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(o.writeBytesBuffer,t,e),this},o.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(a,t,e),this},o._configure()},682:function(e,t){var n,r=Object.prototype.hasOwnProperty;function i(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o(e){try{return encodeURIComponent(e)}catch(e){return null}}function a(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,r={};t=n.exec(e);){var o=i(t[1]),a=i(t[2]);null===o||null===a||o in r||(r[o]=a)}return r}t.stringify=function(e,t){var i,a,s=[];for(a in"string"!=typeof(t=t||"")&&(t="?"),e)if(r.call(e,a)){if(!(i=e[a])&&(null===i||i===n||isNaN(i))&&(i=""),a=o(a),i=o(i),null===a||null===i)continue;s.push(a+"="+i)}return s.length?t+s.join("&"):""},t.parse=a},995:function(e){e.exports=function(e,t){if(t=t.split(":")[0],!(e*=1))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},337:function(e,t,n){var r=n(995),i=n(682),o=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,a=/[\n\r\t]/g,s=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,l=/:\d+$/,u=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,c=/^[a-zA-Z]:/;function d(e){return(e||"").toString().replace(o,"")}var f=[["#","hash"],["?","query"],function(e,t){return m(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],h={hash:1,query:1};function p(e){var t,r,i=(t="undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{}).location||{},o={},a=typeof(e=e||i);if("blob:"===e.protocol)o=new y(unescape(e.pathname),{});else if("string"===a)for(r in o=new y(e,{}),h)delete o[r];else if("object"===a){for(r in e)r in h||(o[r]=e[r]);void 0===o.slashes&&(o.slashes=s.test(e.href))}return o}function m(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function g(e,t){e=(e=d(e)).replace(a,""),t=t||{};var n,r=u.exec(e),i=r[1]?r[1].toLowerCase():"",o=!!r[2],s=!!r[3],l=0;return o?s?(n=r[2]+r[3]+r[4],l=r[2].length+r[3].length):(n=r[2]+r[4],l=r[2].length):s?(n=r[3]+r[4],l=r[3].length):n=r[4],"file:"===i?l>=2&&(n=n.slice(2)):m(i)?n=r[4]:i?o&&(n=n.slice(2)):l>=2&&m(t.protocol)&&(n=r[4]),{protocol:i,slashes:o||m(i),slashesCount:l,rest:n}}function v(e,t){if(""===e)return t;for(var n=(t||"/").split("/").slice(0,-1).concat(e.split("/")),r=n.length,i=n[r-1],o=!1,a=0;r--;)"."===n[r]?n.splice(r,1):".."===n[r]?(n.splice(r,1),a++):a&&(0===r&&(o=!0),n.splice(r,1),a--);return o&&n.unshift(""),("."===i||".."===i)&&n.push(""),n.join("/")}function y(e,t,n){if(e=(e=d(e)).replace(a,""),!(this instanceof y))return new y(e,t,n);var o,s,l,u,h,b,w=f.slice(),_=typeof t,x=this,k=0;for("object"!==_&&"string"!==_&&(n=t,t=null),n&&"function"!=typeof n&&(n=i.parse),o=!(s=g(e||"",t=p(t))).protocol&&!s.slashes,x.slashes=s.slashes||o&&t.slashes,x.protocol=s.protocol||t.protocol||"",e=s.rest,("file:"===s.protocol&&(2!==s.slashesCount||c.test(e))||!s.slashes&&(s.protocol||s.slashesCount<2||!m(x.protocol)))&&(w[3]=[/(.*)/,"pathname"]);k<w.length;k++){if("function"==typeof(u=w[k])){e=u(e,x);continue}l=u[0],b=u[1],l!=l?x[b]=e:"string"==typeof l?~(h="@"===l?e.lastIndexOf(l):e.indexOf(l))&&("number"==typeof u[2]?(x[b]=e.slice(0,h),e=e.slice(h+u[2])):(x[b]=e.slice(h),e=e.slice(0,h))):(h=l.exec(e))&&(x[b]=h[1],e=e.slice(0,h.index)),x[b]=x[b]||o&&u[3]&&t[b]||"",u[4]&&(x[b]=x[b].toLowerCase())}n&&(x.query=n(x.query)),o&&t.slashes&&"/"!==x.pathname.charAt(0)&&(""!==x.pathname||""!==t.pathname)&&(x.pathname=v(x.pathname,t.pathname)),"/"!==x.pathname.charAt(0)&&m(x.protocol)&&(x.pathname="/"+x.pathname),r(x.port,x.protocol)||(x.host=x.hostname,x.port=""),x.username=x.password="",x.auth&&(~(h=x.auth.indexOf(":"))?(x.username=x.auth.slice(0,h),x.username=encodeURIComponent(decodeURIComponent(x.username)),x.password=x.auth.slice(h+1),x.password=encodeURIComponent(decodeURIComponent(x.password))):x.username=encodeURIComponent(decodeURIComponent(x.auth)),x.auth=x.password?x.username+":"+x.password:x.username),x.origin="file:"!==x.protocol&&m(x.protocol)&&x.host?x.protocol+"//"+x.host:"null",x.href=x.toString()}y.prototype={set:function(e,t,n){var o=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(n||i.parse)(t)),o[e]=t;break;case"port":o[e]=t,r(t,o.protocol)?t&&(o.host=o.hostname+":"+t):(o.host=o.hostname,o[e]="");break;case"hostname":o[e]=t,o.port&&(t+=":"+o.port),o.host=t;break;case"host":o[e]=t,l.test(t)?(o.port=(t=t.split(":")).pop(),o.hostname=t.join(":")):(o.hostname=t,o.port="");break;case"protocol":o.protocol=t.toLowerCase(),o.slashes=!n;break;case"pathname":case"hash":if(t){var a="pathname"===e?"/":"#";o[e]=t.charAt(0)!==a?a+t:t}else o[e]=t;break;case"username":case"password":o[e]=encodeURIComponent(t);break;case"auth":var s=t.indexOf(":");~s?(o.username=t.slice(0,s),o.username=encodeURIComponent(decodeURIComponent(o.username)),o.password=t.slice(s+1),o.password=encodeURIComponent(decodeURIComponent(o.password))):o.username=encodeURIComponent(decodeURIComponent(t))}for(var u=0;u<f.length;u++){var c=f[u];c[4]&&(o[c[1]]=o[c[1]].toLowerCase())}return o.auth=o.password?o.username+":"+o.password:o.username,o.origin="file:"!==o.protocol&&m(o.protocol)&&o.host?o.protocol+"//"+o.host:"null",o.href=o.toString(),o},toString:function(e){e&&"function"==typeof e||(e=i.stringify);var t,n=this,r=n.host,o=n.protocol;o&&":"!==o.charAt(o.length-1)&&(o+=":");var a=o+(n.protocol&&n.slashes||m(n.protocol)?"//":"");return n.username?(a+=n.username,n.password&&(a+=":"+n.password),a+="@"):n.password?(a+=":"+n.password,a+="@"):"file:"!==n.protocol&&m(n.protocol)&&!r&&"/"!==n.pathname&&(a+="@"),(":"===r[r.length-1]||l.test(n.hostname)&&!n.port)&&(r+=":"),a+=r+n.pathname,(t="object"==typeof n.query?e(n.query):n.query)&&(a+="?"!==t.charAt(0)?"?"+t:t),n.hash&&(a+=n.hash),a}},y.extractProtocol=g,y.location=p,y.trimLeft=d,y.qs=i,e.exports=y},602:function(){}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.loaded=!0,n.exports}(()=>{__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t}})(),(()=>{__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}})(),(()=>{__webpack_require__.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})()})(),(()=>{__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e)})();var url_parse=__webpack_require__(337),url_parse_default=__webpack_require__.n(url_parse);function omit(e,t){let n={...e};for(let e=0;e<t.length;e++){let r=t[e];delete n[r]}return n}function isUnsafeProperty(e){return"__proto__"===e}function isPlainObject(e){if(!e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function merge(e,t){let n=Object.keys(t);for(let r=0;r<n.length;r++){let i=n[r];if(isUnsafeProperty(i))continue;let o=t[i],a=e[i];Array.isArray(o)?Array.isArray(a)?e[i]=merge(a,o):e[i]=merge([],o):isPlainObject(o)?isPlainObject(a)?e[i]=merge(a,o):e[i]=merge({},o):(void 0===a||void 0!==o)&&(e[i]=o)}return e}var enc_base64=__webpack_require__(716),enc_base64_default=__webpack_require__.n(enc_base64);function safeJsonParse(e){try{if(!e)return null;return JSON.parse(e)}catch(e){return null}}function safeJsonParseWithZod(e,t){let n=safeJsonParse(e);if(!n)return null;let{success:r,data:i,error:o}=t.safeParse(n);return r?i:(console.warn(`Failed to parse JSON with Zod: ${e}`,o),null)}function base64ToUint8Array(e){let t=enc_base64_default().parse(e),n=new Uint8Array(t.sigBytes);for(let e=0;e<t.sigBytes;e++){let r=e>>>2,i=e%4;n[e]=t.words[r]>>>24-8*i&255}return n}function generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}const sleep=e=>new Promise(t=>setTimeout(t,e));function $constructor(e,t,n){function r(n,r){var i;for(let o in Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),a.prototype)o in n||Object.defineProperty(n,o,{value:a.prototype[o].bind(n)});n._zod.constr=a,n._zod.def=r}let i=n?.Parent??Object;class o extends i{}function a(e){var t;let i=n?.Parent?new o:this;for(let n of(r(i,e),(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred))n();return i}return Object.defineProperty(o,"name",{value:e}),Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!n?.Parent&&t instanceof n.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}Object.freeze({status:"aborted"}),Symbol("zod_brand");class $ZodAsyncError extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const globalConfig={};function core_config(e){return e&&Object.assign(globalConfig,e),globalConfig}function getEnumValues(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function joinValues(e,t="|"){return e.map(e=>stringifyPrimitive(e)).join(t)}function jsonStringifyReplacer(e,t){return"bigint"==typeof t?t.toString():t}function util_cached(e){let t=!1;return{get value(){if(!t){let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error("cached value already set")}}}function nullish(e){return null==e}function cleanRegex(e){let t=+!!e.startsWith("^"),n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function floatSafeRemainder(e,t){let n=(e.toString().split(".")[1]||"").length,r=t.toString(),i=(r.split(".")[1]||"").length;if(0===i&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let o=n>i?n:i;return Number.parseInt(e.toFixed(o).replace(".",""))%Number.parseInt(t.toFixed(o).replace(".",""))/10**o}const EVALUATING=Symbol("evaluating");function defineLazy(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==EVALUATING)return void 0===r&&(r=EVALUATING,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function objectClone(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function assignProp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function mergeDefs(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}function esc(e){return JSON.stringify(e)}const captureStackTrace="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function util_isObject(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const util_allowsEval=util_cached(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function util_isPlainObject(e){if(!1===util_isObject(e))return!1;let t=e.constructor;if(void 0===t)return!0;let n=t.prototype;return!1!==util_isObject(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function shallowClone(e){return util_isPlainObject(e)?{...e}:e}const propertyKeyTypes=new Set(["string","number","symbol"]),primitiveTypes=new Set(["string","number","bigint","boolean","symbol","undefined"]);function escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function clone(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function normalizeParams(e){let t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return(delete t.message,"string"==typeof t.error)?{...t,error:()=>t.error}:t}function stringifyPrimitive(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}function optionalKeys(e){return Object.keys(e).filter(t=>"optional"===e[t]._zod.optin&&"optional"===e[t]._zod.optout)}const NUMBER_FORMAT_RANGES={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},BIGINT_FORMAT_RANGES={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function pick(e,t){let n=e._zod.def,r=mergeDefs(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return assignProp(this,"shape",e),e},checks:[]});return clone(e,r)}function util_omit(e,t){let n=e._zod.def,r=mergeDefs(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return assignProp(this,"shape",r),r},checks:[]});return clone(e,r)}function extend(e,t){if(!util_isPlainObject(t))throw Error("Invalid input to extend: expected a plain object");let n=mergeDefs(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return assignProp(this,"shape",n),n},checks:[]});return clone(e,n)}function util_merge(e,t){let n=mergeDefs(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return assignProp(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return clone(e,n)}function partial(e,t,n){let r=mergeDefs(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return assignProp(this,"shape",i),i},checks:[]});return clone(t,r)}function required(e,t,n){let r=mergeDefs(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:"nonoptional",innerType:r[t]}))}else for(let t in r)i[t]=new e({type:"nonoptional",innerType:r[t]});return assignProp(this,"shape",i),i},checks:[]});return clone(t,r)}function aborted(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function prefixIssues(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function unwrapMessage(e){return"string"==typeof e?e:e?.message}function finalizeIssue(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=unwrapMessage(e.inst?._zod.def?.error?.(e))??unwrapMessage(t?.error?.(e))??unwrapMessage(n.customError?.(e))??unwrapMessage(n.localeError?.(e))??"Invalid input"),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function getSizableOrigin(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function getLengthableOrigin(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function util_issue(...e){let[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const errors_initializer=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,jsonStringifyReplacer,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$ZodError=$constructor("$ZodError",errors_initializer),$ZodRealError=$constructor("$ZodError",errors_initializer,{Parent:Error});function flattenError(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function formatError(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>i({issues:e}));else if("invalid_key"===t.code)i({issues:t.issues});else if("invalid_element"===t.code)i({issues:t.issues});else if(0===t.path.length)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}function toDotPath(e){let t=[];for(let n of e.map(e=>"object"==typeof e?e.key:e))"number"==typeof n?t.push(`[${n}]`):"symbol"==typeof n?t.push(`[${JSON.stringify(String(n))}]`):/[^\w$]/.test(n)?t.push(`[${JSON.stringify(n)}]`):(t.length&&t.push("."),t.push(n));return t.join("")}function prettifyError(e){let t=[];for(let n of[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length))t.push(`✖ ${n.message}`),n.path?.length&&t.push(` → at ${toDotPath(n.path)}`);return t.join("\n")}const _parse=e=>(t,n,r,i)=>{let o=r?Object.assign(r,{async:!1}):{async:!1},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise)throw new $ZodAsyncError;if(a.issues.length){let t=new(i?.Err??e)(a.issues.map(e=>finalizeIssue(e,o,core_config())));throw captureStackTrace(t,i?.callee),t}return a.value},_parseAsync=e=>async(t,n,r,i)=>{let o=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let t=new(i?.Err??e)(a.issues.map(e=>finalizeIssue(e,o,core_config())));throw captureStackTrace(t,i?.callee),t}return a.value},_safeParse=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new $ZodAsyncError;return o.issues.length?{success:!1,error:new(e??$ZodError)(o.issues.map(e=>finalizeIssue(e,i,core_config())))}:{success:!0,data:o.value}},safeParse=_safeParse($ZodRealError),_safeParseAsync=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>finalizeIssue(e,i,core_config())))}:{success:!0,data:o.value}},safeParseAsync=_safeParseAsync($ZodRealError),cuid=/^[cC][^\s-]{8,}$/,cuid2=/^[0-9a-z]+$/,ulid=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xid=/^[0-9a-vA-V]{20}$/,ksuid=/^[A-Za-z0-9]{27}$/,nanoid=/^[a-zA-Z0-9_-]{21}$/,regexes_duration=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,guid=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uuid=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,email=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_emoji="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function emoji(){return RegExp(_emoji,"u")}const ipv4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,cidrv4=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cidrv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,regexes_base64=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url=/^[A-Za-z0-9_-]*$/,hostname=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,e164=/^\+(?:[0-9]){6,14}[0-9]$/,dateSource="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",regexes_date=RegExp(`^${dateSource}$`);function timeSource(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function regexes_time(e){return RegExp(`^${timeSource(e)}$`)}function datetime(e){let t=timeSource({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${t}(?:${n.join("|")})`;return RegExp(`^${dateSource}T(?:${r})$`)}const regexes_string=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return RegExp(`^${t}$`)},bigint=/^\d+n?$/,integer=/^\d+$/,regexes_number=/^-?\d+(?:\.\d+)?/i,regexes_boolean=/true|false/i,_null=/null/i,_undefined=/undefined/i,lowercase=/^[^A-Z]*$/,uppercase=/^[^a-z]*$/,$ZodCheck=$constructor("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),numericOriginMap={number:"number",bigint:"bigint",object:"date"},$ZodCheckLessThan=$constructor("$ZodCheckLessThan",(e,t)=>{$ZodCheck.init(e,t);let n=numericOriginMap[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckGreaterThan=$constructor("$ZodCheckGreaterThan",(e,t)=>{$ZodCheck.init(e,t);let n=numericOriginMap[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckMultipleOf=$constructor("$ZodCheckMultipleOf",(e,t)=>{$ZodCheck.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===floatSafeRemainder(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckNumberFormat=$constructor("$ZodCheckNumberFormat",(e,t)=>{$ZodCheck.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[i,o]=NUMBER_FORMAT_RANGES[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=o,n&&(r.pattern=integer)}),e._zod.check=a=>{let s=a.value;if(n){if(!Number.isInteger(s))return void a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}))}s<i&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inst:e})}}),$ZodCheckBigIntFormat=$constructor("$ZodCheckBigIntFormat",(e,t)=>{$ZodCheck.init(e,t);let[n,r]=BIGINT_FORMAT_RANGES[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=n,i.maximum=r}),e._zod.check=i=>{let o=i.value;o<n&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),o>r&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:r,inst:e})}}),$ZodCheckMaxSize=$constructor("$ZodCheckMaxSize",(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;r.size<=t.maximum||n.issues.push({origin:getSizableOrigin(r),code:"too_big",maximum:t.maximum,input:r,inst:e,continue:!t.abort})}}),$ZodCheckMinSize=$constructor("$ZodCheckMinSize",(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;r.size>=t.minimum||n.issues.push({origin:getSizableOrigin(r),code:"too_small",minimum:t.minimum,input:r,inst:e,continue:!t.abort})}}),$ZodCheckSizeEquals=$constructor("$ZodCheckSizeEquals",(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=n=>{let r=n.value,i=r.size;if(i===t.size)return;let o=i>t.size;n.issues.push({origin:getSizableOrigin(r),...o?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckMaxLength=$constructor("$ZodCheckMaxLength",(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=getLengthableOrigin(r);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckMinLength=$constructor("$ZodCheckMinLength",(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=getLengthableOrigin(r);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckLengthEquals=$constructor("$ZodCheckLengthEquals",(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let o=getLengthableOrigin(r),a=i>t.length;n.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckStringFormat=$constructor("$ZodCheckStringFormat",(e,t)=>{var n,r;$ZodCheck.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),$ZodCheckRegex=$constructor("$ZodCheckRegex",(e,t)=>{$ZodCheckStringFormat.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),$ZodCheckLowerCase=$constructor("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lowercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckUpperCase=$constructor("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=uppercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckIncludes=$constructor("$ZodCheckIncludes",(e,t)=>{$ZodCheck.init(e,t);let n=escapeRegex(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckStartsWith=$constructor("$ZodCheckStartsWith",(e,t)=>{$ZodCheck.init(e,t);let n=RegExp(`^${escapeRegex(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckEndsWith=$constructor("$ZodCheckEndsWith",(e,t)=>{$ZodCheck.init(e,t);let n=RegExp(`.*${escapeRegex(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckMimeType=$constructor("$ZodCheckMimeType",(e,t)=>{$ZodCheck.init(e,t);let n=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),$ZodCheckOverwrite=$constructor("$ZodCheckOverwrite",(e,t)=>{$ZodCheck.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Doc{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){return Function(...this?.args,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const versions_version={major:4,minor:0,patch:17},$ZodType=$constructor("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=versions_version;let r=[...e._zod.def.checks??[]];for(let t of(e._zod.traits.has("$ZodCheck")&&r.unshift(e),r))for(let n of t._zod.onattach)n(e);if(0===r.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r,i=aborted(e);for(let o of t){if(o._zod.def.when){if(!o._zod.def.when(e))continue}else if(i)continue;let t=e.issues.length,a=o._zod.check(e);if(a instanceof Promise&&n?.async===!1)throw new $ZodAsyncError;if(r||a instanceof Promise)r=(r??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(i||(i=aborted(e,t)))});else{if(e.issues.length===t)continue;i||(i=aborted(e,t))}}return r?r.then(()=>e):e};e._zod.run=(n,i)=>{let o=e._zod.parse(n,i);if(o instanceof Promise){if(!1===i.async)throw new $ZodAsyncError;return o.then(e=>t(e,r,i))}return t(o,r,i)}}e["~standard"]={validate:t=>{try{let n=safeParse(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return safeParseAsync(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),$ZodString=$constructor("$ZodString",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??regexes_string(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(e){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),$ZodStringFormat=$constructor("$ZodStringFormat",(e,t)=>{$ZodCheckStringFormat.init(e,t),$ZodString.init(e,t)}),$ZodGUID=$constructor("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=guid),$ZodStringFormat.init(e,t)}),$ZodUUID=$constructor("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uuid(e))}else t.pattern??(t.pattern=uuid());$ZodStringFormat.init(e,t)}),$ZodEmail=$constructor("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=email),$ZodStringFormat.init(e,t)}),$ZodURL=$constructor("$ZodURL",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),$ZodEmoji=$constructor("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=emoji()),$ZodStringFormat.init(e,t)}),$ZodNanoID=$constructor("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nanoid),$ZodStringFormat.init(e,t)}),$ZodCUID=$constructor("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cuid),$ZodStringFormat.init(e,t)}),$ZodCUID2=$constructor("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cuid2),$ZodStringFormat.init(e,t)}),$ZodULID=$constructor("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ulid),$ZodStringFormat.init(e,t)}),$ZodXID=$constructor("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xid),$ZodStringFormat.init(e,t)}),$ZodKSUID=$constructor("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ksuid),$ZodStringFormat.init(e,t)}),$ZodISODateTime=$constructor("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=datetime(t)),$ZodStringFormat.init(e,t)}),$ZodISODate=$constructor("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=regexes_date),$ZodStringFormat.init(e,t)}),$ZodISOTime=$constructor("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=regexes_time(t)),$ZodStringFormat.init(e,t)}),$ZodISODuration=$constructor("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=regexes_duration),$ZodStringFormat.init(e,t)}),$ZodIPv4=$constructor("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ipv4),$ZodStringFormat.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv4"})}),$ZodIPv6=$constructor("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ipv6),$ZodStringFormat.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv6"}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),$ZodCIDRv4=$constructor("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cidrv4),$ZodStringFormat.init(e,t)}),$ZodCIDRv6=$constructor("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cidrv6),$ZodStringFormat.init(e,t),e._zod.check=n=>{let[r,i]=n.value.split("/");try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function isValidBase64(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const $ZodBase64=$constructor("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=regexes_base64),$ZodStringFormat.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64"}),e._zod.check=n=>{isValidBase64(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function isValidBase64URL(e){if(!base64url.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return isValidBase64(t.padEnd(4*Math.ceil(t.length/4),"="))}const $ZodBase64URL=$constructor("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=base64url),$ZodStringFormat.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64url"}),e._zod.check=n=>{isValidBase64URL(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),$ZodE164=$constructor("$ZodE164",(e,t)=>{t.pattern??(t.pattern=e164),$ZodStringFormat.init(e,t)});function isValidJWT(e,t=null){try{let n=e.split(".");if(3!==n.length)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));if("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))return!1;return!0}catch{return!1}}const $ZodJWT=$constructor("$ZodJWT",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=n=>{isValidJWT(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),$ZodCustomStringFormat=$constructor("$ZodCustomStringFormat",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),$ZodNumber=$constructor("$ZodNumber",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=e._zod.bag.pattern??regexes_number,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}let i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;let o="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),$ZodNumberFormat=$constructor("$ZodNumber",(e,t)=>{$ZodCheckNumberFormat.init(e,t),$ZodNumber.init(e,t)}),$ZodBoolean=$constructor("$ZodBoolean",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=regexes_boolean,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch(e){}let i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),$ZodBigInt=$constructor("$ZodBigInt",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=bigint,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch(e){}return"bigint"==typeof n.value||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),$ZodBigIntFormat=$constructor("$ZodBigInt",(e,t)=>{$ZodCheckBigIntFormat.init(e,t),$ZodBigInt.init(e,t)}),$ZodSymbol=$constructor("$ZodSymbol",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return"symbol"==typeof r||t.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),t}}),$ZodUndefined=$constructor("$ZodUndefined",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=_undefined,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(t,n)=>{let r=t.value;return void 0===r||t.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),t}}),$ZodNull=$constructor("$ZodNull",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=_null,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return null===r||t.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),t}}),$ZodAny=$constructor("$ZodAny",(e,t)=>{$ZodType.init(e,t),e._zod.parse=e=>e}),$ZodUnknown=$constructor("$ZodUnknown",(e,t)=>{$ZodType.init(e,t),e._zod.parse=e=>e}),$ZodNever=$constructor("$ZodNever",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),$ZodVoid=$constructor("$ZodVoid",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return void 0===r||t.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),t}}),$ZodDate=$constructor("$ZodDate",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch(e){}let i=n.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),n}});function handleArrayResult(e,t,n){e.issues.length&&t.issues.push(...prefixIssues(n,e.issues)),t.value[n]=e.value}const $ZodArray=$constructor("$ZodArray",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);let o=[];for(let e=0;e<i.length;e++){let a=i[e],s=t.element._zod.run({value:a,issues:[]},r);s instanceof Promise?o.push(s.then(t=>handleArrayResult(t,n,e))):handleArrayResult(s,n,e)}return o.length?Promise.all(o).then(()=>n):n}});function handlePropertyResult(e,t,n,r){e.issues.length&&t.issues.push(...prefixIssues(n,e.issues)),void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const $ZodObject=$constructor("$ZodObject",(e,t)=>{let n,r;$ZodType.init(e,t);let i=util_cached(()=>{let e=Object.keys(t.shape);for(let n of e)if(!t.shape[n]._zod.traits.has("$ZodType"))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=optionalKeys(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}});defineLazy(e._zod,"propValues",()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values)for(let e of(n[t]??(n[t]=new Set),r.values))n[t].add(e)}return n});let o=e=>{let t=new Doc(["shape","payload","ctx"]),n=i.value,r=e=>{let t=esc(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");let o=Object.create(null),a=0;for(let e of n.keys)o[e]=`key_${a++}`;for(let e of(t.write("const newResult = {}"),n.keys)){let n=o[e],i=esc(e);t.write(`const ${n} = ${r(e)};`),t.write(`
|
|
2
|
-
if (${
|
|
3
|
-
payload.issues = payload.issues.concat(${
|
|
1
|
+
let METADATA_SYMBOL;var compat_ZodFirstPartyTypeKind,__webpack_modules__={188:function(e){e.exports=t;function t(e,t){for(var r=Array(arguments.length-1),n=0,i=2,o=!0;i<arguments.length;)r[n++]=arguments[i++];return new Promise(function(i,a){r[n]=function(e){if(o)if(o=!1,e)a(e);else{for(var t=Array(arguments.length-1),r=0;r<t.length;)t[r++]=arguments[r];i.apply(null,t)}};try{e.apply(t||null,r)}catch(e){o&&(o=!1,a(e))}})}},4:function(e,t){var r=t;r.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=Array(64),i=Array(123),o=0;o<64;)i[n[o]=o<26?o+65:o<52?o+71:o<62?o-4:o-59|43]=o++;r.encode=function(e,t,r){for(var i,o=null,a=[],s=0,l=0;t<r;){var u=e[t++];switch(l){case 0:a[s++]=n[u>>2],i=(3&u)<<4,l=1;break;case 1:a[s++]=n[i|u>>4],i=(15&u)<<2,l=2;break;case 2:a[s++]=n[i|u>>6],a[s++]=n[63&u],l=0}s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,a)),s=0)}return(l&&(a[s++]=n[i],a[s++]=61,1===l&&(a[s++]=61)),o)?(s&&o.push(String.fromCharCode.apply(String,a.slice(0,s))),o.join("")):String.fromCharCode.apply(String,a.slice(0,s))};var a="invalid encoding";r.decode=function(e,t,r){for(var n,o=r,s=0,l=0;l<e.length;){var u=e.charCodeAt(l++);if(61===u&&s>1)break;if(void 0===(u=i[u]))throw Error(a);switch(s){case 0:n=u,s=1;break;case 1:t[r++]=n<<2|(48&u)>>4,n=u,s=2;break;case 2:t[r++]=(15&n)<<4|(60&u)>>2,n=u,s=3;break;case 3:t[r++]=(3&n)<<6|u,s=0}}if(1===s)throw Error(a);return r-o},r.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},730:function(e){function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;n<r.length;)r[n].fn===t?r.splice(n,1):++n;return this},t.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var r=[],n=1;n<arguments.length;)r.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,r)}return this}},791:function(e){function t(e){return"undefined"!=typeof Float32Array?!function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3]}function o(e,n,i){t[0]=e,n[i]=r[3],n[i+1]=r[2],n[i+2]=r[1],n[i+3]=r[0]}function a(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function s(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?i:o,e.writeFloatBE=n?o:i,e.readFloatLE=n?a:s,e.readFloatBE=n?s:a}():!function(){function t(e,t,r,n){var i=+(t<0);if(i&&(t=-t),0===t)e(1/t>0?0:0x80000000,r,n);else if(isNaN(t))e(0x7fc00000,r,n);else if(t>34028234663852886e22)e((i<<31|0x7f800000)>>>0,r,n);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var o=Math.floor(Math.log(t)/Math.LN2),a=8388607&Math.round(t*Math.pow(2,-o)*8388608);e((i<<31|o+127<<23|a)>>>0,r,n)}}function a(e,t,r){var n=e(t,r),i=(n>>31)*2+1,o=n>>>23&255,a=8388607&n;return 255===o?a?NaN:1/0*i:0===o?1401298464324817e-60*i*a:i*Math.pow(2,o-150)*(a+8388608)}e.writeFloatLE=t.bind(null,r),e.writeFloatBE=t.bind(null,n),e.readFloatLE=a.bind(null,i),e.readFloatBE=a.bind(null,o)}(),"undefined"!=typeof Float64Array?!function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3],n[i+4]=r[4],n[i+5]=r[5],n[i+6]=r[6],n[i+7]=r[7]}function o(e,n,i){t[0]=e,n[i]=r[7],n[i+1]=r[6],n[i+2]=r[5],n[i+3]=r[4],n[i+4]=r[3],n[i+5]=r[2],n[i+6]=r[1],n[i+7]=r[0]}function a(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function s(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?i:o,e.writeDoubleBE=n?o:i,e.readDoubleLE=n?a:s,e.readDoubleBE=n?s:a}():!function(){function t(e,t,r,n,i,o){var a,s=+(n<0);if(s&&(n=-n),0===n)e(0,i,o+t),e(1/n>0?0:0x80000000,i,o+r);else if(isNaN(n))e(0,i,o+t),e(0x7ff80000,i,o+r);else if(n>17976931348623157e292)e(0,i,o+t),e((s<<31|0x7ff00000)>>>0,i,o+r);else if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,i,o+t),e((s<<31|a/0x100000000)>>>0,i,o+r);else{var l=Math.floor(Math.log(n)/Math.LN2);1024===l&&(l=1023),e(0x10000000000000*(a=n*Math.pow(2,-l))>>>0,i,o+t),e((s<<31|l+1023<<20|1048576*a&1048575)>>>0,i,o+r)}}function a(e,t,r,n,i){var o=e(n,i+t),a=e(n,i+r),s=(a>>31)*2+1,l=a>>>20&2047,u=0x100000000*(1048575&a)+o;return 2047===l?u?NaN:1/0*s:0===l?5e-324*s*u:s*Math.pow(2,l-1075)*(u+0x10000000000000)}e.writeDoubleLE=t.bind(null,r,0,4),e.writeDoubleBE=t.bind(null,n,4,0),e.readDoubleLE=a.bind(null,i,0,4),e.readDoubleBE=a.bind(null,o,4,0)}(),e}function r(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function n(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function o(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},706:function(module){module.exports=inquire;function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}},338:function(e){e.exports=t;function t(e,t,r){var n=r||8192,i=n>>>1,o=null,a=n;return function(r){if(r<1||r>i)return e(r);a+r>n&&(o=e(n),a=0);var s=t.call(o,a,a+=r);return 7&a&&(a=(7|a)+1),s}}},322:function(e,t){var r=t;r.length=function(e){for(var t=0,r=0,n=0;n<e.length;++n)(r=e.charCodeAt(n))<128?t+=1:r<2048?t+=2:(64512&r)==55296&&(64512&e.charCodeAt(n+1))==56320?(++n,t+=4):t+=3;return t},r.read=function(e,t,r){if(r-t<1)return"";for(var n,i=null,o=[],a=0;t<r;)(n=e[t++])<128?o[a++]=n:n>191&&n<224?o[a++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[a++]=55296+(n>>10),o[a++]=56320+(1023&n)):o[a++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,o)),a=0);return i?(a&&i.push(String.fromCharCode.apply(String,o.slice(0,a))),i.join("")):String.fromCharCode.apply(String,o.slice(0,a))},r.write=function(e,t,r){for(var n,i,o=r,a=0;a<e.length;++a)(n=e.charCodeAt(a))<128?t[r++]=n:(n<2048?t[r++]=n>>6|192:((64512&n)==55296&&(64512&(i=e.charCodeAt(a+1)))==56320?(n=65536+((1023&n)<<10)+(1023&i),++a,t[r++]=n>>18|240,t[r++]=n>>12&63|128):t[r++]=n>>12|224,t[r++]=n>>6&63|128),t[r++]=63&n|128);return r-o}},327:function(e,t,r){e=r.nmd(e),function(t,n){"function"==typeof define&&define.amd?define(["protobufjs/minimal"],n):e&&e.exports&&(e.exports=n(r(643)))}(0,function(e){"use strict";var t=e.Reader,r=e.Writer,n=e.util,i=e.roots.default||(e.roots.default={});return i.biliproto=function(){var o={};return o.community=function(){var o={};return o.service=function(){var o={};return o.dm=function(){var o={};return o.v1=function(){var o={};return o.DanmakuElem=function(){function o(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return o.prototype.id=n.Long?n.Long.fromBits(0,0,!1):0,o.prototype.progress=0,o.prototype.mode=0,o.prototype.fontsize=0,o.prototype.color=0,o.prototype.midHash="",o.prototype.content="",o.prototype.ctime=n.Long?n.Long.fromBits(0,0,!1):0,o.prototype.weight=0,o.prototype.action="",o.prototype.pool=0,o.prototype.idStr="",o.prototype.attr=0,o.prototype.animation="",o.prototype.likeNum=0,o.prototype.colorV2="",o.prototype.dmTypeV2=0,o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=r.create()),null!=e.id&&Object.hasOwnProperty.call(e,"id")&&t.uint32(8).int64(e.id),null!=e.progress&&Object.hasOwnProperty.call(e,"progress")&&t.uint32(16).int32(e.progress),null!=e.mode&&Object.hasOwnProperty.call(e,"mode")&&t.uint32(24).int32(e.mode),null!=e.fontsize&&Object.hasOwnProperty.call(e,"fontsize")&&t.uint32(32).int32(e.fontsize),null!=e.color&&Object.hasOwnProperty.call(e,"color")&&t.uint32(40).uint32(e.color),null!=e.midHash&&Object.hasOwnProperty.call(e,"midHash")&&t.uint32(50).string(e.midHash),null!=e.content&&Object.hasOwnProperty.call(e,"content")&&t.uint32(58).string(e.content),null!=e.ctime&&Object.hasOwnProperty.call(e,"ctime")&&t.uint32(64).int64(e.ctime),null!=e.weight&&Object.hasOwnProperty.call(e,"weight")&&t.uint32(72).int32(e.weight),null!=e.action&&Object.hasOwnProperty.call(e,"action")&&t.uint32(82).string(e.action),null!=e.pool&&Object.hasOwnProperty.call(e,"pool")&&t.uint32(88).int32(e.pool),null!=e.idStr&&Object.hasOwnProperty.call(e,"idStr")&&t.uint32(98).string(e.idStr),null!=e.attr&&Object.hasOwnProperty.call(e,"attr")&&t.uint32(104).int32(e.attr),null!=e.animation&&Object.hasOwnProperty.call(e,"animation")&&t.uint32(114).string(e.animation),null!=e.likeNum&&Object.hasOwnProperty.call(e,"likeNum")&&t.uint32(120).uint32(e.likeNum),null!=e.colorV2&&Object.hasOwnProperty.call(e,"colorV2")&&t.uint32(130).string(e.colorV2),null!=e.dmTypeV2&&Object.hasOwnProperty.call(e,"dmTypeV2")&&t.uint32(136).uint32(e.dmTypeV2),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,r,n){e instanceof t||(e=t.create(e));for(var o=void 0===r?e.len:e.pos+r,a=new i.biliproto.community.service.dm.v1.DanmakuElem;e.pos<o;){var s=e.uint32();if(s===n)break;switch(s>>>3){case 1:a.id=e.int64();break;case 2:a.progress=e.int32();break;case 3:a.mode=e.int32();break;case 4:a.fontsize=e.int32();break;case 5:a.color=e.uint32();break;case 6:a.midHash=e.string();break;case 7:a.content=e.string();break;case 8:a.ctime=e.int64();break;case 9:a.weight=e.int32();break;case 10:a.action=e.string();break;case 11:a.pool=e.int32();break;case 12:a.idStr=e.string();break;case 13:a.attr=e.int32();break;case 14:a.animation=e.string();break;case 15:a.likeNum=e.uint32();break;case 16:a.colorV2=e.string();break;case 17:a.dmTypeV2=e.uint32();break;default:e.skipType(7&s)}}return a},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.id&&e.hasOwnProperty("id")&&!n.isInteger(e.id)&&!(e.id&&n.isInteger(e.id.low)&&n.isInteger(e.id.high))?"id: integer|Long expected":null!=e.progress&&e.hasOwnProperty("progress")&&!n.isInteger(e.progress)?"progress: integer expected":null!=e.mode&&e.hasOwnProperty("mode")&&!n.isInteger(e.mode)?"mode: integer expected":null!=e.fontsize&&e.hasOwnProperty("fontsize")&&!n.isInteger(e.fontsize)?"fontsize: integer expected":null!=e.color&&e.hasOwnProperty("color")&&!n.isInteger(e.color)?"color: integer expected":null!=e.midHash&&e.hasOwnProperty("midHash")&&!n.isString(e.midHash)?"midHash: string expected":null!=e.content&&e.hasOwnProperty("content")&&!n.isString(e.content)?"content: string expected":null!=e.ctime&&e.hasOwnProperty("ctime")&&!n.isInteger(e.ctime)&&!(e.ctime&&n.isInteger(e.ctime.low)&&n.isInteger(e.ctime.high))?"ctime: integer|Long expected":null!=e.weight&&e.hasOwnProperty("weight")&&!n.isInteger(e.weight)?"weight: integer expected":null!=e.action&&e.hasOwnProperty("action")&&!n.isString(e.action)?"action: string expected":null!=e.pool&&e.hasOwnProperty("pool")&&!n.isInteger(e.pool)?"pool: integer expected":null!=e.idStr&&e.hasOwnProperty("idStr")&&!n.isString(e.idStr)?"idStr: string expected":null!=e.attr&&e.hasOwnProperty("attr")&&!n.isInteger(e.attr)?"attr: integer expected":null!=e.animation&&e.hasOwnProperty("animation")&&!n.isString(e.animation)?"animation: string expected":null!=e.likeNum&&e.hasOwnProperty("likeNum")&&!n.isInteger(e.likeNum)?"likeNum: integer expected":null!=e.colorV2&&e.hasOwnProperty("colorV2")&&!n.isString(e.colorV2)?"colorV2: string expected":null!=e.dmTypeV2&&e.hasOwnProperty("dmTypeV2")&&!n.isInteger(e.dmTypeV2)?"dmTypeV2: integer expected":null},o.fromObject=function(e){if(e instanceof i.biliproto.community.service.dm.v1.DanmakuElem)return e;var t=new i.biliproto.community.service.dm.v1.DanmakuElem;return null!=e.id&&(n.Long?(t.id=n.Long.fromValue(e.id)).unsigned=!1:"string"==typeof e.id?t.id=parseInt(e.id,10):"number"==typeof e.id?t.id=e.id:"object"==typeof e.id&&(t.id=new n.LongBits(e.id.low>>>0,e.id.high>>>0).toNumber())),null!=e.progress&&(t.progress=0|e.progress),null!=e.mode&&(t.mode=0|e.mode),null!=e.fontsize&&(t.fontsize=0|e.fontsize),null!=e.color&&(t.color=e.color>>>0),null!=e.midHash&&(t.midHash=String(e.midHash)),null!=e.content&&(t.content=String(e.content)),null!=e.ctime&&(n.Long?(t.ctime=n.Long.fromValue(e.ctime)).unsigned=!1:"string"==typeof e.ctime?t.ctime=parseInt(e.ctime,10):"number"==typeof e.ctime?t.ctime=e.ctime:"object"==typeof e.ctime&&(t.ctime=new n.LongBits(e.ctime.low>>>0,e.ctime.high>>>0).toNumber())),null!=e.weight&&(t.weight=0|e.weight),null!=e.action&&(t.action=String(e.action)),null!=e.pool&&(t.pool=0|e.pool),null!=e.idStr&&(t.idStr=String(e.idStr)),null!=e.attr&&(t.attr=0|e.attr),null!=e.animation&&(t.animation=String(e.animation)),null!=e.likeNum&&(t.likeNum=e.likeNum>>>0),null!=e.colorV2&&(t.colorV2=String(e.colorV2)),null!=e.dmTypeV2&&(t.dmTypeV2=e.dmTypeV2>>>0),t},o.toObject=function(e,t){t||(t={});var r={};if(t.defaults){if(n.Long){var i=new n.Long(0,0,!1);r.id=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else r.id=t.longs===String?"0":0;if(r.progress=0,r.mode=0,r.fontsize=0,r.color=0,r.midHash="",r.content="",n.Long){var i=new n.Long(0,0,!1);r.ctime=t.longs===String?i.toString():t.longs===Number?i.toNumber():i}else r.ctime=t.longs===String?"0":0;r.weight=0,r.action="",r.pool=0,r.idStr="",r.attr=0,r.animation="",r.likeNum=0,r.colorV2="",r.dmTypeV2=0}return null!=e.id&&e.hasOwnProperty("id")&&("number"==typeof e.id?r.id=t.longs===String?String(e.id):e.id:r.id=t.longs===String?n.Long.prototype.toString.call(e.id):t.longs===Number?new n.LongBits(e.id.low>>>0,e.id.high>>>0).toNumber():e.id),null!=e.progress&&e.hasOwnProperty("progress")&&(r.progress=e.progress),null!=e.mode&&e.hasOwnProperty("mode")&&(r.mode=e.mode),null!=e.fontsize&&e.hasOwnProperty("fontsize")&&(r.fontsize=e.fontsize),null!=e.color&&e.hasOwnProperty("color")&&(r.color=e.color),null!=e.midHash&&e.hasOwnProperty("midHash")&&(r.midHash=e.midHash),null!=e.content&&e.hasOwnProperty("content")&&(r.content=e.content),null!=e.ctime&&e.hasOwnProperty("ctime")&&("number"==typeof e.ctime?r.ctime=t.longs===String?String(e.ctime):e.ctime:r.ctime=t.longs===String?n.Long.prototype.toString.call(e.ctime):t.longs===Number?new n.LongBits(e.ctime.low>>>0,e.ctime.high>>>0).toNumber():e.ctime),null!=e.weight&&e.hasOwnProperty("weight")&&(r.weight=e.weight),null!=e.action&&e.hasOwnProperty("action")&&(r.action=e.action),null!=e.pool&&e.hasOwnProperty("pool")&&(r.pool=e.pool),null!=e.idStr&&e.hasOwnProperty("idStr")&&(r.idStr=e.idStr),null!=e.attr&&e.hasOwnProperty("attr")&&(r.attr=e.attr),null!=e.animation&&e.hasOwnProperty("animation")&&(r.animation=e.animation),null!=e.likeNum&&e.hasOwnProperty("likeNum")&&(r.likeNum=e.likeNum),null!=e.colorV2&&e.hasOwnProperty("colorV2")&&(r.colorV2=e.colorV2),null!=e.dmTypeV2&&e.hasOwnProperty("dmTypeV2")&&(r.dmTypeV2=e.dmTypeV2),r},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/biliproto.community.service.dm.v1.DanmakuElem"},o}(),o.Flag=function(){function o(e){if(e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return o.prototype.value=0,o.prototype.description="",o.create=function(e){return new o(e)},o.encode=function(e,t){return t||(t=r.create()),null!=e.value&&Object.hasOwnProperty.call(e,"value")&&t.uint32(8).int32(e.value),null!=e.description&&Object.hasOwnProperty.call(e,"description")&&t.uint32(18).string(e.description),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,r,n){e instanceof t||(e=t.create(e));for(var o=void 0===r?e.len:e.pos+r,a=new i.biliproto.community.service.dm.v1.Flag;e.pos<o;){var s=e.uint32();if(s===n)break;switch(s>>>3){case 1:a.value=e.int32();break;case 2:a.description=e.string();break;default:e.skipType(7&s)}}return a},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){return"object"!=typeof e||null===e?"object expected":null!=e.value&&e.hasOwnProperty("value")&&!n.isInteger(e.value)?"value: integer expected":null!=e.description&&e.hasOwnProperty("description")&&!n.isString(e.description)?"description: string expected":null},o.fromObject=function(e){if(e instanceof i.biliproto.community.service.dm.v1.Flag)return e;var t=new i.biliproto.community.service.dm.v1.Flag;return null!=e.value&&(t.value=0|e.value),null!=e.description&&(t.description=String(e.description)),t},o.toObject=function(e,t){t||(t={});var r={};return t.defaults&&(r.value=0,r.description=""),null!=e.value&&e.hasOwnProperty("value")&&(r.value=e.value),null!=e.description&&e.hasOwnProperty("description")&&(r.description=e.description),r},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/biliproto.community.service.dm.v1.Flag"},o}(),o.DmSegMobileReply=function(){function o(e){if(this.elems=[],e)for(var t=Object.keys(e),r=0;r<t.length;++r)null!=e[t[r]]&&(this[t[r]]=e[t[r]])}return o.prototype.elems=n.emptyArray,o.prototype.state=0,o.prototype.aiFlagForSummary=null,o.create=function(e){return new o(e)},o.encode=function(e,t){if(t||(t=r.create()),null!=e.elems&&e.elems.length)for(var n=0;n<e.elems.length;++n)i.biliproto.community.service.dm.v1.DanmakuElem.encode(e.elems[n],t.uint32(10).fork()).ldelim();return null!=e.state&&Object.hasOwnProperty.call(e,"state")&&t.uint32(16).int32(e.state),null!=e.aiFlagForSummary&&Object.hasOwnProperty.call(e,"aiFlagForSummary")&&i.biliproto.community.service.dm.v1.Flag.encode(e.aiFlagForSummary,t.uint32(26).fork()).ldelim(),t},o.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},o.decode=function(e,r,n){e instanceof t||(e=t.create(e));for(var o=void 0===r?e.len:e.pos+r,a=new i.biliproto.community.service.dm.v1.DmSegMobileReply;e.pos<o;){var s=e.uint32();if(s===n)break;switch(s>>>3){case 1:a.elems&&a.elems.length||(a.elems=[]),a.elems.push(i.biliproto.community.service.dm.v1.DanmakuElem.decode(e,e.uint32()));break;case 2:a.state=e.int32();break;case 3:a.aiFlagForSummary=i.biliproto.community.service.dm.v1.Flag.decode(e,e.uint32());break;default:e.skipType(7&s)}}return a},o.decodeDelimited=function(e){return e instanceof t||(e=new t(e)),this.decode(e,e.uint32())},o.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.elems&&e.hasOwnProperty("elems")){if(!Array.isArray(e.elems))return"elems: array expected";for(var t=0;t<e.elems.length;++t){var r=i.biliproto.community.service.dm.v1.DanmakuElem.verify(e.elems[t]);if(r)return"elems."+r}}if(null!=e.state&&e.hasOwnProperty("state")&&!n.isInteger(e.state))return"state: integer expected";if(null!=e.aiFlagForSummary&&e.hasOwnProperty("aiFlagForSummary")){var r=i.biliproto.community.service.dm.v1.Flag.verify(e.aiFlagForSummary);if(r)return"aiFlagForSummary."+r}return null},o.fromObject=function(e){if(e instanceof i.biliproto.community.service.dm.v1.DmSegMobileReply)return e;var t=new i.biliproto.community.service.dm.v1.DmSegMobileReply;if(e.elems){if(!Array.isArray(e.elems))throw TypeError(".biliproto.community.service.dm.v1.DmSegMobileReply.elems: array expected");t.elems=[];for(var r=0;r<e.elems.length;++r){if("object"!=typeof e.elems[r])throw TypeError(".biliproto.community.service.dm.v1.DmSegMobileReply.elems: object expected");t.elems[r]=i.biliproto.community.service.dm.v1.DanmakuElem.fromObject(e.elems[r])}}if(null!=e.state&&(t.state=0|e.state),null!=e.aiFlagForSummary){if("object"!=typeof e.aiFlagForSummary)throw TypeError(".biliproto.community.service.dm.v1.DmSegMobileReply.aiFlagForSummary: object expected");t.aiFlagForSummary=i.biliproto.community.service.dm.v1.Flag.fromObject(e.aiFlagForSummary)}return t},o.toObject=function(e,t){t||(t={});var r={};if((t.arrays||t.defaults)&&(r.elems=[]),t.defaults&&(r.state=0,r.aiFlagForSummary=null),e.elems&&e.elems.length){r.elems=[];for(var n=0;n<e.elems.length;++n)r.elems[n]=i.biliproto.community.service.dm.v1.DanmakuElem.toObject(e.elems[n],t)}return null!=e.state&&e.hasOwnProperty("state")&&(r.state=e.state),null!=e.aiFlagForSummary&&e.hasOwnProperty("aiFlagForSummary")&&(r.aiFlagForSummary=i.biliproto.community.service.dm.v1.Flag.toObject(e.aiFlagForSummary,t)),r},o.prototype.toJSON=function(){return this.constructor.toObject(this,e.util.toJSONOptions)},o.getTypeUrl=function(e){return void 0===e&&(e="type.googleapis.com"),e+"/biliproto.community.service.dm.v1.DmSegMobileReply"},o}(),o}(),o}(),o}(),o}(),o}(),i})},129:function(e,t,r){!function(n,i,o){e.exports=t=i(r(95),r(716),r(478),r(516),r(947))}(0,function(e){return!function(){var t=e,r=t.lib.BlockCipher,n=t.algo,i=[],o=[],a=[],s=[],l=[],u=[],c=[],d=[],f=[],p=[];!function(){for(var e=[],t=0;t<256;t++)t<128?e[t]=t<<1:e[t]=t<<1^283;for(var r=0,n=0,t=0;t<256;t++){var h=n^n<<1^n<<2^n<<3^n<<4;h=h>>>8^255&h^99,i[r]=h,o[h]=r;var m=e[r],g=e[m],v=e[g],y=257*e[h]^0x1010100*h;a[r]=y<<24|y>>>8,s[r]=y<<16|y>>>16,l[r]=y<<8|y>>>24,u[r]=y;var y=0x1010101*v^65537*g^257*m^0x1010100*r;c[h]=y<<24|y>>>8,d[h]=y<<16|y>>>16,f[h]=y<<8|y>>>24,p[h]=y,r?(r=m^e[e[e[v^m]]],n^=e[e[n]]):r=n=1}}();var h=[0,1,2,4,8,16,32,64,128,27,54],m=n.AES=r.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var e,t=this._keyPriorReset=this._key,r=t.words,n=t.sigBytes/4,o=this._nRounds=n+6,a=(o+1)*4,s=this._keySchedule=[],l=0;l<a;l++)l<n?s[l]=r[l]:(e=s[l-1],l%n?n>6&&l%n==4&&(e=i[e>>>24]<<24|i[e>>>16&255]<<16|i[e>>>8&255]<<8|i[255&e]):e=(i[(e=e<<8|e>>>24)>>>24]<<24|i[e>>>16&255]<<16|i[e>>>8&255]<<8|i[255&e])^h[l/n|0]<<24,s[l]=s[l-n]^e);for(var u=this._invKeySchedule=[],m=0;m<a;m++){var l=a-m;if(m%4)var e=s[l];else var e=s[l-4];m<4||l<=4?u[m]=e:u[m]=c[i[e>>>24]]^d[i[e>>>16&255]]^f[i[e>>>8&255]]^p[i[255&e]]}}},encryptBlock:function(e,t){this._doCryptBlock(e,t,this._keySchedule,a,s,l,u,i)},decryptBlock:function(e,t){var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r,this._doCryptBlock(e,t,this._invKeySchedule,c,d,f,p,o);var r=e[t+1];e[t+1]=e[t+3],e[t+3]=r},_doCryptBlock:function(e,t,r,n,i,o,a,s){for(var l=this._nRounds,u=e[t]^r[0],c=e[t+1]^r[1],d=e[t+2]^r[2],f=e[t+3]^r[3],p=4,h=1;h<l;h++){var m=n[u>>>24]^i[c>>>16&255]^o[d>>>8&255]^a[255&f]^r[p++],g=n[c>>>24]^i[d>>>16&255]^o[f>>>8&255]^a[255&u]^r[p++],v=n[d>>>24]^i[f>>>16&255]^o[u>>>8&255]^a[255&c]^r[p++],y=n[f>>>24]^i[u>>>16&255]^o[c>>>8&255]^a[255&d]^r[p++];u=m,c=g,d=v,f=y}var m=(s[u>>>24]<<24|s[c>>>16&255]<<16|s[d>>>8&255]<<8|s[255&f])^r[p++],g=(s[c>>>24]<<24|s[d>>>16&255]<<16|s[f>>>8&255]<<8|s[255&u])^r[p++],v=(s[d>>>24]<<24|s[f>>>16&255]<<16|s[u>>>8&255]<<8|s[255&c])^r[p++],y=(s[f>>>24]<<24|s[u>>>16&255]<<16|s[c>>>8&255]<<8|s[255&d])^r[p++];e[t]=m,e[t+1]=g,e[t+2]=v,e[t+3]=y},keySize:8});t.AES=r._createHelper(m)}(),e.AES})},947:function(e,t,r){!function(n,i,o){e.exports=t=i(r(95),r(516))}(0,function(e){e.lib.Cipher||function(){var t=e,r=t.lib,n=r.Base,i=r.WordArray,o=r.BufferedBlockAlgorithm,a=t.enc;a.Utf8;var s=a.Base64,l=t.algo.EvpKDF,u=r.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(e,t){return this.create(this._ENC_XFORM_MODE,e,t)},createDecryptor:function(e,t){return this.create(this._DEC_XFORM_MODE,e,t)},init:function(e,t,r){this.cfg=this.cfg.extend(r),this._xformMode=e,this._key=t,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(e){return this._append(e),this._process()},finalize:function(e){return e&&this._append(e),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function e(e){return"string"==typeof e?y:g}return function(t){return{encrypt:function(r,n,i){return e(n).encrypt(t,r,n,i)},decrypt:function(r,n,i){return e(n).decrypt(t,r,n,i)}}}}()});r.StreamCipher=u.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var c=t.mode={},d=r.BlockCipherMode=n.extend({createEncryptor:function(e,t){return this.Encryptor.create(e,t)},createDecryptor:function(e,t){return this.Decryptor.create(e,t)},init:function(e,t){this._cipher=e,this._iv=t}}),f=c.CBC=function(){var e=d.extend();function t(e,t,r){var n,i=this._iv;i?(n=i,this._iv=void 0):n=this._prevBlock;for(var o=0;o<r;o++)e[t+o]^=n[o]}return e.Encryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize;t.call(this,e,r,i),n.encryptBlock(e,r),this._prevBlock=e.slice(r,r+i)}}),e.Decryptor=e.extend({processBlock:function(e,r){var n=this._cipher,i=n.blockSize,o=e.slice(r,r+i);n.decryptBlock(e,r),t.call(this,e,r,i),this._prevBlock=o}}),e}(),p=(t.pad={}).Pkcs7={pad:function(e,t){for(var r=4*t,n=r-e.sigBytes%r,o=n<<24|n<<16|n<<8|n,a=[],s=0;s<n;s+=4)a.push(o);var l=i.create(a,n);e.concat(l)},unpad:function(e){var t=255&e.words[e.sigBytes-1>>>2];e.sigBytes-=t}};r.BlockCipher=u.extend({cfg:u.cfg.extend({mode:f,padding:p}),reset:function(){u.reset.call(this);var e,t=this.cfg,r=t.iv,n=t.mode;this._xformMode==this._ENC_XFORM_MODE?e=n.createEncryptor:(e=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==e?this._mode.init(this,r&&r.words):(this._mode=e.call(n,this,r&&r.words),this._mode.__creator=e)},_doProcessBlock:function(e,t){this._mode.processBlock(e,t)},_doFinalize:function(){var e,t=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(t.pad(this._data,this.blockSize),e=this._process(!0)):(e=this._process(!0),t.unpad(e)),e},blockSize:4});var h=r.CipherParams=n.extend({init:function(e){this.mixIn(e)},toString:function(e){return(e||this.formatter).stringify(this)}}),m=(t.format={}).OpenSSL={stringify:function(e){var t,r=e.ciphertext,n=e.salt;return(t=n?i.create([0x53616c74,0x65645f5f]).concat(n).concat(r):r).toString(s)},parse:function(e){var t,r=s.parse(e),n=r.words;return 0x53616c74==n[0]&&0x65645f5f==n[1]&&(t=i.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),h.create({ciphertext:r,salt:t})}},g=r.SerializableCipher=n.extend({cfg:n.extend({format:m}),encrypt:function(e,t,r,n){n=this.cfg.extend(n);var i=e.createEncryptor(r,n),o=i.finalize(t),a=i.cfg;return h.create({ciphertext:o,key:r,iv:a.iv,algorithm:e,mode:a.mode,padding:a.padding,blockSize:e.blockSize,formatter:n.format})},decrypt:function(e,t,r,n){return n=this.cfg.extend(n),t=this._parse(t,n.format),e.createDecryptor(r,n).finalize(t.ciphertext)},_parse:function(e,t){return"string"==typeof e?t.parse(e,this):e}}),v=(t.kdf={}).OpenSSL={execute:function(e,t,r,n,o){if(n||(n=i.random(8)),o)var a=l.create({keySize:t+r,hasher:o}).compute(e,n);else var a=l.create({keySize:t+r}).compute(e,n);var s=i.create(a.words.slice(t),4*r);return a.sigBytes=4*t,h.create({key:a,iv:s,salt:n})}},y=r.PasswordBasedCipher=g.extend({cfg:g.cfg.extend({kdf:v}),encrypt:function(e,t,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,e.keySize,e.ivSize,n.salt,n.hasher);n.iv=i.iv;var o=g.encrypt.call(this,e,t,i.key,n);return o.mixIn(i),o},decrypt:function(e,t,r,n){n=this.cfg.extend(n),t=this._parse(t,n.format);var i=n.kdf.execute(r,e.keySize,e.ivSize,t.salt,n.hasher);return n.iv=i.iv,g.decrypt.call(this,e,t,i.key,n)}})}()})},95:function(e,t,r){!function(r,n){e.exports=t=n()}(0,function(){var e=e||function(e,t){if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==r.g&&r.g.crypto&&(n=r.g.crypto),!n)try{n=r(488)}catch(e){}var n,i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),a={},s=a.lib={},l=s.Base=function(){return{extend:function(e){var t=o(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),u=s.WordArray=l.extend({init:function(e,r){e=this.words=e||[],t!=r?this.sigBytes=r:this.sigBytes=4*e.length},toString:function(e){return(e||d).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<i;o++){var a=r[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var s=0;s<i;s+=4)t[n+s>>>2]=r[s>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=0xffffffff<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=l.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new u.init(t,e)}}),c=a.enc={},d=c.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new u.init(r,t/2)}},f=c.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var o=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new u.init(r,t)}},p=c.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},h=s.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=p.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,s=o/(4*a),l=(s=t?e.ceil(s):e.max((0|s)-this._minBufferSize,0))*a,c=e.min(4*l,o);if(l){for(var d=0;d<l;d+=a)this._doProcessBlock(i,d);r=i.splice(0,l),n.sigBytes-=c}return new u.init(r,c)},clone:function(){var e=l.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});s.Hasher=h.extend({cfg:l.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){h.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new m.HMAC.init(e,r).finalize(t)}}});var m=a.algo={};return a}(Math);return e})},716:function(e,t,r){!function(n,i){e.exports=t=i(r(95))}(0,function(e){return!function(){var t=e,r=t.lib.WordArray;function n(e,t,n){for(var i=[],o=0,a=0;a<t;a++)if(a%4){var s=n[e.charCodeAt(a-1)]<<a%4*2|n[e.charCodeAt(a)]>>>6-a%4*2;i[o>>>2]|=s<<24-o%4*8,o++}return r.create(i,o)}t.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],o=0;o<r;o+=3)for(var a=(t[o>>>2]>>>24-o%4*8&255)<<16|(t[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|t[o+2>>>2]>>>24-(o+2)%4*8&255,s=0;s<4&&o+.75*s<r;s++)i.push(n.charAt(a>>>6*(3-s)&63));var l=n.charAt(64);if(l)for(;i.length%4;)i.push(l);return i.join("")},parse:function(e){var t=e.length,r=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o<r.length;o++)i[r.charCodeAt(o)]=o}var a=r.charAt(64);if(a){var s=e.indexOf(a);-1!==s&&(t=s)}return n(e,t,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),e.enc.Base64})},60:function(e,t,r){!function(n,i){e.exports=t=i(r(95))}(0,function(e){return e.enc.Utf8})},516:function(e,t,r){!function(n,i,o){e.exports=t=i(r(95),r(825),r(979))}(0,function(e){return!function(){var t=e,r=t.lib,n=r.Base,i=r.WordArray,o=t.algo,a=o.MD5,s=o.EvpKDF=n.extend({cfg:n.extend({keySize:4,hasher:a,iterations:1}),init:function(e){this.cfg=this.cfg.extend(e)},compute:function(e,t){for(var r,n=this.cfg,o=n.hasher.create(),a=i.create(),s=a.words,l=n.keySize,u=n.iterations;s.length<l;){r&&o.update(r),r=o.update(e).finalize(t),o.reset();for(var c=1;c<u;c++)r=o.finalize(r),o.reset();a.concat(r)}return a.sigBytes=4*l,a}});t.EvpKDF=function(e,t,r){return s.create(r).compute(e,t)}}(),e.EvpKDF})},939:function(e,t,r){!function(n,i,o){e.exports=t=i(r(95),r(331),r(979))}(0,function(e){return e.HmacSHA256})},979:function(e,t,r){!function(n,i){e.exports=t=i(r(95))}(0,function(e){!function(){var t=e,r=t.lib.Base,n=t.enc.Utf8;t.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=n.parse(t));var r=e.blockSize,i=4*r;t.sigBytes>i&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),a=this._iKey=t.clone(),s=o.words,l=a.words,u=0;u<r;u++)s[u]^=0x5c5c5c5c,l[u]^=0x36363636;o.sigBytes=a.sigBytes=i,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})}()})},478:function(e,t,r){!function(n,i){e.exports=t=i(r(95))}(0,function(e){return!function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[];!function(){for(var e=0;e<64;e++)s[e]=0x100000000*t.abs(t.sin(e+1))|0}();var l=a.MD5=o.extend({_doReset:function(){this._hash=new i.init([0x67452301,0xefcdab89,0x98badcfe,0x10325476])},_doProcessBlock:function(e,t){for(var r=0;r<16;r++){var n=t+r,i=e[n];e[n]=(i<<8|i>>>24)&0xff00ff|(i<<24|i>>>8)&0xff00ff00}var o=this._hash.words,a=e[t+0],l=e[t+1],p=e[t+2],h=e[t+3],m=e[t+4],g=e[t+5],v=e[t+6],y=e[t+7],b=e[t+8],w=e[t+9],_=e[t+10],x=e[t+11],k=e[t+12],S=e[t+13],O=e[t+14],P=e[t+15],z=o[0],I=o[1],E=o[2],j=o[3];z=u(z,I,E,j,a,7,s[0]),j=u(j,z,I,E,l,12,s[1]),E=u(E,j,z,I,p,17,s[2]),I=u(I,E,j,z,h,22,s[3]),z=u(z,I,E,j,m,7,s[4]),j=u(j,z,I,E,g,12,s[5]),E=u(E,j,z,I,v,17,s[6]),I=u(I,E,j,z,y,22,s[7]),z=u(z,I,E,j,b,7,s[8]),j=u(j,z,I,E,w,12,s[9]),E=u(E,j,z,I,_,17,s[10]),I=u(I,E,j,z,x,22,s[11]),z=u(z,I,E,j,k,7,s[12]),j=u(j,z,I,E,S,12,s[13]),E=u(E,j,z,I,O,17,s[14]),I=u(I,E,j,z,P,22,s[15]),z=c(z,I,E,j,l,5,s[16]),j=c(j,z,I,E,v,9,s[17]),E=c(E,j,z,I,x,14,s[18]),I=c(I,E,j,z,a,20,s[19]),z=c(z,I,E,j,g,5,s[20]),j=c(j,z,I,E,_,9,s[21]),E=c(E,j,z,I,P,14,s[22]),I=c(I,E,j,z,m,20,s[23]),z=c(z,I,E,j,w,5,s[24]),j=c(j,z,I,E,O,9,s[25]),E=c(E,j,z,I,h,14,s[26]),I=c(I,E,j,z,b,20,s[27]),z=c(z,I,E,j,S,5,s[28]),j=c(j,z,I,E,p,9,s[29]),E=c(E,j,z,I,y,14,s[30]),I=c(I,E,j,z,k,20,s[31]),z=d(z,I,E,j,g,4,s[32]),j=d(j,z,I,E,b,11,s[33]),E=d(E,j,z,I,x,16,s[34]),I=d(I,E,j,z,O,23,s[35]),z=d(z,I,E,j,l,4,s[36]),j=d(j,z,I,E,m,11,s[37]),E=d(E,j,z,I,y,16,s[38]),I=d(I,E,j,z,_,23,s[39]),z=d(z,I,E,j,S,4,s[40]),j=d(j,z,I,E,a,11,s[41]),E=d(E,j,z,I,h,16,s[42]),I=d(I,E,j,z,v,23,s[43]),z=d(z,I,E,j,w,4,s[44]),j=d(j,z,I,E,k,11,s[45]),E=d(E,j,z,I,P,16,s[46]),I=d(I,E,j,z,p,23,s[47]),z=f(z,I,E,j,a,6,s[48]),j=f(j,z,I,E,y,10,s[49]),E=f(E,j,z,I,O,15,s[50]),I=f(I,E,j,z,g,21,s[51]),z=f(z,I,E,j,k,6,s[52]),j=f(j,z,I,E,h,10,s[53]),E=f(E,j,z,I,_,15,s[54]),I=f(I,E,j,z,l,21,s[55]),z=f(z,I,E,j,b,6,s[56]),j=f(j,z,I,E,P,10,s[57]),E=f(E,j,z,I,v,15,s[58]),I=f(I,E,j,z,S,21,s[59]),z=f(z,I,E,j,m,6,s[60]),j=f(j,z,I,E,x,10,s[61]),E=f(E,j,z,I,p,15,s[62]),I=f(I,E,j,z,w,21,s[63]),o[0]=o[0]+z|0,o[1]=o[1]+I|0,o[2]=o[2]+E|0,o[3]=o[3]+j|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/0x100000000),a=n;r[(i+64>>>9<<4)+15]=(o<<8|o>>>24)&0xff00ff|(o<<24|o>>>8)&0xff00ff00,r[(i+64>>>9<<4)+14]=(a<<8|a>>>24)&0xff00ff|(a<<24|a>>>8)&0xff00ff00,e.sigBytes=(r.length+1)*4,this._process();for(var s=this._hash,l=s.words,u=0;u<4;u++){var c=l[u];l[u]=(c<<8|c>>>24)&0xff00ff|(c<<24|c>>>8)&0xff00ff00}return s},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,r,n,i,o,a){var s=e+(t&r|~t&n)+i+a;return(s<<o|s>>>32-o)+t}function c(e,t,r,n,i,o,a){var s=e+(t&n|r&~n)+i+a;return(s<<o|s>>>32-o)+t}function d(e,t,r,n,i,o,a){var s=e+(t^r^n)+i+a;return(s<<o|s>>>32-o)+t}function f(e,t,r,n,i,o,a){var s=e+(r^(t|~n))+i+a;return(s<<o|s>>>32-o)+t}r.MD5=o._createHelper(l),r.HmacMD5=o._createHmacHelper(l)}(Math),e.MD5})},760:function(e,t,r){!function(n,i,o){e.exports=t=i(r(95),r(947))}(0,function(e){return e.mode.ECB=function(){var t=e.lib.BlockCipherMode.extend();return t.Encryptor=t.extend({processBlock:function(e,t){this._cipher.encryptBlock(e,t)}}),t.Decryptor=t.extend({processBlock:function(e,t){this._cipher.decryptBlock(e,t)}}),t}(),e.mode.ECB})},186:function(e,t,r){!function(n,i,o){e.exports=t=i(r(95),r(947))}(0,function(e){return e.pad.Pkcs7})},825:function(e,t,r){!function(n,i){e.exports=t=i(r(95))}(0,function(e){return!function(){var t=e,r=t.lib,n=r.WordArray,i=r.Hasher,o=t.algo,a=[],s=o.SHA1=i.extend({_doReset:function(){this._hash=new n.init([0x67452301,0xefcdab89,0x98badcfe,0x10325476,0xc3d2e1f0])},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],s=r[3],l=r[4],u=0;u<80;u++){if(u<16)a[u]=0|e[t+u];else{var c=a[u-3]^a[u-8]^a[u-14]^a[u-16];a[u]=c<<1|c>>>31}var d=(n<<5|n>>>27)+l+a[u];u<20?d+=(i&o|~i&s)+0x5a827999:u<40?d+=(i^o^s)+0x6ed9eba1:u<60?d+=(i&o|i&s|o&s)-0x70e44324:d+=(i^o^s)-0x359d3e2a,l=s,s=o,o=i<<30|i>>>2,i=n,n=d}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+l|0},_doFinalize:function(){var e=this._data,t=e.words,r=8*this._nDataBytes,n=8*e.sigBytes;return t[n>>>5]|=128<<24-n%32,t[(n+64>>>9<<4)+14]=Math.floor(r/0x100000000),t[(n+64>>>9<<4)+15]=r,e.sigBytes=4*t.length,this._process(),this._hash},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA1=i._createHelper(s),t.HmacSHA1=i._createHmacHelper(s)}(),e.SHA1})},331:function(e,t,r){!function(n,i){e.exports=t=i(r(95))}(0,function(e){return!function(t){var r=e,n=r.lib,i=n.WordArray,o=n.Hasher,a=r.algo,s=[],l=[];!function(){function e(e){for(var r=t.sqrt(e),n=2;n<=r;n++)if(!(e%n))return!1;return!0}function r(e){return(e-(0|e))*0x100000000|0}for(var n=2,i=0;i<64;)e(n)&&(i<8&&(s[i]=r(t.pow(n,.5))),l[i]=r(t.pow(n,1/3)),i++),n++}();var u=[],c=a.SHA256=o.extend({_doReset:function(){this._hash=new i.init(s.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],o=r[2],a=r[3],s=r[4],c=r[5],d=r[6],f=r[7],p=0;p<64;p++){if(p<16)u[p]=0|e[t+p];else{var h=u[p-15],m=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,g=u[p-2],v=(g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10;u[p]=m+u[p-7]+v+u[p-16]}var y=s&c^~s&d,b=n&i^n&o^i&o,w=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),_=f+((s<<26|s>>>6)^(s<<21|s>>>11)^(s<<7|s>>>25))+y+l[p]+u[p],x=w+b;f=d,d=c,c=s,s=a+_|0,a=o,o=i,i=n,n=_+x|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+o|0,r[3]=r[3]+a|0,r[4]=r[4]+s|0,r[5]=r[5]+c|0,r[6]=r[6]+d|0,r[7]=r[7]+f|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;return r[i>>>5]|=128<<24-i%32,r[(i+64>>>9<<4)+14]=t.floor(n/0x100000000),r[(i+64>>>9<<4)+15]=n,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});r.SHA256=o._createHelper(c),r.HmacSHA256=o._createHmacHelper(c)}(Math),e.SHA256})},643:function(e,t,r){e.exports=r(447)},447:function(e,t,r){var n=t;function i(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}n.build="minimal",n.Writer=r(114),n.BufferWriter=r(491),n.Reader=r(762),n.BufferReader=r(171),n.util=r(837),n.rpc=r(366),n.roots=r(264),n.configure=i,i()},762:function(e,t,r){e.exports=l;var n,i=r(837),o=i.LongBits,a=i.utf8;function s(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function l(e){this.buf=e,this.pos=0,this.len=e.length}var u="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new l(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new l(e);throw Error("illegal buffer")},c=function(){return i.Buffer?function(e){return(l.create=function(e){return i.Buffer.isBuffer(e)?new n(e):u(e)})(e)}:u};function d(){var e=new o(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw s(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw s(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function f(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function p(){if(this.pos+8>this.len)throw s(this,8);return new o(f(this.buf,this.pos+=4),f(this.buf,this.pos+=4))}l.create=c(),l.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,l.prototype.uint32=function(){var e=0xffffffff;return function(){if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,s(this,10);return e}}(),l.prototype.int32=function(){return 0|this.uint32()},l.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},l.prototype.bool=function(){return 0!==this.uint32()},l.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return f(this.buf,this.pos+=4)},l.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return 0|f(this.buf,this.pos+=4)},l.prototype.float=function(){if(this.pos+4>this.len)throw s(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},l.prototype.double=function(){if(this.pos+8>this.len)throw s(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},l.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw s(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(t,r);if(t===r){var n=i.Buffer;return n?n.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,r)},l.prototype.string=function(){var e=this.bytes();return a.read(e,0,e.length)},l.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw s(this,e);this.pos+=e}else do if(this.pos>=this.len)throw s(this);while(128&this.buf[this.pos++]);return this},l.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},l._configure=function(e){n=e,l.create=c(),n._configure();var t=i.Long?"toLong":"toNumber";i.merge(l.prototype,{int64:function(){return d.call(this)[t](!1)},uint64:function(){return d.call(this)[t](!0)},sint64:function(){return d.call(this).zzDecode()[t](!1)},fixed64:function(){return p.call(this)[t](!0)},sfixed64:function(){return p.call(this)[t](!1)}})}},171:function(e,t,r){e.exports=o;var n=r(762);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(837);function o(e){n.call(this,e)}o._configure=function(){i.Buffer&&(o.prototype._slice=i.Buffer.prototype.slice)},o.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},o._configure()},264:function(e){e.exports={}},366:function(e,t,r){t.Service=r(286)},286:function(e,t,r){e.exports=i;var n=r(837);function i(e,t,r){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=!!t,this.responseDelimited=!!r}(i.prototype=Object.create(n.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,r,i,o,a){if(!o)throw TypeError("request must be specified");var s=this;if(!a)return n.asPromise(e,s,t,r,i,o);if(!s.rpcImpl)return void setTimeout(function(){a(Error("already ended"))},0);try{return s.rpcImpl(t,r[s.requestDelimited?"encodeDelimited":"encode"](o).finish(),function(e,r){if(e)return s.emit("error",e,t),a(e);if(null===r)return void s.end(!0);if(!(r instanceof i))try{r=i[s.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return s.emit("error",e,t),a(e)}return s.emit("data",r,t),a(null,r)})}catch(e){s.emit("error",e,t),setTimeout(function(){a(e)},0);return}},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},926:function(e,t,r){e.exports=i;var n=r(837);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var o=i.zero=new i(0,0);o.toNumber=function(){return 0},o.zzEncode=o.zzDecode=function(){return this},o.length=function(){return 1};var a=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return o;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/0x100000000>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>0xffffffff&&(r=0,++n>0xffffffff&&(n=0))),new i(r,n)},i.from=function(e){if("number"==typeof e)return i.fromNumber(e);if(n.isString(e))if(!n.Long)return i.fromNumber(parseInt(e,10));else e=n.Long.fromString(e);return e.low||e.high?new i(e.low>>>0,e.high>>>0):o},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=~this.lo+1>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+0x100000000*r)}return this.lo+0x100000000*this.hi},i.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,!!e):{low:0|this.lo,high:0|this.hi,unsigned:!!e}};var s=String.prototype.charCodeAt;i.fromHash=function(e){return e===a?o:new i((s.call(e,0)|s.call(e,1)<<8|s.call(e,2)<<16|s.call(e,3)<<24)>>>0,(s.call(e,4)|s.call(e,5)<<8|s.call(e,6)<<16|s.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},837:function(e,t,r){var n=t;function i(e,t,r){for(var n=Object.keys(t),i=0;i<n.length;++i)void 0!==e[n[i]]&&r||(e[n[i]]=t[n[i]]);return e}function o(e){function t(e,r){if(!(this instanceof t))return new t(e,r);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:Error().stack||""}),r&&i(this,r)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}n.asPromise=r(188),n.base64=r(4),n.EventEmitter=r(730),n.float=r(791),n.inquire=r(706),n.utf8=r(322),n.pool=r(338),n.LongBits=r(926),n.isNode=!!(void 0!==r.g&&r.g&&r.g.process&&r.g.process.versions&&r.g.process.versions.node),n.global=n.isNode&&r.g||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||this,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},n.isString=function(e){return"string"==typeof e||e instanceof String},n.isObject=function(e){return e&&"object"==typeof e},n.isset=n.isSet=function(e,t){var r=e[t];return!!(null!=r&&e.hasOwnProperty(t))&&("object"!=typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"==typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(!!t)},n.merge=i,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=o,n.ProtocolError=o("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=1;return function(){for(var e=Object.keys(this),r=e.length-1;r>-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r<e.length;++r)e[r]!==t&&delete this[e[r]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var e=n.Buffer;if(!e){n._Buffer_from=n._Buffer_allocUnsafe=null;return}n._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,r){return new e(t,r)},n._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}}},114:function(e,t,r){e.exports=d;var n,i=r(837),o=i.LongBits,a=i.base64,s=i.utf8;function l(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function u(){}function c(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function d(){this.len=0,this.head=new l(u,0,0),this.tail=this.head,this.states=null}var f=function(){return i.Buffer?function(){return(d.create=function(){return new n})()}:function(){return new d}};function p(e,t,r){t[r]=255&e}function h(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}function m(e,t){this.len=e,this.next=void 0,this.val=t}function g(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function v(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}d.create=f(),d.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(d.alloc=i.pool(d.alloc,i.Array.prototype.subarray)),d.prototype._push=function(e,t,r){return this.tail=this.tail.next=new l(e,t,r),this.len+=t,this},m.prototype=Object.create(l.prototype),m.prototype.fn=h,d.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new m((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<0x10000000?4:5,e)).len,this},d.prototype.int32=function(e){return e<0?this._push(g,10,o.fromNumber(e)):this.uint32(e)},d.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},d.prototype.uint64=function(e){var t=o.from(e);return this._push(g,t.length(),t)},d.prototype.int64=d.prototype.uint64,d.prototype.sint64=function(e){var t=o.from(e).zzEncode();return this._push(g,t.length(),t)},d.prototype.bool=function(e){return this._push(p,1,+!!e)},d.prototype.fixed32=function(e){return this._push(v,4,e>>>0)},d.prototype.sfixed32=d.prototype.fixed32,d.prototype.fixed64=function(e){var t=o.from(e);return this._push(v,4,t.lo)._push(v,4,t.hi)},d.prototype.sfixed64=d.prototype.fixed64,d.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},d.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var y=i.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n<e.length;++n)t[r+n]=e[n]};d.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(p,1,0);if(i.isString(e)){var r=d.alloc(t=a.length(e));a.decode(e,r,0),e=r}return this.uint32(t)._push(y,t,e)},d.prototype.string=function(e){var t=s.length(e);return t?this.uint32(t)._push(s.write,t,e):this._push(p,1,0)},d.prototype.fork=function(){return this.states=new c(this),this.head=this.tail=new l(u,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new l(u,0,0),this.len=0),this},d.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},d.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},d._configure=function(e){n=e,d.create=f(),n._configure()}},491:function(e,t,r){e.exports=o;var n=r(114);(o.prototype=Object.create(n.prototype)).constructor=o;var i=r(837);function o(){n.call(this)}function a(e,t,r){e.length<40?i.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}o._configure=function(){o.alloc=i._Buffer_allocUnsafe,o.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n<e.length;)t[r++]=e[n++]}},o.prototype.bytes=function(e){i.isString(e)&&(e=i._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(o.writeBytesBuffer,t,e),this},o.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(a,t,e),this},o._configure()},682:function(e,t){var r,n=Object.prototype.hasOwnProperty;function i(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function o(e){try{return encodeURIComponent(e)}catch(e){return null}}function a(e){for(var t,r=/([^=?#&]+)=?([^&]*)/g,n={};t=r.exec(e);){var o=i(t[1]),a=i(t[2]);null===o||null===a||o in n||(n[o]=a)}return n}t.stringify=function(e,t){var i,a,s=[];for(a in"string"!=typeof(t=t||"")&&(t="?"),e)if(n.call(e,a)){if(!(i=e[a])&&(null===i||i===r||isNaN(i))&&(i=""),a=o(a),i=o(i),null===a||null===i)continue;s.push(a+"="+i)}return s.length?t+s.join("&"):""},t.parse=a},995:function(e){e.exports=function(e,t){if(t=t.split(":")[0],!(e*=1))return!1;switch(t){case"http":case"ws":return 80!==e;case"https":case"wss":return 443!==e;case"ftp":return 21!==e;case"gopher":return 70!==e;case"file":return!1}return 0!==e}},337:function(e,t,r){var n=r(995),i=r(682),o=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,a=/[\n\r\t]/g,s=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,l=/:\d+$/,u=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,c=/^[a-zA-Z]:/;function d(e){return(e||"").toString().replace(o,"")}var f=[["#","hash"],["?","query"],function(e,t){return m(t.protocol)?e.replace(/\\/g,"/"):e},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],p={hash:1,query:1};function h(e){var t,n,i=(t="undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{}).location||{},o={},a=typeof(e=e||i);if("blob:"===e.protocol)o=new y(unescape(e.pathname),{});else if("string"===a)for(n in o=new y(e,{}),p)delete o[n];else if("object"===a){for(n in e)n in p||(o[n]=e[n]);void 0===o.slashes&&(o.slashes=s.test(e.href))}return o}function m(e){return"file:"===e||"ftp:"===e||"http:"===e||"https:"===e||"ws:"===e||"wss:"===e}function g(e,t){e=(e=d(e)).replace(a,""),t=t||{};var r,n=u.exec(e),i=n[1]?n[1].toLowerCase():"",o=!!n[2],s=!!n[3],l=0;return o?s?(r=n[2]+n[3]+n[4],l=n[2].length+n[3].length):(r=n[2]+n[4],l=n[2].length):s?(r=n[3]+n[4],l=n[3].length):r=n[4],"file:"===i?l>=2&&(r=r.slice(2)):m(i)?r=n[4]:i?o&&(r=r.slice(2)):l>=2&&m(t.protocol)&&(r=n[4]),{protocol:i,slashes:o||m(i),slashesCount:l,rest:r}}function v(e,t){if(""===e)return t;for(var r=(t||"/").split("/").slice(0,-1).concat(e.split("/")),n=r.length,i=r[n-1],o=!1,a=0;n--;)"."===r[n]?r.splice(n,1):".."===r[n]?(r.splice(n,1),a++):a&&(0===n&&(o=!0),r.splice(n,1),a--);return o&&r.unshift(""),("."===i||".."===i)&&r.push(""),r.join("/")}function y(e,t,r){if(e=(e=d(e)).replace(a,""),!(this instanceof y))return new y(e,t,r);var o,s,l,u,p,b,w=f.slice(),_=typeof t,x=this,k=0;for("object"!==_&&"string"!==_&&(r=t,t=null),r&&"function"!=typeof r&&(r=i.parse),o=!(s=g(e||"",t=h(t))).protocol&&!s.slashes,x.slashes=s.slashes||o&&t.slashes,x.protocol=s.protocol||t.protocol||"",e=s.rest,("file:"===s.protocol&&(2!==s.slashesCount||c.test(e))||!s.slashes&&(s.protocol||s.slashesCount<2||!m(x.protocol)))&&(w[3]=[/(.*)/,"pathname"]);k<w.length;k++){if("function"==typeof(u=w[k])){e=u(e,x);continue}l=u[0],b=u[1],l!=l?x[b]=e:"string"==typeof l?~(p="@"===l?e.lastIndexOf(l):e.indexOf(l))&&("number"==typeof u[2]?(x[b]=e.slice(0,p),e=e.slice(p+u[2])):(x[b]=e.slice(p),e=e.slice(0,p))):(p=l.exec(e))&&(x[b]=p[1],e=e.slice(0,p.index)),x[b]=x[b]||o&&u[3]&&t[b]||"",u[4]&&(x[b]=x[b].toLowerCase())}r&&(x.query=r(x.query)),o&&t.slashes&&"/"!==x.pathname.charAt(0)&&(""!==x.pathname||""!==t.pathname)&&(x.pathname=v(x.pathname,t.pathname)),"/"!==x.pathname.charAt(0)&&m(x.protocol)&&(x.pathname="/"+x.pathname),n(x.port,x.protocol)||(x.host=x.hostname,x.port=""),x.username=x.password="",x.auth&&(~(p=x.auth.indexOf(":"))?(x.username=x.auth.slice(0,p),x.username=encodeURIComponent(decodeURIComponent(x.username)),x.password=x.auth.slice(p+1),x.password=encodeURIComponent(decodeURIComponent(x.password))):x.username=encodeURIComponent(decodeURIComponent(x.auth)),x.auth=x.password?x.username+":"+x.password:x.username),x.origin="file:"!==x.protocol&&m(x.protocol)&&x.host?x.protocol+"//"+x.host:"null",x.href=x.toString()}y.prototype={set:function(e,t,r){var o=this;switch(e){case"query":"string"==typeof t&&t.length&&(t=(r||i.parse)(t)),o[e]=t;break;case"port":o[e]=t,n(t,o.protocol)?t&&(o.host=o.hostname+":"+t):(o.host=o.hostname,o[e]="");break;case"hostname":o[e]=t,o.port&&(t+=":"+o.port),o.host=t;break;case"host":o[e]=t,l.test(t)?(o.port=(t=t.split(":")).pop(),o.hostname=t.join(":")):(o.hostname=t,o.port="");break;case"protocol":o.protocol=t.toLowerCase(),o.slashes=!r;break;case"pathname":case"hash":if(t){var a="pathname"===e?"/":"#";o[e]=t.charAt(0)!==a?a+t:t}else o[e]=t;break;case"username":case"password":o[e]=encodeURIComponent(t);break;case"auth":var s=t.indexOf(":");~s?(o.username=t.slice(0,s),o.username=encodeURIComponent(decodeURIComponent(o.username)),o.password=t.slice(s+1),o.password=encodeURIComponent(decodeURIComponent(o.password))):o.username=encodeURIComponent(decodeURIComponent(t))}for(var u=0;u<f.length;u++){var c=f[u];c[4]&&(o[c[1]]=o[c[1]].toLowerCase())}return o.auth=o.password?o.username+":"+o.password:o.username,o.origin="file:"!==o.protocol&&m(o.protocol)&&o.host?o.protocol+"//"+o.host:"null",o.href=o.toString(),o},toString:function(e){e&&"function"==typeof e||(e=i.stringify);var t,r=this,n=r.host,o=r.protocol;o&&":"!==o.charAt(o.length-1)&&(o+=":");var a=o+(r.protocol&&r.slashes||m(r.protocol)?"//":"");return r.username?(a+=r.username,r.password&&(a+=":"+r.password),a+="@"):r.password?(a+=":"+r.password,a+="@"):"file:"!==r.protocol&&m(r.protocol)&&!n&&"/"!==r.pathname&&(a+="@"),(":"===n[n.length-1]||l.test(r.hostname)&&!r.port)&&(n+=":"),a+=n+r.pathname,(t="object"==typeof r.query?e(r.query):r.query)&&(a+="?"!==t.charAt(0)?"?"+t:t),r.hash&&(a+=r.hash),a}},y.extractProtocol=g,y.location=h,y.trimLeft=d,y.qs=i,e.exports=y},488:function(){}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.loaded=!0,r.exports}(()=>{__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t}})(),(()=>{__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}})(),(()=>{__webpack_require__.g=(()=>{if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}})()})(),(()=>{__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{__webpack_require__.nmd=e=>(e.paths=[],e.children||(e.children=[]),e)})();var url_parse=__webpack_require__(337),url_parse_default=__webpack_require__.n(url_parse);function safeJsonParse(e){try{if(!e)return null;return JSON.parse(e)}catch(e){return null}}function safeJsonParseWithZod(e,t){let r=safeJsonParse(e);if(!r)return null;let{success:n,data:i,error:o}=t.safeParse(r);return n?i:(console.warn(`Failed to parse JSON with Zod: ${e}`,o),null)}function $constructor(e,t,r){function n(r,n){var i;for(let o in Object.defineProperty(r,"_zod",{value:r._zod??{},enumerable:!1}),(i=r._zod).traits??(i.traits=new Set),r._zod.traits.add(e),t(r,n),a.prototype)o in r||Object.defineProperty(r,o,{value:a.prototype[o].bind(r)});r._zod.constr=a,r._zod.def=n}let i=r?.Parent??Object;class o extends i{}function a(e){var t;let i=r?.Parent?new o:this;for(let r of(n(i,e),(t=i._zod).deferred??(t.deferred=[]),i._zod.deferred))r();return i}return Object.defineProperty(o,"name",{value:e}),Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}Object.freeze({status:"aborted"}),Symbol("zod_brand");class $ZodAsyncError extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}let globalConfig={};function core_config(e){return e&&Object.assign(globalConfig,e),globalConfig}let cuid=/^[cC][^\s-]{8,}$/,cuid2=/^[0-9a-z]+$/,ulid=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xid=/^[0-9a-vA-V]{20}$/,ksuid=/^[A-Za-z0-9]{27}$/,nanoid=/^[a-zA-Z0-9_-]{21}$/,regexes_duration=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,guid=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,uuid=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,email=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_emoji="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function emoji(){return RegExp(_emoji,"u")}let ipv4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,cidrv4=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cidrv6=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,regexes_base64=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url=/^[A-Za-z0-9_-]*$/,hostname=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,e164=/^\+(?:[0-9]){6,14}[0-9]$/,dateSource="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",regexes_date=RegExp(`^${dateSource}$`);function timeSource(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function regexes_time(e){return RegExp(`^${timeSource(e)}$`)}function datetime(e){let t=timeSource({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return RegExp(`^${dateSource}T(?:${n})$`)}let regexes_string=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return RegExp(`^${t}$`)},bigint=/^\d+n?$/,integer=/^\d+$/,regexes_number=/^-?\d+(?:\.\d+)?/i,regexes_boolean=/true|false/i,_null=/null/i,_undefined=/undefined/i,lowercase=/^[^A-Z]*$/,uppercase=/^[^a-z]*$/;function getEnumValues(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function joinValues(e,t="|"){return e.map(e=>stringifyPrimitive(e)).join(t)}function jsonStringifyReplacer(e,t){return"bigint"==typeof t?t.toString():t}function util_cached(e){let t=!1;return{get value(){if(!t){let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error("cached value already set")}}}function nullish(e){return null==e}function cleanRegex(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function floatSafeRemainder(e,t){let r=(e.toString().split(".")[1]||"").length,n=t.toString(),i=(n.split(".")[1]||"").length;if(0===i&&/\d?e-\d?/.test(n)){let e=n.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let o=r>i?r:i;return Number.parseInt(e.toFixed(o).replace(".",""))%Number.parseInt(t.toFixed(o).replace(".",""))/10**o}let EVALUATING=Symbol("evaluating");function defineLazy(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==EVALUATING)return void 0===n&&(n=EVALUATING,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function objectClone(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function assignProp(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function mergeDefs(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function esc(e){return JSON.stringify(e)}let captureStackTrace="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function util_isObject(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let util_allowsEval=util_cached(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function isPlainObject(e){if(!1===util_isObject(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!1!==util_isObject(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function shallowClone(e){return isPlainObject(e)?{...e}:e}let propertyKeyTypes=new Set(["string","number","symbol"]),primitiveTypes=new Set(["string","number","bigint","boolean","symbol","undefined"]);function escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function clone(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function normalizeParams(e){let t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return(delete t.message,"string"==typeof t.error)?{...t,error:()=>t.error}:t}function stringifyPrimitive(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}function optionalKeys(e){return Object.keys(e).filter(t=>"optional"===e[t]._zod.optin&&"optional"===e[t]._zod.optout)}let NUMBER_FORMAT_RANGES={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-0x80000000,0x7fffffff],uint32:[0,0xffffffff],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},BIGINT_FORMAT_RANGES={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function pick(e,t){let r=e._zod.def,n=mergeDefs(e._zod.def,{get shape(){let e={};for(let n in t){if(!(n in r.shape))throw Error(`Unrecognized key: "${n}"`);t[n]&&(e[n]=r.shape[n])}return assignProp(this,"shape",e),e},checks:[]});return clone(e,n)}function omit(e,t){let r=e._zod.def,n=mergeDefs(e._zod.def,{get shape(){let n={...e._zod.def.shape};for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return assignProp(this,"shape",n),n},checks:[]});return clone(e,n)}function extend(e,t){if(!isPlainObject(t))throw Error("Invalid input to extend: expected a plain object");let r=mergeDefs(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return assignProp(this,"shape",r),r},checks:[]});return clone(e,r)}function merge(e,t){let r=mergeDefs(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return assignProp(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return clone(e,r)}function partial(e,t,r){let n=mergeDefs(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let t in r){if(!(t in n))throw Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(let t in n)i[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return assignProp(this,"shape",i),i},checks:[]});return clone(t,n)}function required(e,t,r){let n=mergeDefs(t._zod.def,{get shape(){let n=t._zod.def.shape,i={...n};if(r)for(let t in r){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);r[t]&&(i[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(let t in n)i[t]=new e({type:"nonoptional",innerType:n[t]});return assignProp(this,"shape",i),i},checks:[]});return clone(t,n)}function aborted(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function prefixIssues(e,t){return t.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function unwrapMessage(e){return"string"==typeof e?e:e?.message}function finalizeIssue(e,t,r){let n={...e,path:e.path??[]};return e.message||(n.message=unwrapMessage(e.inst?._zod.def?.error?.(e))??unwrapMessage(t?.error?.(e))??unwrapMessage(r.customError?.(e))??unwrapMessage(r.localeError?.(e))??"Invalid input"),delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function getSizableOrigin(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function getLengthableOrigin(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function util_issue(...e){let[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}let $ZodCheck=$constructor("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),numericOriginMap={number:"number",bigint:"bigint",object:"date"},$ZodCheckLessThan=$constructor("$ZodCheckLessThan",(e,t)=>{$ZodCheck.init(e,t);let r=numericOriginMap[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??1/0;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckGreaterThan=$constructor("$ZodCheckGreaterThan",(e,t)=>{$ZodCheck.init(e,t);let r=numericOriginMap[typeof t.value];e._zod.onattach.push(e=>{let r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??-1/0;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckMultipleOf=$constructor("$ZodCheckMultipleOf",(e,t)=>{$ZodCheck.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0===floatSafeRemainder(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckNumberFormat=$constructor("$ZodCheckNumberFormat",(e,t)=>{$ZodCheck.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,o]=NUMBER_FORMAT_RANGES[t.format];e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,n.minimum=i,n.maximum=o,r&&(n.pattern=integer)}),e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s))return void a.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}))}s<i&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inst:e})}}),$ZodCheckBigIntFormat=$constructor("$ZodCheckBigIntFormat",(e,t)=>{$ZodCheck.init(e,t);let[r,n]=BIGINT_FORMAT_RANGES[t.format];e._zod.onattach.push(e=>{let i=e._zod.bag;i.format=t.format,i.minimum=r,i.maximum=n}),e._zod.check=i=>{let o=i.value;o<r&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),o>n&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:n,inst:e})}}),$ZodCheckMaxSize=$constructor("$ZodCheckMaxSize",(e,t)=>{var r;$ZodCheck.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value;n.size<=t.maximum||r.issues.push({origin:getSizableOrigin(n),code:"too_big",maximum:t.maximum,input:n,inst:e,continue:!t.abort})}}),$ZodCheckMinSize=$constructor("$ZodCheckMinSize",(e,t)=>{var r;$ZodCheck.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value;n.size>=t.minimum||r.issues.push({origin:getSizableOrigin(n),code:"too_small",minimum:t.minimum,input:n,inst:e,continue:!t.abort})}}),$ZodCheckSizeEquals=$constructor("$ZodCheckSizeEquals",(e,t)=>{var r;$ZodCheck.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.size}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.size,r.maximum=t.size,r.size=t.size}),e._zod.check=r=>{let n=r.value,i=n.size;if(i===t.size)return;let o=i>t.size;r.issues.push({origin:getSizableOrigin(n),...o?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckMaxLength=$constructor("$ZodCheckMaxLength",(e,t)=>{var r;$ZodCheck.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value;if(n.length<=t.maximum)return;let i=getLengthableOrigin(n);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),$ZodCheckMinLength=$constructor("$ZodCheckMinLength",(e,t)=>{var r;$ZodCheck.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value;if(n.length>=t.minimum)return;let i=getLengthableOrigin(n);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),$ZodCheckLengthEquals=$constructor("$ZodCheckLengthEquals",(e,t)=>{var r;$ZodCheck.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return!nullish(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{let n=r.value,i=n.length;if(i===t.length)return;let o=getLengthableOrigin(n),a=i>t.length;r.issues.push({origin:o,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckStringFormat=$constructor("$ZodCheckStringFormat",(e,t)=>{var r,n;$ZodCheck.init(e,t),e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),$ZodCheckRegex=$constructor("$ZodCheckRegex",(e,t)=>{$ZodCheckStringFormat.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),$ZodCheckLowerCase=$constructor("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lowercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckUpperCase=$constructor("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=uppercase),$ZodCheckStringFormat.init(e,t)}),$ZodCheckIncludes=$constructor("$ZodCheckIncludes",(e,t)=>{$ZodCheck.init(e,t);let r=escapeRegex(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckStartsWith=$constructor("$ZodCheckStartsWith",(e,t)=>{$ZodCheck.init(e,t);let r=RegExp(`^${escapeRegex(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckEndsWith=$constructor("$ZodCheckEndsWith",(e,t)=>{$ZodCheck.init(e,t);let r=RegExp(`.*${escapeRegex(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),$ZodCheckMimeType=$constructor("$ZodCheckMimeType",(e,t)=>{$ZodCheck.init(e,t);let r=new Set(t.mime);e._zod.onattach.push(e=>{e._zod.bag.mime=t.mime}),e._zod.check=n=>{r.has(n.value.type)||n.issues.push({code:"invalid_value",values:t.mime,input:n.value.type,inst:e,continue:!t.abort})}}),$ZodCheckOverwrite=$constructor("$ZodCheckOverwrite",(e,t)=>{$ZodCheck.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Doc{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){return Function(...this?.args,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}let errors_initializer=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,jsonStringifyReplacer,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$ZodError=$constructor("$ZodError",errors_initializer),$ZodRealError=$constructor("$ZodError",errors_initializer,{Parent:Error});function flattenError(e,t=e=>e.message){let r={},n=[];for(let i of e.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}function formatError(e,t){let r=t||function(e){return e.message},n={_errors:[]},i=e=>{for(let t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>i({issues:e}));else if("invalid_key"===t.code)i({issues:t.issues});else if("invalid_element"===t.code)i({issues:t.issues});else if(0===t.path.length)n._errors.push(r(t));else{let e=n,i=0;for(;i<t.path.length;){let n=t.path[i];i===t.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(r(t))):e[n]=e[n]||{_errors:[]},e=e[n],i++}}};return i(e),n}function toDotPath(e){let t=[];for(let r of e.map(e=>"object"==typeof e?e.key:e))"number"==typeof r?t.push(`[${r}]`):"symbol"==typeof r?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function prettifyError(e){let t=[];for(let r of[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length))t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${toDotPath(r.path)}`);return t.join("\n")}let _parse=e=>(t,r,n,i)=>{let o=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise)throw new $ZodAsyncError;if(a.issues.length){let t=new(i?.Err??e)(a.issues.map(e=>finalizeIssue(e,o,core_config())));throw captureStackTrace(t,i?.callee),t}return a.value},_parseAsync=e=>async(t,r,n,i)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},a=t._zod.run({value:r,issues:[]},o);if(a instanceof Promise&&(a=await a),a.issues.length){let t=new(i?.Err??e)(a.issues.map(e=>finalizeIssue(e,o,core_config())));throw captureStackTrace(t,i?.callee),t}return a.value},_safeParse=e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new $ZodAsyncError;return o.issues.length?{success:!1,error:new(e??$ZodError)(o.issues.map(e=>finalizeIssue(e,i,core_config())))}:{success:!0,data:o.value}},safeParse=_safeParse($ZodRealError),_safeParseAsync=e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},o=t._zod.run({value:r,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>finalizeIssue(e,i,core_config())))}:{success:!0,data:o.value}},safeParseAsync=_safeParseAsync($ZodRealError),versions_version={major:4,minor:0,patch:17},$ZodType=$constructor("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=versions_version;let n=[...e._zod.def.checks??[]];for(let t of(e._zod.traits.has("$ZodCheck")&&n.unshift(e),n))for(let r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,r)=>{let n,i=aborted(e);for(let o of t){if(o._zod.def.when){if(!o._zod.def.when(e))continue}else if(i)continue;let t=e.issues.length,a=o._zod.check(e);if(a instanceof Promise&&r?.async===!1)throw new $ZodAsyncError;if(n||a instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await a,e.issues.length!==t&&(i||(i=aborted(e,t)))});else{if(e.issues.length===t)continue;i||(i=aborted(e,t))}}return n?n.then(()=>e):e};e._zod.run=(r,i)=>{let o=e._zod.parse(r,i);if(o instanceof Promise){if(!1===i.async)throw new $ZodAsyncError;return o.then(e=>t(e,n,i))}return t(o,n,i)}}e["~standard"]={validate:t=>{try{let r=safeParse(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return safeParseAsync(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),$ZodString=$constructor("$ZodString",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??regexes_string(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),$ZodStringFormat=$constructor("$ZodStringFormat",(e,t)=>{$ZodCheckStringFormat.init(e,t),$ZodString.init(e,t)}),$ZodGUID=$constructor("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=guid),$ZodStringFormat.init(e,t)}),$ZodUUID=$constructor("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=uuid(e))}else t.pattern??(t.pattern=uuid());$ZodStringFormat.init(e,t)}),$ZodEmail=$constructor("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=email),$ZodStringFormat.init(e,t)}),$ZodURL=$constructor("$ZodURL",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),$ZodEmoji=$constructor("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=emoji()),$ZodStringFormat.init(e,t)}),$ZodNanoID=$constructor("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=nanoid),$ZodStringFormat.init(e,t)}),$ZodCUID=$constructor("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=cuid),$ZodStringFormat.init(e,t)}),$ZodCUID2=$constructor("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=cuid2),$ZodStringFormat.init(e,t)}),$ZodULID=$constructor("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ulid),$ZodStringFormat.init(e,t)}),$ZodXID=$constructor("$ZodXID",(e,t)=>{t.pattern??(t.pattern=xid),$ZodStringFormat.init(e,t)}),$ZodKSUID=$constructor("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ksuid),$ZodStringFormat.init(e,t)}),$ZodISODateTime=$constructor("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=datetime(t)),$ZodStringFormat.init(e,t)}),$ZodISODate=$constructor("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=regexes_date),$ZodStringFormat.init(e,t)}),$ZodISOTime=$constructor("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=regexes_time(t)),$ZodStringFormat.init(e,t)}),$ZodISODuration=$constructor("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=regexes_duration),$ZodStringFormat.init(e,t)}),$ZodIPv4=$constructor("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ipv4),$ZodStringFormat.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv4"})}),$ZodIPv6=$constructor("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=ipv6),$ZodStringFormat.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),$ZodCIDRv4=$constructor("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cidrv4),$ZodStringFormat.init(e,t)}),$ZodCIDRv6=$constructor("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cidrv6),$ZodStringFormat.init(e,t),e._zod.check=r=>{let[n,i]=r.value.split("/");try{if(!i)throw Error();let e=Number(i);if(`${e}`!==i||e<0||e>128)throw Error();new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function isValidBase64(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let $ZodBase64=$constructor("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=regexes_base64),$ZodStringFormat.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{isValidBase64(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function isValidBase64URL(e){if(!base64url.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return isValidBase64(t.padEnd(4*Math.ceil(t.length/4),"="))}let $ZodBase64URL=$constructor("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=base64url),$ZodStringFormat.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{isValidBase64URL(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),$ZodE164=$constructor("$ZodE164",(e,t)=>{t.pattern??(t.pattern=e164),$ZodStringFormat.init(e,t)});function isValidJWT(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[n]=r;if(!n)return!1;let i=JSON.parse(atob(n));if("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))return!1;return!0}catch{return!1}}let $ZodJWT=$constructor("$ZodJWT",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=r=>{isValidJWT(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),$ZodCustomStringFormat=$constructor("$ZodCustomStringFormat",(e,t)=>{$ZodStringFormat.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),$ZodNumber=$constructor("$ZodNumber",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=e._zod.bag.pattern??regexes_number,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}let i=r.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return r;let o="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),r}}),$ZodNumberFormat=$constructor("$ZodNumber",(e,t)=>{$ZodCheckNumberFormat.init(e,t),$ZodNumber.init(e,t)}),$ZodBoolean=$constructor("$ZodBoolean",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=regexes_boolean,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch(e){}let i=r.value;return"boolean"==typeof i||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),$ZodBigInt=$constructor("$ZodBigInt",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=bigint,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(e){}return"bigint"==typeof r.value||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),$ZodBigIntFormat=$constructor("$ZodBigInt",(e,t)=>{$ZodCheckBigIntFormat.init(e,t),$ZodBigInt.init(e,t)}),$ZodSymbol=$constructor("$ZodSymbol",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,r)=>{let n=t.value;return"symbol"==typeof n||t.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),t}}),$ZodUndefined=$constructor("$ZodUndefined",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=_undefined,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(t,r)=>{let n=t.value;return void 0===n||t.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),t}}),$ZodNull=$constructor("$ZodNull",(e,t)=>{$ZodType.init(e,t),e._zod.pattern=_null,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{let n=t.value;return null===n||t.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),t}}),$ZodAny=$constructor("$ZodAny",(e,t)=>{$ZodType.init(e,t),e._zod.parse=e=>e}),$ZodUnknown=$constructor("$ZodUnknown",(e,t)=>{$ZodType.init(e,t),e._zod.parse=e=>e}),$ZodNever=$constructor("$ZodNever",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)}),$ZodVoid=$constructor("$ZodVoid",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,r)=>{let n=t.value;return void 0===n||t.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),t}}),$ZodDate=$constructor("$ZodDate",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(e){}let i=r.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),r}});function handleArrayResult(e,t,r){e.issues.length&&t.issues.push(...prefixIssues(r,e.issues)),t.value[r]=e.value}let $ZodArray=$constructor("$ZodArray",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let o=[];for(let e=0;e<i.length;e++){let a=i[e],s=t.element._zod.run({value:a,issues:[]},n);s instanceof Promise?o.push(s.then(t=>handleArrayResult(t,r,e))):handleArrayResult(s,r,e)}return o.length?Promise.all(o).then(()=>r):r}});function handlePropertyResult(e,t,r,n){e.issues.length&&t.issues.push(...prefixIssues(r,e.issues)),void 0===e.value?r in n&&(t.value[r]=void 0):t.value[r]=e.value}let $ZodObject=$constructor("$ZodObject",(e,t)=>{let r,n;$ZodType.init(e,t);let i=util_cached(()=>{let e=Object.keys(t.shape);for(let r of e)if(!t.shape[r]._zod.traits.has("$ZodType"))throw Error(`Invalid element at key "${r}": expected a Zod schema`);let r=optionalKeys(t.shape);return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}});defineLazy(e._zod,"propValues",()=>{let e=t.shape,r={};for(let t in e){let n=e[t]._zod;if(n.values)for(let e of(r[t]??(r[t]=new Set),n.values))r[t].add(e)}return r});let o=e=>{let t=new Doc(["shape","payload","ctx"]),r=i.value,n=e=>{let t=esc(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");let o=Object.create(null),a=0;for(let e of r.keys)o[e]=`key_${a++}`;for(let e of(t.write("const newResult = {}"),r.keys)){let r=o[e],i=esc(e);t.write(`const ${r} = ${n(e)};`),t.write(`
|
|
2
|
+
if (${r}.issues.length) {
|
|
3
|
+
payload.issues = payload.issues.concat(${r}.issues.map(iss => ({
|
|
4
4
|
...iss,
|
|
5
5
|
path: iss.path ? [${i}, ...iss.path] : [${i}]
|
|
6
6
|
})));
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
if (${
|
|
9
|
+
if (${r}.value === undefined) {
|
|
10
10
|
if (${i} in input) {
|
|
11
11
|
newResult[${i}] = undefined;
|
|
12
12
|
}
|
|
13
13
|
} else {
|
|
14
|
-
newResult[${i}] = ${
|
|
14
|
+
newResult[${i}] = ${r}.value;
|
|
15
15
|
}
|
|
16
|
-
`)}t.write("payload.value = newResult;"),t.write("return payload;");let s=t.compile();return(t,n)=>s(e,t,n)},a=util_isObject,s=!globalConfig.jitless,l=util_allowsEval,u=s&&l.value,c=t.catchall;e._zod.parse=(l,d)=>{r??(r=i.value);let f=l.value;if(!a(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;let h=[];if(s&&u&&d?.async===!1&&!0!==d.jitless)n||(n=o(t.shape)),l=n(l,d);else{l.value={};let e=r.shape;for(let t of r.keys){let n=e[t]._zod.run({value:f[t],issues:[]},d);n instanceof Promise?h.push(n.then(e=>handlePropertyResult(e,l,t,f))):handlePropertyResult(n,l,t,f)}}if(!c)return h.length?Promise.all(h).then(()=>l):l;let p=[],m=r.keySet,g=c._zod,v=g.def.type;for(let e of Object.keys(f)){if(m.has(e))continue;if("never"===v){p.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?h.push(t.then(t=>handlePropertyResult(t,l,e,f))):handlePropertyResult(t,l,e,f)}return(p.length&&l.issues.push({code:"unrecognized_keys",keys:p,input:f,inst:e}),h.length)?Promise.all(h).then(()=>l):l}});function handleUnionResults(e,t,n,r){for(let n of e)if(0===n.issues.length)return t.value=n.value,t;let i=e.filter(e=>!aborted(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>finalizeIssue(e,r,core_config())))}),t)}const $ZodUnion=$constructor("$ZodUnion",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),defineLazy(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),defineLazy(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),defineLazy(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>cleanRegex(e.source)).join("|")})$`)}});let n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(n)return r(i,o);let a=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},o);if(t instanceof Promise)s.push(t),a=!0;else{if(0===t.issues.length)return t;s.push(t)}}return a?Promise.all(s).then(t=>handleUnionResults(t,i,e,o)):handleUnionResults(s,i,e,o)}}),$ZodDiscriminatedUnion=$constructor("$ZodDiscriminatedUnion",(e,t)=>{$ZodUnion.init(e,t);let n=e._zod.parse;defineLazy(e._zod,"propValues",()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r))for(let r of(e[t]||(e[t]=new Set),n))e[t].add(r)}return e});let r=util_cached(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,o)=>{let a=i.value;if(!util_isObject(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;let s=r.value.get(a?.[t.discriminator]);return s?s._zod.run(i,o):t.unionFallback?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),$ZodIntersection=$constructor("$ZodIntersection",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),o=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([t,n])=>handleIntersectionResults(e,t,n)):handleIntersectionResults(e,i,o)}});function mergeValues(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(util_isPlainObject(e)&&util_isPlainObject(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};for(let n of r){let r=mergeValues(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=mergeValues(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function handleIntersectionResults(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),aborted(e))return e;let r=mergeValues(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}(e,t)=>{$ZodType.init(e,t);let n=t.items,r=n.length-[...n].reverse().findIndex(e=>"optional"!==e._zod.optin);e._zod.parse=(i,o)=>{let a=i.value;if(!Array.isArray(a))return i.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=[];let s=[];if(!t.rest){let t=a.length>n.length,o=a.length<r-1;if(t||o)return i.issues.push({...t?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:a,inst:e,origin:"array"}),i}let l=-1;for(let e of n){if(++l>=a.length&&l>=r)continue;let t=e._zod.run({value:a[l],issues:[]},o);t instanceof Promise?s.push(t.then(e=>handleTupleResult(e,i,l))):handleTupleResult(t,i,l)}if(t.rest)for(let e of a.slice(n.length)){l++;let n=t.rest._zod.run({value:e,issues:[]},o);n instanceof Promise?s.push(n.then(e=>handleTupleResult(e,i,l))):handleTupleResult(n,i,l)}return s.length?Promise.all(s).then(()=>i):i}};function handleTupleResult(e,t,n){e.issues.length&&t.issues.push(...prefixIssues(n,e.issues)),t.value[n]=e.value}const $ZodRecord=$constructor("$ZodRecord",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!util_isPlainObject(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),n;let o=[];if(t.keyType._zod.values){let a,s=t.keyType._zod.values;for(let e of(n.value={},s))if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){let a=t.valueType._zod.run({value:i[e],issues:[]},r);a instanceof Promise?o.push(a.then(t=>{t.issues.length&&n.issues.push(...prefixIssues(e,t.issues)),n.value[e]=t.value})):(a.issues.length&&n.issues.push(...prefixIssues(e,a.issues)),n.value[e]=a.value)}for(let e in i)s.has(e)||(a=a??[]).push(e);a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a})}else for(let a of(n.value={},Reflect.ownKeys(i))){if("__proto__"===a)continue;let s=t.keyType._zod.run({value:a,issues:[]},r);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(s.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>finalizeIssue(e,r,core_config())),input:a,path:[a],inst:e}),n.value[s.value]=s.value;continue}let l=t.valueType._zod.run({value:i[a],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...prefixIssues(a,e.issues)),n.value[s.value]=e.value})):(l.issues.length&&n.issues.push(...prefixIssues(a,l.issues)),n.value[s.value]=l.value)}return o.length?Promise.all(o).then(()=>n):n}}),$ZodMap=$constructor("$ZodMap",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Map))return n.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),n;let o=[];for(let[a,s]of(n.value=new Map,i)){let l=t.keyType._zod.run({value:a,issues:[]},r),u=t.valueType._zod.run({value:s,issues:[]},r);l instanceof Promise||u instanceof Promise?o.push(Promise.all([l,u]).then(([t,o])=>{handleMapResult(t,o,n,a,i,e,r)})):handleMapResult(l,u,n,a,i,e,r)}return o.length?Promise.all(o).then(()=>n):n}});function handleMapResult(e,t,n,r,i,o,a){e.issues.length&&(propertyKeyTypes.has(typeof r)?n.issues.push(...prefixIssues(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(e=>finalizeIssue(e,a,core_config()))})),t.issues.length&&(propertyKeyTypes.has(typeof r)?n.issues.push(...prefixIssues(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:r,issues:t.issues.map(e=>finalizeIssue(e,a,core_config()))})),n.value.set(e.value,t.value)}(e,t)=>{$ZodType.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!(i instanceof Set))return n.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),n;let o=[];for(let e of(n.value=new Set,i)){let i=t.valueType._zod.run({value:e,issues:[]},r);i instanceof Promise?o.push(i.then(e=>handleSetResult(e,n))):handleSetResult(i,n)}return o.length?Promise.all(o).then(()=>n):n}};function handleSetResult(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const $ZodEnum=$constructor("$ZodEnum",(e,t)=>{$ZodType.init(e,t);let n=getEnumValues(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>propertyKeyTypes.has(typeof e)).map(e=>"string"==typeof e?escapeRegex(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{let o=t.value;return r.has(o)||t.issues.push({code:"invalid_value",values:n,input:o,inst:e}),t}}),$ZodLiteral=$constructor("$ZodLiteral",(e,t)=>{if($ZodType.init(e,t),0===t.values.length)throw Error("Cannot create literal schema with no valid values");e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>"string"==typeof e?escapeRegex(e):e?escapeRegex(e.toString()):String(e)).join("|")})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),n}}),$ZodFile=$constructor("$ZodFile",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,n)=>{let r=t.value;return r instanceof File||t.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),t}}),$ZodTransform=$constructor("$ZodTransform",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(e,n)=>{let r=t.transform(e.value,e);if(n.async)return(r instanceof Promise?r:Promise.resolve(r)).then(t=>(e.value=t,e));if(r instanceof Promise)throw new $ZodAsyncError;return e.value=r,e}});function handleOptionalResult(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const $ZodOptional=$constructor("$ZodOptional",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",e._zod.optout="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),defineLazy(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${cleanRegex(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>handleOptionalResult(t,e.value)):handleOptionalResult(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),$ZodNullable=$constructor("$ZodNullable",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${cleanRegex(e.source)}|null)$`):void 0}),defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),$ZodDefault=$constructor("$ZodDefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(void 0===e.value)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>handleDefaultResult(e,t)):handleDefaultResult(r,t)}});function handleDefaultResult(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const $ZodPrefault=$constructor("$ZodPrefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),$ZodNonOptional=$constructor("$ZodNonOptional",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>handleNonOptionalResult(t,e)):handleNonOptionalResult(i,e)}});function handleNonOptionalResult(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const $ZodSuccess=$constructor("$ZodSuccess",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>(e.value=0===t.issues.length,e)):(e.value=0===r.issues.length,e)}}),$ZodCatch=$constructor("$ZodCatch",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>finalizeIssue(e,n,core_config()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>finalizeIssue(e,n,core_config()))},input:e.value}),e.issues=[]),e)}}),$ZodNaN=$constructor("$ZodNaN",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,n)=>("number"==typeof t.value&&Number.isNaN(t.value)||t.issues.push({input:t.value,inst:e,expected:"nan",code:"invalid_type"}),t)}),$ZodPipe=$constructor("$ZodPipe",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>t.in._zod.values),defineLazy(e._zod,"optin",()=>t.in._zod.optin),defineLazy(e._zod,"optout",()=>t.out._zod.optout),defineLazy(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>handlePipeResult(e,t,n)):handlePipeResult(r,t,n)}});function handlePipeResult(e,t,n){return e.issues.length?e:t.out._zod.run({value:e.value,issues:e.issues},n)}const $ZodReadonly=$constructor("$ZodReadonly",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"propValues",()=>t.innerType._zod.propValues),defineLazy(e._zod,"values",()=>t.innerType._zod.values),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(handleReadonlyResult):handleReadonlyResult(r)}});function handleReadonlyResult(e){return e.value=Object.freeze(e.value),e}const $ZodTemplateLiteral=$constructor("$ZodTemplateLiteral",(e,t)=>{$ZodType.init(e,t);let n=[];for(let e of t.parts)if("object"==typeof e&&null!==e){if(!e._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);let t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw Error(`Invalid template literal part: ${e._zod.traits}`);let r=+!!t.startsWith("^"),i=t.endsWith("$")?t.length-1:t.length;n.push(t.slice(r,i))}else if(null===e||primitiveTypes.has(typeof e))n.push(escapeRegex(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${n.join("")}$`),e._zod.parse=(n,r)=>("string"!=typeof n.value?n.issues.push({input:n.value,inst:e,expected:"template_literal",code:"invalid_type"}):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(n.value)||n.issues.push({input:n.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source})),n)}),$ZodPromise=$constructor("$ZodPromise",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(e,n)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},n))}),$ZodLazy=$constructor("$ZodLazy",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"innerType",()=>t.getter()),defineLazy(e._zod,"pattern",()=>e._zod.innerType._zod.pattern),defineLazy(e._zod,"propValues",()=>e._zod.innerType._zod.propValues),defineLazy(e._zod,"optin",()=>e._zod.innerType._zod.optin??void 0),defineLazy(e._zod,"optout",()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),$ZodCustom=$constructor("$ZodCustom",(e,t)=>{$ZodCheck.init(e,t),$ZodType.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>handleRefineResult(t,n,r,e));handleRefineResult(i,n,r,e)}});function handleRefineResult(e,t,n,r){if(!e){let e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(util_issue(e))}}const en_parsedType=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":if(Array.isArray(e))return"array";if(null===e)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}return t},en_error=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(t){return e[t]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return e=>{switch(e.code){case"invalid_type":return`Invalid input: expected ${e.expected}, received ${en_parsedType(e.input)}`;case"invalid_value":if(1===e.values.length)return`Invalid input: expected ${stringifyPrimitive(e.values[0])}`;return`Invalid option: expected one of ${joinValues(e.values,"|")}`;case"too_big":{let n=e.inclusive?"<=":"<",r=t(e.origin);if(r)return`Too big: expected ${e.origin??"value"} to have ${n}${e.maximum.toString()} ${r.unit??"elements"}`;return`Too big: expected ${e.origin??"value"} to be ${n}${e.maximum.toString()}`}case"too_small":{let n=e.inclusive?">=":">",r=t(e.origin);if(r)return`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`;return`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case"invalid_format":{let t=e;if("starts_with"===t.format)return`Invalid string: must start with "${t.prefix}"`;if("ends_with"===t.format)return`Invalid string: must end with "${t.suffix}"`;if("includes"===t.format)return`Invalid string: must include "${t.includes}"`;if("regex"===t.format)return`Invalid string: must match pattern ${t.pattern}`;return`Invalid ${n[t.format]??e.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${e.divisor}`;case"unrecognized_keys":return`Unrecognized key${e.keys.length>1?"s":""}: ${joinValues(e.keys,", ")}`;case"invalid_key":return`Invalid key in ${e.origin}`;case"invalid_union":default:return"Invalid input";case"invalid_element":return`Invalid value in ${e.origin}`}}};function en(){return{localeError:en_error()}}const zh_CN_error=()=>{let e={string:{unit:"字符",verb:"包含"},file:{unit:"字节",verb:"包含"},array:{unit:"项",verb:"包含"},set:{unit:"项",verb:"包含"}};function t(t){return e[t]??null}let n=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"非数字(NaN)":"数字";case"object":if(Array.isArray(e))return"数组";if(null===e)return"空值(null)";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}return t},r={regex:"输入",email:"电子邮件",url:"URL",emoji:"表情符号",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日期时间",date:"ISO日期",time:"ISO时间",duration:"ISO时长",ipv4:"IPv4地址",ipv6:"IPv6地址",cidrv4:"IPv4网段",cidrv6:"IPv6网段",base64:"base64编码字符串",base64url:"base64url编码字符串",json_string:"JSON字符串",e164:"E.164号码",jwt:"JWT",template_literal:"输入"};return e=>{switch(e.code){case"invalid_type":return`无效输入:期望 ${e.expected},实际接收 ${n(e.input)}`;case"invalid_value":if(1===e.values.length)return`无效输入:期望 ${stringifyPrimitive(e.values[0])}`;return`无效选项:期望以下之一 ${joinValues(e.values,"|")}`;case"too_big":{let n=e.inclusive?"<=":"<",r=t(e.origin);if(r)return`数值过大:期望 ${e.origin??"值"} ${n}${e.maximum.toString()} ${r.unit??"个元素"}`;return`数值过大:期望 ${e.origin??"值"} ${n}${e.maximum.toString()}`}case"too_small":{let n=e.inclusive?">=":">",r=t(e.origin);if(r)return`数值过小:期望 ${e.origin} ${n}${e.minimum.toString()} ${r.unit}`;return`数值过小:期望 ${e.origin} ${n}${e.minimum.toString()}`}case"invalid_format":{let t=e;if("starts_with"===t.format)return`无效字符串:必须以 "${t.prefix}" 开头`;if("ends_with"===t.format)return`无效字符串:必须以 "${t.suffix}" 结尾`;if("includes"===t.format)return`无效字符串:必须包含 "${t.includes}"`;if("regex"===t.format)return`无效字符串:必须满足正则表达式 ${t.pattern}`;return`无效${r[t.format]??e.format}`}case"not_multiple_of":return`无效数字:必须是 ${e.divisor} 的倍数`;case"unrecognized_keys":return`出现未知的键(key): ${joinValues(e.keys,", ")}`;case"invalid_key":return`${e.origin} 中的键(key)无效`;case"invalid_union":return"无效输入";case"invalid_element":return`${e.origin} 中包含无效值(value)`;default:return`无效输入`}}};function zh_CN(){return{localeError:zh_CN_error()}}Symbol("ZodOutput"),Symbol("ZodInput");class $ZodRegistry{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function registry(){return new $ZodRegistry}const globalRegistry=registry();function _string(e,t){return new e({type:"string",...normalizeParams(t)})}function _coercedString(e,t){return new e({type:"string",coerce:!0,...normalizeParams(t)})}function _email(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...normalizeParams(t)})}function _guid(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...normalizeParams(t)})}function _uuid(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _uuidv4(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...normalizeParams(t)})}function _uuidv6(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...normalizeParams(t)})}function _uuidv7(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...normalizeParams(t)})}function _url(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...normalizeParams(t)})}function api_emoji(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...normalizeParams(t)})}function _nanoid(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...normalizeParams(t)})}function _cuid(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _cuid2(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...normalizeParams(t)})}function _ulid(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...normalizeParams(t)})}function _xid(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...normalizeParams(t)})}function _ksuid(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _ipv4(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...normalizeParams(t)})}function _ipv6(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...normalizeParams(t)})}function _cidrv4(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...normalizeParams(t)})}function _cidrv6(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...normalizeParams(t)})}function _base64(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...normalizeParams(t)})}function _base64url(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...normalizeParams(t)})}function _e164(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...normalizeParams(t)})}function _jwt(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...normalizeParams(t)})}function _isoDateTime(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...normalizeParams(t)})}function _isoDate(e,t){return new e({type:"string",format:"date",check:"string_format",...normalizeParams(t)})}function _isoTime(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...normalizeParams(t)})}function _isoDuration(e,t){return new e({type:"string",format:"duration",check:"string_format",...normalizeParams(t)})}function _number(e,t){return new e({type:"number",checks:[],...normalizeParams(t)})}function _coercedNumber(e,t){return new e({type:"number",coerce:!0,checks:[],...normalizeParams(t)})}function _int(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...normalizeParams(t)})}function _boolean(e,t){return new e({type:"boolean",...normalizeParams(t)})}function _any(e){return new e({type:"any"})}function _unknown(e){return new e({type:"unknown"})}function _never(e,t){return new e({type:"never",...normalizeParams(t)})}function _lt(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!1})}function _lte(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!0})}function _gt(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!1})}function _gte(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!0})}function _multipleOf(e,t){return new $ZodCheckMultipleOf({check:"multiple_of",...normalizeParams(t),value:e})}function _maxLength(e,t){return new $ZodCheckMaxLength({check:"max_length",...normalizeParams(t),maximum:e})}function _minLength(e,t){return new $ZodCheckMinLength({check:"min_length",...normalizeParams(t),minimum:e})}function _length(e,t){return new $ZodCheckLengthEquals({check:"length_equals",...normalizeParams(t),length:e})}function _regex(e,t){return new $ZodCheckRegex({check:"string_format",format:"regex",...normalizeParams(t),pattern:e})}function _lowercase(e){return new $ZodCheckLowerCase({check:"string_format",format:"lowercase",...normalizeParams(e)})}function _uppercase(e){return new $ZodCheckUpperCase({check:"string_format",format:"uppercase",...normalizeParams(e)})}function _includes(e,t){return new $ZodCheckIncludes({check:"string_format",format:"includes",...normalizeParams(t),includes:e})}function _startsWith(e,t){return new $ZodCheckStartsWith({check:"string_format",format:"starts_with",...normalizeParams(t),prefix:e})}function _endsWith(e,t){return new $ZodCheckEndsWith({check:"string_format",format:"ends_with",...normalizeParams(t),suffix:e})}function _overwrite(e){return new $ZodCheckOverwrite({check:"overwrite",tx:e})}function _normalize(e){return _overwrite(t=>t.normalize(e))}function _trim(){return _overwrite(e=>e.trim())}function _toLowerCase(){return _overwrite(e=>e.toLowerCase())}function _toUpperCase(){return _overwrite(e=>e.toUpperCase())}function _array(e,t,n){return new e({type:"array",element:t,...normalizeParams(n)})}function _refine(e,t,n){return new e({type:"custom",check:"custom",fn:t,...normalizeParams(n)})}function _superRefine(e){let t=_check(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(util_issue(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(util_issue(r))}},e(n.value,n)));return t}function _check(e,t){let n=new $ZodCheck({check:"custom",...normalizeParams(t)});return n._zod.check=e,n}function _stringbool(e,t){let n=normalizeParams(t),r=n.truthy??["true","1","yes","on","y","enabled"],i=n.falsy??["false","0","no","off","n","disabled"];"sensitive"!==n.case&&(r=r.map(e=>"string"==typeof e?e.toLowerCase():e),i=i.map(e=>"string"==typeof e?e.toLowerCase():e));let o=new Set(r),a=new Set(i),s=e.Pipe??$ZodPipe,l=e.Boolean??$ZodBoolean,u=e.String??$ZodString,c=new(e.Transform??$ZodTransform)({type:"transform",transform:(e,t)=>{let r=e;return"sensitive"!==n.case&&(r=r.toLowerCase()),!!o.has(r)||!a.has(r)&&(t.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:t.value,inst:c,continue:!1}),{})},error:n.error}),d=new s({type:"pipe",in:new u({type:"string",error:n.error}),out:c,error:n.error});return new s({type:"pipe",in:d,out:new l({type:"boolean",error:n.error}),error:n.error})}const ZodISODateTime=$constructor("ZodISODateTime",(e,t)=>{$ZodISODateTime.init(e,t),ZodStringFormat.init(e,t)});function iso_datetime(e){return _isoDateTime(ZodISODateTime,e)}const ZodISODate=$constructor("ZodISODate",(e,t)=>{$ZodISODate.init(e,t),ZodStringFormat.init(e,t)});function iso_date(e){return _isoDate(ZodISODate,e)}const ZodISOTime=$constructor("ZodISOTime",(e,t)=>{$ZodISOTime.init(e,t),ZodStringFormat.init(e,t)});function iso_time(e){return _isoTime(ZodISOTime,e)}const ZodISODuration=$constructor("ZodISODuration",(e,t)=>{$ZodISODuration.init(e,t),ZodStringFormat.init(e,t)});function iso_duration(e){return _isoDuration(ZodISODuration,e)}const classic_errors_initializer=(e,t)=>{$ZodError.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>formatError(e,t)},flatten:{value:t=>flattenError(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)}},isEmpty:{get:()=>0===e.issues.length}})};$constructor("ZodError",classic_errors_initializer);const ZodRealError=$constructor("ZodError",classic_errors_initializer,{Parent:Error}),parse_parse=_parse(ZodRealError),parse_parseAsync=_parseAsync(ZodRealError),parse_safeParse=_safeParse(ZodRealError),parse_safeParseAsync=_safeParseAsync(ZodRealError),ZodType=$constructor("ZodType",(e,t)=>($ZodType.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,n)=>clone(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>parse_parse(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>parse_safeParse(e,t,n),e.parseAsync=async(t,n)=>parse_parseAsync(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>parse_safeParseAsync(e,t,n),e.spa=e.safeParseAsync,e.refine=(t,n)=>e.check(refine(t,n)),e.superRefine=t=>e.check(superRefine(t)),e.overwrite=t=>e.check(_overwrite(t)),e.optional=()=>optional(e),e.nullable=()=>nullable(e),e.nullish=()=>optional(nullable(e)),e.nonoptional=t=>nonoptional(e,t),e.array=()=>schemas_array(e),e.or=t=>union([e,t]),e.and=t=>intersection(e,t),e.transform=t=>pipe(e,transform(t)),e.default=t=>schemas_default(e,t),e.prefault=t=>prefault(e,t),e.catch=t=>schemas_catch(e,t),e.pipe=t=>pipe(e,t),e.readonly=()=>readonly(e),e.describe=t=>{let n=e.clone();return globalRegistry.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>globalRegistry.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return globalRegistry.get(e);let n=e.clone();return globalRegistry.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),_ZodString=$constructor("_ZodString",(e,t)=>{$ZodString.init(e,t),ZodType.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(_regex(...t)),e.includes=(...t)=>e.check(_includes(...t)),e.startsWith=(...t)=>e.check(_startsWith(...t)),e.endsWith=(...t)=>e.check(_endsWith(...t)),e.min=(...t)=>e.check(_minLength(...t)),e.max=(...t)=>e.check(_maxLength(...t)),e.length=(...t)=>e.check(_length(...t)),e.nonempty=(...t)=>e.check(_minLength(1,...t)),e.lowercase=t=>e.check(_lowercase(t)),e.uppercase=t=>e.check(_uppercase(t)),e.trim=()=>e.check(_trim()),e.normalize=(...t)=>e.check(_normalize(...t)),e.toLowerCase=()=>e.check(_toLowerCase()),e.toUpperCase=()=>e.check(_toUpperCase())}),ZodString=$constructor("ZodString",(e,t)=>{$ZodString.init(e,t),_ZodString.init(e,t),e.email=t=>e.check(_email(ZodEmail,t)),e.url=t=>e.check(_url(ZodURL,t)),e.jwt=t=>e.check(_jwt(ZodJWT,t)),e.emoji=t=>e.check(api_emoji(ZodEmoji,t)),e.guid=t=>e.check(_guid(ZodGUID,t)),e.uuid=t=>e.check(_uuid(ZodUUID,t)),e.uuidv4=t=>e.check(_uuidv4(ZodUUID,t)),e.uuidv6=t=>e.check(_uuidv6(ZodUUID,t)),e.uuidv7=t=>e.check(_uuidv7(ZodUUID,t)),e.nanoid=t=>e.check(_nanoid(ZodNanoID,t)),e.guid=t=>e.check(_guid(ZodGUID,t)),e.cuid=t=>e.check(_cuid(ZodCUID,t)),e.cuid2=t=>e.check(_cuid2(ZodCUID2,t)),e.ulid=t=>e.check(_ulid(ZodULID,t)),e.base64=t=>e.check(_base64(ZodBase64,t)),e.base64url=t=>e.check(_base64url(ZodBase64URL,t)),e.xid=t=>e.check(_xid(ZodXID,t)),e.ksuid=t=>e.check(_ksuid(ZodKSUID,t)),e.ipv4=t=>e.check(_ipv4(ZodIPv4,t)),e.ipv6=t=>e.check(_ipv6(ZodIPv6,t)),e.cidrv4=t=>e.check(_cidrv4(ZodCIDRv4,t)),e.cidrv6=t=>e.check(_cidrv6(ZodCIDRv6,t)),e.e164=t=>e.check(_e164(ZodE164,t)),e.datetime=t=>e.check(iso_datetime(t)),e.date=t=>e.check(iso_date(t)),e.time=t=>e.check(iso_time(t)),e.duration=t=>e.check(iso_duration(t))});function schemas_string(e){return _string(ZodString,e)}const ZodStringFormat=$constructor("ZodStringFormat",(e,t)=>{$ZodStringFormat.init(e,t),_ZodString.init(e,t)}),ZodEmail=$constructor("ZodEmail",(e,t)=>{$ZodEmail.init(e,t),ZodStringFormat.init(e,t)}),ZodGUID=$constructor("ZodGUID",(e,t)=>{$ZodGUID.init(e,t),ZodStringFormat.init(e,t)}),ZodUUID=$constructor("ZodUUID",(e,t)=>{$ZodUUID.init(e,t),ZodStringFormat.init(e,t)}),ZodURL=$constructor("ZodURL",(e,t)=>{$ZodURL.init(e,t),ZodStringFormat.init(e,t)}),ZodEmoji=$constructor("ZodEmoji",(e,t)=>{$ZodEmoji.init(e,t),ZodStringFormat.init(e,t)}),ZodNanoID=$constructor("ZodNanoID",(e,t)=>{$ZodNanoID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID=$constructor("ZodCUID",(e,t)=>{$ZodCUID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID2=$constructor("ZodCUID2",(e,t)=>{$ZodCUID2.init(e,t),ZodStringFormat.init(e,t)}),ZodULID=$constructor("ZodULID",(e,t)=>{$ZodULID.init(e,t),ZodStringFormat.init(e,t)}),ZodXID=$constructor("ZodXID",(e,t)=>{$ZodXID.init(e,t),ZodStringFormat.init(e,t)}),ZodKSUID=$constructor("ZodKSUID",(e,t)=>{$ZodKSUID.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv4=$constructor("ZodIPv4",(e,t)=>{$ZodIPv4.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv6=$constructor("ZodIPv6",(e,t)=>{$ZodIPv6.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv4=$constructor("ZodCIDRv4",(e,t)=>{$ZodCIDRv4.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv6=$constructor("ZodCIDRv6",(e,t)=>{$ZodCIDRv6.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64=$constructor("ZodBase64",(e,t)=>{$ZodBase64.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64URL=$constructor("ZodBase64URL",(e,t)=>{$ZodBase64URL.init(e,t),ZodStringFormat.init(e,t)}),ZodE164=$constructor("ZodE164",(e,t)=>{$ZodE164.init(e,t),ZodStringFormat.init(e,t)}),ZodJWT=$constructor("ZodJWT",(e,t)=>{$ZodJWT.init(e,t),ZodStringFormat.init(e,t)}),ZodNumber=$constructor("ZodNumber",(e,t)=>{$ZodNumber.init(e,t),ZodType.init(e,t),e.gt=(t,n)=>e.check(_gt(t,n)),e.gte=(t,n)=>e.check(_gte(t,n)),e.min=(t,n)=>e.check(_gte(t,n)),e.lt=(t,n)=>e.check(_lt(t,n)),e.lte=(t,n)=>e.check(_lte(t,n)),e.max=(t,n)=>e.check(_lte(t,n)),e.int=t=>e.check(schemas_int(t)),e.safe=t=>e.check(schemas_int(t)),e.positive=t=>e.check(_gt(0,t)),e.nonnegative=t=>e.check(_gte(0,t)),e.negative=t=>e.check(_lt(0,t)),e.nonpositive=t=>e.check(_lte(0,t)),e.multipleOf=(t,n)=>e.check(_multipleOf(t,n)),e.step=(t,n)=>e.check(_multipleOf(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function schemas_number(e){return _number(ZodNumber,e)}const ZodNumberFormat=$constructor("ZodNumberFormat",(e,t)=>{$ZodNumberFormat.init(e,t),ZodNumber.init(e,t)});function schemas_int(e){return _int(ZodNumberFormat,e)}const ZodBoolean=$constructor("ZodBoolean",(e,t)=>{$ZodBoolean.init(e,t),ZodType.init(e,t)});function schemas_boolean(e){return _boolean(ZodBoolean,e)}const ZodBigInt=$constructor("ZodBigInt",(e,t)=>{$ZodBigInt.init(e,t),ZodType.init(e,t),e.gte=(t,n)=>e.check(_gte(t,n)),e.min=(t,n)=>e.check(_gte(t,n)),e.gt=(t,n)=>e.check(_gt(t,n)),e.gte=(t,n)=>e.check(_gte(t,n)),e.min=(t,n)=>e.check(_gte(t,n)),e.lt=(t,n)=>e.check(_lt(t,n)),e.lte=(t,n)=>e.check(_lte(t,n)),e.max=(t,n)=>e.check(_lte(t,n)),e.positive=t=>e.check(_gt(BigInt(0),t)),e.negative=t=>e.check(_lt(BigInt(0),t)),e.nonpositive=t=>e.check(_lte(BigInt(0),t)),e.nonnegative=t=>e.check(_gte(BigInt(0),t)),e.multipleOf=(t,n)=>e.check(_multipleOf(t,n));let n=e._zod.bag;e.minValue=n.minimum??null,e.maxValue=n.maximum??null,e.format=n.format??null}),ZodAny=$constructor("ZodAny",(e,t)=>{$ZodAny.init(e,t),ZodType.init(e,t)});function any(){return _any(ZodAny)}const ZodUnknown=$constructor("ZodUnknown",(e,t)=>{$ZodUnknown.init(e,t),ZodType.init(e,t)});function unknown(){return _unknown(ZodUnknown)}const ZodNever=$constructor("ZodNever",(e,t)=>{$ZodNever.init(e,t),ZodType.init(e,t)});function never(e){return _never(ZodNever,e)}const ZodArray=$constructor("ZodArray",(e,t)=>{$ZodArray.init(e,t),ZodType.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(_minLength(t,n)),e.nonempty=t=>e.check(_minLength(1,t)),e.max=(t,n)=>e.check(_maxLength(t,n)),e.length=(t,n)=>e.check(_length(t,n)),e.unwrap=()=>e.element});function schemas_array(e,t){return _array(ZodArray,e,t)}const ZodObject=$constructor("ZodObject",(e,t)=>{$ZodObject.init(e,t),ZodType.init(e,t),defineLazy(e,"shape",()=>t.shape),e.keyof=()=>schemas_enum(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:unknown()}),e.loose=()=>e.clone({...e._zod.def,catchall:unknown()}),e.strict=()=>e.clone({...e._zod.def,catchall:never()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>extend(e,t),e.merge=t=>util_merge(e,t),e.pick=t=>pick(e,t),e.omit=t=>util_omit(e,t),e.partial=(...t)=>partial(ZodOptional,e,t[0]),e.required=(...t)=>required(ZodNonOptional,e,t[0])});function schemas_object(e,t){return new ZodObject({type:"object",get shape(){return assignProp(this,"shape",e?objectClone(e):{}),this.shape},...normalizeParams(t)})}function looseObject(e,t){return new ZodObject({type:"object",get shape(){return assignProp(this,"shape",objectClone(e)),this.shape},catchall:unknown(),...normalizeParams(t)})}const ZodUnion=$constructor("ZodUnion",(e,t)=>{$ZodUnion.init(e,t),ZodType.init(e,t),e.options=t.options});function union(e,t){return new ZodUnion({type:"union",options:e,...normalizeParams(t)})}const ZodIntersection=$constructor("ZodIntersection",(e,t)=>{$ZodIntersection.init(e,t),ZodType.init(e,t)});function intersection(e,t){return new ZodIntersection({type:"intersection",left:e,right:t})}const ZodRecord=$constructor("ZodRecord",(e,t)=>{$ZodRecord.init(e,t),ZodType.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function record(e,t,n){return new ZodRecord({type:"record",keyType:e,valueType:t,...normalizeParams(n)})}const ZodEnum=$constructor("ZodEnum",(e,t)=>{$ZodEnum.init(e,t),ZodType.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})}});function schemas_enum(e,t){return new ZodEnum({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...normalizeParams(t)})}const ZodLiteral=$constructor("ZodLiteral",(e,t)=>{$ZodLiteral.init(e,t),ZodType.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function literal(e,t){return new ZodLiteral({type:"literal",values:Array.isArray(e)?e:[e],...normalizeParams(t)})}const ZodTransform=$constructor("ZodTransform",(e,t)=>{$ZodTransform.init(e,t),ZodType.init(e,t),e._zod.parse=(n,r)=>{n.addIssue=r=>{if("string"==typeof r)n.issues.push(util_issue(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=n.value),t.inst??(t.inst=e),n.issues.push(util_issue(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function transform(e){return new ZodTransform({type:"transform",transform:e})}const ZodOptional=$constructor("ZodOptional",(e,t)=>{$ZodOptional.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function optional(e){return new ZodOptional({type:"optional",innerType:e})}const ZodNullable=$constructor("ZodNullable",(e,t)=>{$ZodNullable.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nullable(e){return new ZodNullable({type:"nullable",innerType:e})}const ZodDefault=$constructor("ZodDefault",(e,t)=>{$ZodDefault.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function schemas_default(e,t){return new ZodDefault({type:"default",innerType:e,get defaultValue(){return"function"==typeof t?t():shallowClone(t)}})}const ZodPrefault=$constructor("ZodPrefault",(e,t)=>{$ZodPrefault.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function prefault(e,t){return new ZodPrefault({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof t?t():shallowClone(t)}})}const ZodNonOptional=$constructor("ZodNonOptional",(e,t)=>{$ZodNonOptional.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nonoptional(e,t){return new ZodNonOptional({type:"nonoptional",innerType:e,...normalizeParams(t)})}const ZodCatch=$constructor("ZodCatch",(e,t)=>{$ZodCatch.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function schemas_catch(e,t){return new ZodCatch({type:"catch",innerType:e,catchValue:"function"==typeof t?t:()=>t})}const ZodPipe=$constructor("ZodPipe",(e,t)=>{$ZodPipe.init(e,t),ZodType.init(e,t),e.in=t.in,e.out=t.out});function pipe(e,t){return new ZodPipe({type:"pipe",in:e,out:t})}const ZodReadonly=$constructor("ZodReadonly",(e,t)=>{$ZodReadonly.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function readonly(e){return new ZodReadonly({type:"readonly",innerType:e})}const ZodCustom=$constructor("ZodCustom",(e,t)=>{$ZodCustom.init(e,t),ZodType.init(e,t)});function refine(e,t={}){return _refine(ZodCustom,e,t)}function superRefine(e){return _superRefine(e)}const stringbool=(...e)=>_stringbool({Pipe:ZodPipe,Boolean:ZodBoolean,String:ZodString,Transform:ZodTransform},...e);function preprocess(e,t){return pipe(transform(e),t)}function coerce_string(e){return _coercedString(ZodString,e)}function coerce_number(e){return _coercedNumber(ZodNumber,e)}function _define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}compat_ZodFirstPartyTypeKind||(compat_ZodFirstPartyTypeKind={}),core_config(en()),core_config(zh_CN());const TTL_7_DAYS=6048e5,TTL_1_DAY=864e5,TTL_2_HOURS=72e5,TTL_5_MINUTES=3e5,StorageValue=schemas_object({value:schemas_string(),expiresAt:schemas_number()});class Storage{async get(e){let t=await Widget.storage.get(e);if(!t)return null;let n=safeJsonParseWithZod(t,StorageValue);return n?(null==n?void 0:n.expiresAt)<Date.now()?(console.warn(`Storage value for key: ${e} has expired`),this.remove(e),null):n.value:(console.warn(`Failed to parse storage value for key: ${e}`),this.remove(e),null)}set(e,t,n){var r;let i=null!=(r=null==n?void 0:n.ttl)?r:this.defaultTTL,o=Date.now()+i,a=StorageValue.parse({value:t,expiresAt:o});return Widget.storage.set(e,JSON.stringify(a))}remove(e){return Widget.storage.remove(e)}clear(){return Widget.storage.clear()}async getJson(e){let t=await this.get(e);return t?safeJsonParse(t):null}setJson(e,t,n){return this.set(e,JSON.stringify(t),n)}async cleanup(){try{let e="__storage_last_cleanup__";this.get(e)||(await Widget.storage.keys()).forEach(e=>{this.get(e)}),this.set(e,"1",{ttl:TTL_1_DAY})}catch(e){console.error("Failed to cleanup storage",e)}}constructor(){_define_property(this,"defaultTTL",TTL_5_MINUTES)}}const storage=new Storage;function fetch_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class HttpStatusError extends Error{constructor(e,t,n,r){super(`HTTP ${e} - Expected: [${t.join(", ")}] - ${n.method} ${n.url}`),fetch_define_property(this,"statusCode",void 0),fetch_define_property(this,"expectedStatus",void 0),fetch_define_property(this,"context",void 0),fetch_define_property(this,"response",void 0),this.statusCode=e,this.expectedStatus=t,this.context=n,this.response=r,this.name="HttpStatusError",console.error(`\u{1F6AB} HTTP Request Failed: ${n.method} ${n.url}`,"Status",e),n.body&&console.error("Request Body:",JSON.stringify(n.body)),n.options&&console.error("Request Options:",omit(n.options,["schema","successStatus"])),console.error("Response:",{headers:r.headers,data:r.data})}}class HttpSchemaError extends Error{constructor(e,t,n){super(`Failed to parse response with schema: ${prettifyError(n)}`),fetch_define_property(this,"context",void 0),fetch_define_property(this,"response",void 0),fetch_define_property(this,"error",void 0),this.context=e,this.response=t,this.error=n,this.name="HttpSchemaError",console.error(`\u{1F6AB} HTTP Request Failed Failed to parse response with schema: ${prettifyError(n)}: ${e.method} ${e.url}`),e.options&&console.error("Request Options:",omit(e.options,["schema","successStatus"])),console.error("Response:",{headers:t.headers,data:t.data})}}class Fetch{setCookie(e){this.cookie=merge(this.cookie,e)}getCookie(e){return this.cookie[e]}setHeaders(e){this.headers=merge(this.headers,e)}async get(e,t){var n,r;null!=t||(t={}),null!=(r=(n=t).headers)||(n.headers={}),t.headers=this.buildHeaders(t.headers);let i=await this.executeRequest("GET",e,t),o={url:e,method:"GET",options:t};return this.handleResponse(i,o,t)}async post(e,t,n){var r,i;null!=n||(n={}),null!=(i=(r=n).headers)||(r.headers={}),n.headers=this.buildHeaders(n.headers);let o=await this.executeRequest("POST",e,t,n),a={url:e,method:"POST",body:t,options:n};return this.handleResponse(o,a,n)}buildHeaders(e){let t=Object.entries(this.cookie).map(e=>{let[t,n]=e;return`${t}=${n}`}).join("; ");return{...this.headers,...t&&{Cookie:t},...e}}createTimeoutPromise(e){return new Promise((t,n)=>{setTimeout(()=>{n(Error(`Request timeout after ${e}ms`))},e)})}async executeRequest(e,t,n,r){var i;let o="GET"===e,a=null!=(i=o?n:r)?i:{},s=this.getCacheConfig(a);if(null==s?void 0:s.cacheKey){let e=await storage.getJson(s.cacheKey);if(e)return console.debug("♻️ fetch cache hit",s.cacheKey),{data:e,statusCode:200,headers:{},fromCache:!0}}let l=o?void 0:n,{timeout:u,schema:c,params:d,...f}=a,h=t;d&&(h=`${t}?${url_parse.qs.stringify(d)}`),console.debug("⬆️ fetch",h,null!=l?l:"",f);let p=o?Widget.http.get(h,f):Widget.http.post(h,l,f);return u&&u>0?Promise.race([p,this.createTimeoutPromise(u)]):p}getCacheConfig(e){return"string"==typeof(null==e?void 0:e.cache)?{cacheKey:e.cache,ttl:void 0}:null==e?void 0:e.cache}constructor(e={},t={}){fetch_define_property(this,"cookie",void 0),fetch_define_property(this,"headers",void 0),fetch_define_property(this,"handleResponse",void 0),this.cookie=e,this.headers=t,this.handleResponse=(e,t,n)=>{var r;if(e.fromCache)return e;if((null==n||null==(r=n.successStatus)?void 0:r.length)&&!n.successStatus.includes(e.statusCode))throw new HttpStatusError(e.statusCode,n.successStatus,t,e);if(null==n?void 0:n.schema){let r=n.schema.safeParse(e.data);if(!r.success)throw new HttpSchemaError(t,e,r.error);e.data=r.data}let i=e.headers["set-cookie"]||e.headers["Set-Cookie"];if(i){let e=i.split(",").reduce((e,t)=>{if(!t)return e;let[n]=t.split(";"),[r,...i]=n.split("=");return r&&i.length>0&&(e[r.trim()]=i.join("=").trim()),e},{});this.setCookie(e)}let o=this.getCacheConfig(n);return(null==o?void 0:o.cacheKey)&&storage.setJson(o.cacheKey,e.data,{ttl:o.ttl}),e}}}function logger_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}new Fetch;class Logger{debug(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];console.debug(`[${this.name}] ${e}`,...n)}info(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];console.info(`[${this.name}] ${e}`,...n)}warn(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];console.warn(`[${this.name}] ${e}`,...n)}error(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];console.error(`[${this.name}] ${e}`,...n)}constructor(e){logger_define_property(this,"name",void 0),this.name=e}}function douban_history_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class DoubanHistory{async getCK(){let e="doubanHistory:ck",t=await storage.get(e);return t||(await this.fetch.get("https://douban.com"),t=this.fetch.getCookie("ck"),await storage.set(e,t)),this.fetch.setCookie({ck:t}),t}async setStatus(e,t,n){let r=await this.getCK(),i=await this.fetch.post(`https://m.douban.com/rexxar/api/v2/${e}/${t}/${n}`,url_parse.qs.stringify({ck:r,tags:"",comment:this.config.customComment,sync_douban:1,rating:0}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Referer:`https://m.douban.com/movie/subject/${t}/`}});this.logger.info(`\u{8BBE}\u{7F6E} ${e} ${t} \u{72B6}\u{6001}\u{4E3A} ${n}`,i.data)}constructor(e){douban_history_define_property(this,"config",void 0),douban_history_define_property(this,"fetch",void 0),douban_history_define_property(this,"logger",void 0),this.config=e,this.fetch=new Fetch,this.logger=new Logger("DoubanHistory"),this.fetch.setCookie({dbcl2:e.dbcl2})}}function trakt_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const TRAKT_API_KEY="7100193031cd53fc7d2ec3eb22fe4162f30f0fb572d18c5b87fa1274c3dab80b";class Trakt{syncHistory(e){let t={};if(e.tmdbId)return"movie"===e.type&&(t.movies=[{watched_at:new Date().toISOString(),ids:{tmdb:parseInt(e.tmdbId,10)}}]),"tv"===e.type&&e.season&&e.episode&&(t.shows=[{ids:{tmdb:parseInt(e.tmdbId,10)},seasons:[{number:parseInt(e.season,10),episodes:[{number:parseInt(e.episode,10),watched_at:new Date().toISOString()}]}]}]),this.fetch.post("https://api.trakt.tv/sync/history",t)}constructor(e){var t;trakt_define_property(this,"fetch",new Fetch),this.fetch.setHeaders({"Content-Type":"application/json",Authorization:`Bearer ${null==(t=e.token)?void 0:t.access_token}`,"trakt-api-key":TRAKT_API_KEY,"trakt-api-version":"2"})}}var constants_MediaType=function(e){return e.Movie="movie",e.TV="tv",e}({});const DEFAULT_COLOR_HEX="ffffff",DEFAULT_COLOR_INT=parseInt(DEFAULT_COLOR_HEX,16),PROVIDER_NAMES={tencent:"腾讯视频",iqiyi:"爱奇艺",youku:"优酷视频",bilibili:"哔哩哔哩",renren:"人人视频",mgtv:"芒果 TV"},searchDanmuParamsSchema=schemas_object({tmdbId:coerce_string().optional(),type:schemas_enum(["movie","tv"]).transform(e=>e).catch("movie"),title:coerce_string().optional(),seriesName:coerce_string().optional(),season:coerce_number().optional(),airDate:coerce_string().optional(),episode:coerce_number().optional(),fuzzyMatch:schemas_enum(["always","never","auto"]).catch("auto").optional().default("auto"),qihooSearch:stringbool().catch(!1).optional().default(!1)}),EMPTY_ANIME_CONFIG={ID:"__empty__",TITLE:"\uD83D\uDE2D 未匹配到资源"};function compact(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];r&&t.push(r)}return t}function keyBy(e,t){let n={};for(let r=0;r<e.length;r++){let i=e[r];n[t(i)]=i}return n}function compareValues(e,t,n){return e<t?"asc"===n?-1:1:e>t?"asc"===n?1:-1:0}function orderBy(e,t,n){return e.slice().sort((e,r)=>{let i=n.length;for(let o=0;o<t.length;o++){let a=i>o?n[o]:n[i-1],s=t[o],l="function"==typeof s,u=compareValues(l?s(e):e[s],l?s(r):r[s],a);if(0!==u)return u}return 0})}function sortBy(e,t){return orderBy(e,t,["asc"])}function uniqWith(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.every(e=>!t(e,i))&&n.push(i)}return n}function getSymbols(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function getTag(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const regexpTag="[object RegExp]",stringTag="[object String]",numberTag="[object Number]",booleanTag="[object Boolean]",argumentsTag="[object Arguments]",symbolTag="[object Symbol]",dateTag="[object Date]",mapTag="[object Map]",setTag="[object Set]",arrayTag="[object Array]",functionTag="[object Function]",arrayBufferTag="[object ArrayBuffer]",objectTag="[object Object]",errorTag="[object Error]",dataViewTag="[object DataView]",uint8ArrayTag="[object Uint8Array]",uint8ClampedArrayTag="[object Uint8ClampedArray]",uint16ArrayTag="[object Uint16Array]",uint32ArrayTag="[object Uint32Array]",bigUint64ArrayTag="[object BigUint64Array]",int8ArrayTag="[object Int8Array]",int16ArrayTag="[object Int16Array]",int32ArrayTag="[object Int32Array]",bigInt64ArrayTag="[object BigInt64Array]",float32ArrayTag="[object Float32Array]",float64ArrayTag="[object Float64Array]";function eq(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function isEqualWith(e,t,n){return isEqualWithImpl(e,t,void 0,void 0,void 0,void 0,n)}function isEqualWithImpl(e,t,n,r,i,o,a){let s=a(e,t,n,r,i,o);if(void 0!==s)return s;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t)}return areObjectsEqual(e,t,o,a)}function areObjectsEqual(e,t,n,r){if(Object.is(e,t))return!0;let i=getTag(e),o=getTag(t);if(i===argumentsTag&&(i=objectTag),o===argumentsTag&&(o=objectTag),i!==o)return!1;switch(i){case stringTag:return e.toString()===t.toString();case numberTag:return eq(e.valueOf(),t.valueOf());case booleanTag:case dateTag:case symbolTag:return Object.is(e.valueOf(),t.valueOf());case regexpTag:return e.source===t.source&&e.flags===t.flags;case functionTag:return e===t}let a=(n=n??new Map).get(e),s=n.get(t);if(null!=a&&null!=s)return a===t;n.set(e,t),n.set(t,e);try{switch(i){case mapTag:if(e.size!==t.size)return!1;for(let[i,o]of e.entries())if(!t.has(i)||!isEqualWithImpl(o,t.get(i),i,e,t,n,r))return!1;return!0;case setTag:{if(e.size!==t.size)return!1;let i=Array.from(e.values()),o=Array.from(t.values());for(let a=0;a<i.length;a++){let s=i[a],l=o.findIndex(i=>isEqualWithImpl(s,i,void 0,e,t,n,r));if(-1===l)return!1;o.splice(l,1)}return!0}case arrayTag:case uint8ArrayTag:case uint8ClampedArrayTag:case uint16ArrayTag:case uint32ArrayTag:case bigUint64ArrayTag:case int8ArrayTag:case int16ArrayTag:case int32ArrayTag:case bigInt64ArrayTag:case float32ArrayTag:case float64ArrayTag:if("undefined"!=typeof Buffer&&Buffer.isBuffer(e)!==Buffer.isBuffer(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!isEqualWithImpl(e[i],t[i],i,e,t,n,r))return!1;return!0;case arrayBufferTag:if(e.byteLength!==t.byteLength)return!1;return areObjectsEqual(new Uint8Array(e),new Uint8Array(t),n,r);case dataViewTag:if(e.byteLength!==t.byteLength||e.byteOffset!==t.byteOffset)return!1;return areObjectsEqual(new Uint8Array(e),new Uint8Array(t),n,r);case errorTag:return e.name===t.name&&e.message===t.message;case objectTag:{if(!(areObjectsEqual(e.constructor,t.constructor,n,r)||isPlainObject(e)&&isPlainObject(t)))return!1;let i=[...Object.keys(e),...getSymbols(e)],o=[...Object.keys(t),...getSymbols(t)];if(i.length!==o.length)return!1;for(let o=0;o<i.length;o++){let a=i[o],s=e[a];if(!Object.hasOwn(t,a))return!1;let l=t[a];if(!isEqualWithImpl(s,l,a,e,t,n,r))return!1}return!0}default:return!1}}finally{n.delete(e),n.delete(t)}}function noop(){}function isEqual(e,t){return isEqualWith(e,t,noop)}function _360kan_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const qihooSearchResponseSchema=schemas_object({data:schemas_object({longData:schemas_object({rows:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({cat_id:schemas_enum(["1","2","3","4"]),id:schemas_string(),en_id:schemas_string(),cat_name:schemas_string(),titleTxt:schemas_string(),playlinks:record(schemas_string(),schemas_string()).optional()}).safeParse(e).data)?t:null})).transform(e=>compact(e))})})}).transform(e=>e.data.longData.rows);class QihooMatcher{async getEpisodeParams(e){var t,n,r,i,o;let{success:a,data:s,error:l}=searchDanmuParamsSchema.safeParse(e);if(!a)return this.logger.error("搜索参数无效,错误:",prettifyError(l)),[];let{seriesName:u,season:c,type:d,episode:f}=s;if(!u)return[];let h=await this.fetch.get(`${this.BASE_API}/index`,{params:{force_v:"1",kw:`${u} ${c&&c>1?c:""}`.trim(),from:"",pageno:"1",v_ap:"1",tab:"all"},schema:qihooSearchResponseSchema});if(!(null==(t=h.data)?void 0:t.length))return[];let p=[];for(let e of h.data){if(d===constants_MediaType.Movie&&"1"!==e.cat_id){this.logger.warn("电影搜索结果中包含电视剧,跳过");continue}if(d===constants_MediaType.TV&&"1"===e.cat_id){this.logger.warn("电视剧搜索结果中包含电影,跳过");continue}if(!e.titleTxt.includes(u)){this.logger.warn("搜索结果中包含的剧集标题与搜索关键词不匹配,跳过");continue}if(!e.playlinks){this.logger.warn("搜索结果中包含的剧集没有播放链接,跳过");continue}if(e.playlinks.qq){let t=null==(n=e.playlinks.qq.match(/\/cover\/([^/]+?)(\/|.html|$)/))?void 0:n[1];t&&p.push({provider:"tencent",idString:scrapers_scraper.scraperMap.tencent.generateIdString({cid:t}),episodeNumber:f})}if(e.playlinks.youku){let{vid:t,showid:n}=url_parse_default()(e.playlinks.youku,!0).query;(t||n)&&p.push({provider:"youku",idString:scrapers_scraper.scraperMap.youku.generateIdString({vid:t,showId:n}),episodeNumber:f})}if(e.playlinks.qiyi){let t=null==(r=e.playlinks.qiyi.match(/\/v_([^/]+?)(\/|.html|$)/))?void 0:r[1],n=t?scrapers_scraper.scraperMap.iqiyi.videoIdToEntityId(t):void 0;n&&p.push({provider:"iqiyi",idString:scrapers_scraper.scraperMap.iqiyi.generateIdString({entityId:n}),episodeNumber:f})}if(e.playlinks.bilibili1){let t=null==(i=(await this.fetch.get(e.playlinks.bilibili1,{cache:e.playlinks.bilibili1})).data.match(/"season_id":(\d+)/))?void 0:i[1];t&&p.push({provider:"bilibili",idString:scrapers_scraper.scraperMap.bilibili.generateIdString({seasonId:t}),episodeNumber:f})}if(e.playlinks.imgo){let t=null==(o=e.playlinks.imgo.match(/\/b\/([^/]+)\//))?void 0:o[1];t&&p.push({provider:"mgtv",idString:scrapers_scraper.scraperMap.mgtv.generateIdString({dramaId:t}),episodeNumber:f})}}return p}constructor(){_360kan_define_property(this,"logger",new Logger("360")),_360kan_define_property(this,"fetch",new Fetch),_360kan_define_property(this,"BASE_API","https://api.so.360kan.com")}}function isDeepKey(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function toKey(e){return"string"==typeof e||"symbol"==typeof e?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function toPath(e){let t=[],n=e.length;if(0===n)return t;let r=0,i="",o="",a=!1;for(46===e.charCodeAt(0)&&(t.push(""),r++);r<n;){let s=e[r];o?"\\"===s&&r+1<n?i+=e[++r]:s===o?o="":i+=s:a?'"'===s||"'"===s?o=s:"]"===s?(a=!1,t.push(i),i=""):i+=s:"["===s?(a=!0,i&&(t.push(i),i="")):"."===s?i&&(t.push(i),i=""):i+=s,r++}return i&&t.push(i),t}function get(e,t,n){if(null==e)return n;switch(typeof t){case"string":{if(isUnsafeProperty(t))return n;let r=e[t];if(void 0===r)if(isDeepKey(t))return get(e,toPath(t),n);else return n;return r}case"number":case"symbol":{"number"==typeof t&&(t=toKey(t));let r=e[t];if(void 0===r)return n;return r}default:{if(Array.isArray(t))return getWithPath(e,t,n);if(isUnsafeProperty(t=Object.is(t?.valueOf(),-0)?"-0":String(t)))return n;let r=e[t];if(void 0===r)return n;return r}}}function getWithPath(e,t,n){if(0===t.length)return n;let r=e;for(let e=0;e<t.length;e++){if(null==r||isUnsafeProperty(t[e]))return n;r=r[t[e]]}return void 0===r?n:r}const GLOBAL_EPISODE_BLACKLIST="^(.*?)((.+?版)|(特(别|典))|((导|演)员|嘉宾|角色)访谈|福利|先导|彩蛋|花絮|预告|特辑|专访|访谈|幕后|周边|资讯|看点|速看|回顾|盘点|合集|PV|MV|CM|OST|ED|OP|BD|特典|SP|NCOP|NCED|MENU|Web-DL|rip|x264|x265|aac|flac)(.*?)$",getEpisodeBlacklistPattern=e=>{let t=[GLOBAL_EPISODE_BLACKLIST];(null==e?void 0:e.trim())&&t.push(e);let n=t.join("|");try{return RegExp(n,"i")}catch(e){return console.error("编译分集黑名单正则表达式失败:",n,"错误:",e),RegExp(GLOBAL_EPISODE_BLACKLIST,"i")}},parseEpNumber=e=>{if(!e)return null;let t=normalizeTitle(e);{let e=/第\s*([0-9]+)\s*(?:[集话話回期])\s*$/.exec(t);if(e)return toInt(e[1])}{let e=/第\s*([零〇一二两三四五六七八九十百千万萬]+)\s*(?:[集话話回期])\s*$/.exec(t);if(e){let t=parseChineseNumeral(e[1]);return Number.isFinite(t)?t:null}}{let e=/S\d{1,3}\s*E(\d{1,4})\s*$/i.exec(t);if(e)return toInt(e[1])}{let e=/EP?\s*0*(\d{1,4})\s*$/i.exec(t);if(e)return toInt(e[1])}{let e=/(?:^|[\s_\-((【[])\s*0*(\d{1,5})\s*(?:[】\]))])?\s*(?:END|FIN|完|完结)?\s*$/i.exec(t);if(e)return toInt(e[1])}return null};function normalizeTitle(e){let t=e.trim();return(t=t.replace(/[0-9]/g,e=>String.fromCharCode(e.charCodeAt(0)-65296+48))).replace(/\u3000/g," ")}function toInt(e){let t=parseInt(e,10);return Number.isFinite(t)?t:null}function parseChineseNumeral(e){let t={零:0,〇:0,一:1,二:2,两:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},n={十:10,百:100,千:1e3,万:1e4,萬:1e4},r=0,i=0,o=0;for(let a of e)if(a in t)o=t[a];else if(a in n){let e=n[a];1e4===e?(r+=i=(i+(o||0))*e,i=0):i+=(o||1)*e,o=0}return r+i+o}function base_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var base_CommentMode=function(e){return e[e.SCROLL=1]="SCROLL",e[e.BOTTOM=4]="BOTTOM",e[e.TOP=5]="TOP",e}({});const providerCommentItemSchema=schemas_object({id:coerce_string().optional(),timestamp:coerce_number(),mode:schemas_enum(base_CommentMode).catch(1).optional().default(1),color:schemas_number().catch(DEFAULT_COLOR_INT).optional().default(DEFAULT_COLOR_INT),content:schemas_string()});class BaseScraper{get providerConfig(){return this._providerConfig}set providerConfig(e){let t=get(e,this.providerName);t&&(this.logger.debug("设置 Provider 配置",t),this._providerConfig=e)}parseIdString(e){var t,n;let r=url_parse.qs.parse(e),i=null==(t=this.idSchema)?void 0:t.safeParse(r);return i?i.success?null!=(n=i.data)?n:null:(this.logger.error("parseIdString",e,prettifyError(i.error)),null):(this.logger.error("parseIdString",e,"idSchema is not defined"),null)}generateIdString(e){return url_parse.qs.stringify(this.idSchema.parse(e))}getEpisodeIndexFromTitle(e){return parseEpNumber(e)}get episodeBlacklistPattern(){return getEpisodeBlacklistPattern(this.PROVIDER_SPECIFIC_BLACKLIST)}constructor(){base_define_property(this,"providerName","base"),base_define_property(this,"logger",void 0),base_define_property(this,"fetch",new Fetch),base_define_property(this,"_providerConfig",{}),base_define_property(this,"PROVIDER_SPECIFIC_BLACKLIST",""),this.logger=new Logger(this.providerName)}}var dm_proto=__webpack_require__(252);const bilibiliIdSchema=schemas_object({seasonId:schemas_string(),aid:schemas_string().optional(),cid:schemas_string().optional()}),pgcEpisodeSchema=schemas_object({aid:schemas_int(),cid:schemas_int(),badge:schemas_string(),duration:schemas_number(),title:schemas_string(),show_title:schemas_string(),long_title:schemas_string()}),pgcEpisodeResultSchema=schemas_object({code:literal(0),result:schemas_object({episodes:schemas_array(unknown().transform(e=>pgcEpisodeSchema.safeParse(e).data)).transform(e=>compact(e))})});function bilibili_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class BilibiliScraper extends BaseScraper{async getEpisodes(e,t){let n=this.parseIdString(e);if(!n)return[];let r=[],i=await this.getPgcEpisodes(n.seasonId),o=1;for(let e of null!=i?i:[]){if("预告"===e.badge){this.logger.warn("预告,跳过,title:",e.title);continue}if(this.episodeBlacklistPattern.test(e.title)){this.logger.warn("黑名单,跳过,title:",e.title);continue}r.push({provider:this.providerName,episodeId:this.generateIdString({seasonId:n.seasonId,aid:e.aid.toString(),cid:e.cid.toString()}),episodeTitle:e.show_title||e.title,episodeNumber:o}),o+=1}return t?r.filter(e=>e.episodeNumber===t):r}async getSegments(e){var t;let{aid:n,cid:r,seasonId:i}=null!=(t=this.parseIdString(e))?t:{};if(!n||!r||!i)return[];let o=await this.getPgcEpisodes(i),a=null==o?void 0:o.find(e=>e.aid===parseInt(n)&&e.cid===parseInt(r));return a?Array.from({length:Math.floor(a.duration/1e3/360)+1},(e,t)=>({provider:this.providerName,startTime:360*t,segmentId:(t+1).toString()})):[]}async getComments(e,t){var n;let{aid:r,cid:i,seasonId:o}=null!=(n=this.parseIdString(e))?n:{};if(!r||!i||!o)return this.logger.warn("aid:",r,"cid:",i,"seasonId:",o,"不存在"),null;let a=await this.getPgcEpisodes(o);if(!(null==a?void 0:a.find(e=>e.aid===parseInt(r)&&e.cid===parseInt(i))))return this.logger.warn("未找到分集,aid:",r,"cid:",i,"seasonId:",o),null;let s=await this.fetchCommentsForCid(r,i,t);return s?s.map(e=>{var t,n;if(!e.progress)return null;let r=(null==(t=e.content)?void 0:t.toString().replace(/\0/g,""))||"";return r&&null!=(n=providerCommentItemSchema.safeParse({id:e.id.toString(),timestamp:e.progress/1e3,mode:e.mode,color:e.color,content:r}).data)?n:null}):(this.logger.warn("未找到弹幕,aid:",r,"cid:",i,"segmentId:",t),null)}async getPgcEpisodes(e){var t;return null==(t=(await this.fetch.get("https://api.bilibili.com/pgc/view/web/ep/list",{params:{season_id:e},schema:pgcEpisodeResultSchema,cache:{cacheKey:`bilibili:episodes:${e}`}})).data)?void 0:t.result.episodes}async fetchCommentsForCid(e,t,n){try{let r=await this.fetch.get("https://api.bilibili.com/x/v2/dm/web/seg.so",{params:{type:"1",oid:t,pid:e,segment_index:n},base64Data:!0});if(404===r.statusCode||304===r.statusCode)return null;return this.DmSegMobileReply.decode(base64ToUint8Array(r.data)).elems}catch(r){this.logger.error("获取分段",n,"失败,aid:",e,"cid:",t,"错误:",r)}return null}constructor(){super(),bilibili_define_property(this,"providerName","bilibili"),bilibili_define_property(this,"idSchema",bilibiliIdSchema),bilibili_define_property(this,"DmSegMobileReply",dm_proto.biliproto.community.service.dm.v1.DmSegMobileReply),this.fetch.setHeaders({Referer:"https://www.bilibili.com/"})}}var enc_utf8=__webpack_require__(60),enc_utf8_default=__webpack_require__.n(enc_utf8);const assignValue=(e,t,n)=>{let r=e[t];Object.hasOwn(e,t)&&eq(r,n)&&(void 0!==n||t in e)||(e[t]=n)},IS_UNSIGNED_INTEGER=/^(?:0|[1-9]\d*)$/;function isIndex(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return IS_UNSIGNED_INTEGER.test(e)}}function isSymbol(e){return"symbol"==typeof e||e instanceof Symbol}const regexIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,regexIsPlainProp=/^\w*$/;function isKey(e,t){return!Array.isArray(e)&&(!!("number"==typeof e||"boolean"==typeof e||null==e||isSymbol(e))||"string"==typeof e&&(regexIsPlainProp.test(e)||!regexIsDeepProp.test(e))||null!=t&&Object.hasOwn(t,e))}function isObject_isObject(e){return null!==e&&("object"==typeof e||"function"==typeof e)}function updateWith(e,t,n,r){if(null==e&&!isObject_isObject(e))return e;let i=isKey(t,e)?[t]:Array.isArray(t)?t:"string"==typeof t?toPath(t):[t],o=e;for(let t=0;t<i.length&&null!=o;t++){let a,s=toKey(i[t]);if(!isUnsafeProperty(s)){if(t===i.length-1)a=n(o[s]);else{let n=o[s],l=r?.(n,s,e);a=void 0!==l?l:isObject_isObject(n)?n:isIndex(i[t+1])?[]:{}}assignValue(o,s,a),o=o[s]}}return e}function set_set(e,t,n){return updateWith(e,t,()=>n,()=>void 0)}const globalParamsConfigSchema=schemas_object({"global.content.aggregation":stringbool().catch(!0),"global.content.blacklist":schemas_string().refine(e=>{try{return new RegExp(e),!0}catch(e){return!1}}).catch(""),"global.experimental.doubanHistory.enabled":stringbool().catch(!1),"global.experimental.doubanHistory.dbcl2":schemas_string().catch(""),"global.experimental.doubanHistory.customComment":schemas_string().catch("自豪的使用 Forward"),"global.experimental.trakt.enabled":stringbool().catch(!1),"global.experimental.trakt.token":schemas_string().transform(e=>e?safeJsonParseWithZod(enc_base64_default().parse(e).toString(enc_utf8_default()),schemas_object({access_token:schemas_string(),expires_at:schemas_number().min(Date.now())})):null).catch(null),"provider.renren.mode":schemas_enum(["default","choice"]).catch("default")}).transform(e=>{let t={};return Object.entries(e).forEach(e=>{let[n,r]=e;set_set(t,n,r)}),t});var md5=__webpack_require__(478),md5_default=__webpack_require__.n(md5);const OptionsBuilder_defaultOptions={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e},captureMetaData:!1},buildOptions=function(e){return Object.assign({},OptionsBuilder_defaultOptions,e)},nameStartChar=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",nameChar=nameStartChar+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",nameRegexp="["+nameStartChar+"]["+nameChar+"]*",regexName=RegExp("^"+nameRegexp+"$");function getAllMatches(e,t){let n=[],r=t.exec(e);for(;r;){let i=[];i.startIndex=t.lastIndex-r[0].length;let o=r.length;for(let e=0;e<o;e++)i.push(r[e]);n.push(i),r=t.exec(e)}return n}const isName=function(e){return null!=regexName.exec(e)};function isExist(e){return void 0!==e}METADATA_SYMBOL="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class XmlNode{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){"__proto__"===e.tagname&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),void 0!==t&&(this.child[this.child.length-1][METADATA_SYMBOL]={startIndex:t})}static getMetaDataSymbol(){return METADATA_SYMBOL}}function readDocType(e,t){let n={};if("O"===e[t+3]&&"C"===e[t+4]&&"T"===e[t+5]&&"Y"===e[t+6]&&"P"===e[t+7]&&"E"===e[t+8]){t+=9;let r=1,i=!1,o=!1,a="";for(;t<e.length;t++)if("<"!==e[t]||o)if(">"===e[t]){if(o?"-"===e[t-1]&&"-"===e[t-2]&&(o=!1,r--):r--,0===r)break}else"["===e[t]?i=!0:a+=e[t];else{if(i&&hasSeq(e,"!ENTITY",t)){let r,i;t+=7,[r,i,t]=readEntityExp(e,t+1),-1===i.indexOf("&")&&(n[r]={regx:RegExp(`&${r};`,"g"),val:i})}else if(i&&hasSeq(e,"!ELEMENT",t)){let{index:n}=readElementExp(e,(t+=8)+1);t=n}else if(i&&hasSeq(e,"!ATTLIST",t))t+=8;else if(i&&hasSeq(e,"!NOTATION",t)){let{index:n}=readNotationExp(e,(t+=9)+1);t=n}else if(hasSeq(e,"!--",t))o=!0;else throw Error("Invalid DOCTYPE");r++,a=""}if(0!==r)throw Error("Unclosed DOCTYPE")}else throw Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:t}}const skipWhitespace=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function readEntityExp(e,t){t=skipWhitespace(e,t);let n="";for(;t<e.length&&!/\s/.test(e[t])&&'"'!==e[t]&&"'"!==e[t];)n+=e[t],t++;if(validateEntityName(n),t=skipWhitespace(e,t),"SYSTEM"===e.substring(t,t+6).toUpperCase())throw Error("External entities are not supported");if("%"===e[t])throw Error("Parameter entities are not supported");let r="";return[t,r]=readIdentifierVal(e,t,"entity"),[n,r,--t]}function readNotationExp(e,t){t=skipWhitespace(e,t);let n="";for(;t<e.length&&!/\s/.test(e[t]);)n+=e[t],t++;validateEntityName(n),t=skipWhitespace(e,t);let r=e.substring(t,t+6).toUpperCase();if("SYSTEM"!==r&&"PUBLIC"!==r)throw Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=skipWhitespace(e,t);let i=null,o=null;if("PUBLIC"===r)[t,i]=readIdentifierVal(e,t,"publicIdentifier"),t=skipWhitespace(e,t),('"'===e[t]||"'"===e[t])&&([t,o]=readIdentifierVal(e,t,"systemIdentifier"));else if("SYSTEM"===r&&([t,o]=readIdentifierVal(e,t,"systemIdentifier"),!o))throw Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:n,publicIdentifier:i,systemIdentifier:o,index:--t}}function readIdentifierVal(e,t,n){let r="",i=e[t];if('"'!==i&&"'"!==i)throw Error(`Expected quoted string, found "${i}"`);for(t++;t<e.length&&e[t]!==i;)r+=e[t],t++;if(e[t]!==i)throw Error(`Unterminated ${n} value`);return[++t,r]}function readElementExp(e,t){t=skipWhitespace(e,t);let n="";for(;t<e.length&&!/\s/.test(e[t]);)n+=e[t],t++;if(!validateEntityName(n))throw Error(`Invalid element name: "${n}"`);t=skipWhitespace(e,t);let r="";if("E"===e[t]&&hasSeq(e,"MPTY",t))t+=4;else if("A"===e[t]&&hasSeq(e,"NY",t))t+=2;else if("("===e[t]){for(t++;t<e.length&&")"!==e[t];)r+=e[t],t++;if(")"!==e[t])throw Error("Unterminated content model")}else throw Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:n,contentModel:r.trim(),index:t}}function hasSeq(e,t,n){for(let r=0;r<t.length;r++)if(t[r]!==e[n+r+1])return!1;return!0}function validateEntityName(e){if(isName(e))return e;throw Error(`Invalid entity name ${e}`)}const hexRegex=/^[-+]?0x[a-fA-F0-9]+$/,numRegex=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,consider={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function toNumber(e,t={}){if(t=Object.assign({},consider,t),!e||"string"!=typeof e)return e;let n=e.trim();if(void 0!==t.skipLike&&t.skipLike.test(n))return e;{if("0"===e)return 0;if(t.hex&&hexRegex.test(n))return parse_int(n,16);if(-1!==n.search(/.+[eE].+/))return resolveEnotation(e,n,t);let r=numRegex.exec(n);if(!r)return e;{let i=r[1]||"",o=r[2],a=trimZeros(r[3]),s=i?"."===e[o.length+1]:"."===e[o.length];if(!t.leadingZeros&&(o.length>1||1===o.length&&!s))return e;{let r=Number(n),s=String(r);if(0===r)return r;if(-1!==s.search(/[eE]/))if(t.eNotation)return r;else return e;if(-1!==n.indexOf("."))if("0"===s)return r;else if(s===a)return r;else if(s===`${i}${a}`)return r;else return e;let l=o?a:n;return o?l===s||i+l===s?r:e:l===s||l===i+s?r:e}}}}const eNotationRegx=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function resolveEnotation(e,t,n){if(!n.eNotation)return e;let r=t.match(eNotationRegx);if(!r)return e;{let i=r[1]||"",o=-1===r[3].indexOf("e")?"E":"e",a=r[2],s=i?e[a.length+1]===o:e[a.length]===o;return a.length>1&&s?e:1===a.length&&(r[3].startsWith(`.${o}`)||r[3][0]===o)?Number(t):n.leadingZeros&&!s?Number(t=(r[1]||"")+r[3]):e}}function trimZeros(e){return e&&-1!==e.indexOf(".")&&("."===(e=e.replace(/0+$/,""))?e="0":"."===e[0]?e="0"+e:"."===e[e.length-1]&&(e=e.substring(0,e.length-1))),e}function parse_int(e,t){if(parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw Error("parseInt, Number.parseInt, window.parseInt are not supported")}function getIgnoreAttributesFn(e){return"function"==typeof e?e:Array.isArray(e)?t=>{for(let n of e)if("string"==typeof n&&t===n||n instanceof RegExp&&n.test(t))return!0}:()=>!1}class OrderedObjParser{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xa2"},pound:{regex:/&(pound|#163);/g,val:"\xa3"},yen:{regex:/&(yen|#165);/g,val:"\xa5"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"\xa9"},reg:{regex:/&(reg|#174);/g,val:"\xae"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>String.fromCodePoint(Number.parseInt(t,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>String.fromCodePoint(Number.parseInt(t,16))}},this.addExternalEntities=addExternalEntities,this.parseXml=parseXml,this.parseTextData=parseTextData,this.resolveNameSpace=resolveNameSpace,this.buildAttributesMap=buildAttributesMap,this.isItStopNode=isItStopNode,this.replaceEntitiesValue=replaceEntitiesValue,this.readStopNodeData=readStopNodeData,this.saveTextToParentTag=saveTextToParentTag,this.addChild=addChild,this.ignoreAttributesFn=getIgnoreAttributesFn(this.options.ignoreAttributes)}}function addExternalEntities(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];this.lastEntities[r]={regex:RegExp("&"+r+";","g"),val:e[r]}}}function parseTextData(e,t,n,r,i,o,a){if(void 0!==e&&(this.options.trimValues&&!r&&(e=e.trim()),e.length>0)){a||(e=this.replaceEntitiesValue(e));let r=this.options.tagValueProcessor(t,e,n,i,o);return null==r?e:typeof r!=typeof e||r!==e?r:this.options.trimValues||e.trim()===e?parseValue(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function resolveNameSpace(e){if(this.options.removeNSPrefix){let t=e.split(":"),n="/"===e.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(e=n+t[1])}return e}const attrsRegx=RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function buildAttributesMap(e,t,n){if(!0!==this.options.ignoreAttributes&&"string"==typeof e){let n=getAllMatches(e,attrsRegx),r=n.length,i={};for(let e=0;e<r;e++){let r=this.resolveNameSpace(n[e][1]);if(this.ignoreAttributesFn(r,t))continue;let o=n[e][4],a=this.options.attributeNamePrefix+r;if(r.length)if(this.options.transformAttributeName&&(a=this.options.transformAttributeName(a)),"__proto__"===a&&(a="#__proto__"),void 0!==o){this.options.trimValues&&(o=o.trim()),o=this.replaceEntitiesValue(o);let e=this.options.attributeValueProcessor(r,o,t);null==e?i[a]=o:typeof e!=typeof o||e!==o?i[a]=e:i[a]=parseValue(o,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(i[a]=!0)}if(Object.keys(i).length){if(this.options.attributesGroupName){let e={};return e[this.options.attributesGroupName]=i,e}return i}}}const parseXml=function(e){e=e.replace(/\r\n?/g,"\n");let t=new XmlNode("!xml"),n=t,r="",i="";for(let o=0;o<e.length;o++)if("<"===e[o])if("/"===e[o+1]){let t=findClosingIndex(e,">",o,"Closing Tag is not closed."),a=e.substring(o+2,t).trim();if(this.options.removeNSPrefix){let e=a.indexOf(":");-1!==e&&(a=a.substr(e+1))}this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&(r=this.saveTextToParentTag(r,n,i));let s=i.substring(i.lastIndexOf(".")+1);if(a&&-1!==this.options.unpairedTags.indexOf(a))throw Error(`Unpaired tag can not be used as closing tag: </${a}>`);let l=0;s&&-1!==this.options.unpairedTags.indexOf(s)?(l=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):l=i.lastIndexOf("."),i=i.substring(0,l),n=this.tagsNodeStack.pop(),r="",o=t}else if("?"===e[o+1]){let t=readTagExp(e,o,!1,"?>");if(!t)throw Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,i),this.options.ignoreDeclaration&&"?xml"===t.tagName||this.options.ignorePiTags);else{let e=new XmlNode(t.tagName);e.add(this.options.textNodeName,""),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[":@"]=this.buildAttributesMap(t.tagExp,i,t.tagName)),this.addChild(n,e,i,o)}o=t.closeIndex+1}else if("!--"===e.substr(o+1,3)){let t=findClosingIndex(e,"--\x3e",o+4,"Comment is not closed.");if(this.options.commentPropName){let a=e.substring(o+4,t-2);r=this.saveTextToParentTag(r,n,i),n.add(this.options.commentPropName,[{[this.options.textNodeName]:a}])}o=t}else if("!D"===e.substr(o+1,2)){let t=readDocType(e,o);this.docTypeEntities=t.entities,o=t.i}else if("!["===e.substr(o+1,2)){let t=findClosingIndex(e,"]]>",o,"CDATA is not closed.")-2,a=e.substring(o+9,t);r=this.saveTextToParentTag(r,n,i);let s=this.parseTextData(a,n.tagname,i,!0,!1,!0,!0);void 0==s&&(s=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:a}]):n.add(this.options.textNodeName,s),o=t+2}else{let a=readTagExp(e,o,this.options.removeNSPrefix),s=a.tagName,l=a.rawTagName,u=a.tagExp,c=a.attrExpPresent,d=a.closeIndex;this.options.transformTagName&&(s=this.options.transformTagName(s)),n&&r&&"!xml"!==n.tagname&&(r=this.saveTextToParentTag(r,n,i,!1));let f=n;f&&-1!==this.options.unpairedTags.indexOf(f.tagname)&&(n=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),s!==t.tagname&&(i+=i?"."+s:s);let h=o;if(this.isItStopNode(this.options.stopNodes,i,s)){let t="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)"/"===s[s.length-1]?(s=s.substr(0,s.length-1),i=i.substr(0,i.length-1),u=s):u=u.substr(0,u.length-1),o=a.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(s))o=a.closeIndex;else{let n=this.readStopNodeData(e,l,d+1);if(!n)throw Error(`Unexpected end of ${l}`);o=n.i,t=n.tagContent}let r=new XmlNode(s);s!==u&&c&&(r[":@"]=this.buildAttributesMap(u,i,s)),t&&(t=this.parseTextData(t,s,i,!0,c,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),r.add(this.options.textNodeName,t),this.addChild(n,r,i,h)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){"/"===s[s.length-1]?(s=s.substr(0,s.length-1),i=i.substr(0,i.length-1),u=s):u=u.substr(0,u.length-1),this.options.transformTagName&&(s=this.options.transformTagName(s));let e=new XmlNode(s);s!==u&&c&&(e[":@"]=this.buildAttributesMap(u,i,s)),this.addChild(n,e,i,h),i=i.substr(0,i.lastIndexOf("."))}else{let e=new XmlNode(s);this.tagsNodeStack.push(n),s!==u&&c&&(e[":@"]=this.buildAttributesMap(u,i,s)),this.addChild(n,e,i,h),n=e}r="",o=d}}else r+=e[o];return t.child};function addChild(e,t,n,r){this.options.captureMetaData||(r=void 0);let i=this.options.updateTag(t.tagname,n,t[":@"]);!1===i||("string"==typeof i&&(t.tagname=i),e.addChild(t,r))}const replaceEntitiesValue=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let n=this.docTypeEntities[t];e=e.replace(n.regx,n.val)}for(let t in this.lastEntities){let n=this.lastEntities[t];e=e.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let n=this.htmlEntities[t];e=e.replace(n.regex,n.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function saveTextToParentTag(e,t,n,r){return e&&(void 0===r&&(r=0===t.child.length),void 0!==(e=this.parseTextData(e,t.tagname,n,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,r))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function isItStopNode(e,t,n){let r="*."+n;for(let n in e){let i=e[n];if(r===i||t===i)return!0}return!1}function tagExpWithClosingIndex(e,t,n=">"){let r,i="";for(let o=t;o<e.length;o++){let t=e[o];if(r)t===r&&(r="");else if('"'===t||"'"===t)r=t;else if(t===n[0]){if(!n[1])return{data:i,index:o};else if(e[o+1]===n[1])return{data:i,index:o}}else" "===t&&(t=" ");i+=t}}function findClosingIndex(e,t,n,r){let i=e.indexOf(t,n);if(-1!==i)return i+t.length-1;throw Error(r)}function readTagExp(e,t,n,r=">"){let i=tagExpWithClosingIndex(e,t+1,r);if(!i)return;let o=i.data,a=i.index,s=o.search(/\s/),l=o,u=!0;-1!==s&&(l=o.substring(0,s),o=o.substring(s+1).trimStart());let c=l;if(n){let e=l.indexOf(":");-1!==e&&(u=(l=l.substr(e+1))!==i.data.substr(e+1))}return{tagName:l,tagExp:o,closeIndex:a,attrExpPresent:u,rawTagName:c}}function readStopNodeData(e,t,n){let r=n,i=1;for(;n<e.length;n++)if("<"===e[n])if("/"===e[n+1]){let o=findClosingIndex(e,">",n,`${t} is not closed`);if(e.substring(n+2,o).trim()===t&&0==--i)return{tagContent:e.substring(r,n),i:o};n=o}else if("?"===e[n+1])n=findClosingIndex(e,"?>",n+1,"StopNode is not closed.");else if("!--"===e.substr(n+1,3))n=findClosingIndex(e,"--\x3e",n+3,"StopNode is not closed.");else if("!["===e.substr(n+1,2))n=findClosingIndex(e,"]]>",n,"StopNode is not closed.")-2;else{let r=readTagExp(e,n,">");r&&((r&&r.tagName)===t&&"/"!==r.tagExp[r.tagExp.length-1]&&i++,n=r.closeIndex)}}function parseValue(e,t,n){if(t&&"string"==typeof e){let t=e.trim();return"true"===t||"false"!==t&&toNumber(e,n)}return isExist(e)?e:""}const node2json_METADATA_SYMBOL=XmlNode.getMetaDataSymbol();function prettify(e,t){return compress(e,t)}function compress(e,t,n){let r,i={};for(let o=0;o<e.length;o++){let a=e[o],s=propName(a),l="";if(l=void 0===n?s:n+"."+s,s===t.textNodeName)void 0===r?r=a[s]:r+=""+a[s];else if(void 0===s)continue;else if(a[s]){let e=compress(a[s],t,l),n=isLeafTag(e,t);void 0!==a[node2json_METADATA_SYMBOL]&&(e[node2json_METADATA_SYMBOL]=a[node2json_METADATA_SYMBOL]),a[":@"]?assignAttributes(e,a[":@"],l,t):1!==Object.keys(e).length||void 0===e[t.textNodeName]||t.alwaysCreateTextNode?0===Object.keys(e).length&&(t.alwaysCreateTextNode?e[t.textNodeName]="":e=""):e=e[t.textNodeName],void 0!==i[s]&&i.hasOwnProperty(s)?(Array.isArray(i[s])||(i[s]=[i[s]]),i[s].push(e)):t.isArray(s,l,n)?i[s]=[e]:i[s]=e}}return"string"==typeof r?r.length>0&&(i[t.textNodeName]=r):void 0!==r&&(i[t.textNodeName]=r),i}function propName(e){let t=Object.keys(e);for(let e=0;e<t.length;e++){let n=t[e];if(":@"!==n)return n}}function assignAttributes(e,t,n,r){if(t){let i=Object.keys(t),o=i.length;for(let a=0;a<o;a++){let o=i[a];r.isArray(o,n+"."+o,!0,!0)?e[o]=[t[o]]:e[o]=t[o]}}}function isLeafTag(e,t){let{textNodeName:n}=t,r=Object.keys(e).length;return 0===r||1===r&&(!!e[n]||"boolean"==typeof e[n]||0===e[n])}const validator_defaultOptions={allowBooleanAttributes:!1,unpairedTags:[]};function validate(e,t){t=Object.assign({},validator_defaultOptions,t);let n=[],r=!1,i=!1;"\uFEFF"===e[0]&&(e=e.substr(1));for(let o=0;o<e.length;o++)if("<"===e[o]&&"?"===e[o+1]){if(o+=2,(o=readPI(e,o)).err)return o}else if("<"===e[o]){let a=o;if("!"===e[++o]){o=readCommentAndCDATA(e,o);continue}{let s=!1;"/"===e[o]&&(s=!0,o++);let l="";for(;o<e.length&&">"!==e[o]&&" "!==e[o]&&" "!==e[o]&&"\n"!==e[o]&&"\r"!==e[o];o++)l+=e[o];if("/"===(l=l.trim())[l.length-1]&&(l=l.substring(0,l.length-1),o--),!validateTagName(l)){let t;return getErrorObject("InvalidTag",t=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",getLineNumberForPosition(e,o))}let u=readAttributeStr(e,o);if(!1===u)return getErrorObject("InvalidAttr","Attributes for '"+l+"' have open quote.",getLineNumberForPosition(e,o));let c=u.value;if(o=u.index,"/"===c[c.length-1]){let n=o-c.length,i=validateAttributeString(c=c.substring(0,c.length-1),t);if(!0!==i)return getErrorObject(i.err.code,i.err.msg,getLineNumberForPosition(e,n+i.err.line));r=!0}else if(s)if(!u.tagClosed)return getErrorObject("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",getLineNumberForPosition(e,o));else{if(c.trim().length>0)return getErrorObject("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",getLineNumberForPosition(e,a));if(0===n.length)return getErrorObject("InvalidTag","Closing tag '"+l+"' has not been opened.",getLineNumberForPosition(e,a));let t=n.pop();if(l!==t.tagName){let n=getLineNumberForPosition(e,t.tagStartPos);return getErrorObject("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+n.line+", col "+n.col+") instead of closing tag '"+l+"'.",getLineNumberForPosition(e,a))}0==n.length&&(i=!0)}else{let s=validateAttributeString(c,t);if(!0!==s)return getErrorObject(s.err.code,s.err.msg,getLineNumberForPosition(e,o-c.length+s.err.line));if(!0===i)return getErrorObject("InvalidXml","Multiple possible root nodes found.",getLineNumberForPosition(e,o));-1!==t.unpairedTags.indexOf(l)||n.push({tagName:l,tagStartPos:a}),r=!0}for(o++;o<e.length;o++)if("<"===e[o])if("!"===e[o+1]){o=readCommentAndCDATA(e,++o);continue}else if("?"===e[o+1]){if((o=readPI(e,++o)).err)return o}else break;else if("&"===e[o]){let t=validateAmpersand(e,o);if(-1==t)return getErrorObject("InvalidChar","char '&' is not expected.",getLineNumberForPosition(e,o));o=t}else if(!0===i&&!isWhiteSpace(e[o]))return getErrorObject("InvalidXml","Extra text at the end",getLineNumberForPosition(e,o));"<"===e[o]&&o--}}else{if(isWhiteSpace(e[o]))continue;return getErrorObject("InvalidChar","char '"+e[o]+"' is not expected.",getLineNumberForPosition(e,o))}return r?1==n.length?getErrorObject("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",getLineNumberForPosition(e,n[0].tagStartPos)):!(n.length>0)||getErrorObject("InvalidXml","Invalid '"+JSON.stringify(n.map(e=>e.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):getErrorObject("InvalidXml","Start tag expected.",1)}function isWhiteSpace(e){return" "===e||" "===e||"\n"===e||"\r"===e}function readPI(e,t){let n=t;for(;t<e.length;t++)if("?"==e[t]||" "==e[t]){let r=e.substr(n,t-n);if(t>5&&"xml"===r)return getErrorObject("InvalidXml","XML declaration allowed only at the start of the document.",getLineNumberForPosition(e,t));if("?"!=e[t]||">"!=e[t+1])continue;t++;break}return t}function readCommentAndCDATA(e,t){if(e.length>t+5&&"-"===e[t+1]&&"-"===e[t+2]){for(t+=3;t<e.length;t++)if("-"===e[t]&&"-"===e[t+1]&&">"===e[t+2]){t+=2;break}}else if(e.length>t+8&&"D"===e[t+1]&&"O"===e[t+2]&&"C"===e[t+3]&&"T"===e[t+4]&&"Y"===e[t+5]&&"P"===e[t+6]&&"E"===e[t+7]){let n=1;for(t+=8;t<e.length;t++)if("<"===e[t])n++;else if(">"===e[t]&&0==--n)break}else if(e.length>t+9&&"["===e[t+1]&&"C"===e[t+2]&&"D"===e[t+3]&&"A"===e[t+4]&&"T"===e[t+5]&&"A"===e[t+6]&&"["===e[t+7]){for(t+=8;t<e.length;t++)if("]"===e[t]&&"]"===e[t+1]&&">"===e[t+2]){t+=2;break}}return t}const doubleQuote='"',singleQuote="'";function readAttributeStr(e,t){let n="",r="",i=!1;for(;t<e.length;t++){if(e[t]===doubleQuote||e[t]===singleQuote)""===r?r=e[t]:r!==e[t]||(r="");else if(">"===e[t]&&""===r){i=!0;break}n+=e[t]}return""===r&&{value:n,index:t,tagClosed:i}}const validAttrStrRegxp=RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function validateAttributeString(e,t){let n=getAllMatches(e,validAttrStrRegxp),r={};for(let e=0;e<n.length;e++){if(0===n[e][1].length)return getErrorObject("InvalidAttr","Attribute '"+n[e][2]+"' has no space in starting.",getPositionFromMatch(n[e]));if(void 0!==n[e][3]&&void 0===n[e][4])return getErrorObject("InvalidAttr","Attribute '"+n[e][2]+"' is without value.",getPositionFromMatch(n[e]));if(void 0===n[e][3]&&!t.allowBooleanAttributes)return getErrorObject("InvalidAttr","boolean attribute '"+n[e][2]+"' is not allowed.",getPositionFromMatch(n[e]));let i=n[e][2];if(!validateAttrName(i))return getErrorObject("InvalidAttr","Attribute '"+i+"' is an invalid name.",getPositionFromMatch(n[e]));if(r.hasOwnProperty(i))return getErrorObject("InvalidAttr","Attribute '"+i+"' is repeated.",getPositionFromMatch(n[e]));r[i]=1}return!0}function validateNumberAmpersand(e,t){let n=/\d/;for("x"===e[t]&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(";"===e[t])return t;if(!e[t].match(n))break}return -1}function validateAmpersand(e,t){if(";"===e[++t])return -1;if("#"===e[t])return validateNumberAmpersand(e,++t);let n=0;for(;t<e.length;t++,n++)if(!e[t].match(/\w/)||!(n<20)){if(";"===e[t])break;return -1}return t}function getErrorObject(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function validateAttrName(e){return isName(e)}function validateTagName(e){return isName(e)}function getLineNumberForPosition(e,t){let n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function getPositionFromMatch(e){return e.startIndex+e[1].length}class XMLParser{constructor(e){this.externalEntities={},this.options=buildOptions(e)}parse(e,t){if("string"==typeof e);else if(e.toString)e=e.toString();else throw Error("XML data is accepted in String or Bytes[] form.");if(t){!0===t&&(t={});let n=validate(e,t);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}let n=new OrderedObjParser(this.options);n.addExternalEntities(this.externalEntities);let r=n.parseXml(e);return this.options.preserveOrder||void 0===r?r:prettify(r,this.options)}addEntity(e,t){if(-1!==t.indexOf("&"))throw Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===t)throw Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return XmlNode.getMetaDataSymbol()}}const iqiyiIdSchema=schemas_object({entityId:schemas_string()}),iqiyiEpisodeTabDataVideoSchema=schemas_object({page_url:schemas_string(),short_display_name:schemas_string().optional(),title:schemas_string(),mark_type_show:schemas_int().optional()}).transform(e=>{var t,n;let r=null!=(n=null==(t=e.page_url.match(/v_(\S+)\.html/))?void 0:t[1])?n:"";return{...e,videoId:r}}),safeParseVideo=e=>{let t=iqiyiEpisodeTabDataVideoSchema.safeParse(e);return t.success?t.data:null},iqiyiTvTabSchema=schemas_object({bk_id:literal("selector_bk"),bk_type:literal("album_episodes"),data:schemas_object({data:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({videos:schemas_object({feature_paged:record(any(),schemas_array(unknown()))})}).safeParse(e).data)?t:null})).transform(e=>{let t=[];for(let i of e){var n,r;if(i)for(let e of Object.values(null!=(r=null==(n=i.videos)?void 0:n.feature_paged)?r:{}))for(let n of e){let e=safeParseVideo(n);e&&t.push(e)}}return t})})}),iqiyiVarietyShowTabSchema=schemas_object({bk_id:literal("source_selector_bk"),bk_type:literal("video_list"),data:schemas_object({data:schemas_array(unknown().transform(e=>{let t=schemas_object({videos:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({data:schemas_array(unknown())}).safeParse(e).data)?t:null}))}).safeParse(e);if(!t.success)return[];let n=[];for(let e of t.data.videos)if(e)for(let t of e.data){let e=safeParseVideo(t);e&&n.push(e)}return n})).transform(e=>e.flat())})}),iqiyiMovieTabSchema=schemas_object({bk_id:literal("film_feature_bk"),bk_type:literal("video_list"),data:schemas_object({data:schemas_object({videos:schemas_array(unknown())}).transform(e=>compact(e.videos.map(safeParseVideo)))})}),iqiyiEpisodeTabSchema=union([iqiyiTvTabSchema,iqiyiMovieTabSchema,iqiyiVarietyShowTabSchema]).transform(e=>e.data.data),iqiyiV3ApiResponseSchema=schemas_object({status_code:schemas_number(),data:schemas_object({template:schemas_object({tabs:schemas_array(schemas_object({tab_id:schemas_string(),tab_title:schemas_string(),blocks:schemas_array(unknown())}))})}).optional()}).transform(e=>{var t,n;let r=[];for(let i of null!=(n=null==(t=e.data)?void 0:t.template.tabs)?n:[])for(let e of i.blocks){let{success:t,data:n}=iqiyiEpisodeTabSchema.safeParse(e);t&&(r=r.concat(n))}return r}),iqiyiVideoBaseInfoResponseSchema=schemas_object({data:schemas_object({tvId:schemas_int(),albumId:schemas_int(),durationSec:schemas_int()})}),iqiyiCommentsEntrySchema=schemas_object({int:schemas_number(),list:schemas_object({bulletInfo:schemas_array(unknown().transform(e=>schemas_object({contentId:schemas_string(),content:schemas_string(),showTime:schemas_number(),color:schemas_string().optional().default(DEFAULT_COLOR_HEX).transform(e=>parseInt(e,16))}).transform(e=>providerCommentItemSchema.safeParse({id:e.contentId.toString(),timestamp:e.showTime,color:e.color,content:e.content}).data).safeParse(e).data)).transform(e=>compact(e))})}),iqiyiCommentsResponseSchema=schemas_object({danmu:looseObject({data:schemas_object({entry:schemas_array(unknown().transform(e=>{var t;return null==(t=iqiyiCommentsEntrySchema.safeParse(e).data)?void 0:t.list.bulletInfo})).transform(e=>compact(e.flat()))})})}).transform(e=>e.danmu.data.entry);function iqiyi_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class IqiyiScraper extends BaseScraper{async getEpisodes(e,t){let n=this.parseIdString(e);if(!n)return[];let r=[];try{r=await this.getEpisodesV3(n.entityId)}catch(e){this.logger.warn("新版API (v3) 获取分集时发生错误:",e),r=[]}return t?r.filter(e=>e.episodeNumber===t):r}async getSegments(e){let t=this.parseIdString(e);if(!t)return[];let n=await this.getVideoBaseInfo(t.entityId),r=null==n?void 0:n.durationSec;return r?Array.from({length:Math.floor(r/300)+1},(e,t)=>({provider:this.providerName,startTime:300*t,segmentId:(t+1).toString()})):[]}async getComments(e,t){let n=this.parseIdString(e);if(!n)return[];let r=n.entityId;if(!r||r.length<4)return[];let i=r.slice(-4,-2),o=r.slice(-2),a=`http://cmts.iqiyi.com/bullet/${i}/${o}/${r}_300_${t}.z`;this.logger.debug("URL构建: s1=",i,"s2=",o,"完整URL=",a);let s=await this.fetch.get(a,{zlibMode:!0}),l=this.xmlParser.parse(s.data),{success:u,data:c,error:d}=iqiyiCommentsResponseSchema.safeParse(l);return u?c:(this.logger.warn("解析弹幕数据时发生错误:",prettifyError(d)),[])}async getEpisodesV3(e){let t={entity_id:e,device_id:"qd5fwuaj4hunxxdgzwkcqmefeb3ww5hx",auth_cookie:"",user_id:"0",vip_type:"-1",vip_status:"0",conduit_id:"",pcv:"13.082.22866",app_version:"13.082.22866",ext:"",app_mode:"standard",scale:"100",timestamp:Date.now().toString(),src:"pca_tvg",os:"",ad_ext:'{"r":"2.2.0-ares6-pure"}'};t.sign=this.createSign(t);try{let e=await this.fetch.get("https://www.iqiyi.com/prelw/tvg/v2/lw/base_info",{params:t,schema:iqiyiV3ApiResponseSchema});if(!e.data)return[];let r=[],i=1;for(let t of e.data){var n;if(17===t.mark_type_show)continue;let e=this.videoIdToEntityId(t.videoId);e&&(this.episodeBlacklistPattern.test(t.title)||(r.push({provider:this.providerName,episodeId:this.generateIdString({entityId:e}),episodeTitle:t.title,episodeNumber:t.short_display_name&&null!=(n=this.getEpisodeIndexFromTitle(t.short_display_name))?n:i}),i+=1))}return r}catch(e){return this.logger.error("获取分集时发生错误:",e),[]}}videoIdToEntityId(e){try{let t,n=parseInt(e,36),r=BigInt(n)^BigInt(0x75706971676c);return(t=r<BigInt(9e5)?BigInt(100)*(r+BigInt(9e5)):r).toString()}catch(t){return this.logger.error("将 video_id '",e,"' 转换为 entity_id 时出错:",t),null}}createSign(e){let t=Object.keys(e).filter(e=>"sign"!==e).sort().map(t=>{var n;return`${t}=${null!=(n=e[t])?n:""}`}).join("&");return md5_default()(`${t}&secret_key=howcuteitis`).toString().toUpperCase()}async getVideoBaseInfo(e){var t;return null==(t=(await this.fetch.get(`https://pcw-api.iqiyi.com/video/video/baseinfo/${e}`,{schema:iqiyiVideoBaseInfoResponseSchema,cache:{cacheKey:`iqiyi:video:baseinfo:${e}`}})).data)?void 0:t.data}constructor(){super(),iqiyi_define_property(this,"providerName","iqiyi"),iqiyi_define_property(this,"xmlParser",new XMLParser({htmlEntities:!0})),iqiyi_define_property(this,"idSchema",iqiyiIdSchema),iqiyi_define_property(this,"PROVIDER_SPECIFIC_BLACKLIST","^(.*?)(抢先(版|篇)?|加更(版|篇)?|花絮|预告|特辑|彩蛋|专访|幕后(故事|花絮)?|直播|纯享|未播|衍生|番外|会员(专属|加长)?|片花|精华|看点|速览|解读|reaction|影评)(.*?)$"),this.fetch.setCookie({pgv_pvid:"40b67e3b06027f3d",video_platform:"2",vversion_name:"8.2.95",video_bucketid:"4",video_omgid:"0a1ff6bc9407c0b1cff86ee5d359614d"}),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Mobile Safari/537.36 Edg/136.0.0.0"})}}const formatDistanceLocale={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},formatDistance=(e,t,n)=>{let r,i=formatDistanceLocale[e];if(r="string"==typeof i?i:1===t?i.one:i.other.replace("{{count}}",t.toString()),n?.addSuffix)if(n.comparison&&n.comparison>0)return"in "+r;else return r+" ago";return r};function buildFormatLongFn(e){return (t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const dateFormats={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},timeFormats={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},dateTimeFormats={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},formatLong_formatLong={date:buildFormatLongFn({formats:dateFormats,defaultWidth:"full"}),time:buildFormatLongFn({formats:timeFormats,defaultWidth:"full"}),dateTime:buildFormatLongFn({formats:dateTimeFormats,defaultWidth:"full"})},formatRelativeLocale={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},formatRelative=(e,t,n,r)=>formatRelativeLocale[e];function buildLocalizeFn(e){return(t,n)=>{let r;if("formatting"===(n?.context?String(n.context):"standalone")&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,i=n?.width?String(n.width):t;r=e.formattingValues[i]||e.formattingValues[t]}else{let t=e.defaultWidth,i=n?.width?String(n.width):e.defaultWidth;r=e.values[i]||e.values[t]}return r[e.argumentCallback?e.argumentCallback(t):t]}}const eraValues={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},quarterValues={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},monthValues={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},dayValues={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},dayPeriodValues={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},formattingDayPeriodValues={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ordinalNumber=(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},localize_localize={ordinalNumber,era:buildLocalizeFn({values:eraValues,defaultWidth:"wide"}),quarter:buildLocalizeFn({values:quarterValues,defaultWidth:"wide",argumentCallback:e=>e-1}),month:buildLocalizeFn({values:monthValues,defaultWidth:"wide"}),day:buildLocalizeFn({values:dayValues,defaultWidth:"wide"}),dayPeriod:buildLocalizeFn({values:dayPeriodValues,defaultWidth:"wide",formattingValues:formattingDayPeriodValues,defaultFormattingWidth:"wide"})};function buildMatchFn(e){return(t,n={})=>{let r,i=n.width,o=i&&e.matchPatterns[i]||e.matchPatterns[e.defaultMatchWidth],a=t.match(o);if(!a)return null;let s=a[0],l=i&&e.parsePatterns[i]||e.parsePatterns[e.defaultParseWidth],u=Array.isArray(l)?findIndex(l,e=>e.test(s)):findKey(l,e=>e.test(s));return r=e.valueCallback?e.valueCallback(u):u,{value:r=n.valueCallback?n.valueCallback(r):r,rest:t.slice(s.length)}}}function findKey(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function findIndex(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function buildMatchPatternFn(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],o=t.match(e.parsePattern);if(!o)return null;let a=e.valueCallback?e.valueCallback(o[0]):o[0];return{value:a=n.valueCallback?n.valueCallback(a):a,rest:t.slice(i.length)}}}const matchOrdinalNumberPattern=/^(\d+)(th|st|nd|rd)?/i,parseOrdinalNumberPattern=/\d+/i,matchEraPatterns={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},parseEraPatterns={any:[/^b/i,/^(a|c)/i]},matchQuarterPatterns={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},parseQuarterPatterns={any:[/1/i,/2/i,/3/i,/4/i]},matchMonthPatterns={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},parseMonthPatterns={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},matchDayPatterns={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},parseDayPatterns={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},matchDayPeriodPatterns={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},parseDayPeriodPatterns={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},match_match={ordinalNumber:buildMatchPatternFn({matchPattern:matchOrdinalNumberPattern,parsePattern:parseOrdinalNumberPattern,valueCallback:e=>parseInt(e,10)}),era:buildMatchFn({matchPatterns:matchEraPatterns,defaultMatchWidth:"wide",parsePatterns:parseEraPatterns,defaultParseWidth:"any"}),quarter:buildMatchFn({matchPatterns:matchQuarterPatterns,defaultMatchWidth:"wide",parsePatterns:parseQuarterPatterns,defaultParseWidth:"any",valueCallback:e=>e+1}),month:buildMatchFn({matchPatterns:matchMonthPatterns,defaultMatchWidth:"wide",parsePatterns:parseMonthPatterns,defaultParseWidth:"any"}),day:buildMatchFn({matchPatterns:matchDayPatterns,defaultMatchWidth:"wide",parsePatterns:parseDayPatterns,defaultParseWidth:"any"}),dayPeriod:buildMatchFn({matchPatterns:matchDayPeriodPatterns,defaultMatchWidth:"any",parsePatterns:parseDayPeriodPatterns,defaultParseWidth:"any"})},enUS={code:"en-US",formatDistance:formatDistance,formatLong:formatLong_formatLong,formatRelative:formatRelative,localize:localize_localize,match:match_match,options:{weekStartsOn:0,firstWeekContainsDate:1}};let defaultOptions_defaultOptions={};function getDefaultOptions(){return defaultOptions_defaultOptions}const millisecondsInWeek=6048e5,millisecondsInDay=864e5,constructFromSymbol=Symbol.for("constructDateFrom");function constructFrom_constructFrom(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&constructFromSymbol in e?e[constructFromSymbol](t):e instanceof Date?new e.constructor(t):new Date(t)}function toDate(e,t){return constructFrom_constructFrom(t||e,e)}function getTimezoneOffsetInMilliseconds(e){let t=toDate(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-n}function normalizeDates(e,...t){let n=constructFrom_constructFrom.bind(null,e||t.find(e=>"object"==typeof e));return t.map(n)}function startOfDay(e,t){let n=toDate(e,t?.in);return n.setHours(0,0,0,0),n}function differenceInCalendarDays(e,t,n){let[r,i]=normalizeDates(n?.in,e,t),o=startOfDay(r),a=startOfDay(i);return Math.round((o-getTimezoneOffsetInMilliseconds(o)-(a-getTimezoneOffsetInMilliseconds(a)))/millisecondsInDay)}function startOfYear(e,t){let n=toDate(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function getDayOfYear(e,t){let n=toDate(e,t?.in);return differenceInCalendarDays(n,startOfYear(n))+1}function startOfWeek(e,t){let n=getDefaultOptions(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=toDate(e,t?.in),o=i.getDay(),a=7*(o<r)+o-r;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function startOfISOWeek(e,t){return startOfWeek(e,{...t,weekStartsOn:1})}function getISOWeekYear_getISOWeekYear(e,t){let n=toDate(e,t?.in),r=n.getFullYear(),i=constructFrom_constructFrom(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let o=startOfISOWeek(i),a=constructFrom_constructFrom(n,0);a.setFullYear(r,0,4),a.setHours(0,0,0,0);let s=startOfISOWeek(a);return n.getTime()>=o.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function startOfISOWeekYear(e,t){let n=getISOWeekYear_getISOWeekYear(e,t),r=constructFrom_constructFrom(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),startOfISOWeek(r)}function getISOWeek_getISOWeek(e,t){let n=toDate(e,t?.in);return Math.round((startOfISOWeek(n)-startOfISOWeekYear(n))/millisecondsInWeek)+1}function getWeekYear(e,t){let n=toDate(e,t?.in),r=n.getFullYear(),i=getDefaultOptions(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=constructFrom_constructFrom(t?.in||e,0);a.setFullYear(r+1,0,o),a.setHours(0,0,0,0);let s=startOfWeek(a,t),l=constructFrom_constructFrom(t?.in||e,0);l.setFullYear(r,0,o),l.setHours(0,0,0,0);let u=startOfWeek(l,t);return+n>=+s?r+1:+n>=+u?r:r-1}function startOfWeekYear_startOfWeekYear(e,t){let n=getDefaultOptions(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=getWeekYear(e,t),o=constructFrom_constructFrom(t?.in||e,0);return o.setFullYear(i,0,r),o.setHours(0,0,0,0),startOfWeek(o,t)}function getWeek(e,t){let n=toDate(e,t?.in);return Math.round((startOfWeek(n,t)-startOfWeekYear_startOfWeekYear(n,t))/millisecondsInWeek)+1}function addLeadingZeros(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}const lightFormatters={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return addLeadingZeros("yy"===t?r%100:r,t.length)},M(e,t){let n=e.getMonth();return"M"===t?String(n+1):addLeadingZeros(n+1,2)},d:(e,t)=>addLeadingZeros(e.getDate(),t.length),a(e,t){let n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return"am"===n?"a.m.":"p.m."}},h:(e,t)=>addLeadingZeros(e.getHours()%12||12,t.length),H:(e,t)=>addLeadingZeros(e.getHours(),t.length),m:(e,t)=>addLeadingZeros(e.getMinutes(),t.length),s:(e,t)=>addLeadingZeros(e.getSeconds(),t.length),S(e,t){let n=t.length;return addLeadingZeros(Math.trunc(e.getMilliseconds()*Math.pow(10,n-3)),t.length)}},dayPeriodEnum={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},formatters={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if("yo"===t){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:"year"})}return lightFormatters.y(e,t)},Y:function(e,t,n,r){let i=getWeekYear(e,r),o=i>0?i:1-i;return"YY"===t?addLeadingZeros(o%100,2):"Yo"===t?n.ordinalNumber(o,{unit:"year"}):addLeadingZeros(o,t.length)},R:function(e,t){return addLeadingZeros(getISOWeekYear_getISOWeekYear(e),t.length)},u:function(e,t){return addLeadingZeros(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return addLeadingZeros(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return addLeadingZeros(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){let r=e.getMonth();switch(t){case"M":case"MM":return lightFormatters.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){let r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return addLeadingZeros(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){let i=getWeek(e,r);return"wo"===t?n.ordinalNumber(i,{unit:"week"}):addLeadingZeros(i,t.length)},I:function(e,t,n){let r=getISOWeek_getISOWeek(e);return"Io"===t?n.ordinalNumber(r,{unit:"week"}):addLeadingZeros(r,t.length)},d:function(e,t,n){return"do"===t?n.ordinalNumber(e.getDate(),{unit:"date"}):lightFormatters.d(e,t)},D:function(e,t,n){let r=getDayOfYear(e);return"Do"===t?n.ordinalNumber(r,{unit:"dayOfYear"}):addLeadingZeros(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){let i=e.getDay(),o=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return addLeadingZeros(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){let i=e.getDay(),o=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return addLeadingZeros(o,t.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){let r=e.getDay(),i=0===r?7:r;switch(t){case"i":return String(i);case"ii":return addLeadingZeros(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){let r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,n){let r,i=e.getHours();switch(r=12===i?dayPeriodEnum.noon:0===i?dayPeriodEnum.midnight:i/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(e,t,n){let r,i=e.getHours();switch(r=i>=17?dayPeriodEnum.evening:i>=12?dayPeriodEnum.afternoon:i>=4?dayPeriodEnum.morning:dayPeriodEnum.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(e,t,n){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),n.ordinalNumber(t,{unit:"hour"})}return lightFormatters.h(e,t)},H:function(e,t,n){return"Ho"===t?n.ordinalNumber(e.getHours(),{unit:"hour"}):lightFormatters.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return"Ko"===t?n.ordinalNumber(r,{unit:"hour"}):addLeadingZeros(r,t.length)},k:function(e,t,n){let r=e.getHours();return(0===r&&(r=24),"ko"===t)?n.ordinalNumber(r,{unit:"hour"}):addLeadingZeros(r,t.length)},m:function(e,t,n){return"mo"===t?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):lightFormatters.m(e,t)},s:function(e,t,n){return"so"===t?n.ordinalNumber(e.getSeconds(),{unit:"second"}):lightFormatters.s(e,t)},S:function(e,t){return lightFormatters.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(0===r)return"Z";switch(t){case"X":return formatTimezoneWithOptionalMinutes(r);case"XXXX":case"XX":return formatTimezone(r);default:return formatTimezone(r,":")}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case"x":return formatTimezoneWithOptionalMinutes(r);case"xxxx":case"xx":return formatTimezone(r);default:return formatTimezone(r,":")}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+formatTimezoneShort(r,":");default:return"GMT"+formatTimezone(r,":")}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+formatTimezoneShort(r,":");default:return"GMT"+formatTimezone(r,":")}},t:function(e,t,n){return addLeadingZeros(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return addLeadingZeros(+e,t.length)}};function formatTimezoneShort(e,t=""){let n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),o=r%60;return 0===o?n+String(i):n+String(i)+t+addLeadingZeros(o,2)}function formatTimezoneWithOptionalMinutes(e,t){return e%60==0?(e>0?"-":"+")+addLeadingZeros(Math.abs(e)/60,2):formatTimezone(e,t)}function formatTimezone(e,t=""){let n=e>0?"-":"+",r=Math.abs(e);return n+addLeadingZeros(Math.trunc(r/60),2)+t+addLeadingZeros(r%60,2)}const dateLongFormatter=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},timeLongFormatter=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},dateTimeLongFormatter=(e,t)=>{let n,r=e.match(/(P+)(p+)?/)||[],i=r[1],o=r[2];if(!o)return dateLongFormatter(e,t);switch(i){case"P":n=t.dateTime({width:"short"});break;case"PP":n=t.dateTime({width:"medium"});break;case"PPP":n=t.dateTime({width:"long"});break;default:n=t.dateTime({width:"full"})}return n.replace("{{date}}",dateLongFormatter(i,t)).replace("{{time}}",timeLongFormatter(o,t))},longFormatters={p:timeLongFormatter,P:dateTimeLongFormatter},dayOfYearTokenRE=/^D+$/,weekYearTokenRE=/^Y+$/,throwTokens=["D","DD","YY","YYYY"];function isProtectedDayOfYearToken(e){return dayOfYearTokenRE.test(e)}function isProtectedWeekYearToken(e){return weekYearTokenRE.test(e)}function warnOrThrowProtectedError(e,t,n){let r=protectedTokens_message(e,t,n);if(console.warn(r),throwTokens.includes(e))throw RangeError(r)}function protectedTokens_message(e,t,n){let r="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}function isDate_isDate(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}function isValid_isValid(e){return!(!isDate_isDate(e)&&"number"!=typeof e||isNaN(+toDate(e)))}const formattingTokensRegExp=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,longFormattingTokensRegExp=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,escapedStringRegExp=/^'([^]*?)'?$/,doubleQuoteRegExp=/''/g,unescapedLatinCharacterRegExp=/[a-zA-Z]/;function format_format(e,t,n){let r=getDefaultOptions(),i=n?.locale??r.locale??enUS,o=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,a=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=toDate(e,n?.in);if(!isValid_isValid(s))throw RangeError("Invalid time value");let l=t.match(longFormattingTokensRegExp).map(e=>{let t=e[0];return"p"===t||"P"===t?(0,longFormatters[t])(e,i.formatLong):e}).join("").match(formattingTokensRegExp).map(e=>{if("''"===e)return{isToken:!1,value:"'"};let t=e[0];if("'"===t)return{isToken:!1,value:cleanEscapedString(e)};if(formatters[t])return{isToken:!0,value:e};if(t.match(unescapedLatinCharacterRegExp))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(l=i.localize.preprocessor(s,l));let u={firstWeekContainsDate:o,weekStartsOn:a,locale:i};return l.map(r=>{if(!r.isToken)return r.value;let o=r.value;return(!n?.useAdditionalWeekYearTokens&&isProtectedWeekYearToken(o)||!n?.useAdditionalDayOfYearTokens&&isProtectedDayOfYearToken(o))&&warnOrThrowProtectedError(o,t,String(e)),(0,formatters[o[0]])(s,o,i.localize,u)}).join("")}function cleanEscapedString(e){let t=e.match(escapedStringRegExp);return t?t[1].replace(doubleQuoteRegExp,"'"):e}function uniqBy(e,t){let n=new Map;for(let r=0;r<e.length;r++){let i=e[r],o=t(i);n.has(o)||n.set(o,i)}return Array.from(n.values())}function identity(e){return e}function range(e,t,n=1){if(null==t&&(t=e,e=0),!Number.isInteger(n)||0===n)throw Error("The step value must be a non-zero integer.");let r=Math.max(Math.ceil((t-e)/n),0),i=Array(r);for(let t=0;t<r;t++)i[t]=e+t*n;return i}function isLength(e){return Number.isSafeInteger(e)&&e>=0}function isArrayLike(e){return null!=e&&"function"!=typeof e&&isLength(e.length)}function reduceRight(e,t=identity,n){let r,i;if(!e)return n;isArrayLike(e)?(r=range(0,e.length).reverse(),null==n&&e.length>0?(n=e[e.length-1],i=1):i=0):(r=Object.keys(e).reverse(),null==n?(n=e[r[0]],i=1):i=0);for(let o=i;o<r.length;o++){let i=r[o];n=t(n,e[i],i,e)}return n}const mgtvIdSchema=schemas_object({dramaId:schemas_string(),videoId:schemas_string().optional()}),mgtvSearchResponseSchema=schemas_object({data:schemas_object({contents:schemas_array(unknown().transform(e=>{var t,n;return null!=(n=null==(t=schemas_object({type:literal("media"),data:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({source:literal("imgo"),title:schemas_string().transform(e=>e.replace(/<[^>]*>?/g,"").trim()),url:schemas_string(),desc:schemas_array(schemas_string())}).transform(e=>{let[,,t,n]=e.url.split("/"),r=n.split(".").shift();return{...e,dramaId:t,videoId:r,get mediaType(){var i,o;return"电影"===(null==(o=e.desc)||null==(i=o[0].split("/"))?void 0:i[0].replace("类型:","").trim())?constants_MediaType.Movie:constants_MediaType.TV}}}).safeParse(e).data)?t:null})).transform(e=>compact(e))}).safeParse(e).data)?void 0:t.data)?n:null})).transform(e=>compact(e))})}).transform(e=>compact(e.data.contents.flat())),episodeBlacklistPattern=getEpisodeBlacklistPattern("^(.*?)(抢先(看|版)|加更(版)?|花絮|预告|特辑|(特别|惊喜|纳凉)?企划|彩蛋|专访|幕后(花絮)?|直播|纯享|未播|衍生|番外|合伙人手记|会员(专享|加长)|片花|精华|看点|速看|解读|reaction|超前营业|超前(vlog)?|陪看(记)?|.{3,}篇|影评)(.*?)$"),mgtvEpisodeInfoResponseSchema=schemas_object({data:schemas_object({tab_m:schemas_array(schemas_object({m:schemas_string()})).catch([]),list:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({isIntact:schemas_string(),isnew:schemas_string(),video_id:schemas_string(),t1:schemas_string().refine(e=>!episodeBlacklistPattern.test(e)),t2:schemas_string().refine(e=>!episodeBlacklistPattern.test(e)),t3:schemas_string(),time:schemas_string().transform(e=>reduceRight(e.split(":"),(e,t,n)=>0===n?e+parseInt(t):1===n?e+60*parseInt(t):e+3600*parseInt(t),0))}).safeParse(e).data)?t:null})).transform(e=>compact(e))})}),mgtvCommentConfigResponseSchema=schemas_object({status:literal(0),data:schemas_object({cdn_list:schemas_string().transform(e=>e.split(",")).catch(["bullet-ali.hitv.com"]),cdn_version:schemas_string()})}).transform(e=>e.data),commentColorSchema=schemas_object({r:schemas_number().min(0).max(255),g:schemas_number().min(0).max(255),b:schemas_number().min(0).max(255)}).transform(e=>256*e.r*256+256*e.g+e.b).catch(-1),mgtvCommentResponseSchema=schemas_object({data:schemas_object({items:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({ids:schemas_string(),content:schemas_string(),time:schemas_number().transform(e=>e/1e3),v2_color:schemas_object({color_left:commentColorSchema,color_right:commentColorSchema}).optional().transform(e=>e&&(-1!==e.color_left||-1!==e.color_right)?-1===e.color_left?e.color_right:-1===e.color_right?e.color_left:(e.color_left+e.color_right)/2:DEFAULT_COLOR_INT),v2_position:schemas_int().optional().transform(e=>{switch(e){case 1:return 5;case 2:return 4;default:return 1}})}).safeParse(e).data)?t:null}).transform(e=>{var t;return e&&null!=(t=providerCommentItemSchema.safeParse({id:e.ids,timestamp:e.time,mode:e.v2_position,color:e.v2_color,content:e.content}).data)?t:null})).transform(e=>compact(e))})}).transform(e=>e.data.items);function mgtv_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class MgTVScraper extends BaseScraper{async search(e){var t;let{success:n,data:r,error:i}=searchDanmuParamsSchema.safeParse(e);if(!n)return this.logger.error("搜索参数无效,错误:",prettifyError(i)),[];let{seriesName:o,season:a,airDate:s}=r;if(!o)return[];let l=await this.fetch.get("https://mobileso.bz.mgtv.com/msite/search/v2",{params:{q:o,pc:30,pn:1,sort:-99,ty:0,du:0,pt:0,corr:1,abroad:0,_support:"10000000000000000"},schema:mgtvSearchResponseSchema});if(!(null==(t=l.data)?void 0:t.length))return this.logger.warn("搜索结果为空"),[];let u=[];for(let e of l.data){if(e.mediaType===constants_MediaType.Movie){u.push({provider:this.providerName,dramaId:e.dramaId,dramaTitle:e.title,season:1});continue}let t=await this.getEpisodeInfo(e.dramaId,s);for(let n of null!=t?t:[])u.push({provider:this.providerName,dramaId:e.dramaId,dramaTitle:n.t3,season:null!=a?a:1})}return u}async getEpisodes(e,t){let n=this.parseIdString(e);if(!n)return[];let r=await this.getEpisodeInfo(n.dramaId);if(!(null==r?void 0:r.length))return[];let i=r.map((e,t)=>{var r;return{provider:this.providerName,episodeId:this.generateIdString({dramaId:n.dramaId,videoId:e.video_id}),episodeTitle:e.t3,episodeNumber:null!=(r=this.getEpisodeIndexFromTitle(e.t2))?r:t+1}});return t?i.filter(e=>e.episodeNumber===t):i}async getSegments(e){let t=this.parseIdString(e);if(!t)return[];let n=await this.getEpisodeInfo(t.dramaId);if(!(null==n?void 0:n.length))return this.logger.warn("没有找到对应的剧集",t.dramaId),[];let r=n.find(e=>e.video_id===t.videoId);return r?Array.from({length:Math.ceil(r.time/60)},(e,t)=>({provider:this.providerName,startTime:60*t,segmentId:t.toString()})):(this.logger.warn("没有找到对应的集数",t.dramaId,t.videoId),[])}async getComments(e,t){var n,r,i;let o=this.parseIdString(e);if(!o)return[];let a=await this.fetch.get("https://galaxy.bz.mgtv.com/getctlbarrage",{params:{version:"8.1.39",abroad:0,uuid:"",os:"10.15.7",platform:0,mac:"",cid:o.dramaId,vid:o.videoId,pid:"",ticket:""},schema:mgtvCommentConfigResponseSchema,cache:{cacheKey:`mgtv:comment_config:${o.dramaId}_${o.videoId}`,ttl:TTL_1_DAY}});return a.data&&null!=(i=(await this.fetch.get(`https://${null==(n=a.data)?void 0:n.cdn_list[0]}/${null==(r=a.data)?void 0:r.cdn_version}/${t}.json`,{schema:mgtvCommentResponseSchema})).data)?i:[]}async getEpisodeInfo(e,t){var n,r,i,o,a;let s="";try{t&&(s=format_format(t,"yyyyMM"))}catch(e){this.logger.warn("Failed to format air date",e)}let l=[],u=await this.getEpisodeInfoByMonth(e,s);if(l.push(...null!=(r=null==u||null==(n=u.data)?void 0:n.list)?r:[]),!s&&(null==u?void 0:u.data.tab_m.length))for(let t of(this.logger.warn("没有指定月份,拉取全部月份"),null!=(i=null==u?void 0:u.data.tab_m)?i:[])){let n=await this.getEpisodeInfoByMonth(e,t.m);l.push(...null!=(a=null==n||null==(o=n.data)?void 0:o.list)?a:[])}return uniqBy(l,e=>e.video_id)}async getEpisodeInfoByMonth(e,t){return(await this.fetch.get("https://pcweb.api.mgtv.com/variety/showlist",{params:{allowedRC:1,collection_id:e,month:t,page:1,_support:"10000000"},schema:mgtvEpisodeInfoResponseSchema,cache:`mgtv_episode_info_${e}_${t}`,successStatus:[200]})).data}constructor(){super(),mgtv_define_property(this,"providerName","mgtv"),mgtv_define_property(this,"idSchema",mgtvIdSchema),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",Referer:"https://www.mgtv.com/","Sec-Fetch-Site":"same-site","Sec-Fetch-Mode":"cors","Sec-Fetch-Dest":"empty"})}}var hmac_sha256=__webpack_require__(939),hmac_sha256_default=__webpack_require__.n(hmac_sha256);function isNil(e){return null==e}var aes=__webpack_require__(129),aes_default=__webpack_require__.n(aes),mode_ecb=__webpack_require__(760),mode_ecb_default=__webpack_require__.n(mode_ecb),pad_pkcs7=__webpack_require__(186),pad_pkcs7_default=__webpack_require__.n(pad_pkcs7);const renrenIdSchema=schemas_object({dramaId:coerce_number(),episodeId:coerce_number().optional()}),AES_KEY="3b744389882a4067",aesResponeSchema=schemas_string().transform(e=>{let t=enc_base64_default().parse(e);return safeJsonParseWithZod(aes_default().decrypt({ciphertext:t},enc_utf8_default().parse(AES_KEY),{mode:mode_ecb_default(),padding:pad_pkcs7_default()}).toString(enc_utf8_default()),schemas_object({data:unknown()}))}),renrenSearchResponseSchema=schemas_object({searchDramaList:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({id:schemas_string(),title:schemas_string(),subtitle:schemas_string().optional(),classify:preprocess(e=>{var t;return null!=(t=({电影:constants_MediaType.Movie,电视剧:constants_MediaType.TV})[e])?t:null},schemas_enum(constants_MediaType).nullish().catch(null)),name:schemas_string().optional(),year:coerce_number().optional()}).safeParse(e).data)?t:null})).transform(e=>compact(e))}),schema_episodeBlacklistPattern=getEpisodeBlacklistPattern(),renrenDramaInfoResponseSchema=schemas_object({dramaInfo:schemas_object({dramaId:coerce_number(),title:schemas_string(),enName:schemas_string().optional(),seasonNo:coerce_number().optional()}).optional(),episodeList:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({id:coerce_number(),episodeNo:coerce_number(),text:schemas_string().optional(),title:schemas_string().refine(e=>!schema_episodeBlacklistPattern.test(e)).optional()}).safeParse(e).data)?t:null})).transform(e=>compact(e))}),renrenCommentItemSchema=schemas_object({d:schemas_string(),p:schemas_string().transform(e=>{let t=e.split(","),n=coerce_number().catch(0).parse(t[0]),r=coerce_number().int().catch(1).parse(t[1]),i=coerce_number().int().catch(DEFAULT_COLOR_INT).parse(t[3]),o=t[6]||"",a=t[7]||`${n.toFixed(3)}:${o}`;return{timestamp:n,mode:r,color:i,userId:o,contentId:a}})}).transform(e=>{var t;return null!=(t=providerCommentItemSchema.safeParse({id:e.p.contentId,timestamp:e.p.timestamp,mode:e.p.mode,color:e.p.color,content:e.d}).data)?t:null});function renren_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const SIGN_SECRET="ES513W0B1CsdUrR13Qk5EgDAKPeeKZY",BASE_API="https://api.rrmj.plus",CLIENT_TYPE="web_pc",CLIENT_VERSION="1.0.0";class RenRenScraper extends BaseScraper{get deviceId(){return generateUUID().toUpperCase()}async search(e){let{success:t,data:n,error:r}=searchDanmuParamsSchema.safeParse(e);if(!t)return this.logger.error("搜索参数无效,错误:",prettifyError(r)),[];let{seriesName:i,season:o}=n;if(!i)return[];let a=await this.request("/m-station/search/drama",{params:{keywords:i,size:Math.max(10,null!=o?o:1),order:"match",search_after:"",isExecuteVipActivity:!0},cache:{cacheKey:`renren:search:${i}`,ttl:TTL_1_DAY},schema:aesResponeSchema.transform(e=>{var t;let n=renrenSearchResponseSchema.safeParse(null==e?void 0:e.data);return n.success?null==(t=n.data)?void 0:t.searchDramaList:(this.logger.warn("搜索解析错误,错误:",prettifyError(n.error),null==e?void 0:e.data),[])})});if(!a.data)return[];this.logger.info("搜索结果:",a.data);let s=[];for await(let e of a.data){var l,u,c,d,f,h,p;let t=e.title.replace(/<[^>]+>/g,"").replace(":",":"),n=await this.getDramaInfo(e.id);if(!n){this.logger.warn("详细信息未找到,title:",t,"id:",e.id);continue}if(!((null==(u=n.dramaInfo)||null==(l=u.enName)?void 0:l.includes(i))||(null==(d=n.dramaInfo)||null==(c=d.title)?void 0:c.includes(i))||t.includes(i)||(null==(f=e.name)?void 0:f.includes(i)))){this.logger.warn("置信度过低,跳过,title:",t,"id:",e.id);continue}let r=!1,a=null!=(p=null==(h=n.dramaInfo)?void 0:h.seasonNo)?p:1;isNil(o)||a!==o||(r=!0);let m={provider:this.providerName,dramaId:e.id,dramaTitle:t,season:a};if(s.push(m),r){this.logger.info("命中高置信度,忽略其他,title:",t,"id:",e.id),s=[m];break}}return s}async getEpisodes(e,t){let n=this.parseIdString(e);if(!n)return[];let r=await this.getDramaInfo(n.dramaId.toString());if(!r)return[];let i=r.episodeList.map(e=>{var t;return{provider:this.providerName,episodeId:this.generateIdString({dramaId:n.dramaId,episodeId:e.id}),episodeTitle:e.title||`${null==(t=r.dramaInfo)?void 0:t.title} E${e.episodeNo}`,episodeNumber:e.episodeNo}});return isNil(t)?i:i.filter(e=>e.episodeNumber===t)}async getSegments(){return[{provider:this.providerName,segmentId:"1",startTime:0}]}async getComments(e){let t=this.parseIdString(e);return(null==t?void 0:t.episodeId)?this.fetchEpisodeDanmu(t.episodeId.toString()):[]}async getDramaInfo(e){return(await this.request("/m-station/drama/page",{params:{hsdrOpen:0,isAgeLimit:0,dramaId:e,hevcOpen:1},schema:aesResponeSchema.transform(t=>{let n=renrenDramaInfoResponseSchema.safeParse(null==t?void 0:t.data);return n.success?n.data:(this.logger.warn("详细信息解析错误,dramaId:",e,"错误:",prettifyError(n.error),null==t?void 0:t.data),null)}),cache:{cacheKey:`renren:dramaInfo:${e}`,ttl:TTL_1_DAY}})).data}async fetchEpisodeDanmu(e){let t=`https://static-dm.rrmj.plus/v1/produce/danmu/EPISODE/${e}`;return"choice"===this.providerConfig.renren.mode&&(t=`https://static-dm.rrmj.plus/v1/produce/danmu/choice/EPISODE/${e}`),(await this.fetch.get(t,{headers:{Accept:"application/json"},schema:schemas_array(unknown().transform(e=>{var t;return null!=(t=renrenCommentItemSchema.safeParse(e).data)?t:null})).transform(e=>compact(e))})).data}generateSignature(e){let{method:t,aliId:n,timestampMs:r,path:i,sortedQuery:o,secret:a}=e,s=[t.toUpperCase(),`aliId:${n}`,`ct:${CLIENT_TYPE}`,`cv:${CLIENT_VERSION}`,`t:${r}`,`${i}?${o}`].join("\n"),l=hmac_sha256_default()(s,a);return enc_base64_default().stringify(l)}generateHeaders(e){let{method:t,path:n,params:r}=e,i=Object.entries(r).sort((e,t)=>e[0].localeCompare(t[0])).map(e=>{let[t,n]=e;return`${t}=${encodeURIComponent(n)}`}).join("&"),o=Date.now(),a=this.deviceId,s=this.generateSignature({method:t,aliId:a,timestampMs:o,path:n,sortedQuery:i,secret:SIGN_SECRET});return{clientVersion:CLIENT_VERSION,deviceId:a,clientType:CLIENT_TYPE,t:o.toString(),aliId:a,umid:a,token:"",cv:CLIENT_VERSION,ct:CLIENT_TYPE,uet:"9","x-ca-sign":s,Accept:"application/json"}}request(e,t){let{params:n={},...r}=t,i=this.generateHeaders({method:"GET",path:e,params:n});return this.fetch.get(`${BASE_API}${e}`,{...r,headers:i,params:n})}constructor(){super(),renren_define_property(this,"providerName","renren"),renren_define_property(this,"idSchema",renrenIdSchema),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0",Origin:"https://rrsp.com.cn",Referer:"https://rrsp.com.cn/"})}}const tencentIdSchema=schemas_object({cid:schemas_string(),vid:schemas_string().optional()}),tencent_schema_episodeBlacklistPattern=getEpisodeBlacklistPattern("拍摄花絮|制作花絮|幕后花絮|未播花絮|独家花絮|花絮特辑|预告片|先导预告|终极预告|正式预告|官方预告|彩蛋片段|删减片段|未播片段|番外彩蛋|精彩片段|精彩看点|精彩回顾|精彩集锦|看点解析|看点预告|NG镜头|NG花絮|番外篇|番外特辑|制作特辑|拍摄特辑|幕后特辑|导演特辑|演员特辑|片尾曲|插曲|主题曲|背景音乐|OST|音乐MV|歌曲MV|前季回顾|剧情回顾|往期回顾|内容总结|剧情盘点|精选合集|剪辑合集|混剪视频|独家专访|演员访谈|导演访谈|主创访谈|媒体采访|发布会采访|抢先看|抢先版|试看版|短剧|vlog|纯享|加更|reaction|精编|会员版|Plus|独家版|特别版|短片|合唱"),tencentEpisodeSchema=schemas_object({vid:schemas_string().refine(e=>!!e),is_trailer:schemas_string().refine(e=>"1"!==e),title:schemas_string().refine(e=>!tencent_schema_episodeBlacklistPattern.test(e)),union_title:schemas_string().refine(e=>!tencent_schema_episodeBlacklistPattern.test(e)).optional()}),tencentEpisodeResultSchema=schemas_object({data:schemas_object({module_list_datas:schemas_array(schemas_object({module_datas:schemas_array(schemas_object({item_data_lists:schemas_object({item_datas:schemas_array(schemas_object({item_params:unknown().transform(e=>{var t;return null!=(t=tencentEpisodeSchema.safeParse(e).data)?t:null})}).transform(e=>{var t;return null!=(t=e.item_params)?t:null})).transform(e=>compact(e))})}))}))})}).transform(e=>{var t,n,r,i,o,a;return null!=(a=null==(o=e.data.module_list_datas)||null==(i=o[0])||null==(r=i.module_datas)||null==(n=r[0])||null==(t=n.item_data_lists)?void 0:t.item_datas)?a:[]}),tencentSegmentIndexSchema=schemas_object({segment_index:record(schemas_string(),schemas_object({segment_name:schemas_string()}))}),tencentCommentItemSchema=schemas_object({id:schemas_string(),content:schemas_string(),time_offset:coerce_number().transform(e=>e/1e3),content_style:schemas_string().nullish().transform(e=>safeJsonParseWithZod(null!=e?e:"{}",schemas_object({color:schemas_string().optional().default(DEFAULT_COLOR_HEX),position:schemas_number().optional().default(1),gradient_colors:schemas_array(schemas_string()).optional()}).transform(e=>{var t;let n=1;2===e.position?n=5:3===e.position&&(n=4);let r=e.color?parseInt(e.color,16):DEFAULT_COLOR_INT;return r===DEFAULT_COLOR_INT&&(null==(t=e.gradient_colors)?void 0:t.length)&&(r=e.gradient_colors.reduce((e,t)=>e+parseInt(t,16),0)/e.gradient_colors.length),{mode:n,color:r}})))}).transform(e=>{var t,n,r;return null!=(r=providerCommentItemSchema.safeParse({id:e.id,timestamp:e.time_offset,mode:null==(t=e.content_style)?void 0:t.mode,color:null==(n=e.content_style)?void 0:n.color,content:e.content}).data)?r:null}),tencentSegmentSchema=schemas_object({barrage_list:schemas_array(unknown().transform(e=>{var t;return null!=(t=tencentCommentItemSchema.safeParse(e).data)?t:null})).transform(e=>e.filter(e=>null!==e))});function tencent_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const tencent_pageSize=100;class TencentScraper extends BaseScraper{async getEpisodes(e,t){let n=this.parseIdString(e);if(!n)return[];let r=await this.internalGetEpisodes(n.cid,t);return void 0!==t?r.filter(e=>e.episodeNumber===t):r}async getSegments(e){let t=this.parseIdString(e);if(!t)return[];let n={};try{var r;let e=await this.fetch.get(`https://dm.video.qq.com/barrage/base/${t.vid}`,{schema:tencentSegmentIndexSchema,cache:{cacheKey:`tencent:segment:${t.vid}`,ttl:TTL_2_HOURS}});if(!e.data)return[];if(!(null==(r=e.data)?void 0:r.segment_index))return this.logger.info("vid:",t.vid,"没有找到弹幕分段索引。"),[];n=e.data.segment_index}catch(e){return this.logger.error("获取弹幕索引失败,vid:",t.vid,"错误:",e),[]}let i=Object.keys(n).sort((e,t)=>parseInt(e,10)-parseInt(t,10));return this.logger.debug("为 vid:",t.vid,"找到",i.length,"个弹幕分段"),i.map(e=>{var t;return{provider:this.providerName,startTime:parseInt(e,10)/1e3,segmentId:null==(t=n[e])?void 0:t.segment_name}})}async getComments(e,t){var n,r;let i=this.parseIdString(e);if(!(null==i?void 0:i.vid))return[];let o=null!=(r=null==(n=(await this.fetch.get(`https://dm.video.qq.com/barrage/segment/${i.vid}/${t}`,{schema:tencentSegmentSchema})).data)?void 0:n.barrage_list)?r:[];return this.logger.info("找到",o.length,"条弹幕"),o}async getEpisodesPage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;this.fetch.setHeaders({Referer:`https://v.qq.com/x/cover/${e}.html`});let n=await this.fetch.post("https://pbaccess.video.qq.com/trpc.universal_backend_service.page_server_rpc.PageServer/GetPageData?video_appid=3000010&vplatform=2",{page_params:{cid:e,page_type:"detail_operation",page_id:"vsite_episode_list",id_type:"1",page_size:tencent_pageSize.toString(),lid:"0",req_from:"web_vsite",page_context:url_parse.qs.stringify({cid:e,detail_page_type:"0",id_type:"1",is_nocopyright:"false",is_skp_style:"false",list_page_context:`page_context:pg=${t};`,page_size:tencent_pageSize.toString(),req_from:"web_vsite",req_from_second_type:"detail_operation",req_type:"0"})},has_cache:1},{headers:{"Content-Type":"application/json"},schema:tencentEpisodeResultSchema,cache:`tencent:episodes:${e}:${t}`});return n.data?n.data.map(t=>{var n;let r=t.union_title&&t.union_title!==t.title?t.union_title:t.title;return{provider:this.providerName,episodeId:this.generateIdString({cid:e,vid:t.vid}),episodeTitle:r,episodeNumber:null!=(n=this.getEpisodeIndexFromTitle(r))?n:0}}):[]}async internalGetEpisodes(e,t){if(!t)return this.getEpisodesPage(e);let n=Math.floor((null!=t?t:1)/tencent_pageSize),r=await this.getEpisodesPage(e,n);if(r.find(e=>e.episodeNumber===t))return r;let i=Math.max(...r.map(e=>{var t;return null!=(t=e.episodeNumber)?t:0})),o=Math.min(...r.map(e=>{var t;return null!=(t=e.episodeNumber)?t:0}));return t>i?this.getEpisodesPage(e,n+1):t<o?this.getEpisodesPage(e,n-1):[]}constructor(){super(),tencent_define_property(this,"providerName","tencent"),tencent_define_property(this,"idSchema",tencentIdSchema),this.fetch.setCookie({pgv_pvid:"40b67e3b06027f3d",video_platform:"2",vversion_name:"8.2.95",video_bucketid:"4",video_omgid:"0a1ff6bc9407c0b1cff86ee5d359614d"}),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"})}}const youkuIdSchema=schemas_object({showId:schemas_string().optional(),vid:schemas_string().optional()}),youku_schema_episodeBlacklistPattern=getEpisodeBlacklistPattern("^(.*?)(抢先(版|篇)?|加更(版|篇)?|花絮|预告|特辑|彩蛋|专访|幕后(故事|花絮)?|直播|纯享|未播|衍生|番外|会员(专属|加长)?|片花|精华|看点|速览|解读|reaction|影评)(.*?)$"),youkuEpisodeInfoSchema=schemas_object({id:schemas_string(),show_id:schemas_string().optional(),title:schemas_string().refine(e=>!youku_schema_episodeBlacklistPattern.test(e)),seq:coerce_number().optional(),duration:schemas_string(),category:schemas_string(),link:schemas_string()}).transform(e=>({...e,get totalMat(){try{let t=parseFloat(e.duration);return Math.floor(t/60)+1}catch(e){return 0}}})),youkuVideoResultSchema=schemas_object({total:schemas_number().or(schemas_string().transform(e=>parseInt(e))),videos:schemas_array(youkuEpisodeInfoSchema)}),youkuCommentSchema=schemas_object({id:schemas_number(),content:schemas_string(),playat:schemas_number().transform(e=>e/1e3),propertis:schemas_string().nullish().transform(e=>safeJsonParseWithZod(null!=e?e:"{}",schemas_object({color:schemas_number().optional().default(DEFAULT_COLOR_INT),pos:schemas_number().optional().transform(e=>{let t=1;return 1===e?t=5:2===e&&(t=4),t})})))}).transform(e=>{var t,n,r;return null!=(r=providerCommentItemSchema.safeParse({id:e.id.toString(),timestamp:e.playat,mode:null==(t=e.propertis)?void 0:t.pos,color:null==(n=e.propertis)?void 0:n.color,content:e.content}).data)?r:null}),youkuDanmuResultSchema=schemas_object({data:schemas_object({result:schemas_array(youkuCommentSchema)})});function youku_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class YoukuScraper extends BaseScraper{get token(){var e,t;return(null!=(t=null==(e=this.fetch.getCookie("_m_h5_tk"))?void 0:e.split("_")[0])?t:"").substring(0,32)}get cna(){var e;return null!=(e=this.fetch.getCookie("cna"))?e:""}async getEpisodes(e,t){var n,r,i;let o=this.parseIdString(e);if(!o)return[];let a=o.showId;if(!a&&o.vid){let e=await this.getVideoInfo(o.vid);a=null!=(n=null==e?void 0:e.show_id)?n:""}if(!a)return[];let s=20,l=null!=t?t:1,u=Math.max(1,Math.ceil(l/20));try{let e=e=>e.filter(e=>!this.EPISODE_BLACKLIST_KEYWORDS.some(t=>e.title.includes(t))),n=(e,t)=>({provider:this.providerName,episodeId:this.generateIdString({showId:a,vid:e.id}),episodeTitle:e.title,episodeNumber:t}),o=await this.getEpisodesPage(a,u,s),c=e(null!=(r=null==o?void 0:o.videos)?r:[]),d=c.find(e=>e.seq===l);if(d)return[n(d,l)];let f=Number(null!=(i=null==o?void 0:o.total)?i:0),h=Math.max(1,Math.ceil(f/s)),p=Array.from({length:h},(e,t)=>t+1).filter(e=>e!==u),m=[];for(let e of p){await sleep(500);let t=await this.getEpisodesPage(a,e,s);m.push(t)}let g=e(m.flatMap(e=>{var t;return null!=(t=null==e?void 0:e.videos)?t:[]})),v=[...c,...g];if(void 0!==t){let e=v.find(e=>e.seq===l);return e?[n(e,l)]:[]}return v.sort((e,t)=>{var n,r;return(null!=(n=e.seq)?n:Number.MAX_SAFE_INTEGER)-(null!=(r=t.seq)?r:Number.MAX_SAFE_INTEGER)}).map((e,t)=>n(e,t+1))}catch(e){return this.logger.error("获取分集失败,showId:",a,"错误:",e),[]}}async getSegments(e){var t;let{vid:n}=null!=(t=this.parseIdString(e))?t:{};if(!n)return[];try{await this.ensureTokenCookie();let e=await this.getVideoInfo(n);if(!e)return this.logger.warn("获取分集信息失败,vid:",n),[];let t=e.totalMat;if(0===t)return this.logger.warn("视频时长为0,无法获取弹幕,vid:",n),[];return Array.from({length:t},(e,t)=>({provider:this.providerName,startTime:60*t,segmentId:t.toString()}))}catch(e){return this.logger.error("获取分段信息失败,vid:",n,"错误:",e),[]}}async getComments(e,t){var n;let{vid:r}=null!=(n=this.parseIdString(e))?n:{};if(!r)return[];try{return await this.ensureTokenCookie(),this.getDanmuContentByMat(r,parseInt(t,10))}catch(e){return this.logger.error("获取弹幕信息失败,vid:",r,"错误:",e),[]}}async getVideoInfo(e){return(await this.fetch.get("https://openapi.youku.com/v2/videos/show_basic.json",{params:{client_id:"53e6cc67237fc59a",package:"com.huawei.hwvplayer.youku",video_id:e},schema:youkuEpisodeInfoSchema,cache:{cacheKey:`youku:segments:${e}`}})).data}async getEpisodesPage(e,t,n){return(await this.fetch.get("https://openapi.youku.com/v2/shows/videos.json",{params:{client_id:"53e6cc67237fc59a",package:"com.huawei.hwvplayer.youku",ext:"show",show_id:e,page:t.toString(),count:n.toString()},schema:youkuVideoResultSchema,cache:{cacheKey:`youku:episodes:${e}:${t}:${n}`}})).data}async getDanmuContentByMat(e,t){if(!this.token)return this.logger.error("无法获取弹幕,_m_h5_tk 缺失"),[];let n={pid:0,ctype:10004,sver:"3.1.0",cver:"v1.0",ctime:Date.now(),guid:this.cna,vid:e,mat:t,mcount:1,type:1},r=JSON.stringify(Object.fromEntries(Object.entries(n).sort())),i=enc_base64_default().stringify(enc_utf8_default().parse(r));n.msg=i,n.sign=this.generateMsgSign(i);let o="24679788",a=JSON.stringify(n),s=Date.now().toString();try{var l,u,c;let e=null!=(c=null==(u=(await this.fetch.get("https://acs.youku.com/h5/mopen.youku.danmu.list/1.0/",{params:{jsv:"2.7.0",appKey:o,t:s,sign:this.generateTokenSign(s,o,a),api:"mopen.youku.danmu.list",v:"1.0",type:"originaljson",dataType:"jsonp",timeout:"20000",jsonpIncPrefix:"utility",data:a},headers:{Referer:"https://v.youku.com"},successStatus:[200],schema:looseObject({data:schemas_object({result:schemas_string().transform(e=>safeJsonParseWithZod(e,youkuDanmuResultSchema)).optional()})})})).data)||null==(l=u.data.result)?void 0:l.data.result)?c:[];return this.logger.info("获取到分段",t,"的弹幕",e.length,"条"),e}catch(n){return this.logger.error("解析弹幕响应失败,vid:",e,"mat:",t,"错误:",n),[]}}generateMsgSign(e){return md5_default()(`${e}MkmC9SoIw6xCkSKHhJ7b5D2r51kBiREr`).toString().toLowerCase()}generateTokenSign(e,t,n){return md5_default()([this.token,e,t,n].join("&")).toString().toLowerCase()}async ensureTokenCookie(){this.fetch.cookie={};try{await this.fetch.get("https://log.mmstat.com/eg.js",{headers:{Cookie:"","If-None-Match":""}})}catch(e){this.logger.warn("无法连接到 youku.com 获取 'cna' cookie。错误:",e)}try{await this.fetch.get("https://acs.youku.com/h5/mtop.com.youku.aplatform.weakget/1.0/?jsv=2.5.1&appKey=24679788")}catch(e){this.logger.error("无法连接到 acs.youku.com 获取令牌 cookie。弹幕获取很可能会失败。错误:",e)}this.cna&&this.token||this.logger.warn("未能获取到弹幕签名所需的全部 cookie。 cna:",this.cna,"token:",this.token)}constructor(){super(),youku_define_property(this,"providerName","youku"),youku_define_property(this,"idSchema",youkuIdSchema),youku_define_property(this,"EPISODE_BLACKLIST_KEYWORDS",["彩蛋","加更","走心","解忧","纯享"]),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"})}}function scrapers_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const scrapers=[TencentScraper,YoukuScraper,IqiyiScraper,BilibiliScraper,RenRenScraper,MgTVScraper];class scrapers_Scraper{get scraperMap(){return this._scraperMap||(this._scraperMap=keyBy(this.scrapers,e=>e.providerName)),this._scraperMap}async getSegmentsByProvider(e,t){let n=this.scraperMap[e];if(!n)return[];let r=await n.getSegments(t);return sortBy(r,["startTime"])}findSegmentAtTime(e,t){var n;if(!e.length)return null;let r=0,i=e.length-1;for(;r<=i;){let n=r+i>>1;e[n].startTime<=t?r=n+1:i=n-1}let o=i;return o<0?null:null!=(n=e[o])?n:null}async getSegmentWithTime(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;for(var t,n,r=arguments.length,i=Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];let a=i.map(async t=>{let{provider:n,idString:r}=t;try{let t=await this.getSegmentsByProvider(n,r);if(!t.length)return null;let i=this.findSegmentAtTime(t,e);if(!i)return null;let o=this.scraperMap[n];if(!o)return null;let a=await o.getComments(r,i.segmentId);if(!(null==a?void 0:a.length))return null;return{provider:n,comments:a}}catch(e){return null}}),s=await Promise.all(a),l=new Map;for(let e of s)if(null==e||null==(t=e.comments)?void 0:t.length)for(let t of e.comments){if(!t)continue;let r="";r=this.globalParams.global.content.aggregation?[t.mode,t.color,t.content].join("___"):null!=(n=t.id)?n:Math.random().toString();let i=l.get(r);i?(t.timestamp<i.item.timestamp&&(i.item=t),i.count+=1):l.set(r,{item:t,count:1,provider:e.provider})}let u=[],c=this.globalParams.global.content.blacklist?new RegExp(this.globalParams.global.content.blacklist):null;return l.forEach(e=>{let{item:t,count:n,provider:r}=e;if(null==c?void 0:c.test(t.content))return;let i=n>1?`${t.content} \xd7 ${n}`:t.content;u.push({cid:t.id,p:`${t.timestamp.toFixed(2)},${t.mode},${t.color},[${r}]`,m:i})}),u}getDanmuWithSegmentTimeByVideoId(e,t){let n=e.split(",").map(e=>{let[t,n]=e.split(":");return{provider:t,idString:n}});return this.getSegmentWithTime(t,...n)}async getEpisodes(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let r=[];for(let{provider:e,idString:n,episodeNumber:i}of uniqWith(t,isEqual)){let t=this.scraperMap[e];t&&r.push(t.getEpisodes(n,i).catch(e=>(console.error(e),[])))}return(await Promise.all(r).catch(e=>(console.error(e),[]))).flat().map(e=>({...e,episodeId:`${e.provider}:${e.episodeId}`}))}getEpisodeNumber(e,t){if(e===constants_MediaType.TV&&t)return parseInt(t)}async getDetailWithAnimeId(e,t,n){let[r,i]=e.split(":");return await this.getEpisodes({provider:r,idString:i,episodeNumber:this.getEpisodeNumber(t,n)})}async getEpisodeParams(e){let t=[];for(let n of this.scrapers)n.search&&t.push(n.search(e).catch(e=>(console.error(e),[])));let n=(await Promise.all(t)).flat();if(!n.length)return[];let r=this.getEpisodeNumber(e.type,e.episode),i=[];for(let e of n)try{let t=this.scraperMap[e.provider];if(!t)continue;let n=t.generateIdString({dramaId:e.dramaId});i.push({provider:e.provider,idString:n,episodeNumber:r})}catch(e){}try{if("true"===e.qihooSearch){let t=new QihooMatcher,n=await t.getEpisodeParams(e);i.push(...n)}}catch(e){}return i}setGlobalParams(e){let{success:t,data:n}=globalParamsConfigSchema.safeParse(e);return t&&(this.globalParams=n,this.scrapers.forEach(e=>{e.providerConfig=n.provider})),n}constructor(){scrapers_define_property(this,"scrapers",[]),scrapers_define_property(this,"globalParams",{}),scrapers_define_property(this,"_scraperMap",void 0),scrapers.forEach(e=>{this.scrapers.push(new e)})}}const scrapers_scraper=new scrapers_Scraper;function imdb_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const episodesRequestSchema=schemas_object({season:coerce_number().optional().default(1),pageSize:coerce_number().optional().default(20),pageToken:schemas_string().optional()}),BASE_URL="https://api.imdbapi.dev";class ImdbMatcher{async getImdbEpisodes(e,t){let{season:n,pageSize:r,pageToken:i}=episodesRequestSchema.parse(null!=t?t:{});return(await this.fetch.get(`${BASE_URL}/titles/${e}/episodes`,{params:{season:n,pageSize:r,pageToken:i},cache:{cacheKey:["imdb","episodes",e,n,r,i].filter(Boolean).join(":")},successStatus:[200],schema:schemas_object({episodes:schemas_array(schemas_object({id:schemas_string(),title:schemas_string().optional(),episodeNumber:schemas_number().optional()})),totalCount:schemas_number(),nextPageToken:schemas_string().optional()})})).data}async getImdbSeasons(e){return(await this.fetch.get(`${BASE_URL}/titles/${e}/seasons`,{cache:{cacheKey:["imdb:seasons",e].join(":")},schema:schemas_object({seasons:schemas_array(schemas_object({season:schemas_string(),episodeCount:schemas_number().optional()}))})})).data}constructor(){imdb_define_property(this,"fetch",new Fetch)}}class TmdbMatcher{async getExternalIds(e,t){let n=null,r=`tmdb:${e}:${t}:external_ids`,i=await storage.getJson(r);return i?n=i:(n=await Widget.tmdb.get(`/${e}/${t}/external_ids`),storage.setJson(r,n,{ttl:TTL_7_DAYS})),n}}function douban_define_property(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class DoubanMatcher{async getDoubanInfoByImdbId(e,t){var n,r,i,o,a,s;let l=e;if(t&&"1"!==t.toString()){let n=await this.imdbMatcher.getImdbSeasons(e);if(!n||parseInt(t.toString())>n.seasons.length)return null;let r=await this.imdbMatcher.getImdbEpisodes(e,{season:t});l=null!=(a=null==r||null==(o=r.episodes.find(e=>1===e.episodeNumber))?void 0:o.id)?a:""}l||(l=e),this.logger.info("通过 imdb id 获取豆瓣信息",l);let u=await this.fetch.post(`https://api.douban.com/v2/movie/imdb/${l}`,{apikey:this.DOUBAN_API_KEY},{headers:{"Content-Type":"application/json"},schema:schemas_object({id:schemas_string(),title:schemas_string().optional()}),cache:{cacheKey:`douban:imdb:${l}`,ttl:TTL_7_DAYS}});if(200!==u.statusCode)throw Error(`Failed to get Douban info: ${u.statusCode}, ${JSON.stringify(u.data)}`);let c=null==(i=u.data)||null==(r=i.id)||null==(n=r.split("/"))?void 0:n.pop();if(!c)throw Error(`Failed to extract Douban ID from response: ${null==(s=u.data)?void 0:s.id}`);return/\d+/.test(c)?{doubanId:c,originResponse:u.data}:null}async getDoubanInfoByTmdbId(e,t,n){if(!t)return null;let r=await this.tmdbMatcher.getExternalIds(e,t);return(this.logger.info("Get external ids by tmdb id",r),r.imdb_id)?this.getDoubanInfoByImdbId(r.imdb_id,n):null}async searchDoubanInfoByName(e){var t,n;return e&&null!=(n=null==(t=(await this.fetch.get("https://m.douban.com/rexxar/api/v2/search",{params:{q:e,start:0,count:20,type:"movie"},headers:{Referer:"https://m.douban.com/movie/","Content-Type":"application/json"},schema:schemas_object({subjects:schemas_object({items:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({type_name:schemas_string(),target_type:schemas_string(),target_id:schemas_string(),target:schemas_object({title:schemas_string(),has_linewatch:schemas_boolean().refine(e=>e)})}).safeParse(e).data)?t:null})).transform(e=>compact(e))})}),cache:{cacheKey:["douban","search",e].filter(Boolean).join(":")}})).data)?void 0:t.subjects.items)?n:[]}async getVideoPlatformInfoByDoubanId(e){var t,n;this.logger.info("获取视频平台信息",e);let r=await this.fetch.get(`https://m.douban.com/rexxar/api/v2/movie/${e}?for_mobile=1`,{headers:{Referer:`https://m.douban.com/movie/subject/${e}/?dt_dapp=1`,"Content-Type":"application/json"},schema:schemas_object({is_tv:schemas_boolean().optional(),vendors:schemas_array(unknown().transform(e=>{let{success:t,data:n,error:r}=schemas_object({id:schemas_string(),is_ad:schemas_boolean().catch(!1).refine(e=>!e),uri:schemas_string()}).safeParse(e);return t?n:(this.logger.error("解析视频平台信息失败",prettifyError(r),e),null)}))}),successStatus:[200],cache:{cacheKey:`douban:${e}:info`,ttl:TTL_7_DAYS}}),i=[];for(let e of null!=(n=null==(t=r.data)?void 0:t.vendors)?n:[]){if(!e)continue;let t=url_parse_default()(e.uri,!0);switch(e.id){case"qq":{let{cid:e,vid:n}=t.query;e&&i.push({provider:"tencent",idString:scrapers_scraper.scraperMap.tencent.generateIdString({cid:e,vid:n})});break}case"iqiyi":{let{tvid:e}=t.query;e&&i.push({provider:"iqiyi",idString:scrapers_scraper.scraperMap.iqiyi.generateIdString({entityId:e})});break}case"youku":{let{showid:e,vid:n}=t.query;(e||n)&&i.push({provider:"youku",idString:scrapers_scraper.scraperMap.youku.generateIdString({showId:e,vid:n})});break}case"bilibili":{let e=t.pathname.split("/").pop();e&&/\d+/.test(e)&&i.push({provider:"bilibili",idString:scrapers_scraper.scraperMap.bilibili.generateIdString({seasonId:e})})}}}return i}async getDoubanIds(e){let t=new Set,{tmdbId:n,type:r,seriesName:i,season:o,fuzzyMatch:a}=searchDanmuParamsSchema.parse(e);try{let e=await this.getDoubanInfoByTmdbId(r,n,o);(null==e?void 0:e.doubanId)&&t.add(e.doubanId)}catch(e){this.logger.error("Error getting douban info by tmdb id",e)}if("always"===a||"auto"===a&&!t.size)try{let e=i;for(let n of(o&&parseInt(o.toString())>1&&(e+=o.toString()),await this.searchDoubanInfoByName(e)))t.add(n.target_id)}catch(e){this.logger.error("Error searching douban info by name",e)}return Array.from(t)}async getEpisodeParams(e){let t=await this.getDoubanIds(e);this.logger.info("获取到豆瓣ID",t);let n=[];for(let e of t){let t=await this.getVideoPlatformInfoByDoubanId(e);n.push(...t)}return this.logger.info("获取到视频平台信息",n),{doubanIds:t,videoPlatformInfo:n}}constructor(){douban_define_property(this,"logger",new Logger("豆瓣")),douban_define_property(this,"tmdbMatcher",new TmdbMatcher),douban_define_property(this,"imdbMatcher",new ImdbMatcher),douban_define_property(this,"fetch",new Fetch),douban_define_property(this,"DOUBAN_API_KEY","0ac44ae016490db2204ce0a042db2916")}}const widgetVersion="0.13.0";WidgetMetadata = {id:"baranwang.danmu.universe",title:"通用弹幕",description:"通用弹幕插件,支持腾讯、优酷、爱奇艺、哔哩哔哩、人人视频等平台",author:"Baran",version:widgetVersion,site:"https://github.com/baranwang/forward-widgets/tree/main/packages/danmu-universe",requiredVersion:"0.0.2",globalParams:[{title:"模糊匹配",name:"fuzzyMatch",description:"是否开启模糊匹配",value:"auto",type:"enumeration",enumOptions:[{title:"自动",value:"auto"},{title:"始终开启",value:"always"},{title:"始终关闭",value:"never"}]},{title:"360 影视搜索(实验性)",name:"qihooSearch",description:"是否开启 360 影视搜索",value:"false",type:"enumeration",belongTo:{paramName:"fuzzyMatch",value:["auto","always"]},enumOptions:[{title:"关闭",value:"false"},{title:"开启",value:"true"}]},{title:"未匹配到资源提示",name:"emptyAnimeTitle",description:"是否显示未匹配到资源提示",value:"true",type:"enumeration",enumOptions:[{title:"开启",value:"true"},{title:"关闭",value:"false"}]},{title:"弹幕内容聚合",name:"global.content.aggregation",value:"true",type:"enumeration",enumOptions:[{title:"开启",value:"true"},{title:"关闭",value:"false"}]},{title:"弹幕内容过滤",name:"global.content.blacklist",value:"",type:"input"},{title:`[${PROVIDER_NAMES.renren}] \u{5F39}\u{5E55}\u{6A21}\u{5F0F}`,name:"provider.renren.mode",description:"弹幕模式,精选弹幕相比默认弹幕质量更高",value:"default",type:"enumeration",enumOptions:[{title:"默认",value:"default"},{title:"精选",value:"choice"}]},{title:"豆瓣书影音档案(实验性)",name:"global.experimental.doubanHistory.enabled",description:"是否开启自动同步豆瓣书影音档案",value:"false",type:"enumeration",enumOptions:[{title:"关闭",value:"false"},{title:"开启",value:"true"}]},{title:"豆瓣 Cookie 中的 dbcl2 值",name:"global.experimental.doubanHistory.dbcl2",value:"",type:"input",belongTo:{paramName:"global.experimental.doubanHistory.enabled",value:["true"]}},{title:"豆瓣自定义评论",name:"global.experimental.doubanHistory.customComment",value:"自豪的使用 Forward*",type:"input",belongTo:{paramName:"global.experimental.doubanHistory.enabled",value:["true"]},placeholders:["自豪的使用 Forward*","Marked by Forward*"].map(e=>({title:e,value:e}))},{title:"Trakt 历史同步(实验性)",name:"global.experimental.trakt.enabled",description:"是否开启自动同步 Trakt 历史",value:"false",type:"enumeration",enumOptions:[{title:"关闭",value:"false"},{title:"开启",value:"true"}]},{title:"Trakt 令牌",description:"通过 trakt-forward.baranwang.workers.dev 获取",name:"global.experimental.trakt.token",value:"",type:"input",belongTo:{paramName:"global.experimental.trakt.enabled",value:["true"]}}],modules:[{type:"danmu",id:"searchDanmu",title:"搜索弹幕",functionName:"searchDanmu",description:"搜索弹幕"},{type:"danmu",id:"getDetail",title:"获取详情",functionName:"getDetail",description:"获取详情"},{type:"danmu",id:"getComments",title:"获取弹幕",functionName:"getComments",description:"获取弹幕"},{type:"danmu",id:"getDanmuWithSegmentTime",title:"获取弹幕切片",functionName:"getComments",description:"获取弹幕切片"}]};const checkShowEmptyAnimeTitle=e=>stringbool().catch(!0).parse(e.emptyAnimeTitle);searchDanmu=async e=>{let t=scrapers_scraper.setGlobalParams(e),{fuzzyMatch:n="auto",type:r,episode:i}=e,o=[],a=new DoubanMatcher,{doubanIds:s,videoPlatformInfo:l}=await a.getEpisodeParams(e);o=o.concat(l);try{if((null==t?void 0:t.global.experimental.trakt.enabled)&&(null==t?void 0:t.global.experimental.trakt.token)){let n=new Trakt(t.global.experimental.trakt);await n.syncHistory(e)}}catch(e){console.error(e)}try{if((null==t?void 0:t.global.experimental.doubanHistory.enabled)&&(null==t?void 0:t.global.experimental.doubanHistory.dbcl2)){let e=new DoubanHistory(t.global.experimental.doubanHistory);1===s.length&&await e.setStatus(r,s[0],"tv"===r?"doing":"done")}}catch(e){console.error(e)}if(!(null==o?void 0:o.length)&&"auto"===n||"always"===n){let t=await scrapers_scraper.getEpisodeParams(e);o=o.concat(t)}"tv"===r&&(o=o.map(e=>({...e,episodeNumber:i?parseInt(i,10):void 0})));let u=await scrapers_scraper.getEpisodes(...o);return("tv"===r&&i&&(u=u.filter(e=>e.episodeNumber===parseInt(i,10))),!u.length&&checkShowEmptyAnimeTitle(e))?{animes:[{animeId:EMPTY_ANIME_CONFIG.ID,animeTitle:EMPTY_ANIME_CONFIG.TITLE}]}:{animes:u.map(e=>{let t=`[${PROVIDER_NAMES[e.provider]}] `;return e.episodeTitle&&(t+=e.episodeTitle),{animeId:e.episodeId,animeTitle:t}})}},getDetail=async e=>{scrapers_scraper.setGlobalParams(e);let{animeId:t,type:n,episode:r}=e;return t&&t!==EMPTY_ANIME_CONFIG.ID?scrapers_scraper.getDetailWithAnimeId(t.toString(),n,r):null},getComments=async e=>{scrapers_scraper.setGlobalParams(e);let{animeId:t,commentId:n,segmentTime:r}=e,i=null!=n?n:t;if(i===EMPTY_ANIME_CONFIG.ID)return null;let o=await scrapers_scraper.getDanmuWithSegmentTimeByVideoId(i.toString(),r);return{comments:o,count:o.length}};
|
|
16
|
+
`)}t.write("payload.value = newResult;"),t.write("return payload;");let s=t.compile();return(t,r)=>s(e,t,r)},a=util_isObject,s=!globalConfig.jitless,l=util_allowsEval,u=s&&l.value,c=t.catchall;e._zod.parse=(l,d)=>{n??(n=i.value);let f=l.value;if(!a(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;let p=[];if(s&&u&&d?.async===!1&&!0!==d.jitless)r||(r=o(t.shape)),l=r(l,d);else{l.value={};let e=n.shape;for(let t of n.keys){let r=e[t]._zod.run({value:f[t],issues:[]},d);r instanceof Promise?p.push(r.then(e=>handlePropertyResult(e,l,t,f))):handlePropertyResult(r,l,t,f)}}if(!c)return p.length?Promise.all(p).then(()=>l):l;let h=[],m=n.keySet,g=c._zod,v=g.def.type;for(let e of Object.keys(f)){if(m.has(e))continue;if("never"===v){h.push(e);continue}let t=g.run({value:f[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>handlePropertyResult(t,l,e,f))):handlePropertyResult(t,l,e,f)}return(h.length&&l.issues.push({code:"unrecognized_keys",keys:h,input:f,inst:e}),p.length)?Promise.all(p).then(()=>l):l}});function handleUnionResults(e,t,r,n){for(let r of e)if(0===r.issues.length)return t.value=r.value,t;let i=e.filter(e=>!aborted(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>finalizeIssue(e,n,core_config())))}),t)}let $ZodUnion=$constructor("$ZodUnion",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),defineLazy(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),defineLazy(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),defineLazy(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>cleanRegex(e.source)).join("|")})$`)}});let r=1===t.options.length,n=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(r)return n(i,o);let a=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},o);if(t instanceof Promise)s.push(t),a=!0;else{if(0===t.issues.length)return t;s.push(t)}}return a?Promise.all(s).then(t=>handleUnionResults(t,i,e,o)):handleUnionResults(s,i,e,o)}}),$ZodDiscriminatedUnion=$constructor("$ZodDiscriminatedUnion",(e,t)=>{$ZodUnion.init(e,t);let r=e._zod.parse;defineLazy(e._zod,"propValues",()=>{let e={};for(let r of t.options){let n=r._zod.propValues;if(!n||0===Object.keys(n).length)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let[t,r]of Object.entries(n))for(let n of(e[t]||(e[t]=new Set),r))e[t].add(n)}return e});let n=util_cached(()=>{let e=t.options,r=new Map;for(let n of e){let e=n._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let t of e){if(r.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,n)}}return r});e._zod.parse=(i,o)=>{let a=i.value;if(!util_isObject(a))return i.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),i;let s=n.value.get(a?.[t.discriminator]);return s?s._zod.run(i,o):t.unionFallback?r(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),i)}}),$ZodIntersection=$constructor("$ZodIntersection",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(e,r)=>{let n=e.value,i=t.left._zod.run({value:n,issues:[]},r),o=t.right._zod.run({value:n,issues:[]},r);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([t,r])=>handleIntersectionResults(e,t,r)):handleIntersectionResults(e,i,o)}});function mergeValues(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(isPlainObject(e)&&isPlainObject(t)){let r=Object.keys(t),n=Object.keys(e).filter(e=>-1!==r.indexOf(e)),i={...e,...t};for(let r of n){let n=mergeValues(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};i[r]=n.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let i=mergeValues(e[n],t[n]);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function handleIntersectionResults(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),aborted(e))return e;let n=mergeValues(t.value,r.value);if(!n.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}(e,t)=>{$ZodType.init(e,t);let r=t.items,n=r.length-[...r].reverse().findIndex(e=>"optional"!==e._zod.optin);e._zod.parse=(i,o)=>{let a=i.value;if(!Array.isArray(a))return i.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=[];let s=[];if(!t.rest){let t=a.length>r.length,o=a.length<n-1;if(t||o)return i.issues.push({...t?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},input:a,inst:e,origin:"array"}),i}let l=-1;for(let e of r){if(++l>=a.length&&l>=n)continue;let t=e._zod.run({value:a[l],issues:[]},o);t instanceof Promise?s.push(t.then(e=>handleTupleResult(e,i,l))):handleTupleResult(t,i,l)}if(t.rest)for(let e of a.slice(r.length)){l++;let r=t.rest._zod.run({value:e,issues:[]},o);r instanceof Promise?s.push(r.then(e=>handleTupleResult(e,i,l))):handleTupleResult(r,i,l)}return s.length?Promise.all(s).then(()=>i):i}};function handleTupleResult(e,t,r){e.issues.length&&t.issues.push(...prefixIssues(r,e.issues)),t.value[r]=e.value}let $ZodRecord=$constructor("$ZodRecord",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!isPlainObject(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let o=[];if(t.keyType._zod.values){let a,s=t.keyType._zod.values;for(let e of(r.value={},s))if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){let a=t.valueType._zod.run({value:i[e],issues:[]},n);a instanceof Promise?o.push(a.then(t=>{t.issues.length&&r.issues.push(...prefixIssues(e,t.issues)),r.value[e]=t.value})):(a.issues.length&&r.issues.push(...prefixIssues(e,a.issues)),r.value[e]=a.value)}for(let e in i)s.has(e)||(a=a??[]).push(e);a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:a})}else for(let a of(r.value={},Reflect.ownKeys(i))){if("__proto__"===a)continue;let s=t.keyType._zod.run({value:a,issues:[]},n);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(s.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>finalizeIssue(e,n,core_config())),input:a,path:[a],inst:e}),r.value[s.value]=s.value;continue}let l=t.valueType._zod.run({value:i[a],issues:[]},n);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&r.issues.push(...prefixIssues(a,e.issues)),r.value[s.value]=e.value})):(l.issues.length&&r.issues.push(...prefixIssues(a,l.issues)),r.value[s.value]=l.value)}return o.length?Promise.all(o).then(()=>r):r}}),$ZodMap=$constructor("$ZodMap",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;let o=[];for(let[a,s]of(r.value=new Map,i)){let l=t.keyType._zod.run({value:a,issues:[]},n),u=t.valueType._zod.run({value:s,issues:[]},n);l instanceof Promise||u instanceof Promise?o.push(Promise.all([l,u]).then(([t,o])=>{handleMapResult(t,o,r,a,i,e,n)})):handleMapResult(l,u,r,a,i,e,n)}return o.length?Promise.all(o).then(()=>r):r}});function handleMapResult(e,t,r,n,i,o,a){e.issues.length&&(propertyKeyTypes.has(typeof n)?r.issues.push(...prefixIssues(n,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(e=>finalizeIssue(e,a,core_config()))})),t.issues.length&&(propertyKeyTypes.has(typeof n)?r.issues.push(...prefixIssues(n,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:n,issues:t.issues.map(e=>finalizeIssue(e,a,core_config()))})),r.value.set(e.value,t.value)}(e,t)=>{$ZodType.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;let o=[];for(let e of(r.value=new Set,i)){let i=t.valueType._zod.run({value:e,issues:[]},n);i instanceof Promise?o.push(i.then(e=>handleSetResult(e,r))):handleSetResult(i,r)}return o.length?Promise.all(o).then(()=>r):r}};function handleSetResult(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}let $ZodEnum=$constructor("$ZodEnum",(e,t)=>{$ZodType.init(e,t);let r=getEnumValues(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=RegExp(`^(${r.filter(e=>propertyKeyTypes.has(typeof e)).map(e=>"string"==typeof e?escapeRegex(e):e.toString()).join("|")})$`),e._zod.parse=(t,i)=>{let o=t.value;return n.has(o)||t.issues.push({code:"invalid_value",values:r,input:o,inst:e}),t}}),$ZodLiteral=$constructor("$ZodLiteral",(e,t)=>{if($ZodType.init(e,t),0===t.values.length)throw Error("Cannot create literal schema with no valid values");e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>"string"==typeof e?escapeRegex(e):e?escapeRegex(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,n)=>{let i=r.value;return e._zod.values.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),$ZodFile=$constructor("$ZodFile",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,r)=>{let n=t.value;return n instanceof File||t.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),t}}),$ZodTransform=$constructor("$ZodTransform",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(e,r)=>{let n=t.transform(e.value,e);if(r.async)return(n instanceof Promise?n:Promise.resolve(n)).then(t=>(e.value=t,e));if(n instanceof Promise)throw new $ZodAsyncError;return e.value=n,e}});function handleOptionalResult(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}let $ZodOptional=$constructor("$ZodOptional",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",e._zod.optout="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),defineLazy(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${cleanRegex(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if("optional"===t.innerType._zod.optin){let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(t=>handleOptionalResult(t,e.value)):handleOptionalResult(n,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,r)}}),$ZodNullable=$constructor("$ZodNullable",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${cleanRegex(e.source)}|null)$`):void 0}),defineLazy(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),$ZodDefault=$constructor("$ZodDefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if(void 0===e.value)return e.value=t.defaultValue,e;let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>handleDefaultResult(e,t)):handleDefaultResult(n,t)}});function handleDefaultResult(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let $ZodPrefault=$constructor("$ZodPrefault",(e,t)=>{$ZodType.init(e,t),e._zod.optin="optional",defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),$ZodNonOptional=$constructor("$ZodNonOptional",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,n)=>{let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(t=>handleNonOptionalResult(t,e)):handleNonOptionalResult(i,e)}});function handleNonOptionalResult(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}let $ZodSuccess=$constructor("$ZodSuccess",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(e,r)=>{let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(t=>(e.value=0===t.issues.length,e)):(e.value=0===n.issues.length,e)}}),$ZodCatch=$constructor("$ZodCatch",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),defineLazy(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>finalizeIssue(e,r,core_config()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>finalizeIssue(e,r,core_config()))},input:e.value}),e.issues=[]),e)}}),$ZodNaN=$constructor("$ZodNaN",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(t,r)=>("number"==typeof t.value&&Number.isNaN(t.value)||t.issues.push({input:t.value,inst:e,expected:"nan",code:"invalid_type"}),t)}),$ZodPipe=$constructor("$ZodPipe",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"values",()=>t.in._zod.values),defineLazy(e._zod,"optin",()=>t.in._zod.optin),defineLazy(e._zod,"optout",()=>t.out._zod.optout),defineLazy(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,r)=>{let n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>handlePipeResult(e,t,r)):handlePipeResult(n,t,r)}});function handlePipeResult(e,t,r){return e.issues.length?e:t.out._zod.run({value:e.value,issues:e.issues},r)}let $ZodReadonly=$constructor("$ZodReadonly",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"propValues",()=>t.innerType._zod.propValues),defineLazy(e._zod,"values",()=>t.innerType._zod.values),defineLazy(e._zod,"optin",()=>t.innerType._zod.optin),defineLazy(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(e,r)=>{let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(handleReadonlyResult):handleReadonlyResult(n)}});function handleReadonlyResult(e){return e.value=Object.freeze(e.value),e}let $ZodTemplateLiteral=$constructor("$ZodTemplateLiteral",(e,t)=>{$ZodType.init(e,t);let r=[];for(let e of t.parts)if("object"==typeof e&&null!==e){if(!e._zod.pattern)throw Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);let t=e._zod.pattern instanceof RegExp?e._zod.pattern.source:e._zod.pattern;if(!t)throw Error(`Invalid template literal part: ${e._zod.traits}`);let n=+!!t.startsWith("^"),i=t.endsWith("$")?t.length-1:t.length;r.push(t.slice(n,i))}else if(null===e||primitiveTypes.has(typeof e))r.push(escapeRegex(`${e}`));else throw Error(`Invalid template literal part: ${e}`);e._zod.pattern=RegExp(`^${r.join("")}$`),e._zod.parse=(r,n)=>("string"!=typeof r.value?r.issues.push({input:r.value,inst:e,expected:"template_literal",code:"invalid_type"}):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source})),r)}),$ZodPromise=$constructor("$ZodPromise",(e,t)=>{$ZodType.init(e,t),e._zod.parse=(e,r)=>Promise.resolve(e.value).then(e=>t.innerType._zod.run({value:e,issues:[]},r))}),$ZodLazy=$constructor("$ZodLazy",(e,t)=>{$ZodType.init(e,t),defineLazy(e._zod,"innerType",()=>t.getter()),defineLazy(e._zod,"pattern",()=>e._zod.innerType._zod.pattern),defineLazy(e._zod,"propValues",()=>e._zod.innerType._zod.propValues),defineLazy(e._zod,"optin",()=>e._zod.innerType._zod.optin??void 0),defineLazy(e._zod,"optout",()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,r)=>e._zod.innerType._zod.run(t,r)}),$ZodCustom=$constructor("$ZodCustom",(e,t)=>{$ZodCheck.init(e,t),$ZodType.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(t=>handleRefineResult(t,r,n,e));handleRefineResult(i,r,n,e)}});function handleRefineResult(e,t,r,n){if(!e){let e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(util_issue(e))}}Symbol("ZodOutput"),Symbol("ZodInput");class $ZodRegistry{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&"object"==typeof r&&"id"in r){if(this._idmap.has(r.id))throw Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function registry(){return new $ZodRegistry}let globalRegistry=registry();function _string(e,t){return new e({type:"string",...normalizeParams(t)})}function _coercedString(e,t){return new e({type:"string",coerce:!0,...normalizeParams(t)})}function _email(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...normalizeParams(t)})}function _guid(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...normalizeParams(t)})}function _uuid(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _uuidv4(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...normalizeParams(t)})}function _uuidv6(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...normalizeParams(t)})}function _uuidv7(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...normalizeParams(t)})}function _url(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...normalizeParams(t)})}function api_emoji(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...normalizeParams(t)})}function _nanoid(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...normalizeParams(t)})}function _cuid(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _cuid2(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...normalizeParams(t)})}function _ulid(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...normalizeParams(t)})}function _xid(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...normalizeParams(t)})}function _ksuid(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...normalizeParams(t)})}function _ipv4(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...normalizeParams(t)})}function _ipv6(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...normalizeParams(t)})}function _cidrv4(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...normalizeParams(t)})}function _cidrv6(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...normalizeParams(t)})}function _base64(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...normalizeParams(t)})}function _base64url(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...normalizeParams(t)})}function _e164(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...normalizeParams(t)})}function _jwt(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...normalizeParams(t)})}function _isoDateTime(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...normalizeParams(t)})}function _isoDate(e,t){return new e({type:"string",format:"date",check:"string_format",...normalizeParams(t)})}function _isoTime(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...normalizeParams(t)})}function _isoDuration(e,t){return new e({type:"string",format:"duration",check:"string_format",...normalizeParams(t)})}function _number(e,t){return new e({type:"number",checks:[],...normalizeParams(t)})}function _coercedNumber(e,t){return new e({type:"number",coerce:!0,checks:[],...normalizeParams(t)})}function _int(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...normalizeParams(t)})}function _boolean(e,t){return new e({type:"boolean",...normalizeParams(t)})}function _any(e){return new e({type:"any"})}function _unknown(e){return new e({type:"unknown"})}function _never(e,t){return new e({type:"never",...normalizeParams(t)})}function _lt(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!1})}function _lte(e,t){return new $ZodCheckLessThan({check:"less_than",...normalizeParams(t),value:e,inclusive:!0})}function _gt(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!1})}function _gte(e,t){return new $ZodCheckGreaterThan({check:"greater_than",...normalizeParams(t),value:e,inclusive:!0})}function _multipleOf(e,t){return new $ZodCheckMultipleOf({check:"multiple_of",...normalizeParams(t),value:e})}function _maxLength(e,t){return new $ZodCheckMaxLength({check:"max_length",...normalizeParams(t),maximum:e})}function _minLength(e,t){return new $ZodCheckMinLength({check:"min_length",...normalizeParams(t),minimum:e})}function _length(e,t){return new $ZodCheckLengthEquals({check:"length_equals",...normalizeParams(t),length:e})}function _regex(e,t){return new $ZodCheckRegex({check:"string_format",format:"regex",...normalizeParams(t),pattern:e})}function _lowercase(e){return new $ZodCheckLowerCase({check:"string_format",format:"lowercase",...normalizeParams(e)})}function _uppercase(e){return new $ZodCheckUpperCase({check:"string_format",format:"uppercase",...normalizeParams(e)})}function _includes(e,t){return new $ZodCheckIncludes({check:"string_format",format:"includes",...normalizeParams(t),includes:e})}function _startsWith(e,t){return new $ZodCheckStartsWith({check:"string_format",format:"starts_with",...normalizeParams(t),prefix:e})}function _endsWith(e,t){return new $ZodCheckEndsWith({check:"string_format",format:"ends_with",...normalizeParams(t),suffix:e})}function _overwrite(e){return new $ZodCheckOverwrite({check:"overwrite",tx:e})}function _normalize(e){return _overwrite(t=>t.normalize(e))}function _trim(){return _overwrite(e=>e.trim())}function _toLowerCase(){return _overwrite(e=>e.toLowerCase())}function _toUpperCase(){return _overwrite(e=>e.toUpperCase())}function _array(e,t,r){return new e({type:"array",element:t,...normalizeParams(r)})}function _refine(e,t,r){return new e({type:"custom",check:"custom",fn:t,...normalizeParams(r)})}function _superRefine(e){let t=_check(r=>(r.addIssue=e=>{if("string"==typeof e)r.issues.push(util_issue(e,r.value,t._zod.def));else{let n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(util_issue(n))}},e(r.value,r)));return t}function _check(e,t){let r=new $ZodCheck({check:"custom",...normalizeParams(t)});return r._zod.check=e,r}function _stringbool(e,t){let r=normalizeParams(t),n=r.truthy??["true","1","yes","on","y","enabled"],i=r.falsy??["false","0","no","off","n","disabled"];"sensitive"!==r.case&&(n=n.map(e=>"string"==typeof e?e.toLowerCase():e),i=i.map(e=>"string"==typeof e?e.toLowerCase():e));let o=new Set(n),a=new Set(i),s=e.Pipe??$ZodPipe,l=e.Boolean??$ZodBoolean,u=e.String??$ZodString,c=new(e.Transform??$ZodTransform)({type:"transform",transform:(e,t)=>{let n=e;return"sensitive"!==r.case&&(n=n.toLowerCase()),!!o.has(n)||!a.has(n)&&(t.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:t.value,inst:c,continue:!1}),{})},error:r.error}),d=new s({type:"pipe",in:new u({type:"string",error:r.error}),out:c,error:r.error});return new s({type:"pipe",in:d,out:new l({type:"boolean",error:r.error}),error:r.error})}let ZodISODateTime=$constructor("ZodISODateTime",(e,t)=>{$ZodISODateTime.init(e,t),ZodStringFormat.init(e,t)});function iso_datetime(e){return _isoDateTime(ZodISODateTime,e)}let ZodISODate=$constructor("ZodISODate",(e,t)=>{$ZodISODate.init(e,t),ZodStringFormat.init(e,t)});function iso_date(e){return _isoDate(ZodISODate,e)}let ZodISOTime=$constructor("ZodISOTime",(e,t)=>{$ZodISOTime.init(e,t),ZodStringFormat.init(e,t)});function iso_time(e){return _isoTime(ZodISOTime,e)}let ZodISODuration=$constructor("ZodISODuration",(e,t)=>{$ZodISODuration.init(e,t),ZodStringFormat.init(e,t)});function iso_duration(e){return _isoDuration(ZodISODuration,e)}let classic_errors_initializer=(e,t)=>{$ZodError.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>formatError(e,t)},flatten:{value:t=>flattenError(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)}},isEmpty:{get:()=>0===e.issues.length}})};$constructor("ZodError",classic_errors_initializer);let ZodRealError=$constructor("ZodError",classic_errors_initializer,{Parent:Error}),parse_parse=_parse(ZodRealError),parse_parseAsync=_parseAsync(ZodRealError),parse_safeParse=_safeParse(ZodRealError),parse_safeParseAsync=_safeParseAsync(ZodRealError),ZodType=$constructor("ZodType",(e,t)=>($ZodType.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,r)=>clone(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.parse=(t,r)=>parse_parse(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>parse_safeParse(e,t,r),e.parseAsync=async(t,r)=>parse_parseAsync(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>parse_safeParseAsync(e,t,r),e.spa=e.safeParseAsync,e.refine=(t,r)=>e.check(refine(t,r)),e.superRefine=t=>e.check(superRefine(t)),e.overwrite=t=>e.check(_overwrite(t)),e.optional=()=>optional(e),e.nullable=()=>nullable(e),e.nullish=()=>optional(nullable(e)),e.nonoptional=t=>nonoptional(e,t),e.array=()=>schemas_array(e),e.or=t=>union([e,t]),e.and=t=>intersection(e,t),e.transform=t=>pipe(e,transform(t)),e.default=t=>schemas_default(e,t),e.prefault=t=>prefault(e,t),e.catch=t=>schemas_catch(e,t),e.pipe=t=>pipe(e,t),e.readonly=()=>readonly(e),e.describe=t=>{let r=e.clone();return globalRegistry.add(r,{description:t}),r},Object.defineProperty(e,"description",{get:()=>globalRegistry.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return globalRegistry.get(e);let r=e.clone();return globalRegistry.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),_ZodString=$constructor("_ZodString",(e,t)=>{$ZodString.init(e,t),ZodType.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...t)=>e.check(_regex(...t)),e.includes=(...t)=>e.check(_includes(...t)),e.startsWith=(...t)=>e.check(_startsWith(...t)),e.endsWith=(...t)=>e.check(_endsWith(...t)),e.min=(...t)=>e.check(_minLength(...t)),e.max=(...t)=>e.check(_maxLength(...t)),e.length=(...t)=>e.check(_length(...t)),e.nonempty=(...t)=>e.check(_minLength(1,...t)),e.lowercase=t=>e.check(_lowercase(t)),e.uppercase=t=>e.check(_uppercase(t)),e.trim=()=>e.check(_trim()),e.normalize=(...t)=>e.check(_normalize(...t)),e.toLowerCase=()=>e.check(_toLowerCase()),e.toUpperCase=()=>e.check(_toUpperCase())}),ZodString=$constructor("ZodString",(e,t)=>{$ZodString.init(e,t),_ZodString.init(e,t),e.email=t=>e.check(_email(ZodEmail,t)),e.url=t=>e.check(_url(ZodURL,t)),e.jwt=t=>e.check(_jwt(ZodJWT,t)),e.emoji=t=>e.check(api_emoji(ZodEmoji,t)),e.guid=t=>e.check(_guid(ZodGUID,t)),e.uuid=t=>e.check(_uuid(ZodUUID,t)),e.uuidv4=t=>e.check(_uuidv4(ZodUUID,t)),e.uuidv6=t=>e.check(_uuidv6(ZodUUID,t)),e.uuidv7=t=>e.check(_uuidv7(ZodUUID,t)),e.nanoid=t=>e.check(_nanoid(ZodNanoID,t)),e.guid=t=>e.check(_guid(ZodGUID,t)),e.cuid=t=>e.check(_cuid(ZodCUID,t)),e.cuid2=t=>e.check(_cuid2(ZodCUID2,t)),e.ulid=t=>e.check(_ulid(ZodULID,t)),e.base64=t=>e.check(_base64(ZodBase64,t)),e.base64url=t=>e.check(_base64url(ZodBase64URL,t)),e.xid=t=>e.check(_xid(ZodXID,t)),e.ksuid=t=>e.check(_ksuid(ZodKSUID,t)),e.ipv4=t=>e.check(_ipv4(ZodIPv4,t)),e.ipv6=t=>e.check(_ipv6(ZodIPv6,t)),e.cidrv4=t=>e.check(_cidrv4(ZodCIDRv4,t)),e.cidrv6=t=>e.check(_cidrv6(ZodCIDRv6,t)),e.e164=t=>e.check(_e164(ZodE164,t)),e.datetime=t=>e.check(iso_datetime(t)),e.date=t=>e.check(iso_date(t)),e.time=t=>e.check(iso_time(t)),e.duration=t=>e.check(iso_duration(t))});function schemas_string(e){return _string(ZodString,e)}let ZodStringFormat=$constructor("ZodStringFormat",(e,t)=>{$ZodStringFormat.init(e,t),_ZodString.init(e,t)}),ZodEmail=$constructor("ZodEmail",(e,t)=>{$ZodEmail.init(e,t),ZodStringFormat.init(e,t)}),ZodGUID=$constructor("ZodGUID",(e,t)=>{$ZodGUID.init(e,t),ZodStringFormat.init(e,t)}),ZodUUID=$constructor("ZodUUID",(e,t)=>{$ZodUUID.init(e,t),ZodStringFormat.init(e,t)}),ZodURL=$constructor("ZodURL",(e,t)=>{$ZodURL.init(e,t),ZodStringFormat.init(e,t)}),ZodEmoji=$constructor("ZodEmoji",(e,t)=>{$ZodEmoji.init(e,t),ZodStringFormat.init(e,t)}),ZodNanoID=$constructor("ZodNanoID",(e,t)=>{$ZodNanoID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID=$constructor("ZodCUID",(e,t)=>{$ZodCUID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID2=$constructor("ZodCUID2",(e,t)=>{$ZodCUID2.init(e,t),ZodStringFormat.init(e,t)}),ZodULID=$constructor("ZodULID",(e,t)=>{$ZodULID.init(e,t),ZodStringFormat.init(e,t)}),ZodXID=$constructor("ZodXID",(e,t)=>{$ZodXID.init(e,t),ZodStringFormat.init(e,t)}),ZodKSUID=$constructor("ZodKSUID",(e,t)=>{$ZodKSUID.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv4=$constructor("ZodIPv4",(e,t)=>{$ZodIPv4.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv6=$constructor("ZodIPv6",(e,t)=>{$ZodIPv6.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv4=$constructor("ZodCIDRv4",(e,t)=>{$ZodCIDRv4.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv6=$constructor("ZodCIDRv6",(e,t)=>{$ZodCIDRv6.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64=$constructor("ZodBase64",(e,t)=>{$ZodBase64.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64URL=$constructor("ZodBase64URL",(e,t)=>{$ZodBase64URL.init(e,t),ZodStringFormat.init(e,t)}),ZodE164=$constructor("ZodE164",(e,t)=>{$ZodE164.init(e,t),ZodStringFormat.init(e,t)}),ZodJWT=$constructor("ZodJWT",(e,t)=>{$ZodJWT.init(e,t),ZodStringFormat.init(e,t)}),ZodNumber=$constructor("ZodNumber",(e,t)=>{$ZodNumber.init(e,t),ZodType.init(e,t),e.gt=(t,r)=>e.check(_gt(t,r)),e.gte=(t,r)=>e.check(_gte(t,r)),e.min=(t,r)=>e.check(_gte(t,r)),e.lt=(t,r)=>e.check(_lt(t,r)),e.lte=(t,r)=>e.check(_lte(t,r)),e.max=(t,r)=>e.check(_lte(t,r)),e.int=t=>e.check(schemas_int(t)),e.safe=t=>e.check(schemas_int(t)),e.positive=t=>e.check(_gt(0,t)),e.nonnegative=t=>e.check(_gte(0,t)),e.negative=t=>e.check(_lt(0,t)),e.nonpositive=t=>e.check(_lte(0,t)),e.multipleOf=(t,r)=>e.check(_multipleOf(t,r)),e.step=(t,r)=>e.check(_multipleOf(t,r)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??-1/0,r.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(r.maximum??1/0,r.exclusiveMaximum??1/0)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function schemas_number(e){return _number(ZodNumber,e)}let ZodNumberFormat=$constructor("ZodNumberFormat",(e,t)=>{$ZodNumberFormat.init(e,t),ZodNumber.init(e,t)});function schemas_int(e){return _int(ZodNumberFormat,e)}let ZodBoolean=$constructor("ZodBoolean",(e,t)=>{$ZodBoolean.init(e,t),ZodType.init(e,t)});function schemas_boolean(e){return _boolean(ZodBoolean,e)}let ZodBigInt=$constructor("ZodBigInt",(e,t)=>{$ZodBigInt.init(e,t),ZodType.init(e,t),e.gte=(t,r)=>e.check(_gte(t,r)),e.min=(t,r)=>e.check(_gte(t,r)),e.gt=(t,r)=>e.check(_gt(t,r)),e.gte=(t,r)=>e.check(_gte(t,r)),e.min=(t,r)=>e.check(_gte(t,r)),e.lt=(t,r)=>e.check(_lt(t,r)),e.lte=(t,r)=>e.check(_lte(t,r)),e.max=(t,r)=>e.check(_lte(t,r)),e.positive=t=>e.check(_gt(BigInt(0),t)),e.negative=t=>e.check(_lt(BigInt(0),t)),e.nonpositive=t=>e.check(_lte(BigInt(0),t)),e.nonnegative=t=>e.check(_gte(BigInt(0),t)),e.multipleOf=(t,r)=>e.check(_multipleOf(t,r));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null}),ZodAny=$constructor("ZodAny",(e,t)=>{$ZodAny.init(e,t),ZodType.init(e,t)});function any(){return _any(ZodAny)}let ZodUnknown=$constructor("ZodUnknown",(e,t)=>{$ZodUnknown.init(e,t),ZodType.init(e,t)});function unknown(){return _unknown(ZodUnknown)}let ZodNever=$constructor("ZodNever",(e,t)=>{$ZodNever.init(e,t),ZodType.init(e,t)});function never(e){return _never(ZodNever,e)}let ZodArray=$constructor("ZodArray",(e,t)=>{$ZodArray.init(e,t),ZodType.init(e,t),e.element=t.element,e.min=(t,r)=>e.check(_minLength(t,r)),e.nonempty=t=>e.check(_minLength(1,t)),e.max=(t,r)=>e.check(_maxLength(t,r)),e.length=(t,r)=>e.check(_length(t,r)),e.unwrap=()=>e.element});function schemas_array(e,t){return _array(ZodArray,e,t)}let ZodObject=$constructor("ZodObject",(e,t)=>{$ZodObject.init(e,t),ZodType.init(e,t),defineLazy(e,"shape",()=>t.shape),e.keyof=()=>schemas_enum(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:unknown()}),e.loose=()=>e.clone({...e._zod.def,catchall:unknown()}),e.strict=()=>e.clone({...e._zod.def,catchall:never()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>extend(e,t),e.merge=t=>merge(e,t),e.pick=t=>pick(e,t),e.omit=t=>omit(e,t),e.partial=(...t)=>partial(ZodOptional,e,t[0]),e.required=(...t)=>required(ZodNonOptional,e,t[0])});function schemas_object(e,t){return new ZodObject({type:"object",get shape(){return assignProp(this,"shape",e?objectClone(e):{}),this.shape},...normalizeParams(t)})}function looseObject(e,t){return new ZodObject({type:"object",get shape(){return assignProp(this,"shape",objectClone(e)),this.shape},catchall:unknown(),...normalizeParams(t)})}let ZodUnion=$constructor("ZodUnion",(e,t)=>{$ZodUnion.init(e,t),ZodType.init(e,t),e.options=t.options});function union(e,t){return new ZodUnion({type:"union",options:e,...normalizeParams(t)})}let ZodIntersection=$constructor("ZodIntersection",(e,t)=>{$ZodIntersection.init(e,t),ZodType.init(e,t)});function intersection(e,t){return new ZodIntersection({type:"intersection",left:e,right:t})}let ZodRecord=$constructor("ZodRecord",(e,t)=>{$ZodRecord.init(e,t),ZodType.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function record(e,t,r){return new ZodRecord({type:"record",keyType:e,valueType:t,...normalizeParams(r)})}let ZodEnum=$constructor("ZodEnum",(e,t)=>{$ZodEnum.init(e,t),ZodType.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{let i={};for(let n of e)if(r.has(n))i[n]=t.entries[n];else throw Error(`Key ${n} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(n),entries:i})},e.exclude=(e,n)=>{let i={...t.entries};for(let t of e)if(r.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(n),entries:i})}});function schemas_enum(e,t){return new ZodEnum({type:"enum",entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...normalizeParams(t)})}let ZodLiteral=$constructor("ZodLiteral",(e,t)=>{$ZodLiteral.init(e,t),ZodType.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function literal(e,t){return new ZodLiteral({type:"literal",values:Array.isArray(e)?e:[e],...normalizeParams(t)})}let ZodTransform=$constructor("ZodTransform",(e,t)=>{$ZodTransform.init(e,t),ZodType.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=n=>{if("string"==typeof n)r.issues.push(util_issue(n,r.value,t));else{let t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),r.issues.push(util_issue(t))}};let i=t.transform(r.value,r);return i instanceof Promise?i.then(e=>(r.value=e,r)):(r.value=i,r)}});function transform(e){return new ZodTransform({type:"transform",transform:e})}let ZodOptional=$constructor("ZodOptional",(e,t)=>{$ZodOptional.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function optional(e){return new ZodOptional({type:"optional",innerType:e})}let ZodNullable=$constructor("ZodNullable",(e,t)=>{$ZodNullable.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nullable(e){return new ZodNullable({type:"nullable",innerType:e})}let ZodDefault=$constructor("ZodDefault",(e,t)=>{$ZodDefault.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function schemas_default(e,t){return new ZodDefault({type:"default",innerType:e,get defaultValue(){return"function"==typeof t?t():shallowClone(t)}})}let ZodPrefault=$constructor("ZodPrefault",(e,t)=>{$ZodPrefault.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function prefault(e,t){return new ZodPrefault({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof t?t():shallowClone(t)}})}let ZodNonOptional=$constructor("ZodNonOptional",(e,t)=>{$ZodNonOptional.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function nonoptional(e,t){return new ZodNonOptional({type:"nonoptional",innerType:e,...normalizeParams(t)})}let ZodCatch=$constructor("ZodCatch",(e,t)=>{$ZodCatch.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function schemas_catch(e,t){return new ZodCatch({type:"catch",innerType:e,catchValue:"function"==typeof t?t:()=>t})}let ZodPipe=$constructor("ZodPipe",(e,t)=>{$ZodPipe.init(e,t),ZodType.init(e,t),e.in=t.in,e.out=t.out});function pipe(e,t){return new ZodPipe({type:"pipe",in:e,out:t})}let ZodReadonly=$constructor("ZodReadonly",(e,t)=>{$ZodReadonly.init(e,t),ZodType.init(e,t),e.unwrap=()=>e._zod.def.innerType});function readonly(e){return new ZodReadonly({type:"readonly",innerType:e})}let ZodCustom=$constructor("ZodCustom",(e,t)=>{$ZodCustom.init(e,t),ZodType.init(e,t)});function refine(e,t={}){return _refine(ZodCustom,e,t)}function superRefine(e){return _superRefine(e)}let stringbool=(...e)=>_stringbool({Pipe:ZodPipe,Boolean:ZodBoolean,String:ZodString,Transform:ZodTransform},...e);function preprocess(e,t){return pipe(transform(e),t)}function asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function _async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function _define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let TTL_7_DAYS=6048e5,TTL_1_DAY=864e5,TTL_2_HOURS=72e5,TTL_5_MINUTES=3e5,StorageValue=schemas_object({value:schemas_string(),expiresAt:schemas_number()});class Storage{get(e){return _async_to_generator(function*(){let t=yield Widget.storage.get(e);if(!t)return null;let r=safeJsonParseWithZod(t,StorageValue);return r?(null==r?void 0:r.expiresAt)<Date.now()?(console.warn(`Storage value for key: ${e} has expired`),this.remove(e),null):r.value:(console.warn(`Failed to parse storage value for key: ${e}`),this.remove(e),null)}).call(this)}set(e,t,r){var n;let i=null!=(n=null==r?void 0:r.ttl)?n:this.defaultTTL,o=Date.now()+i,a=StorageValue.parse({value:t,expiresAt:o});return Widget.storage.set(e,JSON.stringify(a))}remove(e){return Widget.storage.remove(e)}clear(){return Widget.storage.clear()}getJson(e){return _async_to_generator(function*(){let t=yield this.get(e);return t?safeJsonParse(t):null}).call(this)}setJson(e,t,r){return this.set(e,JSON.stringify(t),r)}constructor(){_define_property(this,"defaultTTL",TTL_5_MINUTES)}}let storage=new Storage;function omit_omit(e,t){let r={...e};for(let e=0;e<t.length;e++){let n=t[e];delete r[n]}return r}function isUnsafeProperty(e){return"__proto__"===e}function isPlainObject_isPlainObject(e){if(!e||"object"!=typeof e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function merge_merge(e,t){let r=Object.keys(t);for(let n=0;n<r.length;n++){let i=r[n];if(isUnsafeProperty(i))continue;let o=t[i],a=e[i];Array.isArray(o)?Array.isArray(a)?e[i]=merge_merge(a,o):e[i]=merge_merge([],o):isPlainObject_isPlainObject(o)?isPlainObject_isPlainObject(a)?e[i]=merge_merge(a,o):e[i]=merge_merge({},o):(void 0===a||void 0!==o)&&(e[i]=o)}return e}var querystringify=__webpack_require__(682);function dist_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function dist_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){dist_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){dist_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function dist_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){dist_define_property(e,t,r[t])})}return e}function _object_without_properties(e,t){if(null==e)return{};var r,n,i=_object_without_properties_loose(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function _object_without_properties_loose(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}class HttpStatusError extends Error{constructor(e,t,r,n){super(`HTTP ${e} - Expected: [${t.join(", ")}] - ${r.method} ${r.url}`),dist_define_property(this,"statusCode",void 0),dist_define_property(this,"expectedStatus",void 0),dist_define_property(this,"context",void 0),dist_define_property(this,"response",void 0),this.statusCode=e,this.expectedStatus=t,this.context=r,this.response=n,this.name="HttpStatusError",console.error(`🚫 HTTP Request Failed: ${r.method} ${r.url}`,"Status",e),r.body&&console.error("Request Body:",JSON.stringify(r.body)),r.options&&console.error("Request Options:",omit_omit(r.options,["schema","successStatus"])),console.error("Response:",{headers:n.headers,data:n.data})}}class HttpSchemaError extends Error{constructor(e,t,r){super(`Failed to parse response with schema: ${prettifyError(r)}`),dist_define_property(this,"context",void 0),dist_define_property(this,"response",void 0),dist_define_property(this,"error",void 0),this.context=e,this.response=t,this.error=r,this.name="HttpSchemaError",console.error(`🚫 HTTP Request Failed Failed to parse response with schema: ${prettifyError(r)}: ${e.method} ${e.url}`),e.options&&console.error("Request Options:",omit_omit(e.options,["schema","successStatus"])),console.error("Response:",{headers:t.headers,data:t.data})}}class Fetch{setCookie(e){this.cookie=merge_merge(this.cookie,e)}getCookie(e){return this.cookie[e]}setHeaders(e){this.headers=merge_merge(this.headers,e)}get(e,t){return dist_async_to_generator(function*(){var r,n;null!=t||(t={}),null!=(n=(r=t).headers)||(r.headers={}),t.headers=this.buildHeaders(t.headers);let i=yield this.executeRequest("GET",e,t),o={url:e,method:"GET",options:t};return this.handleResponse(i,o,t)}).call(this)}post(e,t,r){return dist_async_to_generator(function*(){var n,i;null!=r||(r={}),null!=(i=(n=r).headers)||(n.headers={}),r.headers=this.buildHeaders(r.headers);let o=yield this.executeRequest("POST",e,t,r),a={url:e,method:"POST",body:t,options:r};return this.handleResponse(o,a,r)}).call(this)}buildHeaders(e){let t=Object.entries(this.cookie).map(([e,t])=>`${e}=${t}`).join("; ");return _object_spread({},this.headers,t&&{Cookie:t},e)}createTimeoutPromise(e){return new Promise((t,r)=>{setTimeout(()=>{r(Error(`Request timeout after ${e}ms`))},e)})}executeRequest(e,t,r,n){return dist_async_to_generator(function*(){var i;let o="GET"===e,a=null!=(i=o?r:n)?i:{},s=this.getCacheConfig(a);if(null==s?void 0:s.cacheKey){let e=yield storage.getJson(s.cacheKey);if(e)return console.debug("♻️ fetch cache hit",s.cacheKey),{data:e,statusCode:200,headers:{},fromCache:!0}}let l=o?void 0:r,{timeout:u,schema:c,params:d}=a,f=_object_without_properties(a,["timeout","schema","params"]),p=t;d&&(p=`${t}?${(0,querystringify.stringify)(d)}`),console.debug("⬆️ fetch",p,null!=l?l:"",f);let h=o?Widget.http.get(p,f):Widget.http.post(p,l,f);return u&&u>0?Promise.race([h,this.createTimeoutPromise(u)]):h}).call(this)}getCacheConfig(e){return"string"==typeof(null==e?void 0:e.cache)?{cacheKey:e.cache,ttl:void 0}:null==e?void 0:e.cache}constructor(e={},t={}){dist_define_property(this,"cookie",void 0),dist_define_property(this,"headers",void 0),dist_define_property(this,"handleResponse",(e,t,r)=>{var n;if(e.fromCache)return e;if((null==r||null==(n=r.successStatus)?void 0:n.length)&&!r.successStatus.includes(e.statusCode))throw new HttpStatusError(e.statusCode,r.successStatus,t,e);if(null==r?void 0:r.schema){let n=r.schema.safeParse(e.data);if(!n.success)throw new HttpSchemaError(t,e,n.error);e.data=n.data}let i=e.headers["set-cookie"]||e.headers["Set-Cookie"];if(i){let e=i.split(",").reduce((e,t)=>{if(!t)return e;let[r]=t.split(";"),[n,...i]=r.split("=");return n&&i.length>0&&(e[n.trim()]=i.join("=").trim()),e},{});this.setCookie(e)}let o=this.getCacheConfig(r);return(null==o?void 0:o.cacheKey)&&storage.setJson(o.cacheKey,e.data,{ttl:o.ttl}),e}),this.cookie=e,this.headers=t}}function logger_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}new Fetch;class Logger{debug(e,...t){console.debug(`[${this.name}] ${e}`,...t)}info(e,...t){console.info(`[${this.name}] ${e}`,...t)}warn(e,...t){console.warn(`[${this.name}] ${e}`,...t)}error(e,...t){console.error(`[${this.name}] ${e}`,...t)}constructor(e){logger_define_property(this,"name",void 0),this.name=e}}function douban_history_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function douban_history_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){douban_history_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){douban_history_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function douban_history_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class DoubanHistory{getCK(){return douban_history_async_to_generator(function*(){let e="doubanHistory:ck",t=yield storage.get(e);return t||(yield this.fetch.get("https://douban.com"),t=this.fetch.getCookie("ck"),yield storage.set(e,t)),this.fetch.setCookie({ck:t}),t}).call(this)}setStatus(e,t,r){return douban_history_async_to_generator(function*(){let n=yield this.getCK(),i=yield this.fetch.post(`https://m.douban.com/rexxar/api/v2/${e}/${t}/${r}`,url_parse.qs.stringify({ck:n,tags:"",comment:this.config.customComment,sync_douban:1,rating:0}),{headers:{"Content-Type":"application/x-www-form-urlencoded",Referer:`https://m.douban.com/movie/subject/${t}/`}});this.logger.info(`设置 ${e} ${t} 状态为 ${r}`,i.data)}).call(this)}constructor(e){douban_history_define_property(this,"config",void 0),douban_history_define_property(this,"fetch",void 0),douban_history_define_property(this,"logger",void 0),this.config=e,this.fetch=new Fetch,this.logger=new Logger("DoubanHistory"),this.fetch.setCookie({dbcl2:e.dbcl2})}}function coerce_string(e){return _coercedString(ZodString,e)}function coerce_number(e){return _coercedNumber(ZodNumber,e)}function trakt_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function trakt_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){trakt_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){trakt_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function trakt_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let TRAKT_API_KEY="7100193031cd53fc7d2ec3eb22fe4162f30f0fb572d18c5b87fa1274c3dab80b",paramsSchema=union([schemas_object({type:literal("movie"),tmdbId:coerce_number()}),schemas_object({type:literal("tv"),tmdbId:coerce_number(),season:coerce_number(),episode:coerce_number()})]);class Trakt{syncHistory(e){return trakt_async_to_generator(function*(){let t={},{success:r,data:n}=paramsSchema.safeParse(e);if(!r)return;let i=["trakt","sync","history",e.type,e.tmdbId,e.season,e.episode].filter(Boolean).join(":");if(yield storage.get(i))return;yield storage.set(i,"1",{ttl:TTL_2_HOURS});let o=new Date().toISOString();return"movie"===n.type&&(t.movies=[{watched_at:o,ids:{tmdb:n.tmdbId}}]),"tv"===n.type&&(t.shows=[{ids:{tmdb:n.tmdbId},seasons:[{number:n.season,episodes:[{number:n.episode,watched_at:o}]}]}]),this.fetch.post("https://api.trakt.tv/sync/history",t)}).call(this)}constructor(e){var t;trakt_define_property(this,"fetch",new Fetch),this.fetch.setHeaders({"Content-Type":"application/json",Authorization:`Bearer ${null==(t=e.token)?void 0:t.access_token}`,"trakt-api-key":TRAKT_API_KEY,"trakt-api-version":"2"})}}let en_parsedType=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":if(Array.isArray(e))return"array";if(null===e)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}return t},en_error=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(t){return e[t]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return e=>{switch(e.code){case"invalid_type":return`Invalid input: expected ${e.expected}, received ${en_parsedType(e.input)}`;case"invalid_value":if(1===e.values.length)return`Invalid input: expected ${stringifyPrimitive(e.values[0])}`;return`Invalid option: expected one of ${joinValues(e.values,"|")}`;case"too_big":{let r=e.inclusive?"<=":"<",n=t(e.origin);if(n)return`Too big: expected ${e.origin??"value"} to have ${r}${e.maximum.toString()} ${n.unit??"elements"}`;return`Too big: expected ${e.origin??"value"} to be ${r}${e.maximum.toString()}`}case"too_small":{let r=e.inclusive?">=":">",n=t(e.origin);if(n)return`Too small: expected ${e.origin} to have ${r}${e.minimum.toString()} ${n.unit}`;return`Too small: expected ${e.origin} to be ${r}${e.minimum.toString()}`}case"invalid_format":{let t=e;if("starts_with"===t.format)return`Invalid string: must start with "${t.prefix}"`;if("ends_with"===t.format)return`Invalid string: must end with "${t.suffix}"`;if("includes"===t.format)return`Invalid string: must include "${t.includes}"`;if("regex"===t.format)return`Invalid string: must match pattern ${t.pattern}`;return`Invalid ${r[t.format]??e.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${e.divisor}`;case"unrecognized_keys":return`Unrecognized key${e.keys.length>1?"s":""}: ${joinValues(e.keys,", ")}`;case"invalid_key":return`Invalid key in ${e.origin}`;case"invalid_union":default:return"Invalid input";case"invalid_element":return`Invalid value in ${e.origin}`}}};function en(){return{localeError:en_error()}}let zh_CN_error=()=>{let e={string:{unit:"字符",verb:"包含"},file:{unit:"字节",verb:"包含"},array:{unit:"项",verb:"包含"},set:{unit:"项",verb:"包含"}};function t(t){return e[t]??null}let r=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"非数字(NaN)":"数字";case"object":if(Array.isArray(e))return"数组";if(null===e)return"空值(null)";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}return t},n={regex:"输入",email:"电子邮件",url:"URL",emoji:"表情符号",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日期时间",date:"ISO日期",time:"ISO时间",duration:"ISO时长",ipv4:"IPv4地址",ipv6:"IPv6地址",cidrv4:"IPv4网段",cidrv6:"IPv6网段",base64:"base64编码字符串",base64url:"base64url编码字符串",json_string:"JSON字符串",e164:"E.164号码",jwt:"JWT",template_literal:"输入"};return e=>{switch(e.code){case"invalid_type":return`无效输入:期望 ${e.expected},实际接收 ${r(e.input)}`;case"invalid_value":if(1===e.values.length)return`无效输入:期望 ${stringifyPrimitive(e.values[0])}`;return`无效选项:期望以下之一 ${joinValues(e.values,"|")}`;case"too_big":{let r=e.inclusive?"<=":"<",n=t(e.origin);if(n)return`数值过大:期望 ${e.origin??"值"} ${r}${e.maximum.toString()} ${n.unit??"个元素"}`;return`数值过大:期望 ${e.origin??"值"} ${r}${e.maximum.toString()}`}case"too_small":{let r=e.inclusive?">=":">",n=t(e.origin);if(n)return`数值过小:期望 ${e.origin} ${r}${e.minimum.toString()} ${n.unit}`;return`数值过小:期望 ${e.origin} ${r}${e.minimum.toString()}`}case"invalid_format":{let t=e;if("starts_with"===t.format)return`无效字符串:必须以 "${t.prefix}" 开头`;if("ends_with"===t.format)return`无效字符串:必须以 "${t.suffix}" 结尾`;if("includes"===t.format)return`无效字符串:必须包含 "${t.includes}"`;if("regex"===t.format)return`无效字符串:必须满足正则表达式 ${t.pattern}`;return`无效${n[t.format]??e.format}`}case"not_multiple_of":return`无效数字:必须是 ${e.divisor} 的倍数`;case"unrecognized_keys":return`出现未知的键(key): ${joinValues(e.keys,", ")}`;case"invalid_key":return`${e.origin} 中的键(key)无效`;case"invalid_union":return"无效输入";case"invalid_element":return`${e.origin} 中包含无效值(value)`;default:return`无效输入`}}};function zh_CN(){return{localeError:zh_CN_error()}}compat_ZodFirstPartyTypeKind||(compat_ZodFirstPartyTypeKind={}),core_config(en()),core_config(zh_CN());var constants_MediaType=function(e){return e.Movie="movie",e.TV="tv",e}({});let DEFAULT_COLOR_HEX="ffffff",DEFAULT_COLOR_INT=parseInt(DEFAULT_COLOR_HEX,16),PROVIDER_NAMES={tencent:"腾讯视频",iqiyi:"爱奇艺",youku:"优酷视频",bilibili:"哔哩哔哩",renren:"人人视频",mgtv:"芒果 TV"},searchDanmuParamsSchema=schemas_object({tmdbId:coerce_string().optional(),type:schemas_enum(["movie","tv"]).transform(e=>e).catch("movie"),title:coerce_string().optional(),seriesName:coerce_string().optional(),season:coerce_number().optional(),airDate:coerce_string().optional(),episode:coerce_number().optional(),fuzzyMatch:schemas_enum(["always","never","auto"]).catch("auto").optional().default("auto"),qihooSearch:stringbool().catch(!1).optional().default(!1)}),EMPTY_ANIME_CONFIG={ID:"__empty__",TITLE:"\uD83D\uDE2D 未匹配到资源"};function compact(e){let t=[];for(let r=0;r<e.length;r++){let n=e[r];n&&t.push(n)}return t}function keyBy(e,t){let r={};for(let n=0;n<e.length;n++){let i=e[n];r[t(i)]=i}return r}function compareValues(e,t,r){return e<t?"asc"===r?-1:1:e>t?"asc"===r?1:-1:0}function orderBy(e,t,r){return e.slice().sort((e,n)=>{let i=r.length;for(let o=0;o<t.length;o++){let a=i>o?r[o]:r[i-1],s=t[o],l="function"==typeof s,u=compareValues(l?s(e):e[s],l?s(n):n[s],a);if(0!==u)return u}return 0})}function sortBy(e,t){return orderBy(e,t,["asc"])}function uniqWith(e,t){let r=[];for(let n=0;n<e.length;n++){let i=e[n];r.every(e=>!t(e,i))&&r.push(i)}return r}function getSymbols(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function getTag(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}let regexpTag="[object RegExp]",stringTag="[object String]",numberTag="[object Number]",booleanTag="[object Boolean]",argumentsTag="[object Arguments]",symbolTag="[object Symbol]",dateTag="[object Date]",mapTag="[object Map]",setTag="[object Set]",arrayTag="[object Array]",functionTag="[object Function]",arrayBufferTag="[object ArrayBuffer]",objectTag="[object Object]",errorTag="[object Error]",dataViewTag="[object DataView]",uint8ArrayTag="[object Uint8Array]",uint8ClampedArrayTag="[object Uint8ClampedArray]",uint16ArrayTag="[object Uint16Array]",uint32ArrayTag="[object Uint32Array]",bigUint64ArrayTag="[object BigUint64Array]",int8ArrayTag="[object Int8Array]",int16ArrayTag="[object Int16Array]",int32ArrayTag="[object Int32Array]",bigInt64ArrayTag="[object BigInt64Array]",float32ArrayTag="[object Float32Array]",float64ArrayTag="[object Float64Array]";function eq(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function isEqualWith(e,t,r){return isEqualWithImpl(e,t,void 0,void 0,void 0,void 0,r)}function isEqualWithImpl(e,t,r,n,i,o,a){let s=a(e,t,r,n,i,o);if(void 0!==s)return s;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t)}return areObjectsEqual(e,t,o,a)}function areObjectsEqual(e,t,r,n){if(Object.is(e,t))return!0;let i=getTag(e),o=getTag(t);if(i===argumentsTag&&(i=objectTag),o===argumentsTag&&(o=objectTag),i!==o)return!1;switch(i){case stringTag:return e.toString()===t.toString();case numberTag:return eq(e.valueOf(),t.valueOf());case booleanTag:case dateTag:case symbolTag:return Object.is(e.valueOf(),t.valueOf());case regexpTag:return e.source===t.source&&e.flags===t.flags;case functionTag:return e===t}let a=(r=r??new Map).get(e),s=r.get(t);if(null!=a&&null!=s)return a===t;r.set(e,t),r.set(t,e);try{switch(i){case mapTag:if(e.size!==t.size)return!1;for(let[i,o]of e.entries())if(!t.has(i)||!isEqualWithImpl(o,t.get(i),i,e,t,r,n))return!1;return!0;case setTag:{if(e.size!==t.size)return!1;let i=Array.from(e.values()),o=Array.from(t.values());for(let a=0;a<i.length;a++){let s=i[a],l=o.findIndex(i=>isEqualWithImpl(s,i,void 0,e,t,r,n));if(-1===l)return!1;o.splice(l,1)}return!0}case arrayTag:case uint8ArrayTag:case uint8ClampedArrayTag:case uint16ArrayTag:case uint32ArrayTag:case bigUint64ArrayTag:case int8ArrayTag:case int16ArrayTag:case int32ArrayTag:case bigInt64ArrayTag:case float32ArrayTag:case float64ArrayTag:if("undefined"!=typeof Buffer&&Buffer.isBuffer(e)!==Buffer.isBuffer(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!isEqualWithImpl(e[i],t[i],i,e,t,r,n))return!1;return!0;case arrayBufferTag:if(e.byteLength!==t.byteLength)return!1;return areObjectsEqual(new Uint8Array(e),new Uint8Array(t),r,n);case dataViewTag:if(e.byteLength!==t.byteLength||e.byteOffset!==t.byteOffset)return!1;return areObjectsEqual(new Uint8Array(e),new Uint8Array(t),r,n);case errorTag:return e.name===t.name&&e.message===t.message;case objectTag:{if(!(areObjectsEqual(e.constructor,t.constructor,r,n)||isPlainObject_isPlainObject(e)&&isPlainObject_isPlainObject(t)))return!1;let i=[...Object.keys(e),...getSymbols(e)],o=[...Object.keys(t),...getSymbols(t)];if(i.length!==o.length)return!1;for(let o=0;o<i.length;o++){let a=i[o],s=e[a];if(!Object.hasOwn(t,a))return!1;let l=t[a];if(!isEqualWithImpl(s,l,a,e,t,r,n))return!1}return!0}default:return!1}}finally{r.delete(e),r.delete(t)}}function noop(){}function isEqual(e,t){return isEqualWith(e,t,noop)}function _360kan_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function _360kan_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){_360kan_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){_360kan_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function _360kan_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let qihooSearchResponseSchema=schemas_object({data:schemas_object({longData:schemas_object({rows:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({cat_id:schemas_enum(["1","2","3","4"]),id:schemas_string(),en_id:schemas_string(),cat_name:schemas_string(),titleTxt:schemas_string(),playlinks:record(schemas_string(),schemas_string()).optional()}).safeParse(e).data)?t:null})).transform(e=>compact(e))})})}).transform(e=>e.data.longData.rows);class QihooMatcher{getEpisodeParams(e){return _360kan_async_to_generator(function*(){var t,r,n,i,o;let{success:a,data:s,error:l}=searchDanmuParamsSchema.safeParse(e);if(!a)return this.logger.error("搜索参数无效,错误:",prettifyError(l)),[];let{seriesName:u,season:c,type:d,episode:f}=s;if(!u)return[];let p=yield this.fetch.get(`${this.BASE_API}/index`,{params:{force_v:"1",kw:`${u} ${c&&c>1?c:""}`.trim(),from:"",pageno:"1",v_ap:"1",tab:"all"},schema:qihooSearchResponseSchema});if(!(null==(t=p.data)?void 0:t.length))return[];let h=[];for(let e of p.data){if(d===constants_MediaType.Movie&&"1"!==e.cat_id){this.logger.warn("电影搜索结果中包含电视剧,跳过");continue}if(d===constants_MediaType.TV&&"1"===e.cat_id){this.logger.warn("电视剧搜索结果中包含电影,跳过");continue}if(!e.titleTxt.includes(u)){this.logger.warn("搜索结果中包含的剧集标题与搜索关键词不匹配,跳过");continue}if(!e.playlinks){this.logger.warn("搜索结果中包含的剧集没有播放链接,跳过");continue}if(e.playlinks.qq){let t=null==(r=e.playlinks.qq.match(/\/cover\/([^/]+?)(\/|.html|$)/))?void 0:r[1];t&&h.push({provider:"tencent",idString:scrapers_scraper.scraperMap.tencent.generateIdString({cid:t}),episodeNumber:f})}if(e.playlinks.youku){let{vid:t,showid:r}=url_parse_default()(e.playlinks.youku,!0).query;(t||r)&&h.push({provider:"youku",idString:scrapers_scraper.scraperMap.youku.generateIdString({vid:t,showId:r}),episodeNumber:f})}if(e.playlinks.qiyi){let t=null==(n=e.playlinks.qiyi.match(/\/v_([^/]+?)(\/|.html|$)/))?void 0:n[1],r=t?scrapers_scraper.scraperMap.iqiyi.videoIdToEntityId(t):void 0;r&&h.push({provider:"iqiyi",idString:scrapers_scraper.scraperMap.iqiyi.generateIdString({entityId:r}),episodeNumber:f})}if(e.playlinks.bilibili1){let t=null==(i=(yield this.fetch.get(e.playlinks.bilibili1,{cache:e.playlinks.bilibili1})).data.match(/"season_id":(\d+)/))?void 0:i[1];t&&h.push({provider:"bilibili",idString:scrapers_scraper.scraperMap.bilibili.generateIdString({seasonId:t}),episodeNumber:f})}if(e.playlinks.imgo){let t=null==(o=e.playlinks.imgo.match(/\/b\/([^/]+)\//))?void 0:o[1];t&&h.push({provider:"mgtv",idString:scrapers_scraper.scraperMap.mgtv.generateIdString({dramaId:t}),episodeNumber:f})}}return h}).call(this)}constructor(){_360kan_define_property(this,"logger",new Logger("360")),_360kan_define_property(this,"fetch",new Fetch),_360kan_define_property(this,"BASE_API","https://api.so.360kan.com")}}var enc_base64=__webpack_require__(716),enc_base64_default=__webpack_require__.n(enc_base64);function base64ToUint8Array(e){let t=enc_base64_default().parse(e),r=new Uint8Array(t.sigBytes);for(let e=0;e<t.sigBytes;e++){let n=e>>>2,i=e%4;r[e]=t.words[n]>>>24-8*i&255}return r}function generateUUID(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function isDeepKey(e){switch(typeof e){case"number":case"symbol":return!1;case"string":return e.includes(".")||e.includes("[")||e.includes("]")}}function toKey(e){return"string"==typeof e||"symbol"==typeof e?e:Object.is(e?.valueOf?.(),-0)?"-0":String(e)}function toPath(e){let t=[],r=e.length;if(0===r)return t;let n=0,i="",o="",a=!1;for(46===e.charCodeAt(0)&&(t.push(""),n++);n<r;){let s=e[n];o?"\\"===s&&n+1<r?i+=e[++n]:s===o?o="":i+=s:a?'"'===s||"'"===s?o=s:"]"===s?(a=!1,t.push(i),i=""):i+=s:"["===s?(a=!0,i&&(t.push(i),i="")):"."===s?i&&(t.push(i),i=""):i+=s,n++}return i&&t.push(i),t}function get(e,t,r){if(null==e)return r;switch(typeof t){case"string":{if(isUnsafeProperty(t))return r;let n=e[t];if(void 0===n)if(isDeepKey(t))return get(e,toPath(t),r);else return r;return n}case"number":case"symbol":{"number"==typeof t&&(t=toKey(t));let n=e[t];if(void 0===n)return r;return n}default:{if(Array.isArray(t))return getWithPath(e,t,r);if(isUnsafeProperty(t=Object.is(t?.valueOf(),-0)?"-0":String(t)))return r;let n=e[t];if(void 0===n)return r;return n}}}function getWithPath(e,t,r){if(0===t.length)return r;let n=e;for(let e=0;e<t.length;e++){if(null==n||isUnsafeProperty(t[e]))return r;n=n[t[e]]}return void 0===n?r:n}let GLOBAL_EPISODE_BLACKLIST="^(.*?)((.+?版)|(特(别|典))|((导|演)员|嘉宾|角色)访谈|福利|先导|彩蛋|花絮|预告|特辑|专访|访谈|幕后|周边|资讯|看点|速看|回顾|盘点|合集|PV|MV|CM|OST|ED|OP|BD|特典|SP|NCOP|NCED|MENU|Web-DL|rip|x264|x265|aac|flac)(.*?)$",getEpisodeBlacklistPattern=e=>{let t=[GLOBAL_EPISODE_BLACKLIST];(null==e?void 0:e.trim())&&t.push(e);let r=t.join("|");try{return RegExp(r,"i")}catch(e){return console.error("编译分集黑名单正则表达式失败:",r,"错误:",e),RegExp(GLOBAL_EPISODE_BLACKLIST,"i")}},parseEpNumber=e=>{if(!e)return null;let t=normalizeTitle(e);{let e=/第\s*([0-9]+)\s*(?:[集话話回期])\s*$/.exec(t);if(e)return toInt(e[1])}{let e=/第\s*([零〇一二两三四五六七八九十百千万萬]+)\s*(?:[集话話回期])\s*$/.exec(t);if(e){let t=parseChineseNumeral(e[1]);return Number.isFinite(t)?t:null}}{let e=/S\d{1,3}\s*E(\d{1,4})\s*$/i.exec(t);if(e)return toInt(e[1])}{let e=/EP?\s*0*(\d{1,4})\s*$/i.exec(t);if(e)return toInt(e[1])}{let e=/(?:^|[\s_\-((【[])\s*0*(\d{1,5})\s*(?:[】\]))])?\s*(?:END|FIN|完|完结)?\s*$/i.exec(t);if(e)return toInt(e[1])}return null};function normalizeTitle(e){let t=e.trim();return(t=t.replace(/[0-9]/g,e=>String.fromCharCode(e.charCodeAt(0)-65296+48))).replace(/\u3000/g," ")}function toInt(e){let t=parseInt(e,10);return Number.isFinite(t)?t:null}function parseChineseNumeral(e){let t={零:0,〇:0,一:1,二:2,两:2,三:3,四:4,五:5,六:6,七:7,八:8,九:9},r={十:10,百:100,千:1e3,万:1e4,萬:1e4},n=0,i=0,o=0;for(let a of e)if(a in t)o=t[a];else if(a in r){let e=r[a];1e4===e?(n+=i=(i+(o||0))*e,i=0):i+=(o||1)*e,o=0}return n+i+o}function base_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var base_CommentMode=function(e){return e[e.SCROLL=1]="SCROLL",e[e.BOTTOM=4]="BOTTOM",e[e.TOP=5]="TOP",e}({});let providerCommentItemSchema=schemas_object({id:coerce_string().optional(),timestamp:coerce_number(),mode:schemas_enum(base_CommentMode).catch(1).optional().default(1),color:schemas_number().catch(DEFAULT_COLOR_INT).optional().default(DEFAULT_COLOR_INT),content:schemas_string()});class BaseScraper{get providerConfig(){return this._providerConfig}set providerConfig(e){let t=get(e,this.providerName);t&&(this.logger.debug("设置 Provider 配置",t),this._providerConfig=e)}parseIdString(e){var t,r;let n=url_parse.qs.parse(e),i=null==(t=this.idSchema)?void 0:t.safeParse(n);return i?i.success?null!=(r=i.data)?r:null:(this.logger.error("parseIdString",e,prettifyError(i.error)),null):(this.logger.error("parseIdString",e,"idSchema is not defined"),null)}generateIdString(e){return url_parse.qs.stringify(this.idSchema.parse(e))}getEpisodeIndexFromTitle(e){return parseEpNumber(e)}get episodeBlacklistPattern(){return getEpisodeBlacklistPattern(this.PROVIDER_SPECIFIC_BLACKLIST)}constructor(){base_define_property(this,"providerName","base"),base_define_property(this,"logger",void 0),base_define_property(this,"fetch",new Fetch),base_define_property(this,"_providerConfig",{}),base_define_property(this,"PROVIDER_SPECIFIC_BLACKLIST",""),this.logger=new Logger(this.providerName)}}var dm_proto=__webpack_require__(327);let bilibiliIdSchema=schemas_object({seasonId:schemas_string(),aid:schemas_string().optional(),cid:schemas_string().optional()}),pgcEpisodeSchema=schemas_object({aid:schemas_int(),cid:schemas_int(),badge:schemas_string(),duration:schemas_number(),title:schemas_string(),show_title:schemas_string(),long_title:schemas_string()}),pgcEpisodeResultSchema=schemas_object({code:literal(0),result:schemas_object({episodes:schemas_array(unknown().transform(e=>pgcEpisodeSchema.safeParse(e).data)).transform(e=>compact(e))})});function bilibili_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function bilibili_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){bilibili_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){bilibili_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function bilibili_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class BilibiliScraper extends BaseScraper{getEpisodes(e,t){return bilibili_async_to_generator(function*(){let r=this.parseIdString(e);if(!r)return[];let n=[],i=yield this.getPgcEpisodes(r.seasonId),o=1;for(let e of null!=i?i:[]){if("预告"===e.badge){this.logger.warn("预告,跳过,title:",e.title);continue}if(this.episodeBlacklistPattern.test(e.title)){this.logger.warn("黑名单,跳过,title:",e.title);continue}n.push({provider:this.providerName,episodeId:this.generateIdString({seasonId:r.seasonId,aid:e.aid.toString(),cid:e.cid.toString()}),episodeTitle:e.show_title||e.title,episodeNumber:o}),o+=1}return t?n.filter(e=>e.episodeNumber===t):n}).call(this)}getSegments(e){return bilibili_async_to_generator(function*(){var t;let{aid:r,cid:n,seasonId:i}=null!=(t=this.parseIdString(e))?t:{};if(!r||!n||!i)return[];let o=yield this.getPgcEpisodes(i),a=null==o?void 0:o.find(e=>e.aid===parseInt(r)&&e.cid===parseInt(n));return a?Array.from({length:Math.floor(a.duration/1e3/360)+1},(e,t)=>({provider:this.providerName,startTime:360*t,segmentId:(t+1).toString()})):[]}).call(this)}getComments(e,t){return bilibili_async_to_generator(function*(){var r;let{aid:n,cid:i,seasonId:o}=null!=(r=this.parseIdString(e))?r:{};if(!n||!i||!o)return this.logger.warn("aid:",n,"cid:",i,"seasonId:",o,"不存在"),null;let a=yield this.getPgcEpisodes(o);if(!(null==a?void 0:a.find(e=>e.aid===parseInt(n)&&e.cid===parseInt(i))))return this.logger.warn("未找到分集,aid:",n,"cid:",i,"seasonId:",o),null;let s=yield this.fetchCommentsForCid(n,i,t);return s?s.map(e=>{var t,r;if(!e.progress)return null;let n=(null==(t=e.content)?void 0:t.toString().replace(/\0/g,""))||"";return n&&null!=(r=providerCommentItemSchema.safeParse({id:e.id.toString(),timestamp:e.progress/1e3,mode:e.mode,color:e.color,content:n}).data)?r:null}):(this.logger.warn("未找到弹幕,aid:",n,"cid:",i,"segmentId:",t),null)}).call(this)}getPgcEpisodes(e){return bilibili_async_to_generator(function*(){var t;return null==(t=(yield this.fetch.get("https://api.bilibili.com/pgc/view/web/ep/list",{params:{season_id:e},schema:pgcEpisodeResultSchema,cache:{cacheKey:`bilibili:episodes:${e}`}})).data)?void 0:t.result.episodes}).call(this)}fetchCommentsForCid(e,t,r){return bilibili_async_to_generator(function*(){try{let n=yield this.fetch.get("https://api.bilibili.com/x/v2/dm/web/seg.so",{params:{type:"1",oid:t,pid:e,segment_index:r},base64Data:!0});if(404===n.statusCode||304===n.statusCode)return null;return this.DmSegMobileReply.decode(base64ToUint8Array(n.data)).elems}catch(n){this.logger.error("获取分段",r,"失败,aid:",e,"cid:",t,"错误:",n)}return null}).call(this)}constructor(){super(),bilibili_define_property(this,"providerName","bilibili"),bilibili_define_property(this,"idSchema",bilibiliIdSchema),bilibili_define_property(this,"DmSegMobileReply",dm_proto.biliproto.community.service.dm.v1.DmSegMobileReply),this.fetch.setHeaders({Referer:"https://www.bilibili.com/"})}}var enc_utf8=__webpack_require__(60),enc_utf8_default=__webpack_require__.n(enc_utf8);let assignValue=(e,t,r)=>{let n=e[t];Object.hasOwn(e,t)&&eq(n,r)&&(void 0!==r||t in e)||(e[t]=r)},IS_UNSIGNED_INTEGER=/^(?:0|[1-9]\d*)$/;function isIndex(e,t=Number.MAX_SAFE_INTEGER){switch(typeof e){case"number":return Number.isInteger(e)&&e>=0&&e<t;case"symbol":return!1;case"string":return IS_UNSIGNED_INTEGER.test(e)}}function isSymbol(e){return"symbol"==typeof e||e instanceof Symbol}let regexIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,regexIsPlainProp=/^\w*$/;function isKey(e,t){return!Array.isArray(e)&&(!!("number"==typeof e||"boolean"==typeof e||null==e||isSymbol(e))||"string"==typeof e&&(regexIsPlainProp.test(e)||!regexIsDeepProp.test(e))||null!=t&&Object.hasOwn(t,e))}function isObject_isObject(e){return null!==e&&("object"==typeof e||"function"==typeof e)}function updateWith(e,t,r,n){if(null==e&&!isObject_isObject(e))return e;let i=isKey(t,e)?[t]:Array.isArray(t)?t:"string"==typeof t?toPath(t):[t],o=e;for(let t=0;t<i.length&&null!=o;t++){let a,s=toKey(i[t]);if(!isUnsafeProperty(s)){if(t===i.length-1)a=r(o[s]);else{let r=o[s],l=n?.(r,s,e);a=void 0!==l?l:isObject_isObject(r)?r:isIndex(i[t+1])?[]:{}}assignValue(o,s,a),o=o[s]}}return e}function set_set(e,t,r){return updateWith(e,t,()=>r,()=>void 0)}let globalParamsConfigSchema=schemas_object({"global.content.aggregation":stringbool().catch(!0),"global.content.blacklist":schemas_string().refine(e=>{try{return new RegExp(e),!0}catch(e){return!1}}).catch(""),"global.experimental.doubanHistory.enabled":stringbool().catch(!1),"global.experimental.doubanHistory.dbcl2":schemas_string().catch(""),"global.experimental.doubanHistory.customComment":schemas_string().catch("自豪的使用 Forward"),"global.experimental.trakt.enabled":stringbool().catch(!1),"global.experimental.trakt.token":schemas_string().transform(e=>e?safeJsonParseWithZod(enc_base64_default().parse(e).toString(enc_utf8_default()),schemas_object({access_token:schemas_string(),expires_at:schemas_number().min(Date.now())})):null).catch(null),"provider.renren.mode":schemas_enum(["default","choice"]).catch("default")}).transform(e=>{let t={};return Object.entries(e).forEach(([e,r])=>{set_set(t,e,r)}),t});var md5=__webpack_require__(478),md5_default=__webpack_require__.n(md5);let OptionsBuilder_defaultOptions={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,r){return e},captureMetaData:!1},buildOptions=function(e){return Object.assign({},OptionsBuilder_defaultOptions,e)},nameStartChar=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",nameChar=nameStartChar+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",nameRegexp="["+nameStartChar+"]["+nameChar+"]*",regexName=RegExp("^"+nameRegexp+"$");function getAllMatches(e,t){let r=[],n=t.exec(e);for(;n;){let i=[];i.startIndex=t.lastIndex-n[0].length;let o=n.length;for(let e=0;e<o;e++)i.push(n[e]);r.push(i),n=t.exec(e)}return r}let isName=function(e){return null!=regexName.exec(e)};function isExist(e){return void 0!==e}METADATA_SYMBOL="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class XmlNode{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){"__proto__"===e.tagname&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),void 0!==t&&(this.child[this.child.length-1][METADATA_SYMBOL]={startIndex:t})}static getMetaDataSymbol(){return METADATA_SYMBOL}}function readDocType(e,t){let r={};if("O"===e[t+3]&&"C"===e[t+4]&&"T"===e[t+5]&&"Y"===e[t+6]&&"P"===e[t+7]&&"E"===e[t+8]){t+=9;let n=1,i=!1,o=!1,a="";for(;t<e.length;t++)if("<"!==e[t]||o)if(">"===e[t]){if(o?"-"===e[t-1]&&"-"===e[t-2]&&(o=!1,n--):n--,0===n)break}else"["===e[t]?i=!0:a+=e[t];else{if(i&&hasSeq(e,"!ENTITY",t)){let n,i;t+=7,[n,i,t]=readEntityExp(e,t+1),-1===i.indexOf("&")&&(r[n]={regx:RegExp(`&${n};`,"g"),val:i})}else if(i&&hasSeq(e,"!ELEMENT",t)){let{index:r}=readElementExp(e,(t+=8)+1);t=r}else if(i&&hasSeq(e,"!ATTLIST",t))t+=8;else if(i&&hasSeq(e,"!NOTATION",t)){let{index:r}=readNotationExp(e,(t+=9)+1);t=r}else if(hasSeq(e,"!--",t))o=!0;else throw Error("Invalid DOCTYPE");n++,a=""}if(0!==n)throw Error("Unclosed DOCTYPE")}else throw Error("Invalid Tag instead of DOCTYPE");return{entities:r,i:t}}let skipWhitespace=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function readEntityExp(e,t){t=skipWhitespace(e,t);let r="";for(;t<e.length&&!/\s/.test(e[t])&&'"'!==e[t]&&"'"!==e[t];)r+=e[t],t++;if(validateEntityName(r),t=skipWhitespace(e,t),"SYSTEM"===e.substring(t,t+6).toUpperCase())throw Error("External entities are not supported");if("%"===e[t])throw Error("Parameter entities are not supported");let n="";return[t,n]=readIdentifierVal(e,t,"entity"),[r,n,--t]}function readNotationExp(e,t){t=skipWhitespace(e,t);let r="";for(;t<e.length&&!/\s/.test(e[t]);)r+=e[t],t++;validateEntityName(r),t=skipWhitespace(e,t);let n=e.substring(t,t+6).toUpperCase();if("SYSTEM"!==n&&"PUBLIC"!==n)throw Error(`Expected SYSTEM or PUBLIC, found "${n}"`);t+=n.length,t=skipWhitespace(e,t);let i=null,o=null;if("PUBLIC"===n)[t,i]=readIdentifierVal(e,t,"publicIdentifier"),t=skipWhitespace(e,t),('"'===e[t]||"'"===e[t])&&([t,o]=readIdentifierVal(e,t,"systemIdentifier"));else if("SYSTEM"===n&&([t,o]=readIdentifierVal(e,t,"systemIdentifier"),!o))throw Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:r,publicIdentifier:i,systemIdentifier:o,index:--t}}function readIdentifierVal(e,t,r){let n="",i=e[t];if('"'!==i&&"'"!==i)throw Error(`Expected quoted string, found "${i}"`);for(t++;t<e.length&&e[t]!==i;)n+=e[t],t++;if(e[t]!==i)throw Error(`Unterminated ${r} value`);return[++t,n]}function readElementExp(e,t){t=skipWhitespace(e,t);let r="";for(;t<e.length&&!/\s/.test(e[t]);)r+=e[t],t++;if(!validateEntityName(r))throw Error(`Invalid element name: "${r}"`);t=skipWhitespace(e,t);let n="";if("E"===e[t]&&hasSeq(e,"MPTY",t))t+=4;else if("A"===e[t]&&hasSeq(e,"NY",t))t+=2;else if("("===e[t]){for(t++;t<e.length&&")"!==e[t];)n+=e[t],t++;if(")"!==e[t])throw Error("Unterminated content model")}else throw Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:r,contentModel:n.trim(),index:t}}function hasSeq(e,t,r){for(let n=0;n<t.length;n++)if(t[n]!==e[r+n+1])return!1;return!0}function validateEntityName(e){if(isName(e))return e;throw Error(`Invalid entity name ${e}`)}let hexRegex=/^[-+]?0x[a-fA-F0-9]+$/,numRegex=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,consider={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function toNumber(e,t={}){if(t=Object.assign({},consider,t),!e||"string"!=typeof e)return e;let r=e.trim();if(void 0!==t.skipLike&&t.skipLike.test(r))return e;{if("0"===e)return 0;if(t.hex&&hexRegex.test(r))return parse_int(r,16);if(-1!==r.search(/.+[eE].+/))return resolveEnotation(e,r,t);let n=numRegex.exec(r);if(!n)return e;{let i=n[1]||"",o=n[2],a=trimZeros(n[3]),s=i?"."===e[o.length+1]:"."===e[o.length];if(!t.leadingZeros&&(o.length>1||1===o.length&&!s))return e;{let n=Number(r),s=String(n);if(0===n)return n;if(-1!==s.search(/[eE]/))if(t.eNotation)return n;else return e;if(-1!==r.indexOf("."))if("0"===s)return n;else if(s===a)return n;else if(s===`${i}${a}`)return n;else return e;let l=o?a:r;return o?l===s||i+l===s?n:e:l===s||l===i+s?n:e}}}}let eNotationRegx=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function resolveEnotation(e,t,r){if(!r.eNotation)return e;let n=t.match(eNotationRegx);if(!n)return e;{let i=n[1]||"",o=-1===n[3].indexOf("e")?"E":"e",a=n[2],s=i?e[a.length+1]===o:e[a.length]===o;return a.length>1&&s?e:1===a.length&&(n[3].startsWith(`.${o}`)||n[3][0]===o)?Number(t):r.leadingZeros&&!s?Number(t=(n[1]||"")+n[3]):e}}function trimZeros(e){return e&&-1!==e.indexOf(".")&&("."===(e=e.replace(/0+$/,""))?e="0":"."===e[0]?e="0"+e:"."===e[e.length-1]&&(e=e.substring(0,e.length-1))),e}function parse_int(e,t){if(parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw Error("parseInt, Number.parseInt, window.parseInt are not supported")}function getIgnoreAttributesFn(e){return"function"==typeof e?e:Array.isArray(e)?t=>{for(let r of e)if("string"==typeof r&&t===r||r instanceof RegExp&&r.test(t))return!0}:()=>!1}class OrderedObjParser{constructor(e){this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xa2"},pound:{regex:/&(pound|#163);/g,val:"\xa3"},yen:{regex:/&(yen|#165);/g,val:"\xa5"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"\xa9"},reg:{regex:/&(reg|#174);/g,val:"\xae"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>String.fromCodePoint(Number.parseInt(t,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>String.fromCodePoint(Number.parseInt(t,16))}},this.addExternalEntities=addExternalEntities,this.parseXml=parseXml,this.parseTextData=parseTextData,this.resolveNameSpace=resolveNameSpace,this.buildAttributesMap=buildAttributesMap,this.isItStopNode=isItStopNode,this.replaceEntitiesValue=replaceEntitiesValue,this.readStopNodeData=readStopNodeData,this.saveTextToParentTag=saveTextToParentTag,this.addChild=addChild,this.ignoreAttributesFn=getIgnoreAttributesFn(this.options.ignoreAttributes)}}function addExternalEntities(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let n=t[r];this.lastEntities[n]={regex:RegExp("&"+n+";","g"),val:e[n]}}}function parseTextData(e,t,r,n,i,o,a){if(void 0!==e&&(this.options.trimValues&&!n&&(e=e.trim()),e.length>0)){a||(e=this.replaceEntitiesValue(e));let n=this.options.tagValueProcessor(t,e,r,i,o);return null==n?e:typeof n!=typeof e||n!==e?n:this.options.trimValues||e.trim()===e?parseValue(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function resolveNameSpace(e){if(this.options.removeNSPrefix){let t=e.split(":"),r="/"===e.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(e=r+t[1])}return e}let attrsRegx=RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function buildAttributesMap(e,t,r){if(!0!==this.options.ignoreAttributes&&"string"==typeof e){let r=getAllMatches(e,attrsRegx),n=r.length,i={};for(let e=0;e<n;e++){let n=this.resolveNameSpace(r[e][1]);if(this.ignoreAttributesFn(n,t))continue;let o=r[e][4],a=this.options.attributeNamePrefix+n;if(n.length)if(this.options.transformAttributeName&&(a=this.options.transformAttributeName(a)),"__proto__"===a&&(a="#__proto__"),void 0!==o){this.options.trimValues&&(o=o.trim()),o=this.replaceEntitiesValue(o);let e=this.options.attributeValueProcessor(n,o,t);null==e?i[a]=o:typeof e!=typeof o||e!==o?i[a]=e:i[a]=parseValue(o,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(i[a]=!0)}if(Object.keys(i).length){if(this.options.attributesGroupName){let e={};return e[this.options.attributesGroupName]=i,e}return i}}}let parseXml=function(e){e=e.replace(/\r\n?/g,"\n");let t=new XmlNode("!xml"),r=t,n="",i="";for(let o=0;o<e.length;o++)if("<"===e[o])if("/"===e[o+1]){let t=findClosingIndex(e,">",o,"Closing Tag is not closed."),a=e.substring(o+2,t).trim();if(this.options.removeNSPrefix){let e=a.indexOf(":");-1!==e&&(a=a.substr(e+1))}this.options.transformTagName&&(a=this.options.transformTagName(a)),r&&(n=this.saveTextToParentTag(n,r,i));let s=i.substring(i.lastIndexOf(".")+1);if(a&&-1!==this.options.unpairedTags.indexOf(a))throw Error(`Unpaired tag can not be used as closing tag: </${a}>`);let l=0;s&&-1!==this.options.unpairedTags.indexOf(s)?(l=i.lastIndexOf(".",i.lastIndexOf(".")-1),this.tagsNodeStack.pop()):l=i.lastIndexOf("."),i=i.substring(0,l),r=this.tagsNodeStack.pop(),n="",o=t}else if("?"===e[o+1]){let t=readTagExp(e,o,!1,"?>");if(!t)throw Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,r,i),this.options.ignoreDeclaration&&"?xml"===t.tagName||this.options.ignorePiTags);else{let e=new XmlNode(t.tagName);e.add(this.options.textNodeName,""),t.tagName!==t.tagExp&&t.attrExpPresent&&(e[":@"]=this.buildAttributesMap(t.tagExp,i,t.tagName)),this.addChild(r,e,i,o)}o=t.closeIndex+1}else if("!--"===e.substr(o+1,3)){let t=findClosingIndex(e,"--\x3e",o+4,"Comment is not closed.");if(this.options.commentPropName){let a=e.substring(o+4,t-2);n=this.saveTextToParentTag(n,r,i),r.add(this.options.commentPropName,[{[this.options.textNodeName]:a}])}o=t}else if("!D"===e.substr(o+1,2)){let t=readDocType(e,o);this.docTypeEntities=t.entities,o=t.i}else if("!["===e.substr(o+1,2)){let t=findClosingIndex(e,"]]>",o,"CDATA is not closed.")-2,a=e.substring(o+9,t);n=this.saveTextToParentTag(n,r,i);let s=this.parseTextData(a,r.tagname,i,!0,!1,!0,!0);void 0==s&&(s=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:a}]):r.add(this.options.textNodeName,s),o=t+2}else{let a=readTagExp(e,o,this.options.removeNSPrefix),s=a.tagName,l=a.rawTagName,u=a.tagExp,c=a.attrExpPresent,d=a.closeIndex;this.options.transformTagName&&(s=this.options.transformTagName(s)),r&&n&&"!xml"!==r.tagname&&(n=this.saveTextToParentTag(n,r,i,!1));let f=r;f&&-1!==this.options.unpairedTags.indexOf(f.tagname)&&(r=this.tagsNodeStack.pop(),i=i.substring(0,i.lastIndexOf("."))),s!==t.tagname&&(i+=i?"."+s:s);let p=o;if(this.isItStopNode(this.options.stopNodes,i,s)){let t="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)"/"===s[s.length-1]?(s=s.substr(0,s.length-1),i=i.substr(0,i.length-1),u=s):u=u.substr(0,u.length-1),o=a.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(s))o=a.closeIndex;else{let r=this.readStopNodeData(e,l,d+1);if(!r)throw Error(`Unexpected end of ${l}`);o=r.i,t=r.tagContent}let n=new XmlNode(s);s!==u&&c&&(n[":@"]=this.buildAttributesMap(u,i,s)),t&&(t=this.parseTextData(t,s,i,!0,c,!0,!0)),i=i.substr(0,i.lastIndexOf(".")),n.add(this.options.textNodeName,t),this.addChild(r,n,i,p)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){"/"===s[s.length-1]?(s=s.substr(0,s.length-1),i=i.substr(0,i.length-1),u=s):u=u.substr(0,u.length-1),this.options.transformTagName&&(s=this.options.transformTagName(s));let e=new XmlNode(s);s!==u&&c&&(e[":@"]=this.buildAttributesMap(u,i,s)),this.addChild(r,e,i,p),i=i.substr(0,i.lastIndexOf("."))}else{let e=new XmlNode(s);this.tagsNodeStack.push(r),s!==u&&c&&(e[":@"]=this.buildAttributesMap(u,i,s)),this.addChild(r,e,i,p),r=e}n="",o=d}}else n+=e[o];return t.child};function addChild(e,t,r,n){this.options.captureMetaData||(n=void 0);let i=this.options.updateTag(t.tagname,r,t[":@"]);!1===i||("string"==typeof i&&(t.tagname=i),e.addChild(t,n))}let replaceEntitiesValue=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let r=this.docTypeEntities[t];e=e.replace(r.regx,r.val)}for(let t in this.lastEntities){let r=this.lastEntities[t];e=e.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let r=this.htmlEntities[t];e=e.replace(r.regex,r.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function saveTextToParentTag(e,t,r,n){return e&&(void 0===n&&(n=0===t.child.length),void 0!==(e=this.parseTextData(e,t.tagname,r,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,n))&&""!==e&&t.add(this.options.textNodeName,e),e=""),e}function isItStopNode(e,t,r){let n="*."+r;for(let r in e){let i=e[r];if(n===i||t===i)return!0}return!1}function tagExpWithClosingIndex(e,t,r=">"){let n,i="";for(let o=t;o<e.length;o++){let t=e[o];if(n)t===n&&(n="");else if('"'===t||"'"===t)n=t;else if(t===r[0]){if(!r[1])return{data:i,index:o};else if(e[o+1]===r[1])return{data:i,index:o}}else" "===t&&(t=" ");i+=t}}function findClosingIndex(e,t,r,n){let i=e.indexOf(t,r);if(-1!==i)return i+t.length-1;throw Error(n)}function readTagExp(e,t,r,n=">"){let i=tagExpWithClosingIndex(e,t+1,n);if(!i)return;let o=i.data,a=i.index,s=o.search(/\s/),l=o,u=!0;-1!==s&&(l=o.substring(0,s),o=o.substring(s+1).trimStart());let c=l;if(r){let e=l.indexOf(":");-1!==e&&(u=(l=l.substr(e+1))!==i.data.substr(e+1))}return{tagName:l,tagExp:o,closeIndex:a,attrExpPresent:u,rawTagName:c}}function readStopNodeData(e,t,r){let n=r,i=1;for(;r<e.length;r++)if("<"===e[r])if("/"===e[r+1]){let o=findClosingIndex(e,">",r,`${t} is not closed`);if(e.substring(r+2,o).trim()===t&&0==--i)return{tagContent:e.substring(n,r),i:o};r=o}else if("?"===e[r+1])r=findClosingIndex(e,"?>",r+1,"StopNode is not closed.");else if("!--"===e.substr(r+1,3))r=findClosingIndex(e,"--\x3e",r+3,"StopNode is not closed.");else if("!["===e.substr(r+1,2))r=findClosingIndex(e,"]]>",r,"StopNode is not closed.")-2;else{let n=readTagExp(e,r,">");n&&((n&&n.tagName)===t&&"/"!==n.tagExp[n.tagExp.length-1]&&i++,r=n.closeIndex)}}function parseValue(e,t,r){if(t&&"string"==typeof e){let t=e.trim();return"true"===t||"false"!==t&&toNumber(e,r)}return isExist(e)?e:""}let node2json_METADATA_SYMBOL=XmlNode.getMetaDataSymbol();function prettify(e,t){return compress(e,t)}function compress(e,t,r){let n,i={};for(let o=0;o<e.length;o++){let a=e[o],s=propName(a),l="";if(l=void 0===r?s:r+"."+s,s===t.textNodeName)void 0===n?n=a[s]:n+=""+a[s];else if(void 0===s)continue;else if(a[s]){let e=compress(a[s],t,l),r=isLeafTag(e,t);void 0!==a[node2json_METADATA_SYMBOL]&&(e[node2json_METADATA_SYMBOL]=a[node2json_METADATA_SYMBOL]),a[":@"]?assignAttributes(e,a[":@"],l,t):1!==Object.keys(e).length||void 0===e[t.textNodeName]||t.alwaysCreateTextNode?0===Object.keys(e).length&&(t.alwaysCreateTextNode?e[t.textNodeName]="":e=""):e=e[t.textNodeName],void 0!==i[s]&&i.hasOwnProperty(s)?(Array.isArray(i[s])||(i[s]=[i[s]]),i[s].push(e)):t.isArray(s,l,r)?i[s]=[e]:i[s]=e}}return"string"==typeof n?n.length>0&&(i[t.textNodeName]=n):void 0!==n&&(i[t.textNodeName]=n),i}function propName(e){let t=Object.keys(e);for(let e=0;e<t.length;e++){let r=t[e];if(":@"!==r)return r}}function assignAttributes(e,t,r,n){if(t){let i=Object.keys(t),o=i.length;for(let a=0;a<o;a++){let o=i[a];n.isArray(o,r+"."+o,!0,!0)?e[o]=[t[o]]:e[o]=t[o]}}}function isLeafTag(e,t){let{textNodeName:r}=t,n=Object.keys(e).length;return 0===n||1===n&&(!!e[r]||"boolean"==typeof e[r]||0===e[r])}let validator_defaultOptions={allowBooleanAttributes:!1,unpairedTags:[]};function validate(e,t){t=Object.assign({},validator_defaultOptions,t);let r=[],n=!1,i=!1;"\uFEFF"===e[0]&&(e=e.substr(1));for(let o=0;o<e.length;o++)if("<"===e[o]&&"?"===e[o+1]){if(o+=2,(o=readPI(e,o)).err)return o}else if("<"===e[o]){let a=o;if("!"===e[++o]){o=readCommentAndCDATA(e,o);continue}{let s=!1;"/"===e[o]&&(s=!0,o++);let l="";for(;o<e.length&&">"!==e[o]&&" "!==e[o]&&" "!==e[o]&&"\n"!==e[o]&&"\r"!==e[o];o++)l+=e[o];if("/"===(l=l.trim())[l.length-1]&&(l=l.substring(0,l.length-1),o--),!validateTagName(l)){let t;return getErrorObject("InvalidTag",t=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",getLineNumberForPosition(e,o))}let u=readAttributeStr(e,o);if(!1===u)return getErrorObject("InvalidAttr","Attributes for '"+l+"' have open quote.",getLineNumberForPosition(e,o));let c=u.value;if(o=u.index,"/"===c[c.length-1]){let r=o-c.length,i=validateAttributeString(c=c.substring(0,c.length-1),t);if(!0!==i)return getErrorObject(i.err.code,i.err.msg,getLineNumberForPosition(e,r+i.err.line));n=!0}else if(s)if(!u.tagClosed)return getErrorObject("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",getLineNumberForPosition(e,o));else{if(c.trim().length>0)return getErrorObject("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",getLineNumberForPosition(e,a));if(0===r.length)return getErrorObject("InvalidTag","Closing tag '"+l+"' has not been opened.",getLineNumberForPosition(e,a));let t=r.pop();if(l!==t.tagName){let r=getLineNumberForPosition(e,t.tagStartPos);return getErrorObject("InvalidTag","Expected closing tag '"+t.tagName+"' (opened in line "+r.line+", col "+r.col+") instead of closing tag '"+l+"'.",getLineNumberForPosition(e,a))}0==r.length&&(i=!0)}else{let s=validateAttributeString(c,t);if(!0!==s)return getErrorObject(s.err.code,s.err.msg,getLineNumberForPosition(e,o-c.length+s.err.line));if(!0===i)return getErrorObject("InvalidXml","Multiple possible root nodes found.",getLineNumberForPosition(e,o));-1!==t.unpairedTags.indexOf(l)||r.push({tagName:l,tagStartPos:a}),n=!0}for(o++;o<e.length;o++)if("<"===e[o])if("!"===e[o+1]){o=readCommentAndCDATA(e,++o);continue}else if("?"===e[o+1]){if((o=readPI(e,++o)).err)return o}else break;else if("&"===e[o]){let t=validateAmpersand(e,o);if(-1==t)return getErrorObject("InvalidChar","char '&' is not expected.",getLineNumberForPosition(e,o));o=t}else if(!0===i&&!isWhiteSpace(e[o]))return getErrorObject("InvalidXml","Extra text at the end",getLineNumberForPosition(e,o));"<"===e[o]&&o--}}else{if(isWhiteSpace(e[o]))continue;return getErrorObject("InvalidChar","char '"+e[o]+"' is not expected.",getLineNumberForPosition(e,o))}return n?1==r.length?getErrorObject("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",getLineNumberForPosition(e,r[0].tagStartPos)):!(r.length>0)||getErrorObject("InvalidXml","Invalid '"+JSON.stringify(r.map(e=>e.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):getErrorObject("InvalidXml","Start tag expected.",1)}function isWhiteSpace(e){return" "===e||" "===e||"\n"===e||"\r"===e}function readPI(e,t){let r=t;for(;t<e.length;t++)if("?"==e[t]||" "==e[t]){let n=e.substr(r,t-r);if(t>5&&"xml"===n)return getErrorObject("InvalidXml","XML declaration allowed only at the start of the document.",getLineNumberForPosition(e,t));if("?"!=e[t]||">"!=e[t+1])continue;t++;break}return t}function readCommentAndCDATA(e,t){if(e.length>t+5&&"-"===e[t+1]&&"-"===e[t+2]){for(t+=3;t<e.length;t++)if("-"===e[t]&&"-"===e[t+1]&&">"===e[t+2]){t+=2;break}}else if(e.length>t+8&&"D"===e[t+1]&&"O"===e[t+2]&&"C"===e[t+3]&&"T"===e[t+4]&&"Y"===e[t+5]&&"P"===e[t+6]&&"E"===e[t+7]){let r=1;for(t+=8;t<e.length;t++)if("<"===e[t])r++;else if(">"===e[t]&&0==--r)break}else if(e.length>t+9&&"["===e[t+1]&&"C"===e[t+2]&&"D"===e[t+3]&&"A"===e[t+4]&&"T"===e[t+5]&&"A"===e[t+6]&&"["===e[t+7]){for(t+=8;t<e.length;t++)if("]"===e[t]&&"]"===e[t+1]&&">"===e[t+2]){t+=2;break}}return t}let doubleQuote='"',singleQuote="'";function readAttributeStr(e,t){let r="",n="",i=!1;for(;t<e.length;t++){if(e[t]===doubleQuote||e[t]===singleQuote)""===n?n=e[t]:n!==e[t]||(n="");else if(">"===e[t]&&""===n){i=!0;break}r+=e[t]}return""===n&&{value:r,index:t,tagClosed:i}}let validAttrStrRegxp=RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function validateAttributeString(e,t){let r=getAllMatches(e,validAttrStrRegxp),n={};for(let e=0;e<r.length;e++){if(0===r[e][1].length)return getErrorObject("InvalidAttr","Attribute '"+r[e][2]+"' has no space in starting.",getPositionFromMatch(r[e]));if(void 0!==r[e][3]&&void 0===r[e][4])return getErrorObject("InvalidAttr","Attribute '"+r[e][2]+"' is without value.",getPositionFromMatch(r[e]));if(void 0===r[e][3]&&!t.allowBooleanAttributes)return getErrorObject("InvalidAttr","boolean attribute '"+r[e][2]+"' is not allowed.",getPositionFromMatch(r[e]));let i=r[e][2];if(!validateAttrName(i))return getErrorObject("InvalidAttr","Attribute '"+i+"' is an invalid name.",getPositionFromMatch(r[e]));if(n.hasOwnProperty(i))return getErrorObject("InvalidAttr","Attribute '"+i+"' is repeated.",getPositionFromMatch(r[e]));n[i]=1}return!0}function validateNumberAmpersand(e,t){let r=/\d/;for("x"===e[t]&&(t++,r=/[\da-fA-F]/);t<e.length;t++){if(";"===e[t])return t;if(!e[t].match(r))break}return -1}function validateAmpersand(e,t){if(";"===e[++t])return -1;if("#"===e[t])return validateNumberAmpersand(e,++t);let r=0;for(;t<e.length;t++,r++)if(!e[t].match(/\w/)||!(r<20)){if(";"===e[t])break;return -1}return t}function getErrorObject(e,t,r){return{err:{code:e,msg:t,line:r.line||r,col:r.col}}}function validateAttrName(e){return isName(e)}function validateTagName(e){return isName(e)}function getLineNumberForPosition(e,t){let r=e.substring(0,t).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function getPositionFromMatch(e){return e.startIndex+e[1].length}class XMLParser{constructor(e){this.externalEntities={},this.options=buildOptions(e)}parse(e,t){if("string"==typeof e);else if(e.toString)e=e.toString();else throw Error("XML data is accepted in String or Bytes[] form.");if(t){!0===t&&(t={});let r=validate(e,t);if(!0!==r)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}let r=new OrderedObjParser(this.options);r.addExternalEntities(this.externalEntities);let n=r.parseXml(e);return this.options.preserveOrder||void 0===n?n:prettify(n,this.options)}addEntity(e,t){if(-1!==t.indexOf("&"))throw Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===t)throw Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return XmlNode.getMetaDataSymbol()}}function schema_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function schema_object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){schema_define_property(e,t,r[t])})}return e}function schema_ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):schema_ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}let iqiyiIdSchema=schemas_object({entityId:schemas_string()}),iqiyiEpisodeTabDataVideoSchema=schemas_object({page_url:schemas_string(),short_display_name:schemas_string().optional(),title:schemas_string(),mark_type_show:schemas_int().optional()}).transform(e=>{var t,r;let n=null!=(r=null==(t=e.page_url.match(/v_(\S+)\.html/))?void 0:t[1])?r:"";return _object_spread_props(schema_object_spread({},e),{videoId:n})}),safeParseVideo=e=>{let t=iqiyiEpisodeTabDataVideoSchema.safeParse(e);return t.success?t.data:null},iqiyiTvTabSchema=schemas_object({bk_id:literal("selector_bk"),bk_type:literal("album_episodes"),data:schemas_object({data:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({videos:schemas_object({feature_paged:record(any(),schemas_array(unknown()))})}).safeParse(e).data)?t:null})).transform(e=>{let t=[];for(let i of e){var r,n;if(i)for(let e of Object.values(null!=(n=null==(r=i.videos)?void 0:r.feature_paged)?n:{}))for(let r of e){let e=safeParseVideo(r);e&&t.push(e)}}return t})})}),iqiyiVarietyShowTabSchema=schemas_object({bk_id:literal("source_selector_bk"),bk_type:literal("video_list"),data:schemas_object({data:schemas_array(unknown().transform(e=>{let t=schemas_object({videos:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({data:schemas_array(unknown())}).safeParse(e).data)?t:null}))}).safeParse(e);if(!t.success)return[];let r=[];for(let e of t.data.videos)if(e)for(let t of e.data){let e=safeParseVideo(t);e&&r.push(e)}return r})).transform(e=>e.flat())})}),iqiyiMovieTabSchema=schemas_object({bk_id:literal("film_feature_bk"),bk_type:literal("video_list"),data:schemas_object({data:schemas_object({videos:schemas_array(unknown())}).transform(e=>compact(e.videos.map(safeParseVideo)))})}),iqiyiEpisodeTabSchema=union([iqiyiTvTabSchema,iqiyiMovieTabSchema,iqiyiVarietyShowTabSchema]).transform(e=>e.data.data),iqiyiV3ApiResponseSchema=schemas_object({status_code:schemas_number(),data:schemas_object({template:schemas_object({tabs:schemas_array(schemas_object({tab_id:schemas_string(),tab_title:schemas_string(),blocks:schemas_array(unknown())}))})}).optional()}).transform(e=>{var t,r;let n=[];for(let i of null!=(r=null==(t=e.data)?void 0:t.template.tabs)?r:[])for(let e of i.blocks){let{success:t,data:r}=iqiyiEpisodeTabSchema.safeParse(e);t&&(n=n.concat(r))}return n}),iqiyiVideoBaseInfoResponseSchema=schemas_object({data:schemas_object({tvId:schemas_int(),albumId:schemas_int(),durationSec:schemas_int()})}),iqiyiCommentsEntrySchema=schemas_object({int:schemas_number(),list:schemas_object({bulletInfo:schemas_array(unknown().transform(e=>schemas_object({contentId:schemas_string(),content:schemas_string(),showTime:schemas_number(),color:schemas_string().optional().default(DEFAULT_COLOR_HEX).transform(e=>parseInt(e,16))}).transform(e=>providerCommentItemSchema.safeParse({id:e.contentId.toString(),timestamp:e.showTime,color:e.color,content:e.content}).data).safeParse(e).data)).transform(e=>compact(e))})}),iqiyiCommentsResponseSchema=schemas_object({danmu:looseObject({data:schemas_object({entry:schemas_array(unknown().transform(e=>{var t;return null==(t=iqiyiCommentsEntrySchema.safeParse(e).data)?void 0:t.list.bulletInfo})).transform(e=>compact(e.flat()))})})}).transform(e=>e.danmu.data.entry);function iqiyi_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function iqiyi_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){iqiyi_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){iqiyi_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function iqiyi_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class IqiyiScraper extends BaseScraper{getEpisodes(e,t){return iqiyi_async_to_generator(function*(){let r=this.parseIdString(e);if(!r)return[];let n=[];try{n=yield this.getEpisodesV3(r.entityId)}catch(e){this.logger.warn("新版API (v3) 获取分集时发生错误:",e),n=[]}return t?n.filter(e=>e.episodeNumber===t):n}).call(this)}getSegments(e){return iqiyi_async_to_generator(function*(){let t=this.parseIdString(e);if(!t)return[];let r=yield this.getVideoBaseInfo(t.entityId),n=null==r?void 0:r.durationSec;return n?Array.from({length:Math.floor(n/300)+1},(e,t)=>({provider:this.providerName,startTime:300*t,segmentId:(t+1).toString()})):[]}).call(this)}getComments(e,t){return iqiyi_async_to_generator(function*(){let r=this.parseIdString(e);if(!r)return[];let n=r.entityId;if(!n||n.length<4)return[];let i=n.slice(-4,-2),o=n.slice(-2),a=`http://cmts.iqiyi.com/bullet/${i}/${o}/${n}_300_${t}.z`;this.logger.debug("URL构建: s1=",i,"s2=",o,"完整URL=",a);let s=yield this.fetch.get(a,{zlibMode:!0}),l=this.xmlParser.parse(s.data),{success:u,data:c,error:d}=iqiyiCommentsResponseSchema.safeParse(l);return u?c:(this.logger.warn("解析弹幕数据时发生错误:",prettifyError(d)),[])}).call(this)}getEpisodesV3(e){return iqiyi_async_to_generator(function*(){let t={entity_id:e,device_id:"qd5fwuaj4hunxxdgzwkcqmefeb3ww5hx",auth_cookie:"",user_id:"0",vip_type:"-1",vip_status:"0",conduit_id:"",pcv:"13.082.22866",app_version:"13.082.22866",ext:"",app_mode:"standard",scale:"100",timestamp:Date.now().toString(),src:"pca_tvg",os:"",ad_ext:'{"r":"2.2.0-ares6-pure"}'};t.sign=this.createSign(t);try{let e=yield this.fetch.get("https://www.iqiyi.com/prelw/tvg/v2/lw/base_info",{params:t,schema:iqiyiV3ApiResponseSchema});if(!e.data)return[];let n=[],i=1;for(let t of e.data){var r;if(17===t.mark_type_show)continue;let e=this.videoIdToEntityId(t.videoId);e&&(this.episodeBlacklistPattern.test(t.title)||(n.push({provider:this.providerName,episodeId:this.generateIdString({entityId:e}),episodeTitle:t.title,episodeNumber:t.short_display_name&&null!=(r=this.getEpisodeIndexFromTitle(t.short_display_name))?r:i}),i+=1))}return n}catch(e){return this.logger.error("获取分集时发生错误:",e),[]}}).call(this)}videoIdToEntityId(e){try{let t,r=parseInt(e,36),n=BigInt(r)^BigInt(0x75706971676c);return(t=n<BigInt(9e5)?BigInt(100)*(n+BigInt(9e5)):n).toString()}catch(t){return this.logger.error("将 video_id '",e,"' 转换为 entity_id 时出错:",t),null}}createSign(e){let t=Object.keys(e).filter(e=>"sign"!==e).sort().map(t=>{var r;return`${t}=${null!=(r=e[t])?r:""}`}).join("&");return md5_default()(`${t}&secret_key=howcuteitis`).toString().toUpperCase()}getVideoBaseInfo(e){return iqiyi_async_to_generator(function*(){var t;return null==(t=(yield this.fetch.get(`https://pcw-api.iqiyi.com/video/video/baseinfo/${e}`,{schema:iqiyiVideoBaseInfoResponseSchema,cache:{cacheKey:`iqiyi:video:baseinfo:${e}`}})).data)?void 0:t.data}).call(this)}constructor(){super(),iqiyi_define_property(this,"providerName","iqiyi"),iqiyi_define_property(this,"xmlParser",new XMLParser({htmlEntities:!0})),iqiyi_define_property(this,"idSchema",iqiyiIdSchema),iqiyi_define_property(this,"PROVIDER_SPECIFIC_BLACKLIST","^(.*?)(抢先(版|篇)?|加更(版|篇)?|花絮|预告|特辑|彩蛋|专访|幕后(故事|花絮)?|直播|纯享|未播|衍生|番外|会员(专属|加长)?|片花|精华|看点|速览|解读|reaction|影评)(.*?)$"),this.fetch.setCookie({pgv_pvid:"40b67e3b06027f3d",video_platform:"2",vversion_name:"8.2.95",video_bucketid:"4",video_omgid:"0a1ff6bc9407c0b1cff86ee5d359614d"}),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Mobile Safari/537.36 Edg/136.0.0.0"})}}let formatDistanceLocale={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},formatDistance=(e,t,r)=>{let n,i=formatDistanceLocale[e];if(n="string"==typeof i?i:1===t?i.one:i.other.replace("{{count}}",t.toString()),r?.addSuffix)if(r.comparison&&r.comparison>0)return"in "+n;else return n+" ago";return n};function buildFormatLongFn(e){return (t={})=>{let r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}let dateFormats={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},timeFormats={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},dateTimeFormats={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},formatLong_formatLong={date:buildFormatLongFn({formats:dateFormats,defaultWidth:"full"}),time:buildFormatLongFn({formats:timeFormats,defaultWidth:"full"}),dateTime:buildFormatLongFn({formats:dateTimeFormats,defaultWidth:"full"})},formatRelativeLocale={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},formatRelative=(e,t,r,n)=>formatRelativeLocale[e];function buildLocalizeFn(e){return(t,r)=>{let n;if("formatting"===(r?.context?String(r.context):"standalone")&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,i=r?.width?String(r.width):t;n=e.formattingValues[i]||e.formattingValues[t]}else{let t=e.defaultWidth,i=r?.width?String(r.width):e.defaultWidth;n=e.values[i]||e.values[t]}return n[e.argumentCallback?e.argumentCallback(t):t]}}let eraValues={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},quarterValues={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},monthValues={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},dayValues={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},dayPeriodValues={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},formattingDayPeriodValues={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ordinalNumber=(e,t)=>{let r=Number(e),n=r%100;if(n>20||n<10)switch(n%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},localize_localize={ordinalNumber,era:buildLocalizeFn({values:eraValues,defaultWidth:"wide"}),quarter:buildLocalizeFn({values:quarterValues,defaultWidth:"wide",argumentCallback:e=>e-1}),month:buildLocalizeFn({values:monthValues,defaultWidth:"wide"}),day:buildLocalizeFn({values:dayValues,defaultWidth:"wide"}),dayPeriod:buildLocalizeFn({values:dayPeriodValues,defaultWidth:"wide",formattingValues:formattingDayPeriodValues,defaultFormattingWidth:"wide"})};function buildMatchFn(e){return(t,r={})=>{let n,i=r.width,o=i&&e.matchPatterns[i]||e.matchPatterns[e.defaultMatchWidth],a=t.match(o);if(!a)return null;let s=a[0],l=i&&e.parsePatterns[i]||e.parsePatterns[e.defaultParseWidth],u=Array.isArray(l)?findIndex(l,e=>e.test(s)):findKey(l,e=>e.test(s));return n=e.valueCallback?e.valueCallback(u):u,{value:n=r.valueCallback?r.valueCallback(n):n,rest:t.slice(s.length)}}}function findKey(e,t){for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function findIndex(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return r}function buildMatchPatternFn(e){return(t,r={})=>{let n=t.match(e.matchPattern);if(!n)return null;let i=n[0],o=t.match(e.parsePattern);if(!o)return null;let a=e.valueCallback?e.valueCallback(o[0]):o[0];return{value:a=r.valueCallback?r.valueCallback(a):a,rest:t.slice(i.length)}}}let matchOrdinalNumberPattern=/^(\d+)(th|st|nd|rd)?/i,parseOrdinalNumberPattern=/\d+/i,matchEraPatterns={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},parseEraPatterns={any:[/^b/i,/^(a|c)/i]},matchQuarterPatterns={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},parseQuarterPatterns={any:[/1/i,/2/i,/3/i,/4/i]},matchMonthPatterns={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},parseMonthPatterns={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},matchDayPatterns={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},parseDayPatterns={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},matchDayPeriodPatterns={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},parseDayPeriodPatterns={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},match_match={ordinalNumber:buildMatchPatternFn({matchPattern:matchOrdinalNumberPattern,parsePattern:parseOrdinalNumberPattern,valueCallback:e=>parseInt(e,10)}),era:buildMatchFn({matchPatterns:matchEraPatterns,defaultMatchWidth:"wide",parsePatterns:parseEraPatterns,defaultParseWidth:"any"}),quarter:buildMatchFn({matchPatterns:matchQuarterPatterns,defaultMatchWidth:"wide",parsePatterns:parseQuarterPatterns,defaultParseWidth:"any",valueCallback:e=>e+1}),month:buildMatchFn({matchPatterns:matchMonthPatterns,defaultMatchWidth:"wide",parsePatterns:parseMonthPatterns,defaultParseWidth:"any"}),day:buildMatchFn({matchPatterns:matchDayPatterns,defaultMatchWidth:"wide",parsePatterns:parseDayPatterns,defaultParseWidth:"any"}),dayPeriod:buildMatchFn({matchPatterns:matchDayPeriodPatterns,defaultMatchWidth:"any",parsePatterns:parseDayPeriodPatterns,defaultParseWidth:"any"})},enUS={code:"en-US",formatDistance:formatDistance,formatLong:formatLong_formatLong,formatRelative:formatRelative,localize:localize_localize,match:match_match,options:{weekStartsOn:0,firstWeekContainsDate:1}},defaultOptions_defaultOptions={};function getDefaultOptions(){return defaultOptions_defaultOptions}let millisecondsInWeek=6048e5,millisecondsInDay=864e5,constructFromSymbol=Symbol.for("constructDateFrom");function constructFrom(e,t){return"function"==typeof e?e(t):e&&"object"==typeof e&&constructFromSymbol in e?e[constructFromSymbol](t):e instanceof Date?new e.constructor(t):new Date(t)}function toDate(e,t){return constructFrom(t||e,e)}function getTimezoneOffsetInMilliseconds(e){let t=toDate(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),e-r}function normalizeDates(e,...t){let r=constructFrom.bind(null,e||t.find(e=>"object"==typeof e));return t.map(r)}function startOfDay(e,t){let r=toDate(e,t?.in);return r.setHours(0,0,0,0),r}function differenceInCalendarDays(e,t,r){let[n,i]=normalizeDates(r?.in,e,t),o=startOfDay(n),a=startOfDay(i);return Math.round((o-getTimezoneOffsetInMilliseconds(o)-(a-getTimezoneOffsetInMilliseconds(a)))/millisecondsInDay)}function startOfYear(e,t){let r=toDate(e,t?.in);return r.setFullYear(r.getFullYear(),0,1),r.setHours(0,0,0,0),r}function getDayOfYear(e,t){let r=toDate(e,t?.in);return differenceInCalendarDays(r,startOfYear(r))+1}function startOfWeek(e,t){let r=getDefaultOptions(),n=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,i=toDate(e,t?.in),o=i.getDay(),a=7*(o<n)+o-n;return i.setDate(i.getDate()-a),i.setHours(0,0,0,0),i}function startOfISOWeek(e,t){return startOfWeek(e,{...t,weekStartsOn:1})}function getISOWeekYear(e,t){let r=toDate(e,t?.in),n=r.getFullYear(),i=constructFrom(r,0);i.setFullYear(n+1,0,4),i.setHours(0,0,0,0);let o=startOfISOWeek(i),a=constructFrom(r,0);a.setFullYear(n,0,4),a.setHours(0,0,0,0);let s=startOfISOWeek(a);return r.getTime()>=o.getTime()?n+1:r.getTime()>=s.getTime()?n:n-1}function startOfISOWeekYear(e,t){let r=getISOWeekYear(e,t),n=constructFrom(t?.in||e,0);return n.setFullYear(r,0,4),n.setHours(0,0,0,0),startOfISOWeek(n)}function getISOWeek(e,t){let r=toDate(e,t?.in);return Math.round((startOfISOWeek(r)-startOfISOWeekYear(r))/millisecondsInWeek)+1}function getWeekYear(e,t){let r=toDate(e,t?.in),n=r.getFullYear(),i=getDefaultOptions(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,a=constructFrom(t?.in||e,0);a.setFullYear(n+1,0,o),a.setHours(0,0,0,0);let s=startOfWeek(a,t),l=constructFrom(t?.in||e,0);l.setFullYear(n,0,o),l.setHours(0,0,0,0);let u=startOfWeek(l,t);return+r>=+s?n+1:+r>=+u?n:n-1}function startOfWeekYear(e,t){let r=getDefaultOptions(),n=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,i=getWeekYear(e,t),o=constructFrom(t?.in||e,0);return o.setFullYear(i,0,n),o.setHours(0,0,0,0),startOfWeek(o,t)}function getWeek(e,t){let r=toDate(e,t?.in);return Math.round((startOfWeek(r,t)-startOfWeekYear(r,t))/millisecondsInWeek)+1}function addLeadingZeros(e,t){return(e<0?"-":"")+Math.abs(e).toString().padStart(t,"0")}let lightFormatters={y(e,t){let r=e.getFullYear(),n=r>0?r:1-r;return addLeadingZeros("yy"===t?n%100:n,t.length)},M(e,t){let r=e.getMonth();return"M"===t?String(r+1):addLeadingZeros(r+1,2)},d:(e,t)=>addLeadingZeros(e.getDate(),t.length),a(e,t){let r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];default:return"am"===r?"a.m.":"p.m."}},h:(e,t)=>addLeadingZeros(e.getHours()%12||12,t.length),H:(e,t)=>addLeadingZeros(e.getHours(),t.length),m:(e,t)=>addLeadingZeros(e.getMinutes(),t.length),s:(e,t)=>addLeadingZeros(e.getSeconds(),t.length),S(e,t){let r=t.length;return addLeadingZeros(Math.trunc(e.getMilliseconds()*Math.pow(10,r-3)),t.length)}},dayPeriodEnum={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},formatters={G:function(e,t,r){let n=+(e.getFullYear()>0);switch(t){case"G":case"GG":case"GGG":return r.era(n,{width:"abbreviated"});case"GGGGG":return r.era(n,{width:"narrow"});default:return r.era(n,{width:"wide"})}},y:function(e,t,r){if("yo"===t){let t=e.getFullYear(),n=t>0?t:1-t;return r.ordinalNumber(n,{unit:"year"})}return lightFormatters.y(e,t)},Y:function(e,t,r,n){let i=getWeekYear(e,n),o=i>0?i:1-i;return"YY"===t?addLeadingZeros(o%100,2):"Yo"===t?r.ordinalNumber(o,{unit:"year"}):addLeadingZeros(o,t.length)},R:function(e,t){return addLeadingZeros(getISOWeekYear(e),t.length)},u:function(e,t){return addLeadingZeros(e.getFullYear(),t.length)},Q:function(e,t,r){let n=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(n);case"QQ":return addLeadingZeros(n,2);case"Qo":return r.ordinalNumber(n,{unit:"quarter"});case"QQQ":return r.quarter(n,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(n,{width:"narrow",context:"formatting"});default:return r.quarter(n,{width:"wide",context:"formatting"})}},q:function(e,t,r){let n=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(n);case"qq":return addLeadingZeros(n,2);case"qo":return r.ordinalNumber(n,{unit:"quarter"});case"qqq":return r.quarter(n,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(n,{width:"narrow",context:"standalone"});default:return r.quarter(n,{width:"wide",context:"standalone"})}},M:function(e,t,r){let n=e.getMonth();switch(t){case"M":case"MM":return lightFormatters.M(e,t);case"Mo":return r.ordinalNumber(n+1,{unit:"month"});case"MMM":return r.month(n,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(n,{width:"narrow",context:"formatting"});default:return r.month(n,{width:"wide",context:"formatting"})}},L:function(e,t,r){let n=e.getMonth();switch(t){case"L":return String(n+1);case"LL":return addLeadingZeros(n+1,2);case"Lo":return r.ordinalNumber(n+1,{unit:"month"});case"LLL":return r.month(n,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(n,{width:"narrow",context:"standalone"});default:return r.month(n,{width:"wide",context:"standalone"})}},w:function(e,t,r,n){let i=getWeek(e,n);return"wo"===t?r.ordinalNumber(i,{unit:"week"}):addLeadingZeros(i,t.length)},I:function(e,t,r){let n=getISOWeek(e);return"Io"===t?r.ordinalNumber(n,{unit:"week"}):addLeadingZeros(n,t.length)},d:function(e,t,r){return"do"===t?r.ordinalNumber(e.getDate(),{unit:"date"}):lightFormatters.d(e,t)},D:function(e,t,r){let n=getDayOfYear(e);return"Do"===t?r.ordinalNumber(n,{unit:"dayOfYear"}):addLeadingZeros(n,t.length)},E:function(e,t,r){let n=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(n,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(n,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(n,{width:"short",context:"formatting"});default:return r.day(n,{width:"wide",context:"formatting"})}},e:function(e,t,r,n){let i=e.getDay(),o=(i-n.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return addLeadingZeros(o,2);case"eo":return r.ordinalNumber(o,{unit:"day"});case"eee":return r.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(i,{width:"short",context:"formatting"});default:return r.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,r,n){let i=e.getDay(),o=(i-n.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return addLeadingZeros(o,t.length);case"co":return r.ordinalNumber(o,{unit:"day"});case"ccc":return r.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(i,{width:"narrow",context:"standalone"});case"cccccc":return r.day(i,{width:"short",context:"standalone"});default:return r.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,r){let n=e.getDay(),i=0===n?7:n;switch(t){case"i":return String(i);case"ii":return addLeadingZeros(i,t.length);case"io":return r.ordinalNumber(i,{unit:"day"});case"iii":return r.day(n,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(n,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(n,{width:"short",context:"formatting"});default:return r.day(n,{width:"wide",context:"formatting"})}},a:function(e,t,r){let n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(n,{width:"narrow",context:"formatting"});default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},b:function(e,t,r){let n,i=e.getHours();switch(n=12===i?dayPeriodEnum.noon:0===i?dayPeriodEnum.midnight:i/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(n,{width:"narrow",context:"formatting"});default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},B:function(e,t,r){let n,i=e.getHours();switch(n=i>=17?dayPeriodEnum.evening:i>=12?dayPeriodEnum.afternoon:i>=4?dayPeriodEnum.morning:dayPeriodEnum.night,t){case"B":case"BB":case"BBB":return r.dayPeriod(n,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(n,{width:"narrow",context:"formatting"});default:return r.dayPeriod(n,{width:"wide",context:"formatting"})}},h:function(e,t,r){if("ho"===t){let t=e.getHours()%12;return 0===t&&(t=12),r.ordinalNumber(t,{unit:"hour"})}return lightFormatters.h(e,t)},H:function(e,t,r){return"Ho"===t?r.ordinalNumber(e.getHours(),{unit:"hour"}):lightFormatters.H(e,t)},K:function(e,t,r){let n=e.getHours()%12;return"Ko"===t?r.ordinalNumber(n,{unit:"hour"}):addLeadingZeros(n,t.length)},k:function(e,t,r){let n=e.getHours();return(0===n&&(n=24),"ko"===t)?r.ordinalNumber(n,{unit:"hour"}):addLeadingZeros(n,t.length)},m:function(e,t,r){return"mo"===t?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):lightFormatters.m(e,t)},s:function(e,t,r){return"so"===t?r.ordinalNumber(e.getSeconds(),{unit:"second"}):lightFormatters.s(e,t)},S:function(e,t){return lightFormatters.S(e,t)},X:function(e,t,r){let n=e.getTimezoneOffset();if(0===n)return"Z";switch(t){case"X":return formatTimezoneWithOptionalMinutes(n);case"XXXX":case"XX":return formatTimezone(n);default:return formatTimezone(n,":")}},x:function(e,t,r){let n=e.getTimezoneOffset();switch(t){case"x":return formatTimezoneWithOptionalMinutes(n);case"xxxx":case"xx":return formatTimezone(n);default:return formatTimezone(n,":")}},O:function(e,t,r){let n=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+formatTimezoneShort(n,":");default:return"GMT"+formatTimezone(n,":")}},z:function(e,t,r){let n=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+formatTimezoneShort(n,":");default:return"GMT"+formatTimezone(n,":")}},t:function(e,t,r){return addLeadingZeros(Math.trunc(e/1e3),t.length)},T:function(e,t,r){return addLeadingZeros(+e,t.length)}};function formatTimezoneShort(e,t=""){let r=e>0?"-":"+",n=Math.abs(e),i=Math.trunc(n/60),o=n%60;return 0===o?r+String(i):r+String(i)+t+addLeadingZeros(o,2)}function formatTimezoneWithOptionalMinutes(e,t){return e%60==0?(e>0?"-":"+")+addLeadingZeros(Math.abs(e)/60,2):formatTimezone(e,t)}function formatTimezone(e,t=""){let r=e>0?"-":"+",n=Math.abs(e);return r+addLeadingZeros(Math.trunc(n/60),2)+t+addLeadingZeros(n%60,2)}let dateLongFormatter=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},timeLongFormatter=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},dateTimeLongFormatter=(e,t)=>{let r,n=e.match(/(P+)(p+)?/)||[],i=n[1],o=n[2];if(!o)return dateLongFormatter(e,t);switch(i){case"P":r=t.dateTime({width:"short"});break;case"PP":r=t.dateTime({width:"medium"});break;case"PPP":r=t.dateTime({width:"long"});break;default:r=t.dateTime({width:"full"})}return r.replace("{{date}}",dateLongFormatter(i,t)).replace("{{time}}",timeLongFormatter(o,t))},longFormatters={p:timeLongFormatter,P:dateTimeLongFormatter},dayOfYearTokenRE=/^D+$/,weekYearTokenRE=/^Y+$/,throwTokens=["D","DD","YY","YYYY"];function isProtectedDayOfYearToken(e){return dayOfYearTokenRE.test(e)}function isProtectedWeekYearToken(e){return weekYearTokenRE.test(e)}function warnOrThrowProtectedError(e,t,r){let n=protectedTokens_message(e,t,r);if(console.warn(n),throwTokens.includes(e))throw RangeError(n)}function protectedTokens_message(e,t,r){let n="Y"===e[0]?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${n} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}function isDate_isDate(e){return e instanceof Date||"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)}function isValid_isValid(e){return!(!isDate_isDate(e)&&"number"!=typeof e||isNaN(+toDate(e)))}let formattingTokensRegExp=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,longFormattingTokensRegExp=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,escapedStringRegExp=/^'([^]*?)'?$/,doubleQuoteRegExp=/''/g,unescapedLatinCharacterRegExp=/[a-zA-Z]/;function format_format(e,t,r){let n=getDefaultOptions(),i=r?.locale??n.locale??enUS,o=r?.firstWeekContainsDate??r?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=r?.weekStartsOn??r?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,s=toDate(e,r?.in);if(!isValid_isValid(s))throw RangeError("Invalid time value");let l=t.match(longFormattingTokensRegExp).map(e=>{let t=e[0];return"p"===t||"P"===t?(0,longFormatters[t])(e,i.formatLong):e}).join("").match(formattingTokensRegExp).map(e=>{if("''"===e)return{isToken:!1,value:"'"};let t=e[0];if("'"===t)return{isToken:!1,value:cleanEscapedString(e)};if(formatters[t])return{isToken:!0,value:e};if(t.match(unescapedLatinCharacterRegExp))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(l=i.localize.preprocessor(s,l));let u={firstWeekContainsDate:o,weekStartsOn:a,locale:i};return l.map(n=>{if(!n.isToken)return n.value;let o=n.value;return(!r?.useAdditionalWeekYearTokens&&isProtectedWeekYearToken(o)||!r?.useAdditionalDayOfYearTokens&&isProtectedDayOfYearToken(o))&&warnOrThrowProtectedError(o,t,String(e)),(0,formatters[o[0]])(s,o,i.localize,u)}).join("")}function cleanEscapedString(e){let t=e.match(escapedStringRegExp);return t?t[1].replace(doubleQuoteRegExp,"'"):e}function uniqBy(e,t){let r=new Map;for(let n=0;n<e.length;n++){let i=e[n],o=t(i);r.has(o)||r.set(o,i)}return Array.from(r.values())}function identity(e){return e}function range(e,t,r=1){if(null==t&&(t=e,e=0),!Number.isInteger(r)||0===r)throw Error("The step value must be a non-zero integer.");let n=Math.max(Math.ceil((t-e)/r),0),i=Array(n);for(let t=0;t<n;t++)i[t]=e+t*r;return i}function isLength(e){return Number.isSafeInteger(e)&&e>=0}function isArrayLike(e){return null!=e&&"function"!=typeof e&&isLength(e.length)}function reduceRight(e,t=identity,r){let n,i;if(!e)return r;isArrayLike(e)?(n=range(0,e.length).reverse(),null==r&&e.length>0?(r=e[e.length-1],i=1):i=0):(n=Object.keys(e).reverse(),null==r?(r=e[n[0]],i=1):i=0);for(let o=i;o<n.length;o++){let i=n[o];r=t(r,e[i],i,e)}return r}function mgtv_schema_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function mgtv_schema_object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){mgtv_schema_define_property(e,t,r[t])})}return e}function mgtv_schema_ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function schema_object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):mgtv_schema_ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}let mgtvIdSchema=schemas_object({dramaId:schemas_string(),videoId:schemas_string().optional()}),mgtvSearchResponseSchema=schemas_object({data:schemas_object({contents:schemas_array(unknown().transform(e=>{var t,r;return null!=(r=null==(t=schemas_object({type:literal("media"),data:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({source:literal("imgo"),title:schemas_string().transform(e=>e.replace(/<[^>]*>?/g,"").trim()),url:schemas_string(),desc:schemas_array(schemas_string())}).transform(e=>{let[,,t,r]=e.url.split("/"),n=r.split(".").shift();return schema_object_spread_props(mgtv_schema_object_spread({},e),{dramaId:t,videoId:n,get mediaType(){var i,o;return"电影"===(null==(o=e.desc)||null==(i=o[0].split("/"))?void 0:i[0].replace("类型:","").trim())?constants_MediaType.Movie:constants_MediaType.TV}})}).safeParse(e).data)?t:null})).transform(e=>compact(e))}).safeParse(e).data)?void 0:t.data)?r:null})).transform(e=>compact(e))})}).transform(e=>compact(e.data.contents.flat())),episodeBlacklistPattern=getEpisodeBlacklistPattern("^(.*?)(抢先(看|版)|加更(版)?|花絮|预告|特辑|(特别|惊喜|纳凉)?企划|彩蛋|专访|幕后(花絮)?|直播|纯享|未播|衍生|番外|合伙人手记|会员(专享|加长)|片花|精华|看点|速看|解读|reaction|超前营业|超前(vlog)?|陪看(记)?|.{3,}篇|影评)(.*?)$"),mgtvEpisodeInfoResponseSchema=schemas_object({data:schemas_object({tab_m:schemas_array(schemas_object({m:schemas_string()})).catch([]),list:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({isIntact:schemas_string(),isnew:schemas_string(),video_id:schemas_string(),t1:schemas_string().refine(e=>!episodeBlacklistPattern.test(e)),t2:schemas_string().refine(e=>!episodeBlacklistPattern.test(e)),t3:schemas_string(),time:schemas_string().transform(e=>reduceRight(e.split(":"),(e,t,r)=>0===r?e+parseInt(t):1===r?e+60*parseInt(t):e+3600*parseInt(t),0))}).safeParse(e).data)?t:null})).transform(e=>compact(e))})}),mgtvCommentConfigResponseSchema=schemas_object({status:literal(0),data:schemas_object({cdn_list:schemas_string().transform(e=>e.split(",")).catch(["bullet-ali.hitv.com"]),cdn_version:schemas_string()})}).transform(e=>e.data),commentColorSchema=schemas_object({r:schemas_number().min(0).max(255),g:schemas_number().min(0).max(255),b:schemas_number().min(0).max(255)}).transform(e=>256*e.r*256+256*e.g+e.b).catch(-1),mgtvCommentResponseSchema=schemas_object({data:schemas_object({items:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({ids:schemas_string(),content:schemas_string(),time:schemas_number().transform(e=>e/1e3),v2_color:schemas_object({color_left:commentColorSchema,color_right:commentColorSchema}).optional().transform(e=>e&&(-1!==e.color_left||-1!==e.color_right)?-1===e.color_left?e.color_right:-1===e.color_right?e.color_left:(e.color_left+e.color_right)/2:DEFAULT_COLOR_INT),v2_position:schemas_int().optional().transform(e=>{switch(e){case 1:return 5;case 2:return 4;default:return 1}})}).safeParse(e).data)?t:null}).transform(e=>{var t;return e&&null!=(t=providerCommentItemSchema.safeParse({id:e.ids,timestamp:e.time,mode:e.v2_position,color:e.v2_color,content:e.content}).data)?t:null})).transform(e=>compact(e))})}).transform(e=>e.data.items);function mgtv_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function mgtv_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){mgtv_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){mgtv_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function mgtv_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class MgTVScraper extends BaseScraper{search(e){return mgtv_async_to_generator(function*(){var t;let{success:r,data:n,error:i}=searchDanmuParamsSchema.safeParse(e);if(!r)return this.logger.error("搜索参数无效,错误:",prettifyError(i)),[];let{seriesName:o,season:a,airDate:s}=n;if(!o)return[];let l=yield this.fetch.get("https://mobileso.bz.mgtv.com/msite/search/v2",{params:{q:o,pc:30,pn:1,sort:-99,ty:0,du:0,pt:0,corr:1,abroad:0,_support:"10000000000000000"},schema:mgtvSearchResponseSchema});if(!(null==(t=l.data)?void 0:t.length))return this.logger.warn("搜索结果为空"),[];let u=[];for(let e of l.data){if(e.mediaType===constants_MediaType.Movie){u.push({provider:this.providerName,dramaId:e.dramaId,dramaTitle:e.title,season:1});continue}let t=yield this.getEpisodeInfo(e.dramaId,s);for(let r of null!=t?t:[])u.push({provider:this.providerName,dramaId:e.dramaId,dramaTitle:r.t3,season:null!=a?a:1})}return u}).call(this)}getEpisodes(e,t){return mgtv_async_to_generator(function*(){let r=this.parseIdString(e);if(!r)return[];let n=yield this.getEpisodeInfo(r.dramaId);if(!(null==n?void 0:n.length))return[];let i=n.map((e,t)=>{var n;return{provider:this.providerName,episodeId:this.generateIdString({dramaId:r.dramaId,videoId:e.video_id}),episodeTitle:e.t3,episodeNumber:null!=(n=this.getEpisodeIndexFromTitle(e.t2))?n:t+1}});return t?i.filter(e=>e.episodeNumber===t):i}).call(this)}getSegments(e){return mgtv_async_to_generator(function*(){let t=this.parseIdString(e);if(!t)return[];let r=yield this.getEpisodeInfo(t.dramaId);if(!(null==r?void 0:r.length))return this.logger.warn("没有找到对应的剧集",t.dramaId),[];let n=r.find(e=>e.video_id===t.videoId);return n?Array.from({length:Math.ceil(n.time/60)},(e,t)=>({provider:this.providerName,startTime:60*t,segmentId:t.toString()})):(this.logger.warn("没有找到对应的集数",t.dramaId,t.videoId),[])}).call(this)}getComments(e,t){return mgtv_async_to_generator(function*(){var r,n,i;let o=this.parseIdString(e);if(!o)return[];let a=yield this.fetch.get("https://galaxy.bz.mgtv.com/getctlbarrage",{params:{version:"8.1.39",abroad:0,uuid:"",os:"10.15.7",platform:0,mac:"",cid:o.dramaId,vid:o.videoId,pid:"",ticket:""},schema:mgtvCommentConfigResponseSchema,cache:{cacheKey:`mgtv:comment_config:${o.dramaId}_${o.videoId}`,ttl:TTL_1_DAY}});return a.data&&null!=(i=(yield this.fetch.get(`https://${null==(r=a.data)?void 0:r.cdn_list[0]}/${null==(n=a.data)?void 0:n.cdn_version}/${t}.json`,{schema:mgtvCommentResponseSchema})).data)?i:[]}).call(this)}getEpisodeInfo(e,t){return mgtv_async_to_generator(function*(){var r,n,i,o,a;let s="";try{t&&(s=format_format(t,"yyyyMM"))}catch(e){this.logger.warn("Failed to format air date",e)}let l=[],u=yield this.getEpisodeInfoByMonth(e,s);if(l.push(...null!=(n=null==u||null==(r=u.data)?void 0:r.list)?n:[]),!s&&(null==u?void 0:u.data.tab_m.length))for(let t of(this.logger.warn("没有指定月份,拉取全部月份"),null!=(i=null==u?void 0:u.data.tab_m)?i:[])){let r=yield this.getEpisodeInfoByMonth(e,t.m);l.push(...null!=(a=null==r||null==(o=r.data)?void 0:o.list)?a:[])}return uniqBy(l,e=>e.video_id)}).call(this)}getEpisodeInfoByMonth(e,t){return mgtv_async_to_generator(function*(){return(yield this.fetch.get("https://pcweb.api.mgtv.com/variety/showlist",{params:{allowedRC:1,collection_id:e,month:t,page:1,_support:"10000000"},schema:mgtvEpisodeInfoResponseSchema,cache:`mgtv_episode_info_${e}_${t}`,successStatus:[200]})).data}).call(this)}constructor(){super(),mgtv_define_property(this,"providerName","mgtv"),mgtv_define_property(this,"idSchema",mgtvIdSchema),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",Referer:"https://www.mgtv.com/","Sec-Fetch-Site":"same-site","Sec-Fetch-Mode":"cors","Sec-Fetch-Dest":"empty"})}}var hmac_sha256=__webpack_require__(939),hmac_sha256_default=__webpack_require__.n(hmac_sha256);function isNil(e){return null==e}var aes=__webpack_require__(129),aes_default=__webpack_require__.n(aes),mode_ecb=__webpack_require__(760),mode_ecb_default=__webpack_require__.n(mode_ecb),pad_pkcs7=__webpack_require__(186),pad_pkcs7_default=__webpack_require__.n(pad_pkcs7);let renrenIdSchema=schemas_object({dramaId:coerce_number(),episodeId:coerce_number().optional()}),AES_KEY="3b744389882a4067",aesResponeSchema=schemas_string().transform(e=>{let t=enc_base64_default().parse(e);return safeJsonParseWithZod(aes_default().decrypt({ciphertext:t},enc_utf8_default().parse(AES_KEY),{mode:mode_ecb_default(),padding:pad_pkcs7_default()}).toString(enc_utf8_default()),schemas_object({data:unknown()}))}),renrenSearchResponseSchema=schemas_object({searchDramaList:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({id:schemas_string(),title:schemas_string(),subtitle:schemas_string().optional(),classify:preprocess(e=>{var t;return null!=(t=({电影:constants_MediaType.Movie,电视剧:constants_MediaType.TV})[e])?t:null},schemas_enum(constants_MediaType).nullish().catch(null)),name:schemas_string().optional(),year:coerce_number().optional()}).safeParse(e).data)?t:null})).transform(e=>compact(e))}),schema_episodeBlacklistPattern=getEpisodeBlacklistPattern(),renrenDramaInfoResponseSchema=schemas_object({dramaInfo:schemas_object({dramaId:coerce_number(),title:schemas_string(),enName:schemas_string().optional(),seasonNo:coerce_number().optional()}).optional(),episodeList:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({id:coerce_number(),episodeNo:coerce_number(),text:schemas_string().optional(),title:schemas_string().refine(e=>!schema_episodeBlacklistPattern.test(e)).optional()}).safeParse(e).data)?t:null})).transform(e=>compact(e))}),renrenCommentItemSchema=schemas_object({d:schemas_string(),p:schemas_string().transform(e=>{let t=e.split(","),r=coerce_number().catch(0).parse(t[0]),n=coerce_number().int().catch(1).parse(t[1]),i=coerce_number().int().catch(DEFAULT_COLOR_INT).parse(t[3]),o=t[6]||"",a=t[7]||`${r.toFixed(3)}:${o}`;return{timestamp:r,mode:n,color:i,userId:o,contentId:a}})}).transform(e=>{var t;return null!=(t=providerCommentItemSchema.safeParse({id:e.p.contentId,timestamp:e.p.timestamp,mode:e.p.mode,color:e.p.color,content:e.d}).data)?t:null});function _async_iterator(e){var t,r,n,i=2;for("undefined"!=typeof Symbol&&(r=Symbol.asyncIterator,n=Symbol.iterator);i--;){if(r&&null!=(t=e[r]))return t.call(e);if(n&&null!=(t=e[n]))return new AsyncFromSyncIterator(t.call(e));r="@@asyncIterator",n="@@iterator"}throw TypeError("Object is not async iterable")}function AsyncFromSyncIterator(e){function t(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var t=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:t}})}return(AsyncFromSyncIterator=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return t(this.n.apply(this.s,arguments))},return:function(e){var r=this.s.return;return void 0===r?Promise.resolve({value:e,done:!0}):t(r.apply(this.s,arguments))},throw:function(e){var r=this.s.return;return void 0===r?Promise.reject(e):t(r.apply(this.s,arguments))}},new AsyncFromSyncIterator(e)}function renren_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function renren_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){renren_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){renren_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function renren_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function renren_object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){renren_define_property(e,t,r[t])})}return e}function renren_ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function renren_object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):renren_ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function renren_object_without_properties(e,t){if(null==e)return{};var r,n,i=renren_object_without_properties_loose(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function renren_object_without_properties_loose(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}let SIGN_SECRET="ES513W0B1CsdUrR13Qk5EgDAKPeeKZY",BASE_API="https://api.rrmj.plus",CLIENT_TYPE="web_pc",CLIENT_VERSION="1.0.0";class RenRenScraper extends BaseScraper{get deviceId(){return generateUUID().toUpperCase()}search(e){return renren_async_to_generator(function*(){let{success:t,data:r,error:n}=searchDanmuParamsSchema.safeParse(e);if(!t)return this.logger.error("搜索参数无效,错误:",prettifyError(n)),[];let{seriesName:i,season:o}=r;if(!i)return[];let a=yield this.request("/m-station/search/drama",{params:{keywords:i,size:Math.max(10,null!=o?o:1),order:"match",search_after:"",isExecuteVipActivity:!0},cache:{cacheKey:`renren:search:${i}`,ttl:TTL_1_DAY},schema:aesResponeSchema.transform(e=>{var t;let r=renrenSearchResponseSchema.safeParse(null==e?void 0:e.data);return r.success?null==(t=r.data)?void 0:t.searchDramaList:(this.logger.warn("搜索解析错误,错误:",prettifyError(r.error),null==e?void 0:e.data),[])})});if(!a.data)return[];this.logger.info("搜索结果:",a.data);let s=[];var l,u=!1,c=!1;try{for(var d,f,p,h,m,g,v,y,b=_async_iterator(a.data);u=!(y=yield b.next()).done;u=!1){let e=y.value,t=e.title.replace(/<[^>]+>/g,"").replace(":",":"),r=yield this.getDramaInfo(e.id);if(!r){this.logger.warn("详细信息未找到,title:",t,"id:",e.id);continue}if(!((null==(f=r.dramaInfo)||null==(d=f.enName)?void 0:d.includes(i))||(null==(h=r.dramaInfo)||null==(p=h.title)?void 0:p.includes(i))||t.includes(i)||(null==(m=e.name)?void 0:m.includes(i)))){this.logger.warn("置信度过低,跳过,title:",t,"id:",e.id);continue}let n=!1,a=null!=(v=null==(g=r.dramaInfo)?void 0:g.seasonNo)?v:1;isNil(o)||a!==o||(n=!0);let l={provider:this.providerName,dramaId:e.id,dramaTitle:t,season:a};if(s.push(l),n){this.logger.info("命中高置信度,忽略其他,title:",t,"id:",e.id),s=[l];break}}}catch(e){c=!0,l=e}finally{try{u&&null!=b.return&&(yield b.return())}finally{if(c)throw l}}return s}).call(this)}getEpisodes(e,t){return renren_async_to_generator(function*(){let r=this.parseIdString(e);if(!r)return[];let n=yield this.getDramaInfo(r.dramaId.toString());if(!n)return[];let i=n.episodeList.map(e=>{var t;return{provider:this.providerName,episodeId:this.generateIdString({dramaId:r.dramaId,episodeId:e.id}),episodeTitle:e.title||`${null==(t=n.dramaInfo)?void 0:t.title} E${e.episodeNo}`,episodeNumber:e.episodeNo}});return isNil(t)?i:i.filter(e=>e.episodeNumber===t)}).call(this)}getSegments(){return renren_async_to_generator(function*(){return[{provider:this.providerName,segmentId:"1",startTime:0}]}).call(this)}getComments(e){return renren_async_to_generator(function*(){let t=this.parseIdString(e);return(null==t?void 0:t.episodeId)?this.fetchEpisodeDanmu(t.episodeId.toString()):[]}).call(this)}getDramaInfo(e){return renren_async_to_generator(function*(){return(yield this.request("/m-station/drama/page",{params:{hsdrOpen:0,isAgeLimit:0,dramaId:e,hevcOpen:1},schema:aesResponeSchema.transform(t=>{let r=renrenDramaInfoResponseSchema.safeParse(null==t?void 0:t.data);return r.success?r.data:(this.logger.warn("详细信息解析错误,dramaId:",e,"错误:",prettifyError(r.error),null==t?void 0:t.data),null)}),cache:{cacheKey:`renren:dramaInfo:${e}`,ttl:TTL_1_DAY}})).data}).call(this)}fetchEpisodeDanmu(e){return renren_async_to_generator(function*(){let t=`https://static-dm.rrmj.plus/v1/produce/danmu/EPISODE/${e}`;return"choice"===this.providerConfig.renren.mode&&(t=`https://static-dm.rrmj.plus/v1/produce/danmu/choice/EPISODE/${e}`),(yield this.fetch.get(t,{headers:{Accept:"application/json"},schema:schemas_array(unknown().transform(e=>{var t;return null!=(t=renrenCommentItemSchema.safeParse(e).data)?t:null})).transform(e=>compact(e))})).data}).call(this)}generateSignature({method:e,aliId:t,timestampMs:r,path:n,sortedQuery:i,secret:o}){let a=[e.toUpperCase(),`aliId:${t}`,`ct:${CLIENT_TYPE}`,`cv:${CLIENT_VERSION}`,`t:${r}`,`${n}?${i}`].join("\n"),s=hmac_sha256_default()(a,o);return enc_base64_default().stringify(s)}generateHeaders({method:e,path:t,params:r}){let n=Object.entries(r).sort((e,t)=>e[0].localeCompare(t[0])).map(([e,t])=>`${e}=${encodeURIComponent(t)}`).join("&"),i=Date.now(),o=this.deviceId,a=this.generateSignature({method:e,aliId:o,timestampMs:i,path:t,sortedQuery:n,secret:SIGN_SECRET});return{clientVersion:CLIENT_VERSION,deviceId:o,clientType:CLIENT_TYPE,t:i.toString(),aliId:o,umid:o,token:"",cv:CLIENT_VERSION,ct:CLIENT_TYPE,uet:"9","x-ca-sign":a,Accept:"application/json"}}request(e,t){let{params:r={}}=t,n=renren_object_without_properties(t,["params"]),i=this.generateHeaders({method:"GET",path:e,params:r});return this.fetch.get(`${BASE_API}${e}`,renren_object_spread_props(renren_object_spread({},n),{headers:i,params:r}))}constructor(){super(),renren_define_property(this,"providerName","renren"),renren_define_property(this,"idSchema",renrenIdSchema),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0",Origin:"https://rrsp.com.cn",Referer:"https://rrsp.com.cn/"})}}let tencentIdSchema=schemas_object({cid:schemas_string(),vid:schemas_string().optional()}),tencent_schema_episodeBlacklistPattern=getEpisodeBlacklistPattern("拍摄花絮|制作花絮|幕后花絮|未播花絮|独家花絮|花絮特辑|预告片|先导预告|终极预告|正式预告|官方预告|彩蛋片段|删减片段|未播片段|番外彩蛋|精彩片段|精彩看点|精彩回顾|精彩集锦|看点解析|看点预告|NG镜头|NG花絮|番外篇|番外特辑|制作特辑|拍摄特辑|幕后特辑|导演特辑|演员特辑|片尾曲|插曲|主题曲|背景音乐|OST|音乐MV|歌曲MV|前季回顾|剧情回顾|往期回顾|内容总结|剧情盘点|精选合集|剪辑合集|混剪视频|独家专访|演员访谈|导演访谈|主创访谈|媒体采访|发布会采访|抢先看|抢先版|试看版|短剧|vlog|纯享|加更|reaction|精编|会员版|Plus|独家版|特别版|短片|合唱"),tencentEpisodeSchema=schemas_object({vid:schemas_string().refine(e=>!!e),is_trailer:schemas_string().refine(e=>"1"!==e),title:schemas_string().refine(e=>!tencent_schema_episodeBlacklistPattern.test(e)),union_title:schemas_string().refine(e=>!tencent_schema_episodeBlacklistPattern.test(e)).optional()}),tencentEpisodeResultSchema=schemas_object({data:schemas_object({module_list_datas:schemas_array(schemas_object({module_datas:schemas_array(schemas_object({item_data_lists:schemas_object({item_datas:schemas_array(schemas_object({item_params:unknown().transform(e=>{var t;return null!=(t=tencentEpisodeSchema.safeParse(e).data)?t:null})}).transform(e=>{var t;return null!=(t=e.item_params)?t:null})).transform(e=>compact(e))})}))}))})}).transform(e=>{var t,r,n,i,o,a;return null!=(a=null==(o=e.data.module_list_datas)||null==(i=o[0])||null==(n=i.module_datas)||null==(r=n[0])||null==(t=r.item_data_lists)?void 0:t.item_datas)?a:[]}),tencentSegmentIndexSchema=schemas_object({segment_index:record(schemas_string(),schemas_object({segment_name:schemas_string()}))}),tencentCommentItemSchema=schemas_object({id:schemas_string(),content:schemas_string(),time_offset:coerce_number().transform(e=>e/1e3),content_style:schemas_string().nullish().transform(e=>safeJsonParseWithZod(null!=e?e:"{}",schemas_object({color:schemas_string().optional().default(DEFAULT_COLOR_HEX),position:schemas_number().optional().default(1),gradient_colors:schemas_array(schemas_string()).optional()}).transform(e=>{var t;let r=1;2===e.position?r=5:3===e.position&&(r=4);let n=e.color?parseInt(e.color,16):DEFAULT_COLOR_INT;return n===DEFAULT_COLOR_INT&&(null==(t=e.gradient_colors)?void 0:t.length)&&(n=e.gradient_colors.reduce((e,t)=>e+parseInt(t,16),0)/e.gradient_colors.length),{mode:r,color:n}})))}).transform(e=>{var t,r,n;return null!=(n=providerCommentItemSchema.safeParse({id:e.id,timestamp:e.time_offset,mode:null==(t=e.content_style)?void 0:t.mode,color:null==(r=e.content_style)?void 0:r.color,content:e.content}).data)?n:null}),tencentSegmentSchema=schemas_object({barrage_list:schemas_array(unknown().transform(e=>{var t;return null!=(t=tencentCommentItemSchema.safeParse(e).data)?t:null})).transform(e=>e.filter(e=>null!==e))});function tencent_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function tencent_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){tencent_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){tencent_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function tencent_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let tencent_pageSize=100;class TencentScraper extends BaseScraper{getEpisodes(e,t){return tencent_async_to_generator(function*(){let r=this.parseIdString(e);if(!r)return[];let n=yield this.internalGetEpisodes(r.cid,t);return void 0!==t?n.filter(e=>e.episodeNumber===t):n}).call(this)}getSegments(e){return tencent_async_to_generator(function*(){let t=this.parseIdString(e);if(!t)return[];let r={};try{var n;let e=yield this.fetch.get(`https://dm.video.qq.com/barrage/base/${t.vid}`,{schema:tencentSegmentIndexSchema,cache:{cacheKey:`tencent:segment:${t.vid}`,ttl:TTL_2_HOURS}});if(!e.data)return[];if(!(null==(n=e.data)?void 0:n.segment_index))return this.logger.info("vid:",t.vid,"没有找到弹幕分段索引。"),[];r=e.data.segment_index}catch(e){return this.logger.error("获取弹幕索引失败,vid:",t.vid,"错误:",e),[]}let i=Object.keys(r).sort((e,t)=>parseInt(e,10)-parseInt(t,10));return this.logger.debug("为 vid:",t.vid,"找到",i.length,"个弹幕分段"),i.map(e=>{var t;return{provider:this.providerName,startTime:parseInt(e,10)/1e3,segmentId:null==(t=r[e])?void 0:t.segment_name}})}).call(this)}getComments(e,t){return tencent_async_to_generator(function*(){var r,n;let i=this.parseIdString(e);if(!(null==i?void 0:i.vid))return[];let o=null!=(n=null==(r=(yield this.fetch.get(`https://dm.video.qq.com/barrage/segment/${i.vid}/${t}`,{schema:tencentSegmentSchema})).data)?void 0:r.barrage_list)?n:[];return this.logger.info("找到",o.length,"条弹幕"),o}).call(this)}getEpisodesPage(e,t=0){return tencent_async_to_generator(function*(){this.fetch.setHeaders({Referer:`https://v.qq.com/x/cover/${e}.html`});let r=yield this.fetch.post("https://pbaccess.video.qq.com/trpc.universal_backend_service.page_server_rpc.PageServer/GetPageData?video_appid=3000010&vplatform=2",{page_params:{cid:e,page_type:"detail_operation",page_id:"vsite_episode_list",id_type:"1",page_size:tencent_pageSize.toString(),lid:"0",req_from:"web_vsite",page_context:url_parse.qs.stringify({cid:e,detail_page_type:"0",id_type:"1",is_nocopyright:"false",is_skp_style:"false",list_page_context:`page_context:pg=${t};`,page_size:tencent_pageSize.toString(),req_from:"web_vsite",req_from_second_type:"detail_operation",req_type:"0"})},has_cache:1},{headers:{"Content-Type":"application/json"},schema:tencentEpisodeResultSchema,cache:`tencent:episodes:${e}:${t}`});return r.data?r.data.map(t=>{var r;let n=t.union_title&&t.union_title!==t.title?t.union_title:t.title;return{provider:this.providerName,episodeId:this.generateIdString({cid:e,vid:t.vid}),episodeTitle:n,episodeNumber:null!=(r=this.getEpisodeIndexFromTitle(n))?r:0}}):[]}).call(this)}internalGetEpisodes(e,t){return tencent_async_to_generator(function*(){if(!t)return this.getEpisodesPage(e);let r=Math.floor((null!=t?t:1)/tencent_pageSize),n=yield this.getEpisodesPage(e,r);if(n.find(e=>e.episodeNumber===t))return n;let i=Math.max(...n.map(e=>{var t;return null!=(t=e.episodeNumber)?t:0})),o=Math.min(...n.map(e=>{var t;return null!=(t=e.episodeNumber)?t:0}));return t>i?this.getEpisodesPage(e,r+1):t<o?this.getEpisodesPage(e,r-1):[]}).call(this)}constructor(){super(),tencent_define_property(this,"providerName","tencent"),tencent_define_property(this,"idSchema",tencentIdSchema),this.fetch.setCookie({pgv_pvid:"40b67e3b06027f3d",video_platform:"2",vversion_name:"8.2.95",video_bucketid:"4",video_omgid:"0a1ff6bc9407c0b1cff86ee5d359614d"}),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"})}}function youku_schema_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function youku_schema_object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){youku_schema_define_property(e,t,r[t])})}return e}function youku_schema_ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function youku_schema_object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):youku_schema_ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}let youkuIdSchema=schemas_object({showId:schemas_string().optional(),vid:schemas_string().optional()}),youku_schema_episodeBlacklistPattern=getEpisodeBlacklistPattern("^(.*?)(抢先(版|篇)?|加更(版|篇)?|花絮|预告|特辑|彩蛋|专访|幕后(故事|花絮)?|直播|纯享|未播|衍生|番外|会员(专属|加长)?|片花|精华|看点|速览|解读|reaction|影评)(.*?)$"),youkuEpisodeInfoSchema=schemas_object({id:schemas_string(),show_id:schemas_string().optional(),title:schemas_string().refine(e=>!youku_schema_episodeBlacklistPattern.test(e)),seq:coerce_number().optional(),duration:schemas_string(),category:schemas_string(),link:schemas_string()}).transform(e=>youku_schema_object_spread_props(youku_schema_object_spread({},e),{get totalMat(){try{let t=parseFloat(e.duration);return Math.floor(t/60)+1}catch(e){return 0}}})),youkuVideoResultSchema=schemas_object({total:schemas_number().or(schemas_string().transform(e=>parseInt(e))),videos:schemas_array(youkuEpisodeInfoSchema)}),youkuCommentSchema=schemas_object({id:schemas_number(),content:schemas_string(),playat:schemas_number().transform(e=>e/1e3),propertis:schemas_string().nullish().transform(e=>safeJsonParseWithZod(null!=e?e:"{}",schemas_object({color:schemas_number().optional().default(DEFAULT_COLOR_INT),pos:schemas_number().optional().transform(e=>{let t=1;return 1===e?t=5:2===e&&(t=4),t})})))}).transform(e=>{var t,r,n;return null!=(n=providerCommentItemSchema.safeParse({id:e.id.toString(),timestamp:e.playat,mode:null==(t=e.propertis)?void 0:t.pos,color:null==(r=e.propertis)?void 0:r.color,content:e.content}).data)?n:null}),youkuDanmuResultSchema=schemas_object({data:schemas_object({result:schemas_array(youkuCommentSchema)})});function youku_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function youku_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){youku_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){youku_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function youku_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class YoukuScraper extends BaseScraper{get token(){var e,t;return(null!=(t=null==(e=this.fetch.getCookie("_m_h5_tk"))?void 0:e.split("_")[0])?t:"").substring(0,32)}get cna(){var e;return null!=(e=this.fetch.getCookie("cna"))?e:""}getEpisodes(e,t){return youku_async_to_generator(function*(){var r,n,i;let o=this.parseIdString(e);if(!o)return[];let a=o.showId;if(!a&&o.vid){let e=yield this.getVideoInfo(o.vid);a=null!=(r=null==e?void 0:e.show_id)?r:""}if(!a)return[];let s=20,l=null!=t?t:1,u=Math.max(1,Math.ceil(l/20));try{let e=e=>e.filter(e=>!this.EPISODE_BLACKLIST_KEYWORDS.some(t=>e.title.includes(t))),r=(e,t)=>({provider:this.providerName,episodeId:this.generateIdString({showId:a,vid:e.id}),episodeTitle:e.title,episodeNumber:t}),o=yield this.getEpisodesPage(a,u,s),c=e(null!=(n=null==o?void 0:o.videos)?n:[]),d=c.find(e=>e.seq===l);if(d)return[r(d,l)];let f=Number(null!=(i=null==o?void 0:o.total)?i:0),p=Math.max(1,Math.ceil(f/s)),h=Array.from({length:p},(e,t)=>t+1).filter(e=>e!==u),m=[];for(let e of h){let t=yield this.getEpisodesPage(a,e,s);m.push(t)}let g=e(m.flatMap(e=>{var t;return null!=(t=null==e?void 0:e.videos)?t:[]})),v=[...c,...g];if(void 0!==t){let e=v.find(e=>e.seq===l);return e?[r(e,l)]:[]}return v.sort((e,t)=>{var r,n;return(null!=(r=e.seq)?r:Number.MAX_SAFE_INTEGER)-(null!=(n=t.seq)?n:Number.MAX_SAFE_INTEGER)}).map((e,t)=>r(e,t+1))}catch(e){return this.logger.error("获取分集失败,showId:",a,"错误:",e),[]}}).call(this)}getSegments(e){return youku_async_to_generator(function*(){var t;let{vid:r}=null!=(t=this.parseIdString(e))?t:{};if(!r)return[];try{yield this.ensureTokenCookie();let e=yield this.getVideoInfo(r);if(!e)return this.logger.warn("获取分集信息失败,vid:",r),[];let t=e.totalMat;if(0===t)return this.logger.warn("视频时长为0,无法获取弹幕,vid:",r),[];return Array.from({length:t},(e,t)=>({provider:this.providerName,startTime:60*t,segmentId:t.toString()}))}catch(e){return this.logger.error("获取分段信息失败,vid:",r,"错误:",e),[]}}).call(this)}getComments(e,t){return youku_async_to_generator(function*(){var r;let{vid:n}=null!=(r=this.parseIdString(e))?r:{};if(!n)return[];try{return yield this.ensureTokenCookie(),this.getDanmuContentByMat(n,parseInt(t,10))}catch(e){return this.logger.error("获取弹幕信息失败,vid:",n,"错误:",e),[]}}).call(this)}getVideoInfo(e){return youku_async_to_generator(function*(){return(yield this.fetch.get("https://openapi.youku.com/v2/videos/show_basic.json",{params:{client_id:"53e6cc67237fc59a",package:"com.huawei.hwvplayer.youku",video_id:e},schema:youkuEpisodeInfoSchema,cache:{cacheKey:`youku:segments:${e}`}})).data}).call(this)}getEpisodesPage(e,t,r){return youku_async_to_generator(function*(){return(yield this.fetch.get("https://openapi.youku.com/v2/shows/videos.json",{params:{client_id:"53e6cc67237fc59a",package:"com.huawei.hwvplayer.youku",ext:"show",show_id:e,page:t.toString(),count:r.toString()},schema:youkuVideoResultSchema,cache:{cacheKey:`youku:episodes:${e}:${t}:${r}`}})).data}).call(this)}getDanmuContentByMat(e,t){return youku_async_to_generator(function*(){if(!this.token)return this.logger.error("无法获取弹幕,_m_h5_tk 缺失"),[];let r={pid:0,ctype:10004,sver:"3.1.0",cver:"v1.0",ctime:Date.now(),guid:this.cna,vid:e,mat:t,mcount:1,type:1},n=JSON.stringify(Object.fromEntries(Object.entries(r).sort())),i=enc_base64_default().stringify(enc_utf8_default().parse(n));r.msg=i,r.sign=this.generateMsgSign(i);let o="24679788",a=JSON.stringify(r),s=Date.now().toString();try{var l,u,c;let e=null!=(c=null==(u=(yield this.fetch.get("https://acs.youku.com/h5/mopen.youku.danmu.list/1.0/",{params:{jsv:"2.7.0",appKey:o,t:s,sign:this.generateTokenSign(s,o,a),api:"mopen.youku.danmu.list",v:"1.0",type:"originaljson",dataType:"jsonp",timeout:"20000",jsonpIncPrefix:"utility",data:a},headers:{Referer:"https://v.youku.com"},successStatus:[200],schema:looseObject({data:schemas_object({result:schemas_string().transform(e=>safeJsonParseWithZod(e,youkuDanmuResultSchema)).optional()})})})).data)||null==(l=u.data.result)?void 0:l.data.result)?c:[];return this.logger.info("获取到分段",t,"的弹幕",e.length,"条"),e}catch(r){return this.logger.error("解析弹幕响应失败,vid:",e,"mat:",t,"错误:",r),[]}}).call(this)}generateMsgSign(e){return md5_default()(`${e}MkmC9SoIw6xCkSKHhJ7b5D2r51kBiREr`).toString().toLowerCase()}generateTokenSign(e,t,r){return md5_default()([this.token,e,t,r].join("&")).toString().toLowerCase()}ensureTokenCookie(){return youku_async_to_generator(function*(){this.fetch.cookie={};try{yield this.fetch.get("https://log.mmstat.com/eg.js",{headers:{Cookie:"","If-None-Match":""}})}catch(e){this.logger.warn("无法连接到 youku.com 获取 'cna' cookie。错误:",e)}try{yield this.fetch.get("https://acs.youku.com/h5/mtop.com.youku.aplatform.weakget/1.0/?jsv=2.5.1&appKey=24679788")}catch(e){this.logger.error("无法连接到 acs.youku.com 获取令牌 cookie。弹幕获取很可能会失败。错误:",e)}this.cna&&this.token||this.logger.warn("未能获取到弹幕签名所需的全部 cookie。 cna:",this.cna,"token:",this.token)}).call(this)}constructor(){super(),youku_define_property(this,"providerName","youku"),youku_define_property(this,"idSchema",youkuIdSchema),youku_define_property(this,"EPISODE_BLACKLIST_KEYWORDS",["彩蛋","加更","走心","解忧","纯享"]),this.fetch.setHeaders({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"})}}function scrapers_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function scrapers_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){scrapers_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){scrapers_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function scrapers_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function scrapers_object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){scrapers_define_property(e,t,r[t])})}return e}function scrapers_ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function scrapers_object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):scrapers_ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}let scrapers=[TencentScraper,YoukuScraper,IqiyiScraper,BilibiliScraper,RenRenScraper,MgTVScraper];class scrapers_Scraper{get scraperMap(){return this._scraperMap||(this._scraperMap=keyBy(this.scrapers,e=>e.providerName)),this._scraperMap}getSegmentsByProvider(e,t){return scrapers_async_to_generator(function*(){let r=this.scraperMap[e];if(!r)return[];let n=yield r.getSegments(t);return sortBy(n,["startTime"])}).call(this)}findSegmentAtTime(e,t){var r;if(!e.length)return null;let n=0,i=e.length-1;for(;n<=i;){let r=n+i>>1;e[r].startTime<=t?n=r+1:i=r-1}let o=i;return o<0?null:null!=(r=e[o])?r:null}getSegmentWithTime(e=0,...t){return scrapers_async_to_generator(function*(){let r=t.map(({provider:t,idString:r})=>scrapers_async_to_generator(function*(){try{let n=yield this.getSegmentsByProvider(t,r);if(!n.length)return null;let i=this.findSegmentAtTime(n,e);if(!i)return null;let o=this.scraperMap[t];if(!o)return null;let a=yield o.getComments(r,i.segmentId);if(!(null==a?void 0:a.length))return null;return{provider:t,comments:a}}catch(e){return null}}).call(this)),n=yield Promise.all(r),i=new Map;for(let e of n){var o,a;if(null==e||null==(o=e.comments)?void 0:o.length)for(let t of e.comments){if(!t)continue;let r="";r=this.globalParams.global.content.aggregation?[t.mode,t.color,t.content].join("___"):null!=(a=t.id)?a:Math.random().toString();let n=i.get(r);n?(t.timestamp<n.item.timestamp&&(n.item=t),n.count+=1):i.set(r,{item:t,count:1,provider:e.provider})}}let s=[],l=this.globalParams.global.content.blacklist?new RegExp(this.globalParams.global.content.blacklist):null;return i.forEach(({item:e,count:t,provider:r})=>{if(null==l?void 0:l.test(e.content))return;let n=t>1?`${e.content} \xd7 ${t}`:e.content;s.push({cid:e.id,p:`${e.timestamp.toFixed(2)},${e.mode},${e.color},[${r}]`,m:n})}),s}).call(this)}getDanmuWithSegmentTimeByVideoId(e,t){let r=e.split(",").map(e=>{let[t,r]=e.split(":");return{provider:t,idString:r}});return this.getSegmentWithTime(t,...r)}getEpisodes(...e){return scrapers_async_to_generator(function*(){let t=[];for(let{provider:r,idString:n,episodeNumber:i}of uniqWith(e,isEqual)){let e=this.scraperMap[r];e&&t.push(e.getEpisodes(n,i).catch(e=>(console.error(e),[])))}return(yield Promise.all(t).catch(e=>(console.error(e),[]))).flat().map(e=>scrapers_object_spread_props(scrapers_object_spread({},e),{episodeId:`${e.provider}:${e.episodeId}`}))}).call(this)}getEpisodeNumber(e,t){if(e===constants_MediaType.TV&&t)return parseInt(t)}getDetailWithAnimeId(e,t,r){return scrapers_async_to_generator(function*(){let[n,i]=e.split(":");return yield this.getEpisodes({provider:n,idString:i,episodeNumber:this.getEpisodeNumber(t,r)})}).call(this)}getEpisodeParams(e){return scrapers_async_to_generator(function*(){let t=[];for(let r of this.scrapers)r.search&&t.push(r.search(e).catch(e=>(console.error(e),[])));let r=(yield Promise.all(t)).flat();if(!r.length)return[];let n=this.getEpisodeNumber(e.type,e.episode),i=[];for(let e of r)try{let t=this.scraperMap[e.provider];if(!t)continue;let r=t.generateIdString({dramaId:e.dramaId});i.push({provider:e.provider,idString:r,episodeNumber:n})}catch(e){}try{if("true"===e.qihooSearch){let t=new QihooMatcher,r=yield t.getEpisodeParams(e);i.push(...r)}}catch(e){}return i}).call(this)}setGlobalParams(e){let{success:t,data:r}=globalParamsConfigSchema.safeParse(e);return t&&(this.globalParams=r,this.scrapers.forEach(e=>{e.providerConfig=r.provider})),r}constructor(){scrapers_define_property(this,"scrapers",[]),scrapers_define_property(this,"globalParams",{}),scrapers_define_property(this,"_scraperMap",void 0),scrapers.forEach(e=>{this.scrapers.push(new e)})}}let scrapers_scraper=new scrapers_Scraper;function imdb_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function imdb_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){imdb_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){imdb_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function imdb_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}let episodesRequestSchema=schemas_object({season:coerce_number().optional().default(1),pageSize:coerce_number().optional().default(20),pageToken:schemas_string().optional()}),BASE_URL="https://api.imdbapi.dev";class ImdbMatcher{getImdbEpisodes(e,t){return imdb_async_to_generator(function*(){let{season:r,pageSize:n,pageToken:i}=episodesRequestSchema.parse(null!=t?t:{});return(yield this.fetch.get(`${BASE_URL}/titles/${e}/episodes`,{params:{season:r,pageSize:n,pageToken:i},cache:{cacheKey:["imdb","episodes",e,r,n,i].filter(Boolean).join(":")},successStatus:[200],schema:schemas_object({episodes:schemas_array(schemas_object({id:schemas_string(),title:schemas_string().optional(),episodeNumber:schemas_number().optional()})),totalCount:schemas_number(),nextPageToken:schemas_string().optional()})})).data}).call(this)}getImdbSeasons(e){return imdb_async_to_generator(function*(){return(yield this.fetch.get(`${BASE_URL}/titles/${e}/seasons`,{cache:{cacheKey:["imdb:seasons",e].join(":")},schema:schemas_object({seasons:schemas_array(schemas_object({season:schemas_string(),episodeCount:schemas_number().optional()}))})})).data}).call(this)}constructor(){imdb_define_property(this,"fetch",new Fetch)}}function tmdb_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function tmdb_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){tmdb_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){tmdb_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}class TmdbMatcher{getExternalIds(e,t){return tmdb_async_to_generator(function*(){let r=null,n=`tmdb:${e}:${t}:external_ids`,i=yield storage.getJson(n);return i?r=i:(r=yield Widget.tmdb.get(`/${e}/${t}/external_ids`),storage.setJson(n,r,{ttl:TTL_7_DAYS})),r})()}}function douban_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function douban_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){douban_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){douban_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function douban_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class DoubanMatcher{getDoubanInfoByImdbId(e,t){return douban_async_to_generator(function*(){var r,n,i,o,a,s;let l=e;if(t&&"1"!==t.toString()){let r=yield this.imdbMatcher.getImdbSeasons(e);if(!r||parseInt(t.toString())>r.seasons.length)return null;let n=yield this.imdbMatcher.getImdbEpisodes(e,{season:t});l=null!=(a=null==n||null==(o=n.episodes.find(e=>1===e.episodeNumber))?void 0:o.id)?a:""}l||(l=e),this.logger.info("通过 imdb id 获取豆瓣信息",l);let u=yield this.fetch.post(`https://api.douban.com/v2/movie/imdb/${l}`,{apikey:this.DOUBAN_API_KEY},{headers:{"Content-Type":"application/json"},schema:schemas_object({id:schemas_string(),title:schemas_string().optional()}),cache:{cacheKey:`douban:imdb:${l}`,ttl:TTL_7_DAYS}});if(200!==u.statusCode)throw Error(`Failed to get Douban info: ${u.statusCode}, ${JSON.stringify(u.data)}`);let c=null==(i=u.data)||null==(n=i.id)||null==(r=n.split("/"))?void 0:r.pop();if(!c)throw Error(`Failed to extract Douban ID from response: ${null==(s=u.data)?void 0:s.id}`);return/\d+/.test(c)?{doubanId:c,originResponse:u.data}:null}).call(this)}getDoubanInfoByTmdbId(e,t,r){return douban_async_to_generator(function*(){if(!t)return null;let n=yield this.tmdbMatcher.getExternalIds(e,t);return(this.logger.info("Get external ids by tmdb id",n),n.imdb_id)?this.getDoubanInfoByImdbId(n.imdb_id,r):null}).call(this)}searchDoubanInfoByName(e){return douban_async_to_generator(function*(){var t,r;return e&&null!=(r=null==(t=(yield this.fetch.get("https://m.douban.com/rexxar/api/v2/search",{params:{q:e,start:0,count:20,type:"movie"},headers:{Referer:"https://m.douban.com/movie/","Content-Type":"application/json"},schema:schemas_object({subjects:schemas_object({items:schemas_array(unknown().transform(e=>{var t;return null!=(t=schemas_object({type_name:schemas_string(),target_type:schemas_string(),target_id:schemas_string(),target:schemas_object({title:schemas_string(),has_linewatch:schemas_boolean().refine(e=>e)})}).safeParse(e).data)?t:null})).transform(e=>compact(e))})}),cache:{cacheKey:["douban","search",e].filter(Boolean).join(":")}})).data)?void 0:t.subjects.items)?r:[]}).call(this)}getVideoPlatformInfoByDoubanId(e){return douban_async_to_generator(function*(){var t,r;this.logger.info("获取视频平台信息",e);let n=yield this.fetch.get(`https://m.douban.com/rexxar/api/v2/movie/${e}?for_mobile=1`,{headers:{Referer:`https://m.douban.com/movie/subject/${e}/?dt_dapp=1`,"Content-Type":"application/json"},schema:schemas_object({is_tv:schemas_boolean().optional(),vendors:schemas_array(unknown().transform(e=>{let{success:t,data:r,error:n}=schemas_object({id:schemas_string(),is_ad:schemas_boolean().catch(!1).refine(e=>!e),uri:schemas_string()}).safeParse(e);return t?r:(this.logger.error("解析视频平台信息失败",prettifyError(n),e),null)}))}),successStatus:[200],cache:{cacheKey:`douban:${e}:info`,ttl:TTL_7_DAYS}}),i=[];for(let e of null!=(r=null==(t=n.data)?void 0:t.vendors)?r:[]){if(!e)continue;let t=url_parse_default()(e.uri,!0);switch(e.id){case"qq":{let{cid:e,vid:r}=t.query;e&&i.push({provider:"tencent",idString:scrapers_scraper.scraperMap.tencent.generateIdString({cid:e,vid:r})});break}case"iqiyi":{let{tvid:e}=t.query;e&&i.push({provider:"iqiyi",idString:scrapers_scraper.scraperMap.iqiyi.generateIdString({entityId:e})});break}case"youku":{let{showid:e,vid:r}=t.query;(e||r)&&i.push({provider:"youku",idString:scrapers_scraper.scraperMap.youku.generateIdString({showId:e,vid:r})});break}case"bilibili":{let e=t.pathname.split("/").pop();e&&/\d+/.test(e)&&i.push({provider:"bilibili",idString:scrapers_scraper.scraperMap.bilibili.generateIdString({seasonId:e})})}}}return i}).call(this)}getDoubanIds(e){return douban_async_to_generator(function*(){let t=new Set,{tmdbId:r,type:n,seriesName:i,season:o,fuzzyMatch:a}=searchDanmuParamsSchema.parse(e);try{let e=yield this.getDoubanInfoByTmdbId(n,r,o);(null==e?void 0:e.doubanId)&&t.add(e.doubanId)}catch(e){this.logger.error("Error getting douban info by tmdb id",e)}if("always"===a||"auto"===a&&!t.size)try{let e=i;for(let r of(o&&parseInt(o.toString())>1&&(e+=o.toString()),yield this.searchDoubanInfoByName(e)))t.add(r.target_id)}catch(e){this.logger.error("Error searching douban info by name",e)}return Array.from(t)}).call(this)}getEpisodeParams(e){return douban_async_to_generator(function*(){let t=yield this.getDoubanIds(e);this.logger.info("获取到豆瓣ID",t);let r=[];for(let e of t){let t=yield this.getVideoPlatformInfoByDoubanId(e);r.push(...t)}return this.logger.info("获取到视频平台信息",r),{doubanIds:t,videoPlatformInfo:r}}).call(this)}constructor(){douban_define_property(this,"logger",new Logger("豆瓣")),douban_define_property(this,"tmdbMatcher",new TmdbMatcher),douban_define_property(this,"imdbMatcher",new ImdbMatcher),douban_define_property(this,"fetch",new Fetch),douban_define_property(this,"DOUBAN_API_KEY","0ac44ae016490db2204ce0a042db2916")}}function src_asyncGeneratorStep(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function src_async_to_generator(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){src_asyncGeneratorStep(o,n,i,a,s,"next",e)}function s(e){src_asyncGeneratorStep(o,n,i,a,s,"throw",e)}a(void 0)})}}function src_define_property(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function src_object_spread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){src_define_property(e,t,r[t])})}return e}function src_ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function src_object_spread_props(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):src_ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}let widgetVersion="0.13.2";WidgetMetadata = {id:"baranwang.danmu.universe",title:"通用弹幕",description:"通用弹幕插件,支持腾讯、优酷、爱奇艺、哔哩哔哩、人人视频等平台",author:"Baran",version:widgetVersion,site:"https://github.com/baranwang/forward-widgets/tree/main/apps/danmu-universe",requiredVersion:"0.0.2",globalParams:[{title:"模糊匹配",name:"fuzzyMatch",description:"是否开启模糊匹配",value:"auto",type:"enumeration",enumOptions:[{title:"自动",value:"auto"},{title:"始终开启",value:"always"},{title:"始终关闭",value:"never"}]},{title:"360 影视搜索(实验性)",name:"qihooSearch",description:"是否开启 360 影视搜索",value:"false",type:"enumeration",belongTo:{paramName:"fuzzyMatch",value:["auto","always"]},enumOptions:[{title:"关闭",value:"false"},{title:"开启",value:"true"}]},{title:"未匹配到资源提示",name:"emptyAnimeTitle",description:"是否显示未匹配到资源提示",value:"true",type:"enumeration",enumOptions:[{title:"开启",value:"true"},{title:"关闭",value:"false"}]},{title:"弹幕内容聚合",name:"global.content.aggregation",value:"true",type:"enumeration",enumOptions:[{title:"开启",value:"true"},{title:"关闭",value:"false"}]},{title:"弹幕内容过滤",name:"global.content.blacklist",value:"",type:"input"},{title:`[${PROVIDER_NAMES.renren}] 弹幕模式`,name:"provider.renren.mode",description:"弹幕模式,精选弹幕相比默认弹幕质量更高",value:"default",type:"enumeration",enumOptions:[{title:"默认",value:"default"},{title:"精选",value:"choice"}]},{title:"豆瓣书影音档案(实验性)",name:"global.experimental.doubanHistory.enabled",description:"是否开启自动同步豆瓣书影音档案",value:"false",type:"enumeration",enumOptions:[{title:"关闭",value:"false"},{title:"开启",value:"true"}]},{title:"豆瓣 Cookie 中的 dbcl2 值",name:"global.experimental.doubanHistory.dbcl2",value:"",type:"input",belongTo:{paramName:"global.experimental.doubanHistory.enabled",value:["true"]}},{title:"豆瓣自定义评论",name:"global.experimental.doubanHistory.customComment",value:"自豪的使用 Forward*",type:"input",belongTo:{paramName:"global.experimental.doubanHistory.enabled",value:["true"]},placeholders:["自豪的使用 Forward*","Marked by Forward*"].map(e=>({title:e,value:e}))},{title:"Trakt 历史同步(实验性)",name:"global.experimental.trakt.enabled",description:"是否开启自动同步 Trakt 历史",value:"false",type:"enumeration",enumOptions:[{title:"关闭",value:"false"},{title:"开启",value:"true"}]},{title:"Trakt 令牌",description:"通过 trakt-forward.baranwang.workers.dev 获取",name:"global.experimental.trakt.token",value:"",type:"input",belongTo:{paramName:"global.experimental.trakt.enabled",value:["true"]}}],modules:[{type:"danmu",id:"searchDanmu",title:"搜索弹幕",functionName:"searchDanmu",description:"搜索弹幕"},{type:"danmu",id:"getDetail",title:"获取详情",functionName:"getDetail",description:"获取详情"},{type:"danmu",id:"getComments",title:"获取弹幕",functionName:"getComments",description:"获取弹幕"},{type:"danmu",id:"getDanmuWithSegmentTime",title:"获取弹幕切片",functionName:"getComments",description:"获取弹幕切片"}]};let checkShowEmptyAnimeTitle=e=>stringbool().catch(!0).parse(e.emptyAnimeTitle);searchDanmu=e=>src_async_to_generator(function*(){let t=scrapers_scraper.setGlobalParams(e),{fuzzyMatch:r="auto",type:n,episode:i}=e,o=[],a=new DoubanMatcher,{doubanIds:s,videoPlatformInfo:l}=yield a.getEpisodeParams(e);o=o.concat(l);try{if((null==t?void 0:t.global.experimental.trakt.enabled)&&(null==t?void 0:t.global.experimental.trakt.token)){let r=new Trakt(t.global.experimental.trakt);yield r.syncHistory(e)}}catch(e){console.error(e)}try{if((null==t?void 0:t.global.experimental.doubanHistory.enabled)&&(null==t?void 0:t.global.experimental.doubanHistory.dbcl2)){let e=new DoubanHistory(t.global.experimental.doubanHistory);1===s.length&&(yield e.setStatus(n,s[0],"tv"===n?"doing":"done"))}}catch(e){console.error(e)}if(!(null==o?void 0:o.length)&&"auto"===r||"always"===r){let t=yield scrapers_scraper.getEpisodeParams(e);o=o.concat(t)}"tv"===n&&(o=o.map(e=>src_object_spread_props(src_object_spread({},e),{episodeNumber:i?parseInt(i,10):void 0})));let u=yield scrapers_scraper.getEpisodes(...o);return("tv"===n&&i&&(u=u.filter(e=>e.episodeNumber===parseInt(i,10))),!u.length&&checkShowEmptyAnimeTitle(e))?{animes:[{animeId:EMPTY_ANIME_CONFIG.ID,animeTitle:EMPTY_ANIME_CONFIG.TITLE}]}:{animes:u.map(e=>{let t=`[${PROVIDER_NAMES[e.provider]}] `;return e.episodeTitle&&(t+=e.episodeTitle),{animeId:e.episodeId,animeTitle:t}})}})(),getDetail=e=>src_async_to_generator(function*(){scrapers_scraper.setGlobalParams(e);let{animeId:t,type:r,episode:n}=e;return t&&t!==EMPTY_ANIME_CONFIG.ID?scrapers_scraper.getDetailWithAnimeId(t.toString(),r,n):null})(),getComments=e=>src_async_to_generator(function*(){scrapers_scraper.setGlobalParams(e);let{animeId:t,commentId:r,segmentTime:n}=e,i=null!=r?r:t;if(i===EMPTY_ANIME_CONFIG.ID)return null;let o=yield scrapers_scraper.getDanmuWithSegmentTimeByVideoId(i.toString(),n);return{comments:o,count:o.length}})();
|