/**
 * Element parsing/serialization utilities
 */
/**
 * Parse element JSON string into ElementData
 */
export function parse_element(element_json) {
    try {
        const parsed = JSON.parse(element_json);
        return parsed;
    }
    catch {
        return null;
    }
}
/**
 * Stringify ElementData to JSON
 */
export function stringify_element(data) {
    return JSON.stringify(data, null, 2);
}
/**
 * Type guard: check if element data is a field
 */
export function is_field_element(data) {
    return data.field_type === 'field';
}
/**
 * Type guard: check if element data is a group
 */
export function is_group_element(data) {
    return data.field_type === 'group';
}
/**
 * Check if an ElementRecord represents a field element
 */
export function is_field_record(record) {
    const data = parse_element(record.element);
    return data !== null && is_field_element(data);
}
/**
 * Check if an ElementRecord represents a group element
 */
export function is_group_record(record) {
    const data = parse_element(record.element);
    return data !== null && is_group_element(data);
}
/**
 * Create a default field element data object
 */
export function create_default_field(id, label) {
    return {
        id,
        label,
        field_type: 'field',
        component_type: 'HazoCollabFormInputbox',
        value: '',
        description: '',
        required: false,
    };
}
/**
 * Create a default group element data object
 */
export function create_default_group(id, label) {
    return {
        id,
        label,
        field_type: 'group',
        description: '',
        reference_element: [],
    };
}
//# sourceMappingURL=element_utils.js.map