/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
/**
 * @internal
 */
export function matchProperties(a, b) {
    if (!a && !b) {
        return true;
    }
    const keysA = a ? Object.keys(a) : [];
    const keysB = b ? Object.keys(b) : [];
    if (keysA.length !== keysB.length) {
        return false;
    }
    for (const key of keysA) {
        if (b?.[key] === undefined) {
            return false;
        }
        else if (typeof b[key] === "object") {
            if (!matchProperties(a?.[key], b[key])) {
                return false;
            }
        }
        else if (b[key] !== a?.[key]) {
            return false;
        }
    }
    return true;
}
/**
 * @deprecated This functionality was not intended for public export and will
 * be removed in a future release.
 * @internal
 */
export function extend(base, extension) {
    if (extension !== undefined) {
        // eslint-disable-next-line guard-for-in, no-restricted-syntax
        for (const key in extension) {
            const v = extension[key];
            if (v === null) {
                // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
                delete base[key];
            }
            else {
                base[key] = v;
            }
        }
    }
    return base;
}
/**
 * @deprecated This functionality was not intended for public export and will
 * be removed in a future release.
 * @internal
 */
export function clone(extension) {
    if (extension === undefined) {
        return undefined;
    }
    const cloneMap = createMap();
    // eslint-disable-next-line guard-for-in, no-restricted-syntax
    for (const key in extension) {
        const v = extension[key];
        if (v !== null) {
            cloneMap[key] = v;
        }
    }
    return cloneMap;
}
/**
 * @deprecated This functionality was not intended for public export and will
 * be removed in a future release.
 * @internal
 */
export function addProperties(oldProps, newProps) {
    const _oldProps = oldProps ?? createMap();
    extend(_oldProps, newProps);
    return _oldProps;
}
/**
 * @deprecated This functionality was not intended for public export and will
 * be removed in a future release.
 * @internal
 */
export function extendIfUndefined(base, extension) {
    if (extension !== undefined) {
        // eslint-disable-next-line no-restricted-syntax
        for (const key in extension) {
            if (base[key] === undefined) {
                base[key] = extension[key];
            }
        }
    }
    return base;
}
/**
 * @deprecated This functionality was not intended for public export and will
 * be removed in a future release.
 * @internal
 */
// Create a MapLike with good performance.
export function createMap() {
    return Object.create(null);
}
//# sourceMappingURL=properties.mjs.map