decord/source/modules/masked_link/SharedStateUtils.tsx

80 lines
2.4 KiB
TypeScript
Raw Normal View History

// Module ID: 12981
// Function ID: 12982
// Name: SharedStateUtils
// Dependencies: [32, 19, 8401, 2]
2026-07-29 08:29:29 +00:00
// Exports: useModalState, useUrlParts
2026-07-20 16:05:17 +00:00
// Module 12981 (SharedStateUtils)
import MaskedLinkStoreMethodsAdditional from "MaskedLinkStoreMethodsAdditional" /* 8401 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
2026-07-23 10:11:24 +00:00
require = fn;
const size = fn(2);
const result = size.fileFinishedImporting("modules/masked_link/SharedStateUtils.tsx");
2026-07-29 08:29:29 +00:00
export const useUrlParts = function useUrlParts(url) {
2026-08-24 06:08:38 +00:00
closure_0 = url;
2026-07-20 16:05:17 +00:00
const items = [url];
const memo = noop.useMemo(() => {
const url = { protocol: MaskedLinkStoreMethodsAdditional.getProtocol(str), hostname: null };
url.hostname = MaskedLinkStoreMethodsAdditional.getHostname(str);
return url;
2026-07-20 16:05:17 +00:00
}, items);
({ protocol, hostname } = memo);
let str = "";
if ("//" === url.substr(protocol.length, 2)) {
str = "//";
}
url = { protocol, authorityPrefix: str, hostname, theRestOfTheUrl: url.replace("" + protocol + str + hostname, "") };
return url;
2026-07-29 08:29:29 +00:00
};
2026-07-20 16:05:17 +00:00
export const useModalState = function useModalState(url) {
2026-07-29 08:29:29 +00:00
const str = url.url;
2026-07-20 16:05:17 +00:00
const trustUrl = url.trustUrl;
const onConfirm = url.onConfirm;
const onCancel = url.onCancel;
const onClose = url.onClose;
2026-07-23 10:11:24 +00:00
const tmp = onConfirm(onCancel.useState(false), 2);
const shouldTrustUrl = tmp[0];
2026-07-29 08:29:29 +00:00
const items = [str];
const memo = onCancel.useMemo(() => {
const url = { protocol: MaskedLinkStoreMethodsAdditional.getProtocol(str), hostname: null };
url.hostname = MaskedLinkStoreMethodsAdditional.getHostname(str);
return url;
2026-07-29 08:29:29 +00:00
}, items);
({ protocol, hostname } = memo);
let str2 = "";
if ("//" === str.substr(protocol.length, 2)) {
str2 = "//";
}
const items1 = [str, shouldTrustUrl, trustUrl, onConfirm, onClose];
2026-07-29 08:29:29 +00:00
const replaced = str.replace("" + protocol + str2 + hostname, "");
const items2 = [onCancel, onClose];
const callback = obj.useCallback(() => {
2026-07-20 16:05:17 +00:00
if (first) {
2026-07-29 08:29:29 +00:00
trustUrl(str);
2026-07-20 16:05:17 +00:00
}
onConfirm();
2026-07-29 08:29:29 +00:00
if (onClose != null) {
onClose();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}, items1);
url = {
2026-07-20 16:05:17 +00:00
protocol,
2026-07-29 08:29:29 +00:00
authorityPrefix: str2,
2026-07-20 16:05:17 +00:00
hostname,
2026-07-29 08:29:29 +00:00
theRestOfTheUrl: replaced,
shouldTrustUrl,
2026-07-20 16:05:17 +00:00
setShouldTrustUrl: tmp[1],
handleConfirm: callback,
2026-07-29 08:29:29 +00:00
handleCancel: obj.useCallback(() => {
onCancel();
2026-07-29 08:29:29 +00:00
if (onClose != null) {
onClose();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}, items2)
2026-07-20 16:05:17 +00:00
};
return url;
2026-07-20 16:05:17 +00:00
};