decord/source/modules/masked_link/SharedStateUtils.tsx

75 lines
2 KiB
TypeScript
Raw Normal View History

2026-07-28 08:39:19 +00:00
// Module ID: 12269
// Function ID: 95696
2026-07-20 16:05:17 +00:00
// Name: useUrlParts
2026-07-28 08:39:19 +00:00
// Dependencies: [57, 31, 8179, 2]
2026-07-20 16:05:17 +00:00
// Exports: useModalState
2026-07-28 08:39:19 +00:00
// Module 12269 (useUrlParts)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray";
import result from "result";
const require = arg1;
2026-07-20 16:05:17 +00:00
function useUrlParts(url) {
let hostname;
let protocol;
2026-07-23 10:11:24 +00:00
let closure_0 = url;
2026-07-20 16:05:17 +00:00
const items = [url];
const memo = React.useMemo(() => {
2026-07-23 10:11:24 +00:00
const obj = { protocol: url(outer1_1[2]).getProtocol(url) };
const obj2 = url(outer1_1[2]);
obj.hostname = url(outer1_1[2]).getHostname(url);
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-23 10:11:24 +00:00
let obj = { protocol, authorityPrefix: str, hostname, theRestOfTheUrl: url.replace("" + protocol + str + hostname, "") };
2026-07-20 16:05:17 +00:00
return obj;
}
2026-07-23 10:11:24 +00:00
const result = require("getHostname").fileFinishedImporting("modules/masked_link/SharedStateUtils.tsx");
2026-07-20 16:05:17 +00:00
export { useUrlParts };
export const useModalState = function useModalState(url) {
let authorityPrefix;
let hostname;
let protocol;
let theRestOfTheUrl;
url = url.url;
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);
2026-07-20 16:05:17 +00:00
const first = tmp[0];
const items = [url, first, trustUrl, onConfirm, onClose];
2026-07-23 10:11:24 +00:00
({ protocol, authorityPrefix, hostname, theRestOfTheUrl } = onClose(url));
2026-07-20 16:05:17 +00:00
const items1 = [onCancel, onClose];
2026-07-23 10:11:24 +00:00
const callback = onCancel.useCallback(() => {
2026-07-20 16:05:17 +00:00
if (first) {
trustUrl(url);
}
if (null != onClose) {
onClose();
}
onConfirm();
}, items);
2026-07-23 10:11:24 +00:00
const tmp3 = onClose(url);
2026-07-20 16:05:17 +00:00
return {
protocol,
authorityPrefix,
hostname,
theRestOfTheUrl,
shouldTrustUrl: first,
setShouldTrustUrl: tmp[1],
handleConfirm: callback,
2026-07-23 10:11:24 +00:00
handleCancel: onCancel.useCallback(() => {
2026-07-20 16:05:17 +00:00
if (null != onClose) {
onClose();
}
onCancel();
}, items1)
};
};