import WarpError from "../errors/WarpError.js";
const WARNING_NOTICE = 'warning';
const FATAL_NOTICE = 'fatal';
/** Runtime-backed warning or fatal planning notice for graph-model migration. */
export default class GraphModelMigrationNotice {
    kind;
    code;
    message;
    constructor(fields) {
        const checkedFields = requireFields(fields);
        this.kind = requireKind(checkedFields.kind);
        this.code = requireNonEmptyString(checkedFields.code, 'code');
        this.message = requireNonEmptyString(checkedFields.message, 'message');
        Object.freeze(this);
    }
    /** Builds a warning notice. */
    static warning(code, message) {
        return new GraphModelMigrationNotice({ kind: WARNING_NOTICE, code, message });
    }
    /** Builds a fatal planning notice. */
    static fatal(code, message) {
        return new GraphModelMigrationNotice({ kind: FATAL_NOTICE, code, message });
    }
    /** Returns true when this notice blocks planning. */
    isFatal() {
        return this.kind === FATAL_NOTICE;
    }
}
/** Validates the constructor envelope. */
function requireFields(fields) {
    if (fields === null || fields === undefined) {
        throw new WarpError('GraphModelMigrationNotice fields must be provided', 'E_VALIDATION');
    }
    return fields;
}
/** Validates a notice kind. */
function requireKind(kind) {
    if (kind !== WARNING_NOTICE && kind !== FATAL_NOTICE) {
        throw new WarpError('GraphModelMigrationNotice kind must be warning or fatal', 'E_VALIDATION');
    }
    return kind;
}
/** Validates a required non-empty string. */
function requireNonEmptyString(value, name) {
    if (typeof value !== 'string' || value.length === 0) {
        throw new WarpError(`${name} must be a non-empty string`, 'E_VALIDATION');
    }
    return value;
}
