/* eslint-disable */ var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; // node_modules/tslib/tslib.es6.mjs function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } __name(__rest, "__rest"); function __setFunctionName(f, name, prefix) { if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); } __name(__setFunctionName, "__setFunctionName"); function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function(resolve) { resolve(value); }); } __name(adopt, "adopt"); return new (P || (P = Promise))(function(resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } __name(fulfilled, "fulfilled"); function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } __name(rejected, "rejected"); function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } __name(step, "step"); step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } __name(__awaiter, "__awaiter"); function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function() { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } __name(__values, "__values"); function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } __name(__await, "__await"); function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { return this; }, i; function verb(n) { if (g[n]) i[n] = function(v) { return new Promise(function(a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } __name(verb, "verb"); function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } __name(resume, "resume"); function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } __name(step, "step"); function fulfill(value) { resume("next", value); } __name(fulfill, "fulfill"); function reject(value) { resume("throw", value); } __name(reject, "reject"); function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } __name(settle, "settle"); } __name(__asyncGenerator, "__asyncGenerator"); function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { return this; }, i); function verb(n) { i[n] = o[n] && function(v) { return new Promise(function(resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } __name(verb, "verb"); function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v2) { resolve({ value: v2, done: d }); }, reject); } __name(settle, "settle"); } __name(__asyncValues, "__asyncValues"); function __classPrivateFieldGet(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); } __name(__classPrivateFieldGet, "__classPrivateFieldGet"); function __classPrivateFieldSet(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; } __name(__classPrivateFieldSet, "__classPrivateFieldSet"); // dist/src/utils/Utils.js var Utils_exports = {}; __export(Utils_exports, { ChannelError: () => ChannelError, InnertubeError: () => InnertubeError, MissingParamError: () => MissingParamError, OAuthError: () => OAuthError, ParsingError: () => ParsingError, Platform: () => Platform, PlayerError: () => PlayerError, SessionError: () => SessionError, base64ToU8: () => base64ToU8, concatMemos: () => concatMemos, debugFetch: () => debugFetch, deepCompare: () => deepCompare, escapeStringRegexp: () => escapeStringRegexp, generateRandomString: () => generateRandomString, generateSidAuth: () => generateSidAuth, getRandomUserAgent: () => getRandomUserAgent, getStringBetweenStrings: () => getStringBetweenStrings, hasKeys: () => hasKeys, isTextRun: () => isTextRun, streamToIterable: () => streamToIterable, throwIfMissing: () => throwIfMissing, timeToSeconds: () => timeToSeconds, u8ToBase64: () => u8ToBase64 }); // dist/src/parser/helpers.js var helpers_exports = {}; __export(helpers_exports, { Maybe: () => Maybe, Memo: () => Memo, SuperParsedResult: () => SuperParsedResult, YTNode: () => YTNode, observe: () => observe }); // dist/src/utils/Log.js var _a; var Log = class { static doLog(level, tag, args) { if (!this.log_map_[level] || !this.log_level_.includes(level)) return; const tags = [`[${this.YTJS_TAG}]`]; if (tag) tags.push(`[${tag}]`); this.log_map_[level](`${tags.join("")}:`, ...args || []); } static setLevel(...args) { this.log_level_ = args; } }; __name(Log, "Log"); _a = Log; Log.YTJS_TAG = "YOUTUBEJS"; Log.Level = { NONE: 0, ERROR: 1, WARNING: 2, INFO: 3, DEBUG: 4 }; Log.log_map_ = { [Log.Level.ERROR]: (...args) => console.error(...args), [Log.Level.WARNING]: (...args) => console.warn(...args), [Log.Level.INFO]: (...args) => console.info(...args), [Log.Level.DEBUG]: (...args) => console.debug(...args) }; Log.log_level_ = [Log.Level.WARNING]; Log.one_time_warnings_issued_ = /* @__PURE__ */ new Set(); Log.warnOnce = (id, ...args) => { if (_a.one_time_warnings_issued_.has(id)) return; _a.doLog(Log.Level.WARNING, id, args); _a.one_time_warnings_issued_.add(id); }; Log.warn = (tag, ...args) => _a.doLog(Log.Level.WARNING, tag, args); Log.error = (tag, ...args) => _a.doLog(Log.Level.ERROR, tag, args); Log.info = (tag, ...args) => _a.doLog(Log.Level.INFO, tag, args); Log.debug = (tag, ...args) => _a.doLog(Log.Level.DEBUG, tag, args); var Log_default = Log; // dist/src/parser/helpers.js var _YTNode_instances; var _YTNode_is; var _Maybe_instances; var _Maybe_TAG; var _Maybe_value; var _Maybe_checkPrimative; var _Maybe_assertPrimative; var _SuperParsedResult_result; var isObserved = Symbol("ObservedArray.isObserved"); var YTNode = class { constructor() { _YTNode_instances.add(this); this.type = this.constructor.type; } is(...types2) { return types2.some((type) => __classPrivateFieldGet(this, _YTNode_instances, "m", _YTNode_is).call(this, type)); } as(...types2) { if (!this.is(...types2)) { throw new ParsingError(`Cannot cast ${this.type} to one of ${types2.map((t) => t.type).join(", ")}`); } return this; } hasKey(key) { return Reflect.has(this, key); } key(key) { if (!this.hasKey(key)) { throw new ParsingError(`Missing key ${key}`); } return new Maybe(this[key]); } }; __name(YTNode, "YTNode"); _YTNode_instances = /* @__PURE__ */ new WeakSet(), _YTNode_is = /* @__PURE__ */ __name(function _YTNode_is2(type) { return this.type === type.type; }, "_YTNode_is"); YTNode.type = "YTNode"; var Maybe = class { constructor(value) { _Maybe_instances.add(this); _Maybe_TAG.set(this, "Maybe"); _Maybe_value.set(this, void 0); __classPrivateFieldSet(this, _Maybe_value, value, "f"); } get typeof() { return typeof __classPrivateFieldGet(this, _Maybe_value, "f"); } string() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "string"); } isString() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "string"); } number() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "number"); } isNumber() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "number"); } bigint() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "bigint"); } isBigint() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "bigint"); } boolean() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "boolean"); } isBoolean() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "boolean"); } symbol() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "symbol"); } isSymbol() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "symbol"); } undefined() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "undefined"); } isUndefined() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "undefined"); } null() { if (__classPrivateFieldGet(this, _Maybe_value, "f") !== null) throw new TypeError(`Expected null, got ${typeof __classPrivateFieldGet(this, _Maybe_value, "f")}`); return __classPrivateFieldGet(this, _Maybe_value, "f"); } isNull() { return __classPrivateFieldGet(this, _Maybe_value, "f") === null; } object() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "object"); } isObject() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "object"); } function() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_assertPrimative).call(this, "function"); } isFunction() { return __classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, "function"); } array() { if (!Array.isArray(__classPrivateFieldGet(this, _Maybe_value, "f"))) { throw new TypeError(`Expected array, got ${typeof __classPrivateFieldGet(this, _Maybe_value, "f")}`); } return __classPrivateFieldGet(this, _Maybe_value, "f"); } arrayOfMaybe() { const arrayProps = []; return new Proxy(this.array(), { get(target, prop) { if (Reflect.has(arrayProps, prop)) { return Reflect.get(target, prop); } return new Maybe(Reflect.get(target, prop)); } }); } isArray() { return Array.isArray(__classPrivateFieldGet(this, _Maybe_value, "f")); } node() { if (!(__classPrivateFieldGet(this, _Maybe_value, "f") instanceof YTNode)) { throw new TypeError(`Expected YTNode, got ${__classPrivateFieldGet(this, _Maybe_value, "f").constructor.name}`); } return __classPrivateFieldGet(this, _Maybe_value, "f"); } isNode() { return __classPrivateFieldGet(this, _Maybe_value, "f") instanceof YTNode; } nodeOfType(...types2) { return this.node().as(...types2); } isNodeOfType(...types2) { return this.isNode() && this.node().is(...types2); } observed() { if (!this.isObserved()) { throw new TypeError(`Expected ObservedArray, got ${typeof __classPrivateFieldGet(this, _Maybe_value, "f")}`); } return __classPrivateFieldGet(this, _Maybe_value, "f"); } isObserved() { var _a4; return (_a4 = __classPrivateFieldGet(this, _Maybe_value, "f")) === null || _a4 === void 0 ? void 0 : _a4[isObserved]; } parsed() { if (!(__classPrivateFieldGet(this, _Maybe_value, "f") instanceof SuperParsedResult)) { throw new TypeError(`Expected SuperParsedResult, got ${typeof __classPrivateFieldGet(this, _Maybe_value, "f")}`); } return __classPrivateFieldGet(this, _Maybe_value, "f"); } isParsed() { return __classPrivateFieldGet(this, _Maybe_value, "f") instanceof SuperParsedResult; } any() { Log_default.warn(__classPrivateFieldGet(this, _Maybe_TAG, "f"), "This call is not meant to be used outside of debugging. Please use the specific type getter instead."); return __classPrivateFieldGet(this, _Maybe_value, "f"); } instanceof(type) { if (!this.isInstanceof(type)) { throw new TypeError(`Expected instance of ${type.name}, got ${__classPrivateFieldGet(this, _Maybe_value, "f").constructor.name}`); } return __classPrivateFieldGet(this, _Maybe_value, "f"); } isInstanceof(type) { return __classPrivateFieldGet(this, _Maybe_value, "f") instanceof type; } }; __name(Maybe, "Maybe"); _Maybe_TAG = /* @__PURE__ */ new WeakMap(), _Maybe_value = /* @__PURE__ */ new WeakMap(), _Maybe_instances = /* @__PURE__ */ new WeakSet(), _Maybe_checkPrimative = /* @__PURE__ */ __name(function _Maybe_checkPrimative2(type) { if (typeof __classPrivateFieldGet(this, _Maybe_value, "f") !== type) { return false; } return true; }, "_Maybe_checkPrimative"), _Maybe_assertPrimative = /* @__PURE__ */ __name(function _Maybe_assertPrimative2(type) { if (!__classPrivateFieldGet(this, _Maybe_instances, "m", _Maybe_checkPrimative).call(this, type)) { throw new TypeError(`Expected ${type}, got ${this.typeof}`); } return __classPrivateFieldGet(this, _Maybe_value, "f"); }, "_Maybe_assertPrimative"); var SuperParsedResult = class { constructor(result) { _SuperParsedResult_result.set(this, void 0); __classPrivateFieldSet(this, _SuperParsedResult_result, result, "f"); } get is_null() { return __classPrivateFieldGet(this, _SuperParsedResult_result, "f") === null; } get is_array() { return !this.is_null && Array.isArray(__classPrivateFieldGet(this, _SuperParsedResult_result, "f")); } get is_node() { return !this.is_array; } array() { if (!this.is_array) { throw new TypeError("Expected an array, got a node"); } return __classPrivateFieldGet(this, _SuperParsedResult_result, "f"); } item() { if (!this.is_node) { throw new TypeError("Expected a node, got an array"); } return __classPrivateFieldGet(this, _SuperParsedResult_result, "f"); } }; __name(SuperParsedResult, "SuperParsedResult"); _SuperParsedResult_result = /* @__PURE__ */ new WeakMap(); function observe(obj) { return new Proxy(obj, { get(target, prop) { if (prop == "get") { return (rule, del_item) => target.find((obj2, index) => { const match = deepCompare(rule, obj2); if (match && del_item) { target.splice(index, 1); } return match; }); } if (prop == isObserved) { return true; } if (prop == "getAll") { return (rule, del_items) => target.filter((obj2, index) => { const match = deepCompare(rule, obj2); if (match && del_items) { target.splice(index, 1); } return match; }); } if (prop == "matchCondition") { return (condition) => target.find((obj2) => { return condition(obj2); }); } if (prop == "filterType") { return (...types2) => { return observe(target.filter((node) => { if (node.is(...types2)) return true; return false; })); }; } if (prop == "firstOfType") { return (...types2) => { return target.find((node) => { if (node.is(...types2)) return true; return false; }); }; } if (prop == "first") { return () => target[0]; } if (prop == "as") { return (...types2) => { return observe(target.map((node) => { if (node.is(...types2)) return node; throw new ParsingError(`Expected node of any type ${types2.map((type) => type.type).join(", ")}, got ${node.type}`); })); }; } if (prop == "remove") { return (index) => target.splice(index, 1); } return Reflect.get(target, prop); } }); } __name(observe, "observe"); var Memo = class extends Map { getType(...types2) { types2 = types2.flat(); return observe(types2.flatMap((type) => this.get(type.type) || [])); } }; __name(Memo, "Memo"); // dist/src/parser/misc.js var misc_exports = {}; __export(misc_exports, { Author: () => Author, ChildElement: () => ChildElement_default, EmojiRun: () => EmojiRun, Format: () => Format_default, Text: () => Text2, TextRun: () => TextRun, Thumbnail: () => Thumbnail, VideoDetails: () => VideoDetails }); // dist/src/utils/Constants.js var Constants_exports = {}; __export(Constants_exports, { CLIENTS: () => CLIENTS, INNERTUBE_HEADERS_BASE: () => INNERTUBE_HEADERS_BASE, OAUTH: () => OAUTH, STREAM_HEADERS: () => STREAM_HEADERS, URLS: () => URLS }); var URLS = Object.freeze({ YT_BASE: "https://www.youtube.com", YT_MUSIC_BASE: "https://music.youtube.com", YT_SUGGESTIONS: "https://suggestqueries.google.com/complete/", YT_UPLOAD: "https://upload.youtube.com/", API: Object.freeze({ BASE: "https://youtubei.googleapis.com", PRODUCTION_1: "https://www.youtube.com/youtubei/", PRODUCTION_2: "https://youtubei.googleapis.com/youtubei/", STAGING: "https://green-youtubei.sandbox.googleapis.com/youtubei/", RELEASE: "https://release-youtubei.sandbox.googleapis.com/youtubei/", TEST: "https://test-youtubei.sandbox.googleapis.com/youtubei/", CAMI: "http://cami-youtubei.sandbox.googleapis.com/youtubei/", UYTFE: "https://uytfe.sandbox.google.com/youtubei/" }) }); var OAUTH = Object.freeze({ SCOPE: "http://gdata.youtube.com https://www.googleapis.com/auth/youtube-paid-content", GRANT_TYPE: "http://oauth.net/grant_type/device/1.0", MODEL_NAME: "ytlr::", HEADERS: Object.freeze({ "accept": "*/*", "origin": "https://www.youtube.com", "user-agent": "Mozilla/5.0 (ChromiumStylePlatform) Cobalt/Version", "content-type": "application/json", "referer": "https://www.youtube.com/tv", "accept-language": "en-US" }), REGEX: Object.freeze({ AUTH_SCRIPT: /