UNPKG

starknetkit

Version:

<!-- logo --> <p align="center"> <img width='300' src="https://starknetkit-website-git-blo-1541-argentlabs.vercel.app/starknetKit-logo.svg"> </p>

1,481 lines (1,477 loc) 122 kB
var te = Object.defineProperty, ne = (t, e, o) => e in t ? te(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o, _ = (t, e, o) => (ne(t, typeof e != "symbol" ? e + "" : e, o), o), K = (t, e, o) => { if (!e.has(t)) throw TypeError("Cannot " + o); }, N = (t, e, o) => (K(t, e, "read from private field"), o ? o.call(t) : e.get(t)), T = (t, e, o) => { if (e.has(t)) throw TypeError("Cannot add the same private member more than once"); e instanceof WeakSet ? e.add(t) : e.set(t, o); }, B = (t, e, o, n) => (K(t, e, "write to private field"), n ? n.call(t, o) : e.set(t, o), o), E = (t, e, o) => (K(t, e, "access private method"), o); const generateUID = () => `${Date.now()}-${Math.floor(Math.random() * 8999999999999) + 1e12}`, shuffle = (t) => { for (let e = t.length - 1; e > 0; e--) { const o = Math.floor(Math.random() * (e + 1)); [t[e], t[o]] = [t[o], t[e]]; } return t; }, pipe$1 = (...t) => (e) => t.reduce((o, n) => o.then(n), Promise.resolve(e)); function ensureKeysArray(t) { return Object.keys(t); } const ssrSafeWindow = typeof window < "u" ? window : null; function getBuilderId() { return typeof FEDERATION_BUILD_IDENTIFIER < "u" ? FEDERATION_BUILD_IDENTIFIER : ""; } function isDebugMode$1() { return !!""; } function isBrowserEnv$1() { return typeof window < "u"; } const LOG_CATEGORY$1 = "[ Federation Runtime ]"; function assert(t, e) { t || error(e); } function error(t) { throw t instanceof Error ? (t.message = `${LOG_CATEGORY$1}: ${t.message}`, t) : new Error(`${LOG_CATEGORY$1}: ${t}`); } function warn$1(t) { t instanceof Error ? (t.message = `${LOG_CATEGORY$1}: ${t.message}`, console.warn(t)) : console.warn(`${LOG_CATEGORY$1}: ${t}`); } function addUniqueItem(t, e) { return t.findIndex((o) => o === e) === -1 && t.push(e), t; } function getFMId(t) { return "version" in t && t.version ? `${t.name}:${t.version}` : "entry" in t && t.entry ? `${t.name}:${t.entry}` : `${t.name}`; } function isRemoteInfoWithEntry(t) { return typeof t.entry < "u"; } function isPureRemoteEntry(t) { return !t.entry.includes(".json") && t.entry.includes(".js"); } function safeToString$1(t) { try { return JSON.stringify(t, null, 2); } catch { return ""; } } function isObject(t) { return t && typeof t == "object"; } const objectToString = Object.prototype.toString; function isPlainObject(t) { return objectToString.call(t) === "[object Object]"; } function _extends$1$1() { return _extends$1$1 = Object.assign || function(t) { for (var e = 1; e < arguments.length; e++) { var o = arguments[e]; for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && (t[n] = o[n]); } return t; }, _extends$1$1.apply(this, arguments); } function _object_without_properties_loose$1(t, e) { if (t == null) return {}; var o = {}, n = Object.keys(t), r, i; for (i = 0; i < n.length; i++) r = n[i], !(e.indexOf(r) >= 0) && (o[r] = t[r]); return o; } const nativeGlobal = (() => { try { return new Function("return this")(); } catch { return globalThis; } })(), Global = nativeGlobal; function definePropertyGlobalVal(t, e, o) { Object.defineProperty(t, e, { value: o, configurable: !1, writable: !0 }); } function includeOwnProperty(t, e) { return Object.hasOwnProperty.call(t, e); } includeOwnProperty(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__") || definePropertyGlobalVal(globalThis, "__GLOBAL_LOADING_REMOTE_ENTRY__", {}); const globalLoading = globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__; function setGlobalDefaultVal(t) { var e, o, n, r, i, a; includeOwnProperty(t, "__VMOK__") && !includeOwnProperty(t, "__FEDERATION__") && definePropertyGlobalVal(t, "__FEDERATION__", t.__VMOK__), includeOwnProperty(t, "__FEDERATION__") || (definePropertyGlobalVal(t, "__FEDERATION__", { __GLOBAL_PLUGIN__: [], __INSTANCES__: [], moduleInfo: {}, __SHARE__: {}, __MANIFEST_LOADING__: {}, __PRELOADED_MAP__: /* @__PURE__ */ new Map() }), definePropertyGlobalVal(t, "__VMOK__", t.__FEDERATION__)), (e = t.__FEDERATION__).__GLOBAL_PLUGIN__ != null || (e.__GLOBAL_PLUGIN__ = []), (o = t.__FEDERATION__).__INSTANCES__ != null || (o.__INSTANCES__ = []), (n = t.__FEDERATION__).moduleInfo != null || (n.moduleInfo = {}), (r = t.__FEDERATION__).__SHARE__ != null || (r.__SHARE__ = {}), (i = t.__FEDERATION__).__MANIFEST_LOADING__ != null || (i.__MANIFEST_LOADING__ = {}), (a = t.__FEDERATION__).__PRELOADED_MAP__ != null || (a.__PRELOADED_MAP__ = /* @__PURE__ */ new Map()); } setGlobalDefaultVal(globalThis); setGlobalDefaultVal(nativeGlobal); function getGlobalFederationInstance(t, e) { const o = getBuilderId(); return globalThis.__FEDERATION__.__INSTANCES__.find((n) => !!(o && n.options.id === getBuilderId() || n.options.name === t && !n.options.version && !e || n.options.name === t && e && n.options.version === e)); } function setGlobalFederationInstance(t) { globalThis.__FEDERATION__.__INSTANCES__.push(t); } function getGlobalFederationConstructor() { return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__; } function setGlobalFederationConstructor(t, e = isDebugMode$1()) { e && (globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = t, globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.1.2"); } function getInfoWithoutType(t, e) { if (typeof e == "string") { if (t[e]) return { value: t[e], key: e }; { const o = Object.keys(t); for (const n of o) { const [r, i] = n.split(":"), a = `${r}:${e}`, s = t[a]; if (s) return { value: s, key: a }; } return { value: void 0, key: e }; } } else throw new Error("key must be string"); } const getGlobalSnapshot = () => nativeGlobal.__FEDERATION__.moduleInfo, getTargetSnapshotInfoByModuleInfo = (t, e) => { const o = getFMId(t), n = getInfoWithoutType(e, o).value; if (n && !n.version && "version" in t && t.version && (n.version = t.version), n) return n; if ("version" in t && t.version) { const { version: r } = t, i = _object_without_properties_loose$1(t, [ "version" ]), a = getFMId(i), s = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, a).value; if (s?.version === r) return s; } }, getGlobalSnapshotInfoByModuleInfo = (t) => getTargetSnapshotInfoByModuleInfo(t, nativeGlobal.__FEDERATION__.moduleInfo), setGlobalSnapshotInfoByModuleInfo = (t, e) => { const o = getFMId(t); return nativeGlobal.__FEDERATION__.moduleInfo[o] = e, nativeGlobal.__FEDERATION__.moduleInfo; }, addGlobalSnapshot = (t) => (nativeGlobal.__FEDERATION__.moduleInfo = _extends$1$1({}, nativeGlobal.__FEDERATION__.moduleInfo, t), () => { const e = Object.keys(t); for (const o of e) delete nativeGlobal.__FEDERATION__.moduleInfo[o]; }), getRemoteEntryExports = (t, e) => { const o = e || `__FEDERATION_${t}:custom__`, n = globalThis[o]; return { remoteEntryKey: o, entryExports: n }; }, getGlobalHostPlugins = () => nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__, getPreloaded = (t) => globalThis.__FEDERATION__.__PRELOADED_MAP__.get(t), setPreloaded = (t) => globalThis.__FEDERATION__.__PRELOADED_MAP__.set(t, !0), DEFAULT_SCOPE = "default", DEFAULT_REMOTE_TYPE = "global", buildIdentifier = "[0-9A-Za-z-]+", build = `(?:\\+(${buildIdentifier}(?:\\.${buildIdentifier})*))`, numericIdentifier = "0|[1-9]\\d*", numericIdentifierLoose = "[0-9]+", nonNumericIdentifier = "\\d*[a-zA-Z-][a-zA-Z0-9-]*", preReleaseIdentifierLoose = `(?:${numericIdentifierLoose}|${nonNumericIdentifier})`, preReleaseLoose = `(?:-?(${preReleaseIdentifierLoose}(?:\\.${preReleaseIdentifierLoose})*))`, preReleaseIdentifier = `(?:${numericIdentifier}|${nonNumericIdentifier})`, preRelease = `(?:-(${preReleaseIdentifier}(?:\\.${preReleaseIdentifier})*))`, xRangeIdentifier = `${numericIdentifier}|x|X|\\*`, xRangePlain = `[v=\\s]*(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:\\.(${xRangeIdentifier})(?:${preRelease})?${build}?)?)?`, hyphenRange = `^\\s*(${xRangePlain})\\s+-\\s+(${xRangePlain})\\s*$`, mainVersionLoose = `(${numericIdentifierLoose})\\.(${numericIdentifierLoose})\\.(${numericIdentifierLoose})`, loosePlain = `[v=\\s]*${mainVersionLoose}${preReleaseLoose}?${build}?`, gtlt = "((?:<|>)?=?)", comparatorTrim = `(\\s*)${gtlt}\\s*(${loosePlain}|${xRangePlain})`, loneTilde = "(?:~>?)", tildeTrim = `(\\s*)${loneTilde}\\s+`, loneCaret = "(?:\\^)", caretTrim = `(\\s*)${loneCaret}\\s+`, star = "(<|>)?=?\\s*\\*", caret = `^${loneCaret}${xRangePlain}$`, mainVersion = `(${numericIdentifier})\\.(${numericIdentifier})\\.(${numericIdentifier})`, fullPlain = `v?${mainVersion}${preRelease}?${build}?`, tilde = `^${loneTilde}${xRangePlain}$`, xRange = `^${gtlt}\\s*${xRangePlain}$`, comparator = `^${gtlt}\\s*(${fullPlain})$|^$`, gte0 = "^\\s*>=\\s*0.0.0\\s*$"; function parseRegex(t) { return new RegExp(t); } function isXVersion(t) { return !t || t.toLowerCase() === "x" || t === "*"; } function pipe(...t) { return (e) => t.reduce((o, n) => n(o), e); } function extractComparator(t) { return t.match(parseRegex(comparator)); } function combineVersion(t, e, o, n) { const r = `${t}.${e}.${o}`; return n ? `${r}-${n}` : r; } function parseHyphen(t) { return t.replace(parseRegex(hyphenRange), (e, o, n, r, i, a, s, c, l, u, h, g) => (isXVersion(n) ? o = "" : isXVersion(r) ? o = `>=${n}.0.0` : isXVersion(i) ? o = `>=${n}.${r}.0` : o = `>=${o}`, isXVersion(l) ? c = "" : isXVersion(u) ? c = `<${Number(l) + 1}.0.0-0` : isXVersion(h) ? c = `<${l}.${Number(u) + 1}.0-0` : g ? c = `<=${l}.${u}.${h}-${g}` : c = `<=${c}`, `${o} ${c}`.trim())); } function parseComparatorTrim(t) { return t.replace(parseRegex(comparatorTrim), "$1$2$3"); } function parseTildeTrim(t) { return t.replace(parseRegex(tildeTrim), "$1~"); } function parseCaretTrim(t) { return t.replace(parseRegex(caretTrim), "$1^"); } function parseCarets(t) { return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(caret), (o, n, r, i, a) => isXVersion(n) ? "" : isXVersion(r) ? `>=${n}.0.0 <${Number(n) + 1}.0.0-0` : isXVersion(i) ? n === "0" ? `>=${n}.${r}.0 <${n}.${Number(r) + 1}.0-0` : `>=${n}.${r}.0 <${Number(n) + 1}.0.0-0` : a ? n === "0" ? r === "0" ? `>=${n}.${r}.${i}-${a} <${n}.${r}.${Number(i) + 1}-0` : `>=${n}.${r}.${i}-${a} <${n}.${Number(r) + 1}.0-0` : `>=${n}.${r}.${i}-${a} <${Number(n) + 1}.0.0-0` : n === "0" ? r === "0" ? `>=${n}.${r}.${i} <${n}.${r}.${Number(i) + 1}-0` : `>=${n}.${r}.${i} <${n}.${Number(r) + 1}.0-0` : `>=${n}.${r}.${i} <${Number(n) + 1}.0.0-0`)).join(" "); } function parseTildes(t) { return t.trim().split(/\s+/).map((e) => e.replace(parseRegex(tilde), (o, n, r, i, a) => isXVersion(n) ? "" : isXVersion(r) ? `>=${n}.0.0 <${Number(n) + 1}.0.0-0` : isXVersion(i) ? `>=${n}.${r}.0 <${n}.${Number(r) + 1}.0-0` : a ? `>=${n}.${r}.${i}-${a} <${n}.${Number(r) + 1}.0-0` : `>=${n}.${r}.${i} <${n}.${Number(r) + 1}.0-0`)).join(" "); } function parseXRanges(t) { return t.split(/\s+/).map((e) => e.trim().replace(parseRegex(xRange), (o, n, r, i, a, s) => { const c = isXVersion(r), l = c || isXVersion(i), u = l || isXVersion(a); return n === "=" && u && (n = ""), s = "", c ? n === ">" || n === "<" ? "<0.0.0-0" : "*" : n && u ? (l && (i = 0), a = 0, n === ">" ? (n = ">=", l ? (r = Number(r) + 1, i = 0, a = 0) : (i = Number(i) + 1, a = 0)) : n === "<=" && (n = "<", l ? r = Number(r) + 1 : i = Number(i) + 1), n === "<" && (s = "-0"), `${n + r}.${i}.${a}${s}`) : l ? `>=${r}.0.0${s} <${Number(r) + 1}.0.0-0` : u ? `>=${r}.${i}.0${s} <${r}.${Number(i) + 1}.0-0` : o; })).join(" "); } function parseStar(t) { return t.trim().replace(parseRegex(star), ""); } function parseGTE0(t) { return t.trim().replace(parseRegex(gte0), ""); } function compareAtom(t, e) { return t = Number(t) || t, e = Number(e) || e, t > e ? 1 : t === e ? 0 : -1; } function comparePreRelease(t, e) { const { preRelease: o } = t, { preRelease: n } = e; if (o === void 0 && n) return 1; if (o && n === void 0) return -1; if (o === void 0 && n === void 0) return 0; for (let r = 0, i = o.length; r <= i; r++) { const a = o[r], s = n[r]; if (a !== s) return a === void 0 && s === void 0 ? 0 : a ? s ? compareAtom(a, s) : -1 : 1; } return 0; } function compareVersion(t, e) { return compareAtom(t.major, e.major) || compareAtom(t.minor, e.minor) || compareAtom(t.patch, e.patch) || comparePreRelease(t, e); } function eq(t, e) { return t.version === e.version; } function compare(t, e) { switch (t.operator) { case "": case "=": return eq(t, e); case ">": return compareVersion(t, e) < 0; case ">=": return eq(t, e) || compareVersion(t, e) < 0; case "<": return compareVersion(t, e) > 0; case "<=": return eq(t, e) || compareVersion(t, e) > 0; case void 0: return !0; default: return !1; } } function parseComparatorString(t) { return pipe( parseCarets, parseTildes, parseXRanges, parseStar )(t); } function parseRange(t) { return pipe( parseHyphen, parseComparatorTrim, parseTildeTrim, parseCaretTrim )(t.trim()).split(/\s+/).join(" "); } function satisfy(t, e) { if (!t) return !1; const o = parseRange(e).split(" ").map((u) => parseComparatorString(u)).join(" ").split(/\s+/).map((u) => parseGTE0(u)), n = extractComparator(t); if (!n) return !1; const [, r, , i, a, s, c] = n, l = { operator: r, version: combineVersion(i, a, s, c), major: i, minor: a, patch: s, preRelease: c?.split(".") }; for (const u of o) { const h = extractComparator(u); if (!h) return !1; const [, g, , p, d, m, M] = h, I = { operator: g, version: combineVersion(p, d, m, M), major: p, minor: d, patch: m, preRelease: M?.split(".") }; if (!compare(I, l)) return !1; } return !0; } function _extends$6() { return _extends$6 = Object.assign || function(t) { for (var e = 1; e < arguments.length; e++) { var o = arguments[e]; for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && (t[n] = o[n]); } return t; }, _extends$6.apply(this, arguments); } function formatShare(t, e) { let o; return "get" in t ? o = t.get : o = () => Promise.resolve(t.lib), _extends$6({ deps: [], useIn: [], from: e, loading: null }, t, { shareConfig: _extends$6({ requiredVersion: `^${t.version}`, singleton: !1, eager: !1, strictVersion: !1 }, t.shareConfig), get: o, loaded: "lib" in t ? !0 : void 0, scope: Array.isArray(t.scope) ? t.scope : [ "default" ], strategy: t.strategy || "version-first" }); } function formatShareConfigs(t, e) { return t ? Object.keys(t).reduce((o, n) => (o[n] = formatShare(t[n], e), o), {}) : {}; } function versionLt(t, e) { const o = (n) => { if (!Number.isNaN(Number(n))) { const r = n.split("."); let i = n; for (let a = 0; a < 3 - r.length; a++) i += ".0"; return i; } return n; }; return !!satisfy(o(t), `<=${o(e)}`); } const findVersion = (t, e, o, n) => { const r = t[e][o], i = n || function(a, s) { return versionLt(a, s); }; return Object.keys(r).reduce((a, s) => !a || i(a, s) || a === "0" ? s : a, 0); }, isLoaded = (t) => !!t.loaded || typeof t.lib == "function"; function findSingletonVersionOrderByVersion(t, e, o) { const n = t[e][o]; return findVersion(t, e, o, function(r, i) { return !isLoaded(n[r]) && versionLt(r, i); }); } function findSingletonVersionOrderByLoaded(t, e, o) { const n = t[e][o]; return findVersion(t, e, o, function(r, i) { return isLoaded(n[i]) ? isLoaded(n[r]) ? !!versionLt(r, i) : !0 : isLoaded(n[r]) ? !1 : versionLt(r, i); }); } function getFindShareFunction(t) { return t === "loaded-first" ? findSingletonVersionOrderByLoaded : findSingletonVersionOrderByVersion; } function getRegisteredShare(t, e, o, n) { if (!t) return; const { shareConfig: r, scope: i = DEFAULT_SCOPE, strategy: a } = o, s = Array.isArray(i) ? i : [ i ]; for (const c of s) if (r && t[c] && t[c][e]) { const { requiredVersion: l } = r, u = getFindShareFunction(a)(t, c, e), h = () => { if (r.singleton) { if (typeof l == "string" && !satisfy(u, l)) { const p = `Version ${u} from ${u && t[c][e][u].from} of shared singleton module ${e} does not satisfy the requirement of ${o.from} which needs ${l})`; r.strictVersion ? error(p) : warn$1(p); } return t[c][e][u]; } else { if (l === !1 || l === "*" || satisfy(u, l)) return t[c][e][u]; for (const [p, d] of Object.entries(t[c][e])) if (satisfy(p, l)) return d; } }, g = { shareScopeMap: t, scope: c, pkgName: e, version: u, GlobalFederation: Global.__FEDERATION__, resolver: h }; return (n.emit(g) || g).resolver(); } } function getGlobalShareScope() { return Global.__FEDERATION__.__SHARE__; } function _define_property$3(t, e, o) { return e in t ? Object.defineProperty(t, e, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = o, t; } var MANIFEST_EXT = ".json", BROWSER_LOG_KEY = "FEDERATION_DEBUG", BROWSER_LOG_VALUE = "1", NameTransformSymbol = { AT: "@", HYPHEN: "-", SLASH: "/" }, _obj, NameTransformMap = (_obj = {}, _define_property$3(_obj, NameTransformSymbol.AT, "scope_"), _define_property$3(_obj, NameTransformSymbol.HYPHEN, "_"), _define_property$3(_obj, NameTransformSymbol.SLASH, "__"), _obj), _obj1; _obj1 = {}, _define_property$3(_obj1, NameTransformMap[NameTransformSymbol.AT], NameTransformSymbol.AT), _define_property$3(_obj1, NameTransformMap[NameTransformSymbol.HYPHEN], NameTransformSymbol.HYPHEN), _define_property$3(_obj1, NameTransformMap[NameTransformSymbol.SLASH], NameTransformSymbol.SLASH); var SEPARATOR = ":"; function isBrowserEnv() { return typeof window < "u"; } function isDebugMode() { return typeof process < "u" && process.env && process.env.FEDERATION_DEBUG ? !!process.env.FEDERATION_DEBUG : typeof FEDERATION_DEBUG < "u" && !!FEDERATION_DEBUG; } function _array_like_to_array$2(t, e) { (e == null || e > t.length) && (e = t.length); for (var o = 0, n = new Array(e); o < e; o++) n[o] = t[o]; return n; } function _array_without_holes(t) { if (Array.isArray(t)) return _array_like_to_array$2(t); } function _class_call_check(t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(t, e) { for (var o = 0; o < e.length; o++) { var n = e[o]; n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n); } } function _create_class(t, e, o) { return e && _defineProperties(t.prototype, e), o && _defineProperties(t, o), t; } function _define_property$2(t, e, o) { return e in t ? Object.defineProperty(t, e, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = o, t; } function _iterable_to_array$1(t) { if (typeof Symbol < "u" && t[Symbol.iterator] != null || t["@@iterator"] != null) return Array.from(t); } function _non_iterable_spread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _to_consumable_array(t) { return _array_without_holes(t) || _iterable_to_array$1(t) || _unsupported_iterable_to_array$2(t) || _non_iterable_spread(); } function _unsupported_iterable_to_array$2(t, e) { if (t) { if (typeof t == "string") return _array_like_to_array$2(t, e); var o = Object.prototype.toString.call(t).slice(8, -1); if (o === "Object" && t.constructor && (o = t.constructor.name), o === "Map" || o === "Set") return Array.from(o); if (o === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)) return _array_like_to_array$2(t, e); } } function safeToString(t) { try { return JSON.stringify(t, null, 2); } catch { return ""; } } var DEBUG_LOG = "[ FEDERATION DEBUG ]"; function safeGetLocalStorageItem() { try { if (typeof window < "u" && window.localStorage) return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE; } catch { return typeof document < "u"; } return !1; } var Logger = /* @__PURE__ */ function() { function t(e) { _class_call_check(this, t), _define_property$2(this, "enable", !1), _define_property$2(this, "identifier", void 0), this.identifier = e || DEBUG_LOG, isBrowserEnv() && safeGetLocalStorageItem() ? this.enable = !0 : isDebugMode() && (this.enable = !0); } return _create_class(t, [ { key: "info", value: function(e, o) { if (this.enable) { var n = safeToString(o) || ""; isBrowserEnv() ? console.info("%c ".concat(this.identifier, ": ").concat(e, " ").concat(n), "color:#3300CC") : console.info("\x1B[34m%s", "".concat(this.identifier, ": ").concat(e, " ").concat(n ? ` `.concat(n) : "")); } } }, { key: "logOriginalInfo", value: function() { for (var e = arguments.length, o = new Array(e), n = 0; n < e; n++) o[n] = arguments[n]; if (this.enable) if (isBrowserEnv()) { var r; console.info("%c ".concat(this.identifier, ": OriginalInfo"), "color:#3300CC"), (r = console).log.apply(r, _to_consumable_array(o)); } else { var i; console.info("%c ".concat(this.identifier, ": OriginalInfo"), "color:#3300CC"), (i = console).log.apply(i, _to_consumable_array(o)); } } } ]), t; }(), LOG_CATEGORY = "[ Federation Runtime ]"; new Logger(); var composeKeyWithSeparator = function() { for (var t = arguments.length, e = new Array(t), o = 0; o < t; o++) e[o] = arguments[o]; return e.length ? e.reduce(function(n, r) { return r ? n ? "".concat(n).concat(SEPARATOR).concat(r) : r : n; }, "") : ""; }, getResourceUrl = function(t, e) { if ("getPublicPath" in t) { var o = new Function(t.getPublicPath)(); return "".concat(o).concat(e); } else return "publicPath" in t ? "".concat(t.publicPath).concat(e) : (console.warn("Can not get resource url, if in debug mode, please ignore", t, e), ""); }, warn = function(t) { console.warn("".concat(LOG_CATEGORY, ": ").concat(t)); }; function _define_property$1(t, e, o) { return e in t ? Object.defineProperty(t, e, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = o, t; } function _object_spread$1(t) { for (var e = 1; e < arguments.length; e++) { var o = arguments[e] != null ? arguments[e] : {}, n = Object.keys(o); typeof Object.getOwnPropertySymbols == "function" && (n = n.concat(Object.getOwnPropertySymbols(o).filter(function(r) { return Object.getOwnPropertyDescriptor(o, r).enumerable; }))), n.forEach(function(r) { _define_property$1(t, r, o[r]); }); } return t; } function ownKeys(t, e) { var o = Object.keys(t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(t); e && (n = n.filter(function(r) { return Object.getOwnPropertyDescriptor(t, r).enumerable; })), o.push.apply(o, n); } return o; } function _object_spread_props(t, e) { return e = e ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(e)) : ownKeys(Object(e)).forEach(function(o) { Object.defineProperty(t, o, Object.getOwnPropertyDescriptor(e, o)); }), t; } var simpleJoinRemoteEntry = function(t, e) { if (!t) return e; var o = function(r) { if (r === ".") return ""; if (r.startsWith("./")) return r.replace("./", ""); if (r.startsWith("/")) { var i = r.slice(1); return i.endsWith("/") ? i.slice(0, -1) : i; } return r; }, n = o(t); return n ? n.endsWith("/") ? "".concat(n).concat(e) : "".concat(n, "/").concat(e) : e; }; function generateSnapshotFromManifest(t) { var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o, n, r = e.remotes, i = r === void 0 ? {} : r, a = e.overrides, s = a === void 0 ? {} : a, c = e.version, l, u = function() { return "publicPath" in t.metaData ? t.metaData.publicPath : t.metaData.getPublicPath; }, h = Object.keys(s), g = {}; if (!Object.keys(i).length) { var p; g = ((p = t.remotes) === null || p === void 0 ? void 0 : p.reduce(function(w, R) { var U, W = R.federationContainerName; return h.includes(W) ? U = s[W] : "version" in R ? U = R.version : U = R.entry, w[W] = { matchedVersion: U }, w; }, {})) || {}; } Object.keys(i).forEach(function(w) { return g[w] = { matchedVersion: h.includes(w) ? s[w] : i[w] }; }); var d = t.metaData, m = d.remoteEntry, M = m.path, I = m.name, D = m.type, S = d.types, O = d.buildInfo.buildVersion, L = d.globalName, v = t.exposes, y = { version: c || "", buildVersion: O, globalName: L, remoteEntry: simpleJoinRemoteEntry(M, I), remoteEntryType: D, remoteTypes: simpleJoinRemoteEntry(S.path, S.name), remoteTypesZip: S.zip || "", remoteTypesAPI: S.api || "", remotesInfo: g, shared: t?.shared.map(function(w) { return { assets: w.assets, sharedName: w.name }; }), modules: v?.map(function(w) { return { moduleName: w.name, modulePath: w.path, assets: w.assets }; }) }; if (!((o = t.metaData) === null || o === void 0) && o.prefetchInterface) { var A = t.metaData.prefetchInterface; y = _object_spread_props(_object_spread$1({}, y), { prefetchInterface: A }); } if (!((n = t.metaData) === null || n === void 0) && n.prefetchEntry) { var b = t.metaData.prefetchEntry, x = b.path, H = b.name, $ = b.type; y = _object_spread_props(_object_spread$1({}, y), { prefetchEntry: simpleJoinRemoteEntry(x, H), prefetchEntryType: $ }); } return "publicPath" in t.metaData ? l = _object_spread_props(_object_spread$1({}, y), { publicPath: u() }) : l = _object_spread_props(_object_spread$1({}, y), { getPublicPath: u() }), l; } function isManifestProvider(t) { return !!("remoteEntry" in t && t.remoteEntry.includes(MANIFEST_EXT)); } function asyncGeneratorStep$1(t, e, o, n, r, i, a) { try { var s = t[i](a), c = s.value; } catch (l) { o(l); return; } s.done ? e(c) : Promise.resolve(c).then(n, r); } function _async_to_generator$1(t) { return function() { var e = this, o = arguments; return new Promise(function(n, r) { var i = t.apply(e, o); function a(c) { asyncGeneratorStep$1(i, n, r, a, s, "next", c); } function s(c) { asyncGeneratorStep$1(i, n, r, a, s, "throw", c); } a(void 0); }); }; } function _instanceof(t, e) { return e != null && typeof Symbol < "u" && e[Symbol.hasInstance] ? !!e[Symbol.hasInstance](t) : t instanceof e; } function _ts_generator$1(t, e) { var o, n, r, i, a = { label: 0, sent: function() { if (r[0] & 1) throw r[1]; return r[1]; }, trys: [], ops: [] }; return i = { next: s(0), throw: s(1), return: s(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() { return this; }), i; function s(l) { return function(u) { return c([ l, u ]); }; } function c(l) { if (o) throw new TypeError("Generator is already executing."); for (; a; ) try { if (o = 1, n && (r = l[0] & 2 ? n.return : l[0] ? n.throw || ((r = n.return) && r.call(n), 0) : n.next) && !(r = r.call(n, l[1])).done) return r; switch (n = 0, r && (l = [ l[0] & 2, r.value ]), l[0]) { case 0: case 1: r = l; break; case 4: return a.label++, { value: l[1], done: !1 }; case 5: a.label++, n = l[1], l = [ 0 ]; continue; case 7: l = a.ops.pop(), a.trys.pop(); continue; default: if (r = a.trys, !(r = r.length > 0 && r[r.length - 1]) && (l[0] === 6 || l[0] === 2)) { a = 0; continue; } if (l[0] === 3 && (!r || l[1] > r[0] && l[1] < r[3])) { a.label = l[1]; break; } if (l[0] === 6 && a.label < r[1]) { a.label = r[1], r = l; break; } if (r && a.label < r[2]) { a.label = r[2], a.ops.push(l); break; } r[2] && a.ops.pop(), a.trys.pop(); continue; } l = e.call(t, a); } catch (u) { l = [ 6, u ], n = 0; } finally { o = r = 0; } if (l[0] & 5) throw l[1]; return { value: l[0] ? l[1] : void 0, done: !0 }; } } function safeWrapper(t, e) { return _safeWrapper.apply(this, arguments); } function _safeWrapper() { return _safeWrapper = _async_to_generator$1(function(t, e) { var o, n; return _ts_generator$1(this, function(r) { switch (r.label) { case 0: return r.trys.push([ 0, 2, , 3 ]), [ 4, t() ]; case 1: return o = r.sent(), [ 2, o ]; case 2: return n = r.sent(), !e && warn(n), [ 2 ]; case 3: return [ 2 ]; } }); }), _safeWrapper.apply(this, arguments); } function isStaticResourcesEqual(t, e) { var o = /^(https?:)?\/\//i, n = t.replace(o, "").replace(/\/$/, ""), r = e.replace(o, "").replace(/\/$/, ""); return n === r; } function createScript(t, e, o, n) { for (var r = null, i = !0, a = document.getElementsByTagName("script"), s = 0; s < a.length; s++) { var c = a[s], l = c.getAttribute("src"); if (l && isStaticResourcesEqual(l, t)) { r = c, i = !1; break; } } if (!r && (r = document.createElement("script"), r.type = "text/javascript", r.src = t, n)) { var u = n(t); _instanceof(u, HTMLScriptElement) && (r = u); } o && Object.keys(o).forEach(function(g) { r && (g === "async" || g === "defer" ? r[g] = o[g] : r.setAttribute(g, o[g])); }); var h = function(g, p) { if (r && (r.onerror = null, r.onload = null, safeWrapper(function() { r != null && r.parentNode && r.parentNode.removeChild(r); }), g)) { var d = g(p); return e(), d; } e(); }; return r.onerror = h.bind(null, r.onerror), r.onload = h.bind(null, r.onload), { script: r, needAttach: i }; } function createLink(t, e) { for (var o = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, n = arguments.length > 3 ? arguments[3] : void 0, r = null, i = !0, a = document.getElementsByTagName("link"), s = 0; s < a.length; s++) { var c = a[s], l = c.getAttribute("href"), u = c.getAttribute("ref"); if (l && isStaticResourcesEqual(l, t) && u === o.ref) { r = c, i = !1; break; } } if (!r && (r = document.createElement("link"), r.setAttribute("href", t), n)) { var h = n(t); _instanceof(h, HTMLLinkElement) && (r = h); } o && Object.keys(o).forEach(function(p) { r && r.setAttribute(p, o[p]); }); var g = function(p, d) { if (r && (r.onerror = null, r.onload = null, safeWrapper(function() { r != null && r.parentNode && r.parentNode.removeChild(r); }), p)) { var m = p(d); return e(), m; } e(); }; return r.onerror = g.bind(null, r.onerror), r.onload = g.bind(null, r.onload), { link: r, needAttach: i }; } function loadScript(t, e) { var o = e.attrs, n = e.createScriptHook; return new Promise(function(r, i) { var a = createScript(t, r, o, n), s = a.script, c = a.needAttach; c && document.getElementsByTagName("head")[0].appendChild(s); }); } function _array_like_to_array(t, e) { (e == null || e > t.length) && (e = t.length); for (var o = 0, n = new Array(e); o < e; o++) n[o] = t[o]; return n; } function _array_with_holes(t) { if (Array.isArray(t)) return t; } function asyncGeneratorStep(t, e, o, n, r, i, a) { try { var s = t[i](a), c = s.value; } catch (l) { o(l); return; } s.done ? e(c) : Promise.resolve(c).then(n, r); } function _async_to_generator(t) { return function() { var e = this, o = arguments; return new Promise(function(n, r) { var i = t.apply(e, o); function a(c) { asyncGeneratorStep(i, n, r, a, s, "next", c); } function s(c) { asyncGeneratorStep(i, n, r, a, s, "throw", c); } a(void 0); }); }; } function _iterable_to_array_limit(t, e) { var o = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"]; if (o != null) { var n = [], r = !0, i = !1, a, s; try { for (o = o.call(t); !(r = (a = o.next()).done) && (n.push(a.value), !(e && n.length === e)); r = !0) ; } catch (c) { i = !0, s = c; } finally { try { !r && o.return != null && o.return(); } finally { if (i) throw s; } } return n; } } function _non_iterable_rest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _sliced_to_array(t, e) { return _array_with_holes(t) || _iterable_to_array_limit(t, e) || _unsupported_iterable_to_array(t, e) || _non_iterable_rest(); } function _unsupported_iterable_to_array(t, e) { if (t) { if (typeof t == "string") return _array_like_to_array(t, e); var o = Object.prototype.toString.call(t).slice(8, -1); if (o === "Object" && t.constructor && (o = t.constructor.name), o === "Map" || o === "Set") return Array.from(o); if (o === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)) return _array_like_to_array(t, e); } } function _ts_generator(t, e) { var o, n, r, i, a = { label: 0, sent: function() { if (r[0] & 1) throw r[1]; return r[1]; }, trys: [], ops: [] }; return i = { next: s(0), throw: s(1), return: s(2) }, typeof Symbol == "function" && (i[Symbol.iterator] = function() { return this; }), i; function s(l) { return function(u) { return c([ l, u ]); }; } function c(l) { if (o) throw new TypeError("Generator is already executing."); for (; a; ) try { if (o = 1, n && (r = l[0] & 2 ? n.return : l[0] ? n.throw || ((r = n.return) && r.call(n), 0) : n.next) && !(r = r.call(n, l[1])).done) return r; switch (n = 0, r && (l = [ l[0] & 2, r.value ]), l[0]) { case 0: case 1: r = l; break; case 4: return a.label++, { value: l[1], done: !1 }; case 5: a.label++, n = l[1], l = [ 0 ]; continue; case 7: l = a.ops.pop(), a.trys.pop(); continue; default: if (r = a.trys, !(r = r.length > 0 && r[r.length - 1]) && (l[0] === 6 || l[0] === 2)) { a = 0; continue; } if (l[0] === 3 && (!r || l[1] > r[0] && l[1] < r[3])) { a.label = l[1]; break; } if (l[0] === 6 && a.label < r[1]) { a.label = r[1], r = l; break; } if (r && a.label < r[2]) { a.label = r[2], a.ops.push(l); break; } r[2] && a.ops.pop(), a.trys.pop(); continue; } l = e.call(t, a); } catch (u) { l = [ 6, u ], n = 0; } finally { o = r = 0; } if (l[0] & 5) throw l[1]; return { value: l[0] ? l[1] : void 0, done: !0 }; } } function importNodeModule(t) { if (!t) throw new Error("import specifier is required"); var e = new Function("name", "return import(name)"); return e(t).then(function(o) { return o.default; }).catch(function(o) { throw console.error("Error importing module ".concat(t, ":"), o), o; }); } function createScriptNode(url, cb, attrs, createScriptHook) { if (createScriptHook) { var hookResult = createScriptHook(url); hookResult && typeof hookResult == "object" && "url" in hookResult && (url = hookResult.url); } var urlObj; try { urlObj = new URL(url); } catch (t) { console.error("Error constructing URL:", t), cb(new Error("Invalid URL: ".concat(t))); return; } var getFetch = function() { var t = _async_to_generator(function() { var e; return _ts_generator(this, function(o) { switch (o.label) { case 0: return typeof fetch > "u" ? [ 4, importNodeModule("node-fetch") ] : [ 3, 2 ]; case 1: return e = o.sent(), [ 2, e?.default || e ]; case 2: return [ 2, fetch ]; case 3: return [ 2 ]; } }); }); return function() { return t.apply(this, arguments); }; }(); console.log("fetching", urlObj.href), getFetch().then(function(f) { f(urlObj.href).then(function(t) { return t.text(); }).then(function() { var _ref = _async_to_generator(function(data) { var _ref, path, vm, scriptContext, urlDirname, filename, script, exportedInterface, container; return _ts_generator(this, function(_state) { switch (_state.label) { case 0: return [ 4, Promise.all([ importNodeModule("path"), importNodeModule("vm") ]) ]; case 1: _ref = _sliced_to_array.apply(void 0, [ _state.sent(), 2 ]), path = _ref[0], vm = _ref[1], scriptContext = { exports: {}, module: { exports: {} } }, urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/"), filename = path.basename(urlObj.pathname); try { if (script = new vm.Script("(function(exports, module, require, __dirname, __filename) {".concat(data, ` })`), filename), script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename), exportedInterface = scriptContext.module.exports || scriptContext.exports, attrs && exportedInterface && attrs.globalName) return container = exportedInterface[attrs.globalName] || exportedInterface, cb(void 0, container), [ 2 ]; cb(void 0, exportedInterface); } catch (t) { cb(new Error("Script execution error: ".concat(t))); } return [ 2 ]; } }); }); return function(t) { return _ref.apply(this, arguments); }; }()).catch(function(t) { cb(t); }); }); } function loadScriptNode(t, e) { return new Promise(function(o, n) { createScriptNode(t, function(r, i) { if (r) n(r); else { var a, s, c = (e == null || (a = e.attrs) === null || a === void 0 ? void 0 : a.globalName) || "__FEDERATION_".concat(e == null || (s = e.attrs) === null || s === void 0 ? void 0 : s.name, ":custom__"), l = globalThis[c] = i; o(l); } }, e.attrs, e.createScriptHook); }); } function matchRemoteWithNameAndExpose(t, e) { for (const o of t) { const n = e.startsWith(o.name); let r = e.replace(o.name, ""); if (n) { if (r.startsWith("/")) { const s = o.name; return r = `.${r}`, { pkgNameOrAlias: s, expose: r, remote: o }; } else if (r === "") return { pkgNameOrAlias: o.name, expose: ".", remote: o }; } const i = o.alias && e.startsWith(o.alias); let a = o.alias && e.replace(o.alias, ""); if (o.alias && i) { if (a && a.startsWith("/")) { const s = o.alias; return a = `.${a}`, { pkgNameOrAlias: s, expose: a, remote: o }; } else if (a === "") return { pkgNameOrAlias: o.alias, expose: ".", remote: o }; } } } function matchRemote(t, e) { for (const o of t) if (e === o.name || o.alias && e === o.alias) return o; } function registerPlugins(t, e) { const o = getGlobalHostPlugins(); o.length > 0 && o.forEach((n) => { t != null && t.find((r) => r.name !== n.name) && t.push(n); }), t && t.length > 0 && t.forEach((n) => { e.forEach((r) => { r.applyPlugin(n); }); }); } function _extends$5() { return _extends$5 = Object.assign || function(t) { for (var e = 1; e < arguments.length; e++) { var o = arguments[e]; for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && (t[n] = o[n]); } return t; }, _extends$5.apply(this, arguments); } async function loadEsmEntry({ entry: t, remoteEntryExports: e }) { return new Promise((o, n) => { try { e ? o(e) : new Function("callbacks", `import("${t}").then(callbacks[0]).catch(callbacks[1])`)([ o, n ]); } catch (r) { n(r); } }); } async function loadEntryScript({ name: t, globalName: e, entry: o, createScriptHook: n }) { const { entryExports: r } = getRemoteEntryExports(t, e); return r || (typeof document > "u" ? loadScriptNode(o, { attrs: { name: t, globalName: e }, createScriptHook: n }).then(() => { const { remoteEntryKey: i, entryExports: a } = getRemoteEntryExports(t, e); return assert(a, ` Unable to use the ${t}'s '${o}' URL with ${i}'s globalName to get remoteEntry exports. Possible reasons could be: 1. '${o}' is not the correct URL, or the remoteEntry resource or name is incorrect. 2. ${i} cannot be used to get remoteEntry exports in the window object. `), a; }).catch((i) => i) : loadScript(o, { attrs: {}, createScriptHook: n }).then(() => { const { remoteEntryKey: i, entryExports: a } = getRemoteEntryExports(t, e); return assert(a, ` Unable to use the ${t}'s '${o}' URL with ${i}'s globalName to get remoteEntry exports. Possible reasons could be: 1. '${o}' is not the correct URL, or the remoteEntry resource or name is incorrect. 2. ${i} cannot be used to get remoteEntry exports in the window object. `), a; }).catch((i) => i)); } function getRemoteEntryUniqueKey(t) { const { entry: e, name: o } = t; return composeKeyWithSeparator(o, e); } async function getRemoteEntry({ remoteEntryExports: t, remoteInfo: e, createScriptHook: o }) { const { entry: n, name: r, type: i, entryGlobalName: a } = e, s = getRemoteEntryUniqueKey(e); return t || (globalLoading[s] || (i === "esm" ? globalLoading[s] = loadEsmEntry({ entry: n, remoteEntryExports: t }) : globalLoading[s] = loadEntryScript({ name: r, globalName: a, entry: n, createScriptHook: o })), globalLoading[s]); } function getRemoteInfo(t) { return _extends$5({}, t, { entry: "entry" in t ? t.entry : "", type: t.type || DEFAULT_REMOTE_TYPE, entryGlobalName: t.entryGlobalName || t.name, shareScope: t.shareScope || DEFAULT_SCOPE }); } function _extends$4() { return _extends$4 = Object.assign || function(t) { for (var e = 1; e < arguments.length; e++) { var o = arguments[e]; for (var n in o) Object.prototype.hasOwnProperty.call(o, n) && (t[n] = o[n]); } return t; }, _extends$4.apply(this, arguments); } let Module = class { async getEntry() { if (this.remoteEntryExports) return this.remoteEntryExports; const t = await getRemoteEntry({ remoteInfo: this.remoteInfo, remoteEntryExports: this.remoteEntryExports, createScriptHook: (e) => { const o = this.host.loaderHook.lifecycle.createScript.emit({ url: e }); if (typeof document > "u" || o instanceof HTMLScriptElement) return o; } }); return assert(t, `remoteEntryExports is undefined ${safeToString$1(this.remoteInfo)}`), this.remoteEntryExports = t, this.remoteEntryExports; } async get(t, e) { const { loadFactory: o = !0 } = e || { loadFactory: !0 }, n = await this.getEntry(); if (!this.inited) { const i = this.host.shareScopeMap, a = this.remoteInfo.shareScope || "default"; i[a] || (i[a] = {}); const s = i[a], c = [], l = { version: this.remoteInfo.version || "" }; Object.defineProperty(l, "hostId", { value: this.host.options.id || this.host.name, enumerable: !1 }); const u = await this.host.hooks.lifecycle.beforeInitContainer.emit({ shareScope: s, remoteEntryInitOptions: l, initScope: c, remoteInfo: this.remoteInfo, origin: this.host }); await n.init(u.shareScope, u.initScope, u.remoteEntryInitOptions), await this.host.hooks.lifecycle.initContainer.emit(_extends$4({}, u, { remoteEntryExports: n })); } this.lib = n, this.inited = !0; const r = await n.get(t); return assert(r, `${getFMId(this.remoteInfo)} remote don't export ${t}.`), o ? await r() : r; } constructor({ remoteInfo: t, host: e }) { this.inited = !1, this.lib = void 0, this.remoteInfo = t, this.host = e; } }; class SyncHook { on(e) { typeof e == "function" && this.listeners.add(e); } once(e) { const o = this; this.on(function n(...r) { return o.remove(n), e.apply(null, r); }); } emit(...e) { let o; return this.listeners.size > 0 && this.listeners.forEach((n) => { o = n(...e); }), o; } remove(e) { this.listeners.delete(e); } removeAll() { this.listeners.clear(); } constructor(e) { this.type = "", this.listeners = /* @__PURE__ */ new Set(), e && (this.type = e); } } class AsyncHook extends SyncHook { emit(...e) { let o; const n = Array.from(this.listeners); if (n.length > 0) { let r = 0; const i = (a) => a === !1 ? !1 : r < n.length ? Promise.resolve(n[r++].apply(null, e)).then(i) : a; o = i(); } return Promise.resolve(o); } } function checkReturnData(t, e) { if (!isObject(e)) return !1; if (t !== e) { for (const o in t) if (!(o in e)) return !1; } return !0; } class SyncWaterfallHook extends SyncHook { emit(e) { isObject(e) || error(`The data for the "${this.type}" hook should be an object.`); for (const o of this.listeners) try { const n = o(e); if (checkReturnData(e, n)) e = n; else { this.onerror(`A plugin returned an unacceptable value for the "${this.type}" type.`); break; } } catch (n) { warn$1(n), this.onerror(n); } return e; } constructor(e) { super(), this.onerror = error, this.type = e; } } class AsyncWaterfallHook extends SyncHook { emit(e) { isObject(e) || error(`The response data for the "${this.type}" hook must be an object.`); const o = Array.from(this.listeners); if (o.length > 0) { let n = 0; const r = (a) => (warn$1(a), this.onerror(a), e), i = (a) => { if (checkReturnData(e, a)) { if (e = a, n < o.length) try { return Promise.resolve(o[n++](e)).then(i, r); } catch (s) { return r(s); } } else this.onerror(`A plugin returned an incorrect value for the "${this.type}" type.`); return e; }; return Promise.resolve(i(e)); } return Promise.resolve(e); } constructor(e) { super(), this.onerror = error, this.type = e; } } class PluginSystem { applyPlugin(e) { assert(isPlainObject(e), "Plugin configuration is invalid."); const o = e.name; assert(o, "A name must be provided by the plugin."), this.registerPlugins[o] || (this.registerPlugins[o] = e, Object.keys(this.lifecycle).forEach((n) => { const r = e[n]; r && this.lifecycle[n].on(r); })); } removePlugin(e) { assert(e, "A name is required."); const o = this.registerPlugins[e]; assert(o, `The plugin "${e}" is not registered.`), Object.keys(o).forEach((n) => { n !== "name" && this.lifecycle[n].remove(o[n]); }); } inherit({ lifecycle: e, registerPlugins: o }) { Object.keys(e).forEach((n) => { assert(!this.lifecycle[n], `The hook "${n}" has a conflict and cannot be inherited.`), this.lifecycle[n] = e[n]; }), Object.keys(o).forEach((n) => { assert(!this.registerPlugins[n], `T