import { r as __exportAll } from "./chunk-olfrzTEO.js";
import { b as generateId, c as baseCreateDocument, g as createState, h as createReducer, l as baseLoadFromInput, s as baseActions, u as baseSaveToFileHandle, v as defaultBaseState, x as isDocumentAction } from "./dist-uUUuTqM0.js";
import { c as RemoveSubteamInputSchema, l as SetOperationalHubNameInputSchema, n as creators_exports, o as AddSubteamInputSchema, u as SetOperatorTeamInputSchema } from "./creators-BZ72KijW.js";
import { a as assertIsOperationalHubProfileState, c as operationalHubProfileDocumentType, i as assertIsOperationalHubProfileDocument, o as isOperationalHubProfileDocument, s as isOperationalHubProfileState } from "./document-schema-DUJorxA0.js";
//#region document-models/operational-hub-profile/v1/gen/document-model.ts
const documentModel = {
	id: "powerhouse/operational-hub-profile",
	name: "OperationalHubProfile",
	author: {
		name: "Powerhouse",
		website: "https://www.powerhouse.inc/"
	},
	extension: "",
	description: "Profile document for Operational Hubs that manages operator team assignment and subteam relationships.",
	specifications: [{
		state: {
			local: {
				schema: "",
				examples: [],
				initialValue: ""
			},
			global: {
				schema: "type OperationalHubProfileState {\n  name: String!\n  operatorTeam: PHID\n  subteams: [PHID!]!\n}",
				examples: [],
				initialValue: "{\"name\": \"\", \"operatorTeam\": null, \"subteams\": []}"
			}
		},
		modules: [{
			id: "configuration",
			name: "configuration",
			operations: [
				{
					id: "set-operational-hub-name",
					name: "setOperationalHubName",
					scope: "global",
					errors: [],
					schema: "input SetOperationalHubNameInput {\n  name: String!\n}",
					reducer: "state.name = action.input.name;",
					examples: [],
					template: "Set the name of the operational hub",
					description: "Set the name of the operational hub"
				},
				{
					id: "set-operator-team",
					name: "setOperatorTeam",
					scope: "global",
					errors: [],
					schema: "input SetOperatorTeamInput {\n  operatorTeam: PHID\n}",
					reducer: "state.operatorTeam = action.input.operatorTeam || null;",
					examples: [],
					template: "Set the operator team PHID for this operational hub",
					description: "Set the operator team PHID for this operational hub"
				},
				{
					id: "add-subteam",
					name: "addSubteam",
					scope: "global",
					errors: [],
					schema: "input AddSubteamInput {\n  subteam: PHID!\n}",
					reducer: "if (!state.subteams.includes(action.input.subteam)) {\n  state.subteams.push(action.input.subteam);\n}",
					examples: [],
					template: "Add a subteam (builder profile) to the operational hub",
					description: "Add a subteam (builder profile) to the operational hub"
				},
				{
					id: "remove-subteam",
					name: "removeSubteam",
					scope: "global",
					errors: [],
					schema: "input RemoveSubteamInput {\n  subteam: PHID!\n}",
					reducer: "const index = state.subteams.indexOf(action.input.subteam);\nif (index !== -1) {\n  state.subteams.splice(index, 1);\n}",
					examples: [],
					template: "Remove a subteam from the operational hub",
					description: "Remove a subteam from the operational hub"
				}
			],
			description: "Operations for configuring the operational hub profile"
		}],
		version: 1,
		changeLog: []
	}]
};
//#endregion
//#region document-models/operational-hub-profile/v1/src/reducers/configuration.ts
const operationalHubProfileConfigurationOperations = {
	setOperationalHubNameOperation(state, action) {
		state.name = action.input.name;
	},
	setOperatorTeamOperation(state, action) {
		state.operatorTeam = action.input.operatorTeam || null;
	},
	addSubteamOperation(state, action) {
		if (!state.subteams.includes(action.input.subteam)) state.subteams.push(action.input.subteam);
	},
	removeSubteamOperation(state, action) {
		const index = state.subteams.indexOf(action.input.subteam);
		if (index !== -1) state.subteams.splice(index, 1);
	}
};
//#endregion
//#region document-models/operational-hub-profile/v1/gen/reducer.ts
const stateReducer = (state, action, dispatch) => {
	if (isDocumentAction(action)) return state;
	switch (action.type) {
		case "SET_OPERATIONAL_HUB_NAME":
			SetOperationalHubNameInputSchema().parse(action.input);
			operationalHubProfileConfigurationOperations.setOperationalHubNameOperation(state[action.scope], action, dispatch);
			break;
		case "SET_OPERATOR_TEAM":
			SetOperatorTeamInputSchema().parse(action.input);
			operationalHubProfileConfigurationOperations.setOperatorTeamOperation(state[action.scope], action, dispatch);
			break;
		case "ADD_SUBTEAM":
			AddSubteamInputSchema().parse(action.input);
			operationalHubProfileConfigurationOperations.addSubteamOperation(state[action.scope], action, dispatch);
			break;
		case "REMOVE_SUBTEAM":
			RemoveSubteamInputSchema().parse(action.input);
			operationalHubProfileConfigurationOperations.removeSubteamOperation(state[action.scope], action, dispatch);
			break;
		default: return state;
	}
};
const reducer = createReducer(stateReducer);
//#endregion
//#region document-models/operational-hub-profile/v1/actions.ts
/** Actions for the OperationalHubProfile document model */
const actions = {
	...baseActions,
	...creators_exports
};
//#endregion
//#region document-models/operational-hub-profile/v1/gen/utils.ts
const initialGlobalState = {
	name: "",
	operatorTeam: null,
	subteams: []
};
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 = operationalHubProfileDocumentType;
		document.header.id = generateId();
		return document;
	},
	saveToFileHandle(document, input) {
		return baseSaveToFileHandle(document, input);
	},
	loadFromInput(input) {
		return baseLoadFromInput(input, reducer);
	},
	isStateOfType(state) {
		return isOperationalHubProfileState(state);
	},
	assertIsStateOfType(state) {
		return assertIsOperationalHubProfileState(state);
	},
	isDocumentOfType(document) {
		return isOperationalHubProfileDocument(document);
	},
	assertIsDocumentOfType(document) {
		return assertIsOperationalHubProfileDocument(document);
	}
};
//#endregion
//#region document-models/operational-hub-profile/v1/src/utils.ts
var utils_exports = /* @__PURE__ */ __exportAll({});
//#endregion
//#region document-models/operational-hub-profile/v1/utils.ts
/** Utils for the OperationalHubProfile document model */
const utils = {
	...utils$1,
	...utils_exports
};
//#endregion
//#region document-models/operational-hub-profile/v1/module.ts
/** Document model module for the OperationalHubProfile document type */
const OperationalHubProfile = {
	version: 1,
	reducer,
	actions,
	utils,
	documentModel: createState(defaultBaseState(), documentModel)
};
//#endregion
export { utils$1 as a, documentModel as c, initialLocalState as i, utils as n, actions as o, initialGlobalState as r, reducer as s, OperationalHubProfile as t };

//# sourceMappingURL=module-C-RNzl6i.js.map