import type { Action } from "@sveltejs/kit";
import type { Trace } from "./models/Primitive.svelte";

export function arraysAreEqual(arr1: string[], arr2: string[]) {
    if (arr1.length !== arr2.length) {
        return false; // Arrays of different lengths are not equal
    }
    for (let i = 0; i < arr1.length; i++) {
        if (arr1[i] !== arr2[i]) {
            return false; // Mismatched element found
        }
    }
    return true; // All elements match
}


export function tracesAreEqual(arr1: Trace[], arr2: Trace[]) {
    if (arr1.length !== arr2.length) {
        return false; // Arrays of different lengths are not equal
    }
    for (let i = 0; i < arr1.length; i++) {
        if (arr1[i].key !== arr2[i].key) {
            return false; // Mismatched element found
        }
    }
    return true; // All elements match
}

export function tracesAreEqual2(arr1: Trace[], arr2: string[]) {
    if (arr1.length !== arr2.length) {
        return false; // Arrays of different lengths are not equal
    }
    for (let i = 0; i < arr1.length; i++) {
        if (arr1[i].key !== arr2[i]) {
            return false; // Mismatched element found
        }
    }
    return true; // All elements match
}

export function sleep(ms: number): Promise<void> {
    return new Promise(resolve => setTimeout(resolve, ms));
}
