86 lines
3.0 KiB
TypeScript
86 lines
3.0 KiB
TypeScript
// Metro module 4175 (f4176).
|
|
import _slicedToArray from "../../_bundle/_slicedToArray";
|
|
import SnowflakeUtils from "../../utils/SnowflakeUtils";
|
|
import Module1464 from "../../_bundle/Module1464";
|
|
import { getFirstQueryStringValue } from "../../utils/QueryStringUtils";
|
|
let c2404_4, c2404_5, c2404_6, generateInviteKeyFromExtraData;
|
|
const readSnowflake = function readSnowflake(a0) {
|
|
return typeof a0 === "string" ? SnowflakeUtils.isProbablyAValidSnowflake(a0) ? a0 : void 0 : void 0;
|
|
};
|
|
generateInviteKeyFromExtraData = function generateInviteKeyFromExtraData({ baseCode, guildScheduledEventId, targetChannelId, targetMessageId }) {
|
|
const r3 = {};
|
|
if (guildScheduledEventId != null) {
|
|
r3[c2404_4] = guildScheduledEventId;
|
|
}
|
|
if (targetChannelId != null) {
|
|
r3[c2404_5] = targetChannelId;
|
|
if (targetMessageId != null) {
|
|
r3[c2404_6] = targetMessageId;
|
|
}
|
|
}
|
|
const r17 = Module1464.stringify(r3);
|
|
return r17 !== "" ? `${baseCode}?${r17}` : baseCode;
|
|
};
|
|
c2404_4 = "event";
|
|
c2404_5 = "channel";
|
|
c2404_6 = "message";
|
|
export { readSnowflake };
|
|
export function generateInviteKeyFromUrlParams(a0, a1) {
|
|
let r22;
|
|
if (a1 == null) {
|
|
return a0;
|
|
}
|
|
const r4 = a1.charAt(0) === "?" ? a1.substring(1) : a1;
|
|
try {
|
|
r22 = Module1464.parse(r4);
|
|
} catch ($e) {
|
|
return a0;
|
|
}
|
|
const r12 = r22;
|
|
const firstQueryStringValue = getFirstQueryStringValue(r12[c2404_4]);
|
|
const targetChannelId = readSnowflake(getFirstQueryStringValue(r12[c2404_5]));
|
|
return generateInviteKeyFromExtraData({
|
|
baseCode: a0,
|
|
guildScheduledEventId: firstQueryStringValue,
|
|
targetChannelId,
|
|
targetMessageId: targetChannelId != null ? readSnowflake(getFirstQueryStringValue(r22[c2404_6])) : void 0
|
|
});
|
|
}
|
|
export { generateInviteKeyFromExtraData };
|
|
export function parseExtraDataFromInviteKey(a0) {
|
|
const [baseCode, r7] = a0.split("?");
|
|
if (r7 == null) {
|
|
return {
|
|
baseCode
|
|
};
|
|
}
|
|
const r11 = Module1464.parse(r7);
|
|
const firstQueryStringValue = getFirstQueryStringValue(r11[c2404_4]);
|
|
const firstQueryStringValue2 = getFirstQueryStringValue(r11[c2404_5]);
|
|
const targetChannelId = typeof firstQueryStringValue2 === "string" ? SnowflakeUtils.isProbablyAValidSnowflake(firstQueryStringValue2) ? firstQueryStringValue2 : void 0 : void 0;
|
|
const r37 = targetChannelId != null;
|
|
let targetMessageId = void 0;
|
|
if (r37) {
|
|
const firstQueryStringValue3 = getFirstQueryStringValue(r11[c2404_6]);
|
|
targetMessageId = typeof firstQueryStringValue3 === "string" ? SnowflakeUtils.isProbablyAValidSnowflake(firstQueryStringValue3) ? firstQueryStringValue3 : void 0 : void 0;
|
|
}
|
|
return {
|
|
baseCode,
|
|
guildScheduledEventId: firstQueryStringValue,
|
|
targetChannelId,
|
|
targetMessageId
|
|
};
|
|
}
|
|
export function parseInviteCodeFromInviteKey(a0) {
|
|
return _slicedToArray(a0.split("?"), 1)[0];
|
|
}
|
|
export function getInviteKeySearchSuffix(a0) {
|
|
const r4 = a0.indexOf("?");
|
|
return r4 >= 0 ? a0.substring(r4) : "";
|
|
}
|
|
export function getInviteInstanceId(a0, a1) {
|
|
if (a1 != null) {
|
|
return `${a1}:${_slicedToArray(a0.split("?"), 1)[0]}`;
|
|
}
|
|
}
|