/*!
 * Copyright (C) Microsoft Corporation. All rights reserved.
 */
import { isJsonObject } from './schemaUtils.js';
/** Extracts a human-readable display name from CDP connector metadata, for use as the data source label. */
export function tryExtractDisplayNameFromCdpMetadata(metadata) {
    // Assuming metadata contains a 'name' or similar field for the stored procedure
    try {
        // If metadata is a string, try to parse it as JSON
        let json = metadata;
        if (typeof metadata === 'string') {
            json = JSON.parse(metadata);
        }
        // Use type guards to safely access properties
        if (isJsonObject(json)) {
            // Try to get the title first, as it's often more user-friendly
            if ('title' in json && typeof json.title === 'string') {
                return json.title;
            }
            // Fall back to name if title isn't available
            if ('name' in json && typeof json.name === 'string') {
                return json.name;
            }
        }
        // If we can't find a suitable property, use the default name
        return undefined;
    }
    catch (ex) {
        return undefined;
    }
}
//# sourceMappingURL=cdpUtils.js.map