decord/source/modules/masked_link/SharedStateUtils.tsx

81 lines
2.3 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 12473
// Function ID: 12474
2026-07-20 16:05:17 +00:00
// Name: useUrlParts
2026-08-24 06:08:38 +00:00
// Dependencies: [32, 19, 8815, 2]
2026-07-29 08:29:29 +00:00
// Exports: useModalState, useUrlParts
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 12473 (useUrlParts)
import closure_2 from "_slicedToArray" /* 32 */;
import closure_3 from "noop" /* 19 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-08-24 06:08:38 +00:00
const result = require("set").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 = React.useMemo(() => {
2026-08-24 06:08:38 +00:00
const obj = { protocol: str(trustUrl[2]).getProtocol(str), hostname: null };
2026-07-29 08:29:29 +00:00
const obj2 = str(trustUrl[2]);
obj[1] = str(trustUrl[2]).getHostname(str);
2026-07-20 16:05:17 +00:00
return obj;
}, items);
({ protocol, hostname } = memo);
let str = "";
if ("//" === url.substr(protocol.length, 2)) {
str = "//";
}
2026-07-29 08:29:29 +00:00
return { protocol, authorityPrefix: str, hostname, theRestOfTheUrl: url.replace("" + protocol + str + hostname, "") };
};
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-29 08:29:29 +00:00
let first;
let obj = onCancel;
2026-07-23 10:11:24 +00:00
const tmp = onConfirm(onCancel.useState(false), 2);
2026-07-29 08:29:29 +00:00
first = tmp[0];
const items = [str];
const memo = onCancel.useMemo(() => {
2026-08-24 06:08:38 +00:00
const obj = { protocol: str(trustUrl[2]).getProtocol(str), hostname: null };
2026-07-29 08:29:29 +00:00
const obj2 = str(trustUrl[2]);
obj[1] = str(trustUrl[2]).getHostname(str);
return obj;
}, items);
({ protocol, hostname } = memo);
let str2 = "";
if ("//" === str.substr(protocol.length, 2)) {
str2 = "//";
}
const items1 = [str, first, trustUrl, onConfirm, onClose];
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
}
2026-07-29 08:29:29 +00:00
if (onClose != null) {
tmp4();
2026-07-20 16:05:17 +00:00
}
onConfirm();
2026-07-29 08:29:29 +00:00
}, items1);
obj = {
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,
2026-07-20 16:05:17 +00:00
shouldTrustUrl: first,
setShouldTrustUrl: tmp[1],
handleConfirm: callback,
2026-07-29 08:29:29 +00:00
handleCancel: obj.useCallback(() => {
if (onClose != null) {
tmp();
2026-07-20 16:05:17 +00:00
}
onCancel();
2026-07-29 08:29:29 +00:00
}, items2)
2026-07-20 16:05:17 +00:00
};
2026-07-29 08:29:29 +00:00
return obj;
2026-07-20 16:05:17 +00:00
};