import { r as __exportAll } from "./chunk-BSw8zbkd.mjs";
import { A as any, B as generateId, I as object, L as string, P as literal, a as BaseDocumentHeaderSchema, b as isDocumentAction, c as baseCreateDocument, f as createAction, g as createState, h as createReducer, k as _enum, l as baseLoadFromInput, o as BaseDocumentStateSchema, s as baseActions, u as baseSaveToFileHandle, v as defaultBaseState, z as datetime } from "./dist-RakiOObV.mjs";
//#region document-models/observation/v1/gen/schema/zod.ts
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
const definedNonNullAnySchema = any().refine((v) => isDefinedNonNullAny(v));
const ObservationCategorySchema = _enum([
	"FRICTION",
	"METHODOLOGY",
	"PROCESS",
	"QUALITY",
	"SURPRISE"
]);
const ObservationStatusSchema = _enum([
	"ARCHIVED",
	"IMPLEMENTED",
	"PENDING",
	"PROMOTED"
]);
function ArchiveObservationInputSchema() {
	return object({ updatedAt: datetime() });
}
function CreateObservationInputSchema() {
	return object({
		category: ObservationCategorySchema,
		content: string().nullish(),
		description: string(),
		observedAt: datetime(),
		observedBy: string().nullish(),
		title: string()
	});
}
function ImplementObservationInputSchema() {
	return object({ updatedAt: datetime() });
}
function ObservationStateSchema() {
	return object({
		__typename: literal("ObservationState").optional(),
		category: ObservationCategorySchema.nullish(),
		content: string().nullish(),
		description: string().nullish(),
		observedAt: datetime().nullish(),
		observedBy: string().nullish(),
		promotedAt: datetime().nullish(),
		promotedTo: string().nullish(),
		status: ObservationStatusSchema.nullish(),
		title: string().nullish()
	});
}
function PromoteObservationInputSchema() {
	return object({
		promotedAt: datetime(),
		promotedTo: string()
	});
}
//#endregion
//#region document-models/observation/v1/gen/observation-management/creators.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
var creators_exports = /* @__PURE__ */ __exportAll({
	archiveObservation: () => archiveObservation,
	createObservation: () => createObservation,
	implementObservation: () => implementObservation,
	promoteObservation: () => promoteObservation
});
const createObservation = (input) => createAction("CREATE_OBSERVATION", { ...input }, void 0, CreateObservationInputSchema, "global");
const promoteObservation = (input) => createAction("PROMOTE_OBSERVATION", { ...input }, void 0, PromoteObservationInputSchema, "global");
const implementObservation = (input) => createAction("IMPLEMENT_OBSERVATION", { ...input }, void 0, ImplementObservationInputSchema, "global");
const archiveObservation = (input) => createAction("ARCHIVE_OBSERVATION", { ...input }, void 0, ArchiveObservationInputSchema, "global");
//#endregion
//#region document-models/observation/v1/actions.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
/** Actions for the Observation document model */
const actions = {
	...baseActions,
	...creators_exports
};
//#endregion
//#region document-models/observation/v1/gen/document-model.ts
const documentModel = {
	author: {
		name: "BAI",
		website: "https://bai.powerhouse.io/"
	},
	description: "Operational learning signal — captures friction, surprises, methodology insights, and quality observations from knowledge processing",
	extension: "",
	id: "bai/observation",
	name: "Observation",
	specifications: [{
		changeLog: [],
		modules: [{
			description: "Observation lifecycle",
			id: "observation-management",
			name: "observation-management",
			operations: [
				{
					description: "Capture a new friction signal",
					errors: [],
					examples: [],
					id: "create-observation",
					name: "CREATE_OBSERVATION",
					reducer: "state.title = action.input.title;\nstate.description = action.input.description;\nstate.content = action.input.content || null;\nstate.category = action.input.category;\nstate.status = \"PENDING\";\nstate.observedAt = action.input.observedAt;\nstate.observedBy = action.input.observedBy || null;",
					schema: "input CreateObservationInput {\n    title: String!\n    description: String!\n    content: String\n    category: ObservationCategory!\n    observedAt: DateTime!\n    observedBy: String\n}",
					template: "Capture a new friction signal",
					scope: "global"
				},
				{
					description: "Promote to a permanent note",
					errors: [],
					examples: [],
					id: "promote-observation",
					name: "PROMOTE_OBSERVATION",
					reducer: "state.status = \"PROMOTED\";\nstate.promotedTo = action.input.promotedTo;\nstate.promotedAt = action.input.promotedAt;",
					schema: "input PromoteObservationInput {\n    promotedTo: String!\n    promotedAt: DateTime!\n}",
					template: "Promote to a permanent note",
					scope: "global"
				},
				{
					description: "Mark as implemented in system",
					errors: [],
					examples: [],
					id: "implement-observation",
					name: "IMPLEMENT_OBSERVATION",
					reducer: "state.status = \"IMPLEMENTED\";",
					schema: "input ImplementObservationInput {\n    updatedAt: DateTime!\n}",
					template: "Mark as implemented in system",
					scope: "global"
				},
				{
					description: "Archive observation",
					errors: [],
					examples: [],
					id: "archive-observation",
					name: "ARCHIVE_OBSERVATION",
					reducer: "state.status = \"ARCHIVED\";",
					schema: "input ArchiveObservationInput {\n    updatedAt: DateTime!\n}",
					template: "Archive observation",
					scope: "global"
				}
			]
		}],
		state: {
			global: {
				examples: [],
				initialValue: "{\n    \"title\": null,\n    \"description\": null,\n    \"content\": null,\n    \"category\": null,\n    \"status\": \"PENDING\",\n    \"observedAt\": null,\n    \"observedBy\": null,\n    \"promotedTo\": null,\n    \"promotedAt\": null\n}",
				schema: "enum ObservationCategory {\n    METHODOLOGY\n    PROCESS\n    FRICTION\n    SURPRISE\n    QUALITY\n}\n\nenum ObservationStatus {\n    PENDING\n    PROMOTED\n    IMPLEMENTED\n    ARCHIVED\n}\n\ntype ObservationState {\n    title: String\n    description: String\n    content: String\n    category: ObservationCategory\n    status: ObservationStatus\n    observedAt: DateTime\n    observedBy: String\n    promotedTo: String\n    promotedAt: DateTime\n}"
			},
			local: {
				examples: [],
				initialValue: "",
				schema: ""
			}
		},
		version: 1
	}]
};
//#endregion
//#region document-models/observation/v1/src/reducers/observation-management.ts
const observationObservationManagementOperations = {
	createObservationOperation(state, action) {
		state.title = action.input.title;
		state.description = action.input.description;
		state.content = action.input.content || null;
		state.category = action.input.category;
		state.status = "PENDING";
		state.observedAt = action.input.observedAt;
		state.observedBy = action.input.observedBy || null;
	},
	promoteObservationOperation(state, action) {
		state.status = "PROMOTED";
		state.promotedTo = action.input.promotedTo;
		state.promotedAt = action.input.promotedAt;
	},
	implementObservationOperation(state, action) {
		state.status = "IMPLEMENTED";
	},
	archiveObservationOperation(state, action) {
		state.status = "ARCHIVED";
	}
};
//#endregion
//#region document-models/observation/v1/gen/reducer.ts
const stateReducer = (state, action, dispatch) => {
	if (isDocumentAction(action)) return state;
	switch (action.type) {
		case "CREATE_OBSERVATION":
			CreateObservationInputSchema().parse(action.input);
			observationObservationManagementOperations.createObservationOperation(state[action.scope], action, dispatch);
			break;
		case "PROMOTE_OBSERVATION":
			PromoteObservationInputSchema().parse(action.input);
			observationObservationManagementOperations.promoteObservationOperation(state[action.scope], action, dispatch);
			break;
		case "IMPLEMENT_OBSERVATION":
			ImplementObservationInputSchema().parse(action.input);
			observationObservationManagementOperations.implementObservationOperation(state[action.scope], action, dispatch);
			break;
		case "ARCHIVE_OBSERVATION":
			ArchiveObservationInputSchema().parse(action.input);
			observationObservationManagementOperations.archiveObservationOperation(state[action.scope], action, dispatch);
			break;
		default: return state;
	}
};
const reducer = createReducer(stateReducer);
//#endregion
//#region document-models/observation/v1/gen/document-type.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
const observationDocumentType = "bai/observation";
//#endregion
//#region document-models/observation/v1/gen/document-schema.ts
/**
* WARNING: DO NOT EDIT
* This file is auto-generated and updated by codegen
*/
/** Schema for validating the header object of a Observation document */
const ObservationDocumentHeaderSchema = BaseDocumentHeaderSchema.extend({ documentType: literal(observationDocumentType) });
/** Schema for validating the state object of a Observation document */
const ObservationPHStateSchema = BaseDocumentStateSchema.extend({ global: ObservationStateSchema() });
const ObservationDocumentSchema = object({
	header: ObservationDocumentHeaderSchema,
	state: ObservationPHStateSchema,
	initialState: ObservationPHStateSchema
});
/** Simple helper function to check if a state object is a Observation document state object */
function isObservationState(state) {
	return ObservationPHStateSchema.safeParse(state).success;
}
/** Simple helper function to assert that a document state object is a Observation document state object */
function assertIsObservationState(state) {
	ObservationPHStateSchema.parse(state);
}
/** Simple helper function to check if a document is a Observation document */
function isObservationDocument(document) {
	return ObservationDocumentSchema.safeParse(document).success;
}
/** Simple helper function to assert that a document is a Observation document */
function assertIsObservationDocument(document) {
	ObservationDocumentSchema.parse(document);
}
//#endregion
//#region document-models/observation/v1/gen/utils.ts
const initialGlobalState = {
	title: null,
	description: null,
	content: null,
	category: null,
	status: "PENDING",
	observedAt: null,
	observedBy: null,
	promotedTo: null,
	promotedAt: null
};
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 = observationDocumentType;
		document.header.id = generateId();
		return document;
	},
	saveToFileHandle(document, input) {
		return baseSaveToFileHandle(document, input);
	},
	loadFromInput(input) {
		return baseLoadFromInput(input, reducer);
	},
	isStateOfType(state) {
		return isObservationState(state);
	},
	assertIsStateOfType(state) {
		return assertIsObservationState(state);
	},
	isDocumentOfType(document) {
		return isObservationDocument(document);
	},
	assertIsDocumentOfType(document) {
		return assertIsObservationDocument(document);
	}
};
//#endregion
//#region document-models/observation/v1/src/utils.ts
var utils_exports = /* @__PURE__ */ __exportAll({});
//#endregion
//#region document-models/observation/v1/utils.ts
/** Utils for the Observation document model */
const utils = {
	...utils$1,
	...utils_exports
};
//#endregion
//#region document-models/observation/v1/module.ts
/** Document model module for the Observation document type */
const Observation = {
	version: 1,
	reducer,
	actions,
	utils,
	documentModel: createState(defaultBaseState(), documentModel)
};
//#endregion
export { isDefinedNonNullAny as A, CreateObservationInputSchema as C, ObservationStatusSchema as D, ObservationStateSchema as E, PromoteObservationInputSchema as O, ArchiveObservationInputSchema as S, ObservationCategorySchema as T, archiveObservation as _, utils$1 as a, implementObservation as b, ObservationPHStateSchema as c, isObservationDocument as d, isObservationState as f, actions as g, documentModel as h, initialLocalState as i, definedNonNullAnySchema as k, assertIsObservationDocument as l, reducer as m, utils as n, ObservationDocumentHeaderSchema as o, observationDocumentType as p, initialGlobalState as r, ObservationDocumentSchema as s, Observation as t, assertIsObservationState as u, createObservation as v, ImplementObservationInputSchema as w, promoteObservation as x, creators_exports as y };

//# sourceMappingURL=module-DBggFqG0.mjs.map