export function sampleAnalyticsPrivacyFixture(options = {}) {
    const seed = normalizeSeed(options.seed ?? 0xa11a);
    const userId = normalizeText(options.userId ?? "external-parity-runtime-player", "userId");
    const sessionId = normalizeText(options.sessionId ?? "runtime-session", "sessionId");
    const frameMs = positive(options.frameMs ?? 16.7, "frameMs");
    const eventCount = count(options.eventCount ?? 24, "eventCount");
    const errorCount = count(options.errorCount ?? 0, "errorCount");
    const analyticsConsent = options.analyticsConsent ?? true;
    const marketingConsent = options.marketingConsent ?? false;
    const categories = {
        necessary: true,
        analytics: analyticsConsent,
        marketing: marketingConsent,
        preferences: true
    };
    const consentValues = Object.values(categories);
    const blockedWithoutConsent = analyticsConsent ? 0 : eventCount;
    const queuedEvents = analyticsConsent ? Math.min(eventCount, 50) : 0;
    const flushedBatches = analyticsConsent ? Math.ceil(queuedEvents / 10) : 0;
    const fps = Number((1000 / frameMs).toFixed(2));
    const fixture = {
        source: "origin-master-analytics-privacy-adapted",
        consent: {
            version: "1.0",
            explicitRequired: true,
            categories,
            grantedCount: consentValues.filter(Boolean).length,
            deniedCount: consentValues.filter((granted) => !granted).length,
            changeEvents: [
                { category: "analytics", granted: analyticsConsent, previous: false },
                { category: "preferences", granted: true, previous: false }
            ]
        },
        anonymization: {
            userHash: stableHash(`user:${userId}:analytics`),
            sessionHash: stableHash(`session:${sessionId}:analytics`),
            emailRedacted: true,
            tokenRedacted: true,
            ipAnonymized: anonymizeIp(`198.51.${Math.floor(seededUnit(seed) * 100)}.${Math.floor(seededUnit(seed ^ 0x1979) * 240)}`),
            piiPatternHits: 3
        },
        batching: {
            providerMode: analyticsConsent ? "batched-local" : "disabled",
            maxBatchSize: 50,
            queuedEvents,
            flushedBatches,
            offlineQueueEnabled: true,
            blockedWithoutConsent
        },
        metrics: {
            frameMs: Number(frameMs.toFixed(3)),
            fps,
            errorCount,
            errorsPerMinute: Number((errorCount / 3).toFixed(3)),
            loadEvents: 3 + Math.floor(seededUnit(seed ^ 0x441) * 3),
            customMetricCount: 4
        },
        productionReadiness: {
            consentTelemetry: true,
            anonymizationTelemetry: true,
            batchingTelemetry: true,
            metricsTelemetry: true,
            providerBoundaryTelemetry: true
        },
        blockedClaims: [
            "GDPR/CCPA compliance certification",
            "production analytics SaaS integration",
            "real provider delivery guarantees",
            "cross-device identity graph",
            "Unity Analytics parity",
            "Unreal Insights/Analytics parity"
        ],
        claimBoundary: "This fixture ports old analytics, consent, anonymization, batching, and metrics concepts into deterministic local telemetry. It does not send analytics events, certify privacy compliance, integrate a production provider, or claim Unity Analytics or Unreal Insights parity."
    };
    return {
        ...fixture,
        hash: stableHash(JSON.stringify(fixture))
    };
}
function anonymizeIp(ip) {
    const octets = ip.split(".");
    return `${octets[0] ?? "0"}.${octets[1] ?? "0"}.${octets[2] ?? "0"}.0`;
}
function normalizeSeed(seed) {
    if (!Number.isInteger(seed) || seed < 0)
        throw new Error("seed must be a non-negative integer.");
    return seed >>> 0;
}
function normalizeText(value, name) {
    const trimmed = value.trim();
    if (trimmed.length === 0)
        throw new Error(`${name} must not be empty.`);
    return trimmed;
}
function positive(value, name) {
    if (!Number.isFinite(value) || value <= 0)
        throw new Error(`${name} must be a positive finite number.`);
    return value;
}
function count(value, name) {
    if (!Number.isInteger(value) || value < 0)
        throw new Error(`${name} must be a non-negative integer.`);
    return value;
}
function seededUnit(seed) {
    let value = seed >>> 0;
    value ^= value << 13;
    value ^= value >>> 17;
    value ^= value << 5;
    return (value >>> 0) / 0xffffffff;
}
function stableHash(value) {
    let hash = 2166136261;
    for (let index = 0; index < value.length; index += 1) {
        hash ^= value.charCodeAt(index);
        hash = Math.imul(hash, 16777619);
    }
    return (hash >>> 0).toString(16).padStart(8, "0");
}
//# sourceMappingURL=AnalyticsPrivacyFixtures.js.map