/*!
 * Custom elements for Nanopore-Digital Web applications
 */
// Separate file (so it's safe to import into the worker)
/**
 * Accesses a nested property using dot notation.
 * @param obj - the object to access
 * @param path - the property path (e.g., 'props.nested.name')
 * @returns the value at the path, or undefined if not found
 */
export function getNestedProperty(obj, path) {
    if (!obj || path === null || path === undefined)
        return undefined;
    // Convert to string for consistent handling
    const pathStr = String(path);
    // Check for a flattened property first (optimization for transformed values)
    // e.g., obj["user.birthDate"] takes precedence over obj.user.birthDate
    if (obj[pathStr] !== undefined) {
        return obj[pathStr];
    }
    // If the path doesn't contain a dot, just return the direct property
    if (!pathStr.includes('.')) {
        return obj[path];
    }
    // Split the path and traverse the object
    const keys = pathStr.split('.');
    let result = obj;
    for (const key of keys) {
        if (result === null || result === undefined) {
            return undefined;
        }
        result = result[key];
    }
    return result;
}
