import { r as __exportAll } from "./chunk-BSw8zbkd.mjs";
import { B as generateId, b as isDocumentAction, c as baseCreateDocument, f as createAction, g as createState, h as createReducer, l as baseLoadFromInput, s as baseActions, u as baseSaveToFileHandle, v as defaultBaseState } from "./dist-RakiOObV.mjs";
import { a as assertIsHealthReportState, c as healthReportDocumentType, i as assertIsHealthReportDocument, l as AddCheckInputSchema, o as isHealthReportDocument, s as isHealthReportState, u as GenerateReportInputSchema } from "./document-schema-7Cm44odC.mjs";
//#region document-models/health-report/v1/gen/report-management/creators.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
var creators_exports = /* @__PURE__ */ __exportAll({
	addCheck: () => addCheck,
	generateReport: () => generateReport
});
const generateReport = (input) => createAction("GENERATE_REPORT", { ...input }, void 0, GenerateReportInputSchema, "global");
const addCheck = (input) => createAction("ADD_CHECK", { ...input }, void 0, AddCheckInputSchema, "global");
//#endregion
//#region document-models/health-report/v1/actions.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
/** Actions for the HealthReport document model */
const actions = {
	...baseActions,
	...creators_exports
};
//#endregion
//#region document-models/health-report/v1/gen/document-model.ts
const documentModel = {
	author: {
		name: "BAI",
		website: "https://bai.powerhouse.io/"
	},
	description: "Vault diagnostics — point-in-time health report with graph metrics, check results, and recommendations",
	extension: "",
	id: "bai/health-report",
	name: "HealthReport",
	specifications: [{
		changeLog: [],
		modules: [{
			description: "Health report generation",
			id: "report-management",
			name: "report-management",
			operations: [{
				description: "Generate a health report",
				errors: [],
				examples: [],
				id: "generate-report",
				name: "GENERATE_REPORT",
				reducer: "state.generatedAt = action.input.generatedAt;\nstate.generatedBy = action.input.generatedBy || null;\nstate.mode = action.input.mode;\nstate.overallStatus = action.input.overallStatus;\nstate.graphMetrics = action.input.graphMetrics;\nstate.recommendations = action.input.recommendations;\nstate.checks = [];",
				schema: "input GraphMetricsInput {\n    noteCount: Int!\n    mocCount: Int!\n    connectionCount: Int!\n    density: Float!\n    orphanCount: Int!\n    danglingLinkCount: Int!\n    mocCoverage: Float!\n    averageLinksPerNote: Float!\n}\n\ninput GenerateReportInput {\n    generatedAt: DateTime!\n    generatedBy: String\n    mode: String!\n    overallStatus: HealthStatus!\n    graphMetrics: GraphMetricsInput!\n    recommendations: [String!]!\n}",
				template: "Generate a health report",
				scope: "global"
			}, {
				description: "Add a health check result",
				errors: [],
				examples: [],
				id: "add-check",
				name: "ADD_CHECK",
				reducer: "state.checks.push({\n    id: action.input.id,\n    category: action.input.category,\n    status: action.input.status,\n    message: action.input.message,\n    affectedItems: action.input.affectedItems,\n});",
				schema: "input AddCheckInput {\n    id: OID!\n    category: HealthCategory!\n    status: HealthStatus!\n    message: String!\n    affectedItems: [String!]!\n}",
				template: "Add a health check result",
				scope: "global"
			}]
		}],
		state: {
			global: {
				examples: [],
				initialValue: "{\n    \"generatedAt\": null,\n    \"generatedBy\": null,\n    \"mode\": null,\n    \"overallStatus\": null,\n    \"checks\": [],\n    \"graphMetrics\": null,\n    \"recommendations\": []\n}",
				schema: "enum HealthStatus {\n    PASS\n    WARN\n    FAIL\n}\n\nenum HealthCategory {\n    SCHEMA_COMPLIANCE\n    ORPHAN_DETECTION\n    LINK_HEALTH\n    DESCRIPTION_QUALITY\n    THREE_SPACE_BOUNDARIES\n    PROCESSING_THROUGHPUT\n    STALE_NOTES\n    MOC_COHERENCE\n}\n\ntype HealthCheck {\n    id: OID!\n    category: HealthCategory!\n    status: HealthStatus!\n    message: String!\n    affectedItems: [String!]!\n}\n\ntype GraphMetrics {\n    noteCount: Int!\n    mocCount: Int!\n    connectionCount: Int!\n    density: Float!\n    orphanCount: Int!\n    danglingLinkCount: Int!\n    mocCoverage: Float!\n    averageLinksPerNote: Float!\n}\n\ntype HealthReportState {\n    generatedAt: DateTime\n    generatedBy: String\n    mode: String\n    overallStatus: HealthStatus\n    checks: [HealthCheck!]!\n    graphMetrics: GraphMetrics\n    recommendations: [String!]!\n}"
			},
			local: {
				examples: [],
				initialValue: "",
				schema: ""
			}
		},
		version: 1
	}]
};
//#endregion
//#region document-models/health-report/v1/src/reducers/report-management.ts
const healthReportReportManagementOperations = {
	generateReportOperation(state, action) {
		state.generatedAt = action.input.generatedAt;
		state.generatedBy = action.input.generatedBy || null;
		state.mode = action.input.mode;
		state.overallStatus = action.input.overallStatus;
		state.graphMetrics = action.input.graphMetrics;
		state.recommendations = action.input.recommendations;
		state.checks = [];
	},
	addCheckOperation(state, action) {
		state.checks.push({
			id: action.input.id,
			category: action.input.category,
			status: action.input.status,
			message: action.input.message,
			affectedItems: action.input.affectedItems
		});
	}
};
//#endregion
//#region document-models/health-report/v1/gen/reducer.ts
const stateReducer = (state, action, dispatch) => {
	if (isDocumentAction(action)) return state;
	switch (action.type) {
		case "GENERATE_REPORT":
			GenerateReportInputSchema().parse(action.input);
			healthReportReportManagementOperations.generateReportOperation(state[action.scope], action, dispatch);
			break;
		case "ADD_CHECK":
			AddCheckInputSchema().parse(action.input);
			healthReportReportManagementOperations.addCheckOperation(state[action.scope], action, dispatch);
			break;
		default: return state;
	}
};
const reducer = createReducer(stateReducer);
//#endregion
//#region document-models/health-report/v1/gen/utils.ts
const initialGlobalState = {
	generatedAt: null,
	generatedBy: null,
	mode: null,
	overallStatus: null,
	checks: [],
	graphMetrics: null,
	recommendations: []
};
const initialLocalState = {};
const utils$1 = {
	fileExtension: "",
	createState(state) {
		return {
			...defaultBaseState(),
			global: {
				...initialGlobalState,
				...state?.global
			},
			local: {
				...initialLocalState,
				...state?.local
			}
		};
	},
	createDocument(state) {
		const document = baseCreateDocument(utils$1.createState, state);
		document.header.documentType = healthReportDocumentType;
		document.header.id = generateId();
		return document;
	},
	saveToFileHandle(document, input) {
		return baseSaveToFileHandle(document, input);
	},
	loadFromInput(input) {
		return baseLoadFromInput(input, reducer);
	},
	isStateOfType(state) {
		return isHealthReportState(state);
	},
	assertIsStateOfType(state) {
		return assertIsHealthReportState(state);
	},
	isDocumentOfType(document) {
		return isHealthReportDocument(document);
	},
	assertIsDocumentOfType(document) {
		return assertIsHealthReportDocument(document);
	}
};
//#endregion
//#region document-models/health-report/v1/src/utils.ts
var utils_exports = /* @__PURE__ */ __exportAll({});
//#endregion
//#region document-models/health-report/v1/utils.ts
/** Utils for the HealthReport document model */
const utils = {
	...utils$1,
	...utils_exports
};
//#endregion
//#region document-models/health-report/v1/module.ts
/** Document model module for the HealthReport document type */
const HealthReport = {
	version: 1,
	reducer,
	actions,
	utils,
	documentModel: createState(defaultBaseState(), documentModel)
};
//#endregion
export { utils$1 as a, actions as c, generateReport as d, initialLocalState as i, addCheck as l, utils as n, reducer as o, initialGlobalState as r, documentModel as s, HealthReport as t, creators_exports as u };

//# sourceMappingURL=module-B-_Qn-5_.mjs.map