"use client";
import { isValidFingerprintId, FINGERPRINT_DEBUG_OVERRIDE_STORAGE_KEY } from './fingerprint-shared.mjs';

function getLocalStorageValue(key) {
    if (typeof window === 'undefined') {
        return null;
    }
    try {
        return window.localStorage.getItem(key);
    }
    catch (_a) {
        return null;
    }
}
function setLocalStorageValue(key, value) {
    if (typeof window === 'undefined') {
        return;
    }
    try {
        window.localStorage.setItem(key, value);
    }
    catch (_a) {
        // Ignore storage failures in debug helpers.
    }
}
function getDebugFingerprintOverride() {
    const value = getLocalStorageValue(FINGERPRINT_DEBUG_OVERRIDE_STORAGE_KEY);
    if (!value || !isValidFingerprintId(value)) {
        return null;
    }
    return value;
}
function setDebugFingerprintOverride(fingerprintId) {
    if (!isValidFingerprintId(fingerprintId)) {
        throw new Error('Invalid fingerprint ID');
    }
    setLocalStorageValue(FINGERPRINT_DEBUG_OVERRIDE_STORAGE_KEY, fingerprintId);
}

export { getDebugFingerprintOverride, setDebugFingerprintOverride };
