/* 脚本作者:Maasea 引用地址:https://raw.githubusercontent.com/Maasea/sgmodule/master/Script/Youtube/youtube.request.js */ // Build: 2026/7/12 22:44:32 (()=>{var nt=Object.create;var ge=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var ot=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var ft=(n,e,t)=>e in n?ge(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var ut=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var ct=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of st(e))!at.call(n,i)&&i!==t&&ge(n,i,{get:()=>e[i],enumerable:!(r=it(e,i))||r.enumerable});return n};var h=(n,e,t)=>(t=n!=null?nt(ot(n)):{},ct(e||!n||!n.__esModule?ge(t,"default",{value:n,enumerable:!0}):t,n));var Y=(n,e,t)=>(ft(n,typeof e!="symbol"?e+"":e,t),t);var l=ut(Ae=>{"use strict";(function(n){function e(){}function t(){}var r=String.fromCharCode,i={}.toString,s=i.call(n.SharedArrayBuffer),o=i(),a=n.Uint8Array,u=a||Array,c=a?ArrayBuffer:u,d=c.isView||function(w){return w&&"length"in w},I=i.call(c.prototype);c=t.prototype;var y=n.TextEncoder,m=new(a?Uint16Array:u)(32);e.prototype.decode=function(w){if(!d(w)){var U=i.call(w);if(U!==I&&U!==s&&U!==o)throw TypeError("Failed to execute 'decode' on 'TextDecoder': The provided value is not of type '(ArrayBuffer or ArrayBufferView)'");w=a?new u(w):w||[]}for(var x=U="",p=0,k=w.length|0,G=k-32|0,B,T,A=0,J=0,K,V=0,L=-1;p>4){case 15:if(K=w[p=p+1|0]&255,K>>6!==2||247>6===2?J+4|0:24,T=T+256&768;case 13:case 12:K=w[p=p+1|0]&255,A<<=6,A|=(T&31)<<6|K&63,J=J+7|0,p>6===2&&A>>J&&1114112>A?(T=A,A=A-65536|0,0<=A&&(L=(A>>10)+55296|0,T=(A&1023)+56320|0,31>V?(m[V]=L,V=V+1|0,L=-1):(K=L,L=T,T=K))):(T>>=8,p=p-T-1|0,T=65533),A=J=0,B=p<=G?32:k-p|0;default:m[V]=T;continue;case 11:case 10:case 9:case 8:}m[V]=65533}if(x+=r(m[0],m[1],m[2],m[3],m[4],m[5],m[6],m[7],m[8],m[9],m[10],m[11],m[12],m[13],m[14],m[15],m[16],m[17],m[18],m[19],m[20],m[21],m[22],m[23],m[24],m[25],m[26],m[27],m[28],m[29],m[30],m[31]),32>V&&(x=x.slice(0,V-32|0)),p>>31,L=-1,x.length=B)x[k]=B;else{if(2047>=B)x[k]=192|B>>6;else{e:{if(55296<=B)if(56319>=B){var T=w.charCodeAt(p=p+1|0)|0;if(56320<=T&&57343>=T){if(B=(B<<10)+T-56613888|0,65535>18,x[k=k+1|0]=128|B>>12&63,x[k=k+1|0]=128|B>>6&63,x[k=k+1|0]=128|B&63;continue}break e}B=65533}else 57343>=B&&(B=65533);!G&&p<<1>12,x[k=k+1|0]=128|B>>6&63}x[k=k+1|0]=128|B&63}}return a?x.subarray(0,k):x.slice(0,k)},y||(n.TextDecoder=e,n.TextEncoder=t)})(""+void 0==typeof global?""+void 0==typeof globalThis?Ae:globalThis:global)});var ni=h(l(),1);var Kn=h(l(),1);var Nn=h(l());var At=h(l());function Q(n){let e=typeof n;if(e=="object"){if(Array.isArray(n))return"array";if(n===null)return"null"}return e}function Se(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}var Ut=h(l()),C="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),ee=[];for(let n=0;n>4,o=s,i=2;break;case 2:t[r++]=(o&15)<<4|(s&60)>>2,o=s,i=3;break;case 3:t[r++]=(o&3)<<6|s,i=0;break}}if(i==1)throw Error("invalid base64 string.");return t.subarray(0,r)}function ye(n){let e="",t=0,r,i=0;for(let s=0;s>2],i=(r&3)<<4,t=1;break;case 1:e+=C[i|r>>4],i=(r&15)<<2,t=2;break;case 2:e+=C[i|r>>6],e+=C[r&63],t=0;break}return t&&(e+=C[i],e+="=",t==1&&(e+="=")),e}var Dt=h(l()),D;(function(n){n.symbol=Symbol.for("protobuf-ts/unknown"),n.onRead=(t,r,i,s,o)=>{(e(r)?r[n.symbol]:r[n.symbol]=[]).push({no:i,wireType:s,data:o})},n.onWrite=(t,r,i)=>{for(let{no:s,wireType:o,data:a}of n.list(r))i.tag(s,o).raw(a)},n.list=(t,r)=>{if(e(t)){let i=t[n.symbol];return r?i.filter(s=>s.no==r):i}return[]},n.last=(t,r)=>n.list(t,r).slice(-1)[0];let e=t=>t&&Array.isArray(t[n.symbol])})(D||(D={}));var b;(function(n){n[n.Varint=0]="Varint",n[n.Bit64=1]="Bit64",n[n.LengthDelimited=2]="LengthDelimited",n[n.StartGroup=3]="StartGroup",n[n.EndGroup=4]="EndGroup",n[n.Bit32=5]="Bit32"})(b||(b={}));var Xt=h(l());var $t=h(l());var Lt=h(l());function Ue(){let n=0,e=0;for(let r=0;r<28;r+=7){let i=this.buf[this.pos++];if(n|=(i&127)<>4,!(t&128))return this.assertBounds(),[n,e];for(let r=3;r<=31;r+=7){let i=this.buf[this.pos++];if(e|=(i&127)<>>s,a=!(!(o>>>7)&&e==0),u=(a?o|128:o)&255;if(t.push(u),!a)return}let r=n>>>28&15|(e&7)<<4,i=!!(e>>3);if(t.push((i?r|128:r)&255),!!i){for(let s=3;s<31;s=s+7){let o=e>>>s,a=!!(o>>>7),u=(a?o|128:o)&255;if(t.push(u),!a)return}t.push(e>>>31&1)}}var te=(1<<16)*(1<<16);function be(n){let e=n[0]=="-";e&&(n=n.slice(1));let t=1e6,r=0,i=0;function s(o,a){let u=Number(n.slice(o,a));i*=t,r=r*t+u,r>=te&&(i=i+(r/te|0),r=r%te)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),[e,r,i]}function ne(n,e){if(e>>>0<=2097151)return""+(te*e+(n>>>0));let t=n&16777215,r=(n>>>24|e<<8)>>>0&16777215,i=e>>16&65535,s=t+r*6777216+i*6710656,o=r+i*8147497,a=i*2,u=1e7;s>=u&&(o+=Math.floor(s/u),s%=u),o>=u&&(a+=Math.floor(o/u),o%=u);function c(d,I){let y=d?String(d):"";return I?"0000000".slice(y.length)+y:y}return c(a,0)+c(o,a)+c(s,1)}function we(n,e){if(n>=0){for(;n>127;)e.push(n&127|128),n=n>>>7;e.push(n)}else{for(let t=0;t<9;t++)e.push(n&127|128),n=n>>7;e.push(1)}}function Ve(){let n=this.buf[this.pos++],e=n&127;if(!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<7,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<14,!(n&128))return this.assertBounds(),e;if(n=this.buf[this.pos++],e|=(n&127)<<21,!(n&128))return this.assertBounds(),e;n=this.buf[this.pos++],e|=(n&15)<<28;for(let t=5;n&128&&t<10;t++)n=this.buf[this.pos++];if(n&128)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var O;function lt(){let n=new DataView(new ArrayBuffer(8));O=globalThis.BigInt!==void 0&&typeof n.getBigInt64=="function"&&typeof n.getBigUint64=="function"&&typeof n.setBigInt64=="function"&&typeof n.setBigUint64=="function"?{MIN:BigInt("-9223372036854775808"),MAX:BigInt("9223372036854775807"),UMIN:BigInt("0"),UMAX:BigInt("18446744073709551615"),C:BigInt,V:n}:void 0}lt();function De(n){if(!n)throw new Error("BigInt unavailable, see https://github.com/timostamm/protobuf-ts/blob/v1.0.8/MANUAL.md#bigint-support")}var Ke=/^-?[0-9]+$/,se=4294967296,ie=2147483648,oe=class{constructor(e,t){this.lo=e|0,this.hi=t|0}isZero(){return this.lo==0&&this.hi==0}toNumber(){let e=this.hi*se+(this.lo>>>0);if(!Number.isSafeInteger(e))throw new Error("cannot convert to safe number");return e}},E=class extends oe{static from(e){if(O)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=O.C(e);case"number":if(e===0)return this.ZERO;e=O.C(e);case"bigint":if(!e)return this.ZERO;if(eO.UMAX)throw new Error("ulong too large");return O.V.setBigUint64(0,e,!0),new E(O.V.getInt32(0,!0),O.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ke.test(e))throw new Error("string is no integer");let[t,r,i]=be(e);if(t)throw new Error("signed value for ulong");return new E(r,i);case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");if(e<0)throw new Error("signed value for ulong");return new E(e,e/se)}throw new Error("unknown value "+typeof e)}toString(){return O?this.toBigInt().toString():ne(this.lo,this.hi)}toBigInt(){return De(O),O.V.setInt32(0,this.lo,!0),O.V.setInt32(4,this.hi,!0),O.V.getBigUint64(0,!0)}};E.ZERO=new E(0,0);var N=class extends oe{static from(e){if(O)switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=="")throw new Error("string is no integer");e=O.C(e);case"number":if(e===0)return this.ZERO;e=O.C(e);case"bigint":if(!e)return this.ZERO;if(eO.MAX)throw new Error("signed long too large");return O.V.setBigInt64(0,e,!0),new N(O.V.getInt32(0,!0),O.V.getInt32(4,!0))}else switch(typeof e){case"string":if(e=="0")return this.ZERO;if(e=e.trim(),!Ke.test(e))throw new Error("string is no integer");let[t,r,i]=be(e);if(t){if(i>ie||i==ie&&r!=0)throw new Error("signed long too small")}else if(i>=ie)throw new Error("signed long too large");let s=new N(r,i);return t?s.negate():s;case"number":if(e==0)return this.ZERO;if(!Number.isSafeInteger(e))throw new Error("number is no integer");return e>0?new N(e,e/se):new N(-e,-e/se).negate()}throw new Error("unknown value "+typeof e)}isNegative(){return(this.hi&ie)!==0}negate(){let e=~this.hi,t=this.lo;return t?t=~t+1:e+=1,new N(t,e)}toString(){if(O)return this.toBigInt().toString();if(this.isNegative()){let e=this.negate();return"-"+ne(e.lo,e.hi)}return ne(this.lo,this.hi)}toBigInt(){return De(O),O.V.setInt32(0,this.lo,!0),O.V.setInt32(4,this.hi,!0),O.V.getBigInt64(0,!0)}};N.ZERO=new N(0,0);var Le={readUnknownField:!0,readerFactory:n=>new Ie(n)};function Ce(n){return n?Object.assign(Object.assign({},Le),n):Le}var Ie=class{constructor(e,t){this.varint64=Ue,this.uint32=Ve,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0})}tag(){let e=this.uint32(),t=e>>>3,r=e&7;if(t<=0||r<0||r>5)throw new Error("illegal tag: field no "+t+" wire type "+r);return[t,r]}skip(e){let t=this.pos;switch(e){case b.Varint:for(;this.buf[this.pos++]&128;);break;case b.Bit64:this.pos+=4;case b.Bit32:this.pos+=4;break;case b.LengthDelimited:let r=this.uint32();this.pos+=r;break;case b.StartGroup:let i;for(;(i=this.tag()[1])!==b.EndGroup;)this.skip(i);break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(t,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return new N(...this.varint64())}uint64(){return new E(...this.varint64())}sint64(){let[e,t]=this.varint64(),r=-(e&1);return e=(e>>>1|(t&1)<<31)^r,t=t>>>1^r,new N(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return new E(this.sfixed32(),this.sfixed32())}sfixed64(){return new N(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}};var zt=h(l());var _t=h(l());function g(n,e){if(!n)throw new Error(e)}var ht=34028234663852886e22,mt=-34028234663852886e22,dt=4294967295,pt=2147483647,gt=-2147483648;function P(n){if(typeof n!="number")throw new Error("invalid int 32: "+typeof n);if(!Number.isInteger(n)||n>pt||ndt||n<0)throw new Error("invalid uint 32: "+n)}function X(n){if(typeof n!="number")throw new Error("invalid float 32: "+typeof n);if(Number.isFinite(n)&&(n>ht||nnew Ne};function $e(n){return n?Object.assign(Object.assign({},qe),n):qe}var Ne=class{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let i=0;i>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(j(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return P(e),we(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){X(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){j(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){P(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return P(e),e=(e<<1^e>>31)>>>0,we(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=N.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),r=new DataView(t.buffer),i=E.from(e);return r.setInt32(0,i.lo,!0),r.setInt32(4,i.hi,!0),this.raw(t)}int64(e){let t=N.from(e);return re(t.lo,t.hi,this.buf),this}sint64(e){let t=N.from(e),r=t.hi>>31,i=t.lo<<1^r,s=(t.hi<<1|t.lo>>>31)^r;return re(i,s,this.buf),this}uint64(e){let t=E.from(e);return re(t.lo,t.hi,this.buf),this}};var Qt=h(l()),Pe={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0},Me={ignoreUnknownFields:!1};function Je(n){return n?Object.assign(Object.assign({},Me),n):Me}function je(n){return n?Object.assign(Object.assign({},Pe),n):Pe}var tr=h(l()),ae=Symbol.for("protobuf-ts/message-type");var bn=h(l());var or=h(l());var nr=h(l());function ke(n){let e=!1,t=[];for(let r=0;r!i.includes(o))||!r&&i.some(o=>!s.known.includes(o)))return!1;if(t<1)return!0;for(let o of s.oneofs){let a=e[o];if(!We(a))return!1;if(a.oneofKind===void 0)continue;let u=this.fields.find(c=>c.localName===a.oneofKind);if(!u||!this.field(a[a.oneofKind],u,r,t))return!1}for(let o of this.fields)if(o.oneof===void 0&&!this.field(e[o.localName],o,r,t))return!1;return!0}field(e,t,r,i){let s=t.repeat;switch(t.kind){case"scalar":return e===void 0?t.opt:s?this.scalars(e,t.T,i,t.L):this.scalar(e,t.T,t.L);case"enum":return e===void 0?t.opt:s?this.scalars(e,f.INT32,i):this.scalar(e,f.INT32);case"message":return e===void 0?!0:s?this.messages(e,t.T(),r,i):this.message(e,t.T(),r,i);case"map":if(typeof e!="object"||e===null)return!1;if(i<2)return!0;if(!this.mapKeys(e,t.K,i))return!1;switch(t.V.kind){case"scalar":return this.scalars(Object.values(e),t.V.T,i,t.V.L);case"enum":return this.scalars(Object.values(e),f.INT32,i);case"message":return this.messages(Object.values(e),t.V.T(),r,i)}break}return!0}message(e,t,r,i){return r?t.isAssignable(e,i):t.is(e,i)}messages(e,t,r,i){if(!Array.isArray(e))return!1;if(i<2)return!0;if(r){for(let s=0;sparseInt(s)),t,r);case f.BOOL:return this.scalars(i.slice(0,r).map(s=>s=="true"?!0:s=="false"?!1:s),t,r);default:return this.scalars(i,t,r,F.STRING)}}};var Or=h(l());var pr=h(l());function S(n,e){switch(e){case F.BIGINT:return n.toBigInt();case F.NUMBER:return n.toNumber();default:return n.toString()}}var ue=class{constructor(e){this.info=e}prepare(){var e;if(this.fMap===void 0){this.fMap={};let t=(e=this.info.fields)!==null&&e!==void 0?e:[];for(let r of t)this.fMap[r.name]=r,this.fMap[r.jsonName]=r,this.fMap[r.localName]=r}}assert(e,t,r){if(!e){let i=Q(r);throw(i=="number"||i=="boolean")&&(i=r.toString()),new Error(`Cannot parse JSON ${i} for ${this.info.typeName}#${t}`)}}read(e,t,r){this.prepare();let i=[];for(let[s,o]of Object.entries(e)){let a=this.fMap[s];if(!a){if(!r.ignoreUnknownFields)throw new Error(`Found unknown field while reading ${this.info.typeName} from JSON format. JSON key: ${s}`);continue}let u=a.localName,c;if(a.oneof){if(o===null&&(a.kind!=="enum"||a.T()[0]!=="google.protobuf.NullValue"))continue;if(i.includes(a.oneof))throw new Error(`Multiple members of the oneof group "${a.oneof}" of ${this.info.typeName} are present in JSON.`);i.push(a.oneof),c=t[a.oneof]={oneofKind:u}}else c=t;if(a.kind=="map"){if(o===null)continue;this.assert(Se(o),a.name,o);let d=c[u];for(let[I,y]of Object.entries(o)){this.assert(y!==null,a.name+" map value",null);let m;switch(a.V.kind){case"message":m=a.V.T().internalJsonRead(y,r);break;case"enum":if(m=this.enum(a.V.T(),y,a.name,r.ignoreUnknownFields),m===!1)continue;break;case"scalar":m=this.scalar(y,a.V.T,a.V.L,a.name);break}this.assert(m!==void 0,a.name+" map value",y);let w=I;a.K==f.BOOL&&(w=w=="true"?!0:w=="false"?!1:w),w=this.scalar(w,a.K,F.STRING,a.name).toString(),d[w]=m}}else if(a.repeat){if(o===null)continue;this.assert(Array.isArray(o),a.name,o);let d=c[u];for(let I of o){this.assert(I!==null,a.name,null);let y;switch(a.kind){case"message":y=a.T().internalJsonRead(I,r);break;case"enum":if(y=this.enum(a.T(),I,a.name,r.ignoreUnknownFields),y===!1)continue;break;case"scalar":y=this.scalar(I,a.T,a.L,a.name);break}this.assert(y!==void 0,a.name,o),d.push(y)}}else switch(a.kind){case"message":if(o===null&&a.T().typeName!="google.protobuf.Value"){this.assert(a.oneof===void 0,a.name+" (oneof member)",null);continue}c[u]=a.T().internalJsonRead(o,r,c[u]);break;case"enum":let d=this.enum(a.T(),o,a.name,r.ignoreUnknownFields);if(d===!1)continue;c[u]=d;break;case"scalar":c[u]=this.scalar(o,a.T,a.L,a.name);break}}}enum(e,t,r,i){if(e[0]=="google.protobuf.NullValue"&&g(t===null||t==="NULL_VALUE",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} only accepts null.`),t===null)return 0;switch(typeof t){case"number":return g(Number.isInteger(t),`Unable to parse field ${this.info.typeName}#${r}, enum can only be integral number, got ${t}.`),t;case"string":let s=t;e[2]&&t.substring(0,e[2].length)===e[2]&&(s=t.substring(e[2].length));let o=e[1][s];return typeof o>"u"&&i?!1:(g(typeof o=="number",`Unable to parse field ${this.info.typeName}#${r}, enum ${e[0]} has no value for "${t}".`),o)}g(!1,`Unable to parse field ${this.info.typeName}#${r}, cannot parse enum value from ${typeof t}".`)}scalar(e,t,r,i){let s;try{switch(t){case f.DOUBLE:case f.FLOAT:if(e===null)return 0;if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""){s="empty string";break}if(typeof e=="string"&&e.trim().length!==e.length){s="extra whitespace";break}if(typeof e!="string"&&typeof e!="number")break;let o=Number(e);if(Number.isNaN(o)){s="not a number";break}if(!Number.isFinite(o)){s="too large or small";break}return t==f.FLOAT&&X(o),o;case f.INT32:case f.FIXED32:case f.SFIXED32:case f.SINT32:case f.UINT32:if(e===null)return 0;let a;if(typeof e=="number"?a=e:e===""?s="empty string":typeof e=="string"&&(e.trim().length!==e.length?s="extra whitespace":a=Number(e)),a===void 0)break;return t==f.UINT32?j(a):P(a),a;case f.INT64:case f.SFIXED64:case f.SINT64:if(e===null)return S(N.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return S(N.from(e),r);case f.FIXED64:case f.UINT64:if(e===null)return S(E.ZERO,r);if(typeof e!="number"&&typeof e!="string")break;return S(E.from(e),r);case f.BOOL:if(e===null)return!1;if(typeof e!="boolean")break;return e;case f.STRING:if(e===null)return"";if(typeof e!="string"){s="extra whitespace";break}try{encodeURIComponent(e)}catch(u){u="invalid UTF8";break}return e;case f.BYTES:if(e===null||e==="")return new Uint8Array(0);if(typeof e!="string")break;return Z(e)}}catch(o){s=o.message}this.assert(!1,i+(s?" - "+s:""),e)}};var Fr=h(l());var ce=class{constructor(e){var t;this.fields=(t=e.fields)!==null&&t!==void 0?t:[]}write(e,t){let r={},i=e;for(let s of this.fields){if(!s.oneof){let c=this.field(s,i[s.localName],t);c!==void 0&&(r[t.useProtoFieldName?s.name:s.jsonName]=c);continue}let o=i[s.oneof];if(o.oneofKind!==s.localName)continue;let a=s.kind=="scalar"||s.kind=="enum"?Object.assign(Object.assign({},t),{emitDefaultValues:!0}):t,u=this.field(s,o[s.localName],a);g(u!==void 0),r[t.useProtoFieldName?s.name:s.jsonName]=u}return r}field(e,t,r){let i;if(e.kind=="map"){g(typeof t=="object"&&t!==null);let s={};switch(e.V.kind){case"scalar":for(let[u,c]of Object.entries(t)){let d=this.scalar(e.V.T,c,e.name,!1,!0);g(d!==void 0),s[u.toString()]=d}break;case"message":let o=e.V.T();for(let[u,c]of Object.entries(t)){let d=this.message(o,c,e.name,r);g(d!==void 0),s[u.toString()]=d}break;case"enum":let a=e.V.T();for(let[u,c]of Object.entries(t)){g(c===void 0||typeof c=="number");let d=this.enum(a,c,e.name,!1,!0,r.enumAsInteger);g(d!==void 0),s[u.toString()]=d}break}(r.emitDefaultValues||Object.keys(s).length>0)&&(i=s)}else if(e.repeat){g(Array.isArray(t));let s=[];switch(e.kind){case"scalar":for(let u=0;u0||r.emitDefaultValues)&&(i=s)}else switch(e.kind){case"scalar":i=this.scalar(e.T,t,e.name,e.opt,r.emitDefaultValues);break;case"enum":i=this.enum(e.T(),t,e.name,e.opt,r.emitDefaultValues,r.enumAsInteger);break;case"message":i=this.message(e.T(),t,e.name,r);break}return i}enum(e,t,r,i,s,o){if(e[0]=="google.protobuf.NullValue")return!s&&!i?void 0:null;if(t===void 0){g(i);return}if(!(t===0&&!s&&!i))return g(typeof t=="number"),g(Number.isInteger(t)),o||!e[1].hasOwnProperty(t)?t:e[2]?e[2]+e[1][t]:e[1][t]}message(e,t,r,i){return t===void 0?i.emitDefaultValues?null:void 0:e.internalJsonWrite(t,i)}scalar(e,t,r,i,s){if(t===void 0){g(i);return}let o=s||i;switch(e){case f.INT32:case f.SFIXED32:case f.SINT32:return t===0?o?0:void 0:(P(t),t);case f.FIXED32:case f.UINT32:return t===0?o?0:void 0:(j(t),t);case f.FLOAT:X(t);case f.DOUBLE:return t===0?o?0:void 0:(g(typeof t=="number"),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t);case f.STRING:return t===""?o?"":void 0:(g(typeof t=="string"),t);case f.BOOL:return t===!1?o?!1:void 0:(g(typeof t=="boolean"),t);case f.UINT64:case f.FIXED64:g(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let a=E.from(t);return a.isZero()&&!o?void 0:a.toString();case f.INT64:case f.SFIXED64:case f.SINT64:g(typeof t=="number"||typeof t=="string"||typeof t=="bigint");let u=N.from(t);return u.isZero()&&!o?void 0:u.toString();case f.BYTES:return g(t instanceof Uint8Array),t.byteLength?ye(t):o?"":void 0}}};var Pr=h(l());var Dr=h(l());function z(n,e=F.STRING){switch(n){case f.BOOL:return!1;case f.UINT64:case f.FIXED64:return S(E.ZERO,e);case f.INT64:case f.SFIXED64:case f.SINT64:return S(N.ZERO,e);case f.DOUBLE:case f.FLOAT:return 0;case f.BYTES:return new Uint8Array(0);case f.STRING:return"";default:return 0}}var le=class{constructor(e){this.info=e}prepare(){var e;if(!this.fieldNoToField){let t=(e=this.info.fields)!==null&&e!==void 0?e:[];this.fieldNoToField=new Map(t.map(r=>[r.no,r]))}}read(e,t,r,i){this.prepare();let s=i===void 0?e.len:e.pos+i;for(;e.post.no-r.no)}}write(e,t,r){this.prepare();for(let s of this.fields){let o,a,u=s.repeat,c=s.localName;if(s.oneof){let d=e[s.oneof];if(d.oneofKind!==c)continue;o=d[c],a=!0}else o=e[c],a=!1;switch(s.kind){case"scalar":case"enum":let d=s.kind=="enum"?f.INT32:s.T;if(u)if(g(Array.isArray(o)),u==v.PACKED)this.packed(t,d,s.no,o);else for(let I of o)this.scalar(t,d,s.no,I,!0);else o===void 0?g(s.opt):this.scalar(t,d,s.no,o,a||s.opt);break;case"message":if(u){g(Array.isArray(o));for(let I of o)this.message(t,r,s.T(),s.no,I)}else this.message(t,r,s.T(),s.no,o);break;case"map":g(typeof o=="object"&&o!==null);for(let[I,y]of Object.entries(o))this.mapEntry(t,r,s,I,y);break}}let i=r.writeUnknownFields;i!==!1&&(i===!0?D.onWrite:i)(this.info.typeName,e,t)}mapEntry(e,t,r,i,s){e.tag(r.no,b.LengthDelimited),e.fork();let o=i;switch(r.K){case f.INT32:case f.FIXED32:case f.UINT32:case f.SFIXED32:case f.SINT32:o=Number.parseInt(i);break;case f.BOOL:g(i=="true"||i=="false"),o=i=="true";break}switch(this.scalar(e,r.K,1,o,!0),r.V.kind){case"scalar":this.scalar(e,r.V.T,2,s,!0);break;case"enum":this.scalar(e,f.INT32,2,s,!0);break;case"message":this.message(e,t,r.V.T(),2,s);break}e.join()}message(e,t,r,i,s){s!==void 0&&(r.internalBinaryWrite(s,e.tag(i,b.LengthDelimited).fork(),t),e.join())}scalar(e,t,r,i,s){let[o,a,u]=this.scalarInfo(t,i);(!u||s)&&(e.tag(r,o),e[a](i))}packed(e,t,r,i){if(!i.length)return;g(t!==f.BYTES&&t!==f.STRING),e.tag(r,b.LengthDelimited),e.fork();let[,s]=this.scalarInfo(t);for(let o=0;oOe}])}create(e){let t=globalThis.Object.create(this.messagePrototype);return e!==void 0&&M(this,t,e),t}internalBinaryRead(e,t,r,i){let s=i??this.create(),o=e.pos+t;for(;e.posnew de(e,t,r),Surge:(e,t,r)=>new H(e,t,r),Loon:(e,t,r)=>new Ee(e,t,r)});var pe=class extends ${getFn(e,t,r){let i=pe.clientAdapter[t]||t;return super.getFn(e,i,r)}setFn(e,t,r,i){let s=pe.clientAdapter[t]||t;return super.setFn(e,s,r,i)}init(){try{this.request=this.createProxy($request),this.response=this.createProxy($response)}catch(e){this.debug(e.toString())}}getVal(e){return $persistentStore.read(e)}setVal(e,t){$persistentStore.write(e,t)}msg(e=this.name,t="",r="",i){let s={};i&&(s={action:{"open-url":i}}),$notification.post(e,t,r,s)}async fetch(e){return await new Promise((t,r)=>{let{method:i,body:s,bodyBytes:o,...a}=e,u=o??s,c=u instanceof Uint8Array;$httpClient[i.toLowerCase()]({...a,body:u,"binary-mode":c},(d,I,y)=>{d&&r(d);let m=c?"bodyBytes":"body";t({status:I.status??I.statusCode,headers:I.headers,[m]:y})})})}done(e){let t=e.response??e;t.bodyBytes&&(t.body=t.bodyBytes,delete t.bodyBytes),$done(e.response?{response:t}:t)}decodeParams(e){return typeof $argument=="string"&&!$argument.includes("{{{")&&Object.assign(e,JSON.parse($argument)),e}},H=pe;Y(H,"clientAdapter",{bodyBytes:"body"});var q=class extends ${static transferBodyBytes(e,t){return e instanceof ArrayBuffer?t==="Uint8Array"?new Uint8Array(e):e:e instanceof Uint8Array&&t==="ArrayBuffer"?e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset):e}init(){try{this.request=this.createProxy($request),this.response=this.createProxy($response)}catch(e){this.debug(e.toString())}}getFn(e,t,r){let i=q.clientAdapter[t]||t,s=super.getFn(e,i,r);return t==="bodyBytes"&&(s=q.transferBodyBytes(s,"Uint8Array")),s}setFn(e,t,r,i){let s=q.clientAdapter[t]||t,o=r;return t==="bodyBytes"&&(o=q.transferBodyBytes(o,"Uint8Array")),super.setFn(e,s,o,i)}getVal(e){return $prefs.valueForKey(e)}setVal(e,t){$prefs.setValueForKey(e,t)}msg(e=this.name,t="",r="",i){$notify(e,t,r,{"open-url":i??""})}async fetch(e){return await new Promise(t=>{let r={url:"",method:"GET"};for(let[i,s]of Object.entries(e))i==="id"?r.sessionIndex=s:i==="bodyBytes"?r.bodyBytes=q.transferBodyBytes(s,"ArrayBuffer"):r[i]=s;e.bodyBytes&&delete r.body,$task.fetch(r).then(i=>{let s={status:200,headers:{}};for(let[o,a]of Object.entries(i))o==="sessionIndex"?s.id=a:o==="bodyBytes"?s.bodyBytes=q.transferBodyBytes(a,"Uint8Array"):o==="statusCode"?s.status=a:s[o]=a;t(s)})})}done(e){let t=e.response??e,r={};for(let[i,s]of Object.entries(t))i==="status"?r.status=`HTTP/1.1 ${s}`:i==="bodyBytes"?r.bodyBytes=q.transferBodyBytes(s,"ArrayBuffer"):r[i]=s;$done(r)}},de=q;Y(de,"clientAdapter",{id:"sessionIndex",status:"statusCode"});var Ee=class extends H{decodeParams(e){if(typeof $argument<"u")for(let t of Object.keys(e)){let r=$argument?.[t];r!==void 0&&(e[t]=r)}return e}};var Pn=h(l(),1),Be={config:"YouTubeConfig",advertiseInfo:"YouTubeAdvertiseInfo"},Re={music:"youtubeMusic",video:"youtube"},Qe="https://init-stream.maasea.workers.dev/";var R=$.getInstance("YouTube");function Tt(){return(R.request.headers["user-agent"]??R.request.headers["User-Agent"]).includes("music")}function Fe(){return Tt()?Re.music:Re.video}var Gn=h(l(),1);function et(){return R.decodeParams({captionLang:"off",blockUpload:!0,blockImmersive:!0,blockShorts:!1})}var zn=h(l(),1);function tt(){return R.getJSON(Be.config)??{}}function rt(n){R.debug(`saveKeyConfig: ${JSON.stringify(n)}`),R.setJSON(n,Be.config)}function Et(){let n=He({url:R.request.url,headers:R.request.headers,bodyBytes:R.request.bodyBytes,config:tt(),params:et(),platformKey:Fe(),workerUrl:Qe});switch(n.changed&&rt(n.config),n.action){case"headers":R.debug("log_event: \u5265\u79BB content-encoding \u5934\uFF0C\u5E76\u6309\u7F13\u5B58\u72B6\u6001\u51B3\u5B9A\u662F\u5426\u5220 hot-hash \u5934"),R.done({headers:n.headers});break;case"redirect":R.debug("initplayback: \u547D\u4E2D\u7F13\u5B58 key\uFF0C\u91CD\u5B9A\u5411\u5230 Worker \u5904\u7406 UMP"),$done({url:n.redirectUrl});break;case"empty":R.debug("initplayback: encryptedClientKey \u4E0E\u7F13\u5B58\u4E0D\u4E00\u81F4\uFF0C\u9000\u56DE v1/player \u5E76\u6E05\u7F13\u5B58"),$done({response:{status:200,headers:{"Content-Type":"text/plain"},body:new Uint8Array}});break;default:R.exit()}}Et();})();