export function sampleCloudServiceFixture(options = {}) {
    const seed = normalizeSeed(options.seed ?? 0xc10d);
    const playerId = normalizePlayerId(options.playerId ?? "external-parity-runtime-player");
    const score = positiveInteger(options.score ?? 12_400, "score");
    const sessionSeconds = positiveInteger(options.sessionSeconds ?? 180, "sessionSeconds");
    const offlineMode = options.offlineMode ?? true;
    const abTestGroup = seededChoice(seed, ["control", "variant-a", "variant-b"]);
    const difficultyScale = Number((0.86 + seededUnit(seed ^ 0x55a5) * 0.24).toFixed(3));
    const eventMultiplier = Number((1 + Math.min(0.5, sessionSeconds / 1800)).toFixed(3));
    const version = 3 + Math.floor(seededUnit(seed ^ 0x911) * 6);
    const savePayload = JSON.stringify({ playerId, score, sessionSeconds, version });
    const cloudSaveChecksum = stableHash(savePayload);
    const achievements = [
        { id: "first-run", points: 10, progress: 1 },
        { id: "collector", points: 25, progress: Math.min(1, score / 20_000) },
        { id: "speed-clear", points: 50, progress: Math.min(1, sessionSeconds <= 240 ? 1 : 240 / sessionSeconds) }
    ];
    const unlocked = achievements.filter((achievement) => achievement.progress >= 1).map((achievement) => achievement.id);
    const inProgress = achievements.filter((achievement) => achievement.progress < 1).map((achievement) => ({
        id: achievement.id,
        progress: Number(achievement.progress.toFixed(3))
    }));
    const rank = Math.max(1, Math.round(5000 / Math.max(1, score / 500)));
    const integrityHashes = [
        stableHash(`runtime-content:${seed}:arena`),
        stableHash(`runtime-content:${seed}:hero`),
        stableHash(`runtime-content:${seed}:config`)
    ];
    const status = offlineMode ? "offline-cache" : "queued";
    const fixture = {
        source: "origin-master-cloud-services-adapted",
        services: {
            authentication: {
                provider: "guest",
                authenticated: false,
                offlineUserId: `guest-${stableHash(playerId).slice(0, 6)}`,
                tokenIssued: false,
                status
            },
            cloudSave: {
                saveId: "runtime-progress",
                version,
                checksum: cloudSaveChecksum,
                queuedUploads: offlineMode ? 1 : 0,
                conflictResolution: "last-write-wins",
                status: offlineMode ? "queued" : "synced"
            },
            achievements: {
                unlocked,
                inProgress,
                totalPoints: achievements.filter((achievement) => achievement.progress >= 1).reduce((sum, achievement) => sum + achievement.points, 0),
                status
            },
            leaderboard: {
                id: "runtime-score",
                score,
                rank,
                timeFrame: "weekly",
                cachedEntries: 5 + Math.floor(seededUnit(seed ^ 0x7717) * 8),
                status
            },
            remoteConfig: {
                activated: true,
                abTestGroup,
                parameterCount: 4,
                difficultyScale,
                eventMultiplier,
                status
            },
            matchmaking: {
                queue: "casual-runtime",
                region: "local",
                ticketId: `ticket-${stableHash(`${playerId}:${score}`).slice(0, 8)}`,
                estimatedWaitMs: Math.round(1500 + seededUnit(seed ^ 0x4d47) * 3000),
                matchedPlayers: 2,
                status: "simulated-match"
            },
            contentDelivery: {
                manifestId: "runtime-content",
                assetCount: integrityHashes.length,
                cacheHits: offlineMode ? integrityHashes.length : Math.max(1, integrityHashes.length - 1),
                integrityHashes,
                status
            }
        },
        productionReadiness: {
            cloudServiceTelemetry: true,
            offlineQueueTelemetry: true,
            remoteConfigTelemetry: true,
            leaderboardTelemetry: true,
            matchmakingTelemetry: true,
            contentDeliveryTelemetry: true
        },
        blockedClaims: [
            "real cloud authentication backend",
            "production cloud-save conflict resolution",
            "hosted CDN/content-delivery parity",
            "real multiplayer matchmaking service",
            "Unity Gaming Services parity",
            "Unreal Online Services parity",
            "privacy/compliance/security certification"
        ],
        claimBoundary: "This fixture ports old cloud-service concepts into deterministic local telemetry. It does not contact a backend, issue real auth tokens, upload saves, submit leaderboards, run CDN delivery, create multiplayer matches, or claim Unity Gaming Services or Unreal Online Services parity."
    };
    return {
        ...fixture,
        hash: stableHash(JSON.stringify(fixture))
    };
}
function normalizeSeed(seed) {
    if (!Number.isInteger(seed) || seed < 0)
        throw new Error("seed must be a non-negative integer.");
    return seed >>> 0;
}
function normalizePlayerId(playerId) {
    const trimmed = playerId.trim();
    if (trimmed.length === 0)
        throw new Error("playerId must not be empty.");
    return trimmed;
}
function positiveInteger(value, name) {
    if (!Number.isInteger(value) || value <= 0)
        throw new Error(`${name} must be a positive integer.`);
    return value;
}
function seededChoice(seed, values) {
    return values[Math.min(values.length - 1, Math.floor(seededUnit(seed) * values.length))];
}
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=CloudServiceFixtures.js.map