/**
 * Small shared helpers for the page-capture dialog flows (live + offscreen). Extracted to remove
 * the previously-duplicated id generator, title reader, and hidden-iframe scaffolding.
 */
/** Generates a request/correlation id, preferring crypto.randomUUID with a prefixed fallback. */
export function createCaptureRequestId(prefix) {
    const cryptoObject = globalThis.crypto;
    if (cryptoObject?.randomUUID) {
        return cryptoObject.randomUUID();
    }
    return `${prefix}-${Date.now().toString(36)}-${Math.random()
        .toString(36)
        .slice(2)}`;
}
/** Reads <title> from an HTML string, returning undefined on empty/parse failure. */
export function readTitleFromHtml(html) {
    try {
        return (new DOMParser().parseFromString(html, "text/html").title || undefined);
    }
    catch {
        return undefined;
    }
}
/** Creates an offscreen, inert hidden iframe sized to the given dimensions for capture/render. */
export function createHiddenCaptureIframe(width, height) {
    const iframe = document.createElement("iframe");
    iframe.setAttribute("aria-hidden", "true");
    iframe.tabIndex = -1;
    iframe.style.position = "fixed";
    iframe.style.left = "-10000px";
    iframe.style.top = "0";
    iframe.style.width = `${width}px`;
    iframe.style.height = `${height}px`;
    iframe.style.border = "0";
    iframe.style.opacity = "0";
    iframe.style.pointerEvents = "none";
    return iframe;
}
//# sourceMappingURL=captureShared.js.map