import { r as __exportAll } from "./chunk-olfrzTEO.js";
import { B as lazy, I as _enum, L as any, R as array, U as object, V as literal, W as string, a as BaseDocumentHeaderSchema, b as generateId, c as baseCreateDocument, f as createAction, g as createState, h as createReducer, l as baseLoadFromInput, o as BaseDocumentStateSchema, s as baseActions, u as baseSaveToFileHandle, v as defaultBaseState, x as isDocumentAction } from "./dist-uUUuTqM0.js";
//#region document-models/accounts/v1/gen/document-model.ts
const documentModel = {
	id: "powerhouse/accounts",
	name: "Accounts",
	author: {
		name: "Powerhouse",
		website: "https://powerhouse.inc"
	},
	extension: "",
	description: "Document model for managing accounts with KYC/AML status tracking.",
	specifications: [{
		state: {
			local: {
				schema: "",
				examples: [],
				initialValue: ""
			},
			global: {
				schema: "type AccountsState {\n   accounts: [AccountEntry!]!\n}\n\ntype AccountEntry {\n    id: OID!\n    account: String!\n    name: String!\n    budgetPath: String\n    accountTransactionsId: PHID\n    chain: [String!]\n    type: AccountType!\n    owners: [String!]\n    KycAmlStatus: KycAmlStatusType\n}\n\nenum AccountType {\n    Source\n    Internal\n    Destination\n    External\n}\n\nenum KycAmlStatusType {\n    PASSED\n    PENDING\n    FAILED\n}\n\nenum AccountTypeInput {\n  Source\n  Internal\n  Destination\n  External\n}\n\nenum KycAmlStatusTypeInput {\n  PASSED\n  PENDING\n  FAILED\n}",
				examples: [],
				initialValue: "{\"accounts\": []}"
			}
		},
		modules: [{
			id: "accounts",
			name: "accounts",
			operations: [
				{
					id: "add-account",
					name: "addAccount",
					scope: "global",
					errors: [],
					schema: "input AddAccountInput {\n  id: OID!\n  account: String!\n  name: String!\n  budgetPath: String\n  accountTransactionsId: PHID\n  chain: [String!]\n  type: AccountTypeInput!\n  owners: [String!]\n  KycAmlStatus: KycAmlStatusTypeInput\n}",
					reducer: "",
					examples: [],
					template: "",
					description: ""
				},
				{
					id: "update-account",
					name: "updateAccount",
					scope: "global",
					errors: [],
					schema: "input UpdateAccountInput {\n    id: OID!\n    account: String\n    name: String\n    budgetPath: String\n    accountTransactionsId: PHID\n    chain: [String!]\n    type: AccountTypeInput\n    owners: [String!]\n    KycAmlStatus: KycAmlStatusTypeInput\n}",
					reducer: "",
					examples: [],
					template: "",
					description: ""
				},
				{
					id: "delete-account",
					name: "deleteAccount",
					scope: "global",
					errors: [],
					schema: "input DeleteAccountInput {\n    id: OID!\n}",
					reducer: "",
					examples: [],
					template: "",
					description: ""
				},
				{
					id: "update-kyc-status",
					name: "updateKycStatus",
					scope: "global",
					errors: [],
					schema: "input UpdateKycStatusInput {\n    id: OID!\n    KycAmlStatus: KycAmlStatusTypeInput!\n}",
					reducer: "",
					examples: [],
					template: "",
					description: ""
				}
			],
			description: ""
		}],
		version: 1,
		changeLog: []
	}]
};
//#endregion
//#region document-models/accounts/v1/src/reducers/accounts.ts
const accountsAccountsOperations = {
	addAccountOperation(state, action) {
		state.accounts.push({
			id: action.input.id,
			account: action.input.account,
			name: action.input.name,
			budgetPath: action.input.budgetPath || null,
			accountTransactionsId: action.input.accountTransactionsId || null,
			chain: action.input.chain || null,
			type: action.input.type,
			owners: action.input.owners || null,
			KycAmlStatus: action.input.KycAmlStatus || "PENDING"
		});
	},
	updateAccountOperation(state, action) {
		const account = state.accounts.find((account) => account.id === action.input.id);
		if (!account) throw new Error(`Account with id ${action.input.id} not found`);
		if (action.input.account) account.account = action.input.account;
		if (action.input.name) account.name = action.input.name;
		if (action.input.budgetPath) account.budgetPath = action.input.budgetPath;
		if (action.input.accountTransactionsId) account.accountTransactionsId = action.input.accountTransactionsId;
		if (action.input.chain) account.chain = action.input.chain;
		if (action.input.type) account.type = action.input.type;
		if (action.input.owners) account.owners = action.input.owners;
		if (action.input.KycAmlStatus) account.KycAmlStatus = action.input.KycAmlStatus;
	},
	deleteAccountOperation(state, action) {
		state.accounts = state.accounts.filter((account) => account.id !== action.input.id);
	},
	updateKycStatusOperation(state, action) {
		const account = state.accounts.find((account) => account.id === action.input.id);
		if (!account) throw new Error(`Account with id ${action.input.id} not found`);
		account.KycAmlStatus = action.input.KycAmlStatus || "PENDING";
	}
};
//#endregion
//#region document-models/accounts/v1/gen/schema/zod.ts
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
const definedNonNullAnySchema = any().refine((v) => isDefinedNonNullAny(v));
const AccountTypeSchema = _enum([
	"Destination",
	"External",
	"Internal",
	"Source"
]);
const AccountTypeInputSchema = _enum([
	"Destination",
	"External",
	"Internal",
	"Source"
]);
const KycAmlStatusTypeSchema = _enum([
	"FAILED",
	"PASSED",
	"PENDING"
]);
const KycAmlStatusTypeInputSchema = _enum([
	"FAILED",
	"PASSED",
	"PENDING"
]);
function AccountEntrySchema() {
	return object({
		__typename: literal("AccountEntry").optional(),
		KycAmlStatus: KycAmlStatusTypeSchema.nullish(),
		account: string(),
		accountTransactionsId: string().nullish(),
		budgetPath: string().nullish(),
		chain: array(string()).nullish(),
		id: string(),
		name: string(),
		owners: array(string()).nullish(),
		type: AccountTypeSchema
	});
}
function AccountsStateSchema() {
	return object({
		__typename: literal("AccountsState").optional(),
		accounts: array(lazy(() => AccountEntrySchema()))
	});
}
function AddAccountInputSchema() {
	return object({
		KycAmlStatus: KycAmlStatusTypeInputSchema.nullish(),
		account: string(),
		accountTransactionsId: string().nullish(),
		budgetPath: string().nullish(),
		chain: array(string()).nullish(),
		id: string(),
		name: string(),
		owners: array(string()).nullish(),
		type: AccountTypeInputSchema
	});
}
function DeleteAccountInputSchema() {
	return object({ id: string() });
}
function UpdateAccountInputSchema() {
	return object({
		KycAmlStatus: KycAmlStatusTypeInputSchema.nullish(),
		account: string().nullish(),
		accountTransactionsId: string().nullish(),
		budgetPath: string().nullish(),
		chain: array(string()).nullish(),
		id: string(),
		name: string().nullish(),
		owners: array(string()).nullish(),
		type: AccountTypeInputSchema.nullish()
	});
}
function UpdateKycStatusInputSchema() {
	return object({
		KycAmlStatus: KycAmlStatusTypeInputSchema,
		id: string()
	});
}
//#endregion
//#region document-models/accounts/v1/gen/reducer.ts
const stateReducer = (state, action, dispatch) => {
	if (isDocumentAction(action)) return state;
	switch (action.type) {
		case "ADD_ACCOUNT":
			AddAccountInputSchema().parse(action.input);
			accountsAccountsOperations.addAccountOperation(state[action.scope], action, dispatch);
			break;
		case "UPDATE_ACCOUNT":
			UpdateAccountInputSchema().parse(action.input);
			accountsAccountsOperations.updateAccountOperation(state[action.scope], action, dispatch);
			break;
		case "DELETE_ACCOUNT":
			DeleteAccountInputSchema().parse(action.input);
			accountsAccountsOperations.deleteAccountOperation(state[action.scope], action, dispatch);
			break;
		case "UPDATE_KYC_STATUS":
			UpdateKycStatusInputSchema().parse(action.input);
			accountsAccountsOperations.updateKycStatusOperation(state[action.scope], action, dispatch);
			break;
		default: return state;
	}
};
const reducer = createReducer(stateReducer);
//#endregion
//#region document-models/accounts/v1/gen/accounts/creators.ts
var creators_exports = /* @__PURE__ */ __exportAll({
	addAccount: () => addAccount,
	deleteAccount: () => deleteAccount,
	updateAccount: () => updateAccount,
	updateKycStatus: () => updateKycStatus
});
const addAccount = (input) => createAction("ADD_ACCOUNT", { ...input }, void 0, AddAccountInputSchema, "global");
const updateAccount = (input) => createAction("UPDATE_ACCOUNT", { ...input }, void 0, UpdateAccountInputSchema, "global");
const deleteAccount = (input) => createAction("DELETE_ACCOUNT", { ...input }, void 0, DeleteAccountInputSchema, "global");
const updateKycStatus = (input) => createAction("UPDATE_KYC_STATUS", { ...input }, void 0, UpdateKycStatusInputSchema, "global");
//#endregion
//#region document-models/accounts/v1/actions.ts
/** Actions for the Accounts document model */
const actions = {
	...baseActions,
	...creators_exports
};
//#endregion
//#region document-models/accounts/v1/gen/document-type.ts
const accountsDocumentType = "powerhouse/accounts";
//#endregion
//#region document-models/accounts/v1/gen/document-schema.ts
/** Schema for validating the header object of a Accounts document */
const AccountsDocumentHeaderSchema = BaseDocumentHeaderSchema.extend({ documentType: literal(accountsDocumentType) });
/** Schema for validating the state object of a Accounts document */
const AccountsPHStateSchema = BaseDocumentStateSchema.extend({ global: AccountsStateSchema() });
const AccountsDocumentSchema = object({
	header: AccountsDocumentHeaderSchema,
	state: AccountsPHStateSchema,
	initialState: AccountsPHStateSchema
});
/** Simple helper function to check if a state object is a Accounts document state object */
function isAccountsState(state) {
	return AccountsPHStateSchema.safeParse(state).success;
}
/** Simple helper function to assert that a document state object is a Accounts document state object */
function assertIsAccountsState(state) {
	AccountsPHStateSchema.parse(state);
}
/** Simple helper function to check if a document is a Accounts document */
function isAccountsDocument(document) {
	return AccountsDocumentSchema.safeParse(document).success;
}
/** Simple helper function to assert that a document is a Accounts document */
function assertIsAccountsDocument(document) {
	AccountsDocumentSchema.parse(document);
}
//#endregion
//#region document-models/accounts/v1/gen/utils.ts
const initialGlobalState = { accounts: [] };
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 = accountsDocumentType;
		document.header.id = generateId();
		return document;
	},
	saveToFileHandle(document, input) {
		return baseSaveToFileHandle(document, input);
	},
	loadFromInput(input) {
		return baseLoadFromInput(input, reducer);
	},
	isStateOfType(state) {
		return isAccountsState(state);
	},
	assertIsStateOfType(state) {
		return assertIsAccountsState(state);
	},
	isDocumentOfType(document) {
		return isAccountsDocument(document);
	},
	assertIsDocumentOfType(document) {
		return assertIsAccountsDocument(document);
	}
};
//#endregion
//#region document-models/accounts/v1/src/utils.ts
var utils_exports = /* @__PURE__ */ __exportAll({});
//#endregion
//#region document-models/accounts/v1/utils.ts
/** Utils for the Accounts document model */
const utils = {
	...utils$1,
	...utils_exports
};
//#endregion
//#region document-models/accounts/v1/module.ts
/** Document model module for the Accounts document type */
const Accounts = {
	version: 1,
	reducer,
	actions,
	utils,
	documentModel: createState(defaultBaseState(), documentModel)
};
//#endregion
export { UpdateKycStatusInputSchema as A, AccountTypeSchema as C, KycAmlStatusTypeInputSchema as D, DeleteAccountInputSchema as E, isDefinedNonNullAny as M, documentModel as N, KycAmlStatusTypeSchema as O, AccountTypeInputSchema as S, AddAccountInputSchema as T, deleteAccount as _, utils$1 as a, reducer as b, AccountsPHStateSchema as c, isAccountsDocument as d, isAccountsState as f, creators_exports as g, addAccount as h, initialLocalState as i, definedNonNullAnySchema as j, UpdateAccountInputSchema as k, assertIsAccountsDocument as l, actions as m, utils as n, AccountsDocumentHeaderSchema as o, accountsDocumentType as p, initialGlobalState as r, AccountsDocumentSchema as s, Accounts as t, assertIsAccountsState as u, updateAccount as v, AccountsStateSchema as w, AccountEntrySchema as x, updateKycStatus as y };

//# sourceMappingURL=module-DJjNH-7f.js.map