import { n as __exportAll } from "./chunk-YKewjYmz.js";
import { A as any, B as url, F as literal, L as object, N as email, P as lazy, R as string, V as datetime, a as BaseDocumentHeaderSchema, b as generateId, c as baseCreateDocument, f as createAction, g as createState, h as createReducer, j as array, k as _enum, l as baseLoadFromInput, o as BaseDocumentStateSchema, s as baseActions, u as baseSaveToFileHandle, v as defaultBaseState, x as isDocumentAction } from "./dist-CdWSQzOH.js";
//#region document-models/grant-system/v1/gen/document-model.ts
const documentModel = {
	id: "rfp-hub/grant-system",
	name: "GrantSystem",
	author: {
		name: "Powerhouse",
		website: "https://www.powerhouse.inc/"
	},
	extension: "rfps",
	description: "DAOIP-5 Grant System — the organizational entity (DAO, Foundation, Program) that administers grant pools and issues RFPs.",
	specifications: [{
		state: {
			local: {
				schema: "",
				examples: [],
				initialValue: ""
			},
			global: {
				schema: "type GrantSystemState {\n  # DAOIP-5 canonical\n  name: String\n  type: GrantSystemType\n  grantPoolsURI: URL\n  extensions: String\n\n  # schema.org/Grant additions (non-breaking)\n  sameAs: [URL!]!\n\n  # Powerhouse profile additions\n  code: String\n  description: String\n  image: URL\n  coverImage: URL\n  email: EmailAddress\n  contactName: String\n  socials: [Social!]!\n\n  # Publisher verification lifecycle\n  verificationState: VerificationState!\n  verificationMethod: VerificationMethod\n  verifiedAt: DateTime\n  verifiedBy: String\n  revokedAt: DateTime\n  revocationReason: String\n  publisherWallet: EthereumAddress\n}\n\nenum GrantSystemType {\n  DAO\n  FOUNDATION\n  PROTOCOL\n  COMPANY\n  PROGRAM\n  PERSON\n  OTHER\n}\n\nenum VerificationState {\n  UNVERIFIED\n  PENDING_REVIEW\n  VERIFIED\n  SUSPENDED\n  REVOKED\n}\n\nenum VerificationMethod {\n  MANUAL_REVIEW\n  DOMAIN_VERIFICATION\n  WALLET_SIGNATURE\n  THIRD_PARTY_ATTESTATION\n}\n\ntype Social {\n  id: OID!\n  platform: SocialPlatform!\n  url: URL!\n}\n\nenum SocialPlatform {\n  TWITTER\n  DISCORD\n  TELEGRAM\n  GITHUB\n  LINKEDIN\n  FARCASTER\n  LENS\n  MIRROR\n  WEBSITE\n}\n",
				examples: [],
				initialValue: "{\"name\": null, \"type\": null, \"grantPoolsURI\": null, \"extensions\": null, \"sameAs\": [], \"code\": null, \"description\": null, \"image\": null, \"coverImage\": null, \"email\": null, \"contactName\": null, \"socials\": [], \"verificationState\": \"UNVERIFIED\", \"verificationMethod\": null, \"verifiedAt\": null, \"verifiedBy\": null, \"revokedAt\": null, \"revocationReason\": null, \"publisherWallet\": null}"
			}
		},
		modules: [
			{
				id: "identity-module",
				name: "identity",
				description: "Core DAOIP-5 identity + Powerhouse profile fields",
				operations: [
					{
						id: "gs-set-type",
						name: "SET_TYPE",
						description: "",
						schema: "input SetTypeInput {\n    type: GrantSystemType!\n}",
						template: "",
						reducer: "state.type = action.input.type;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-set-code",
						name: "SET_CODE",
						description: "",
						schema: "input SetCodeInput {\n    code: String\n}",
						template: "",
						reducer: "state.code = action.input.code || null;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-set-description",
						name: "SET_DESCRIPTION",
						description: "",
						schema: "input SetDescriptionInput {\n    description: String\n}",
						template: "",
						reducer: "state.description = action.input.description || null;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-set-grant-pools-uri",
						name: "SET_GRANT_POOLS_URI",
						description: "",
						schema: "input SetGrantPoolsUriInput {\n    grantPoolsURI: URL\n}",
						template: "",
						reducer: "state.grantPoolsURI = action.input.grantPoolsURI || null;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-set-extensions",
						name: "SET_EXTENSIONS",
						description: "",
						schema: "input SetExtensionsInput {\n    extensions: String\n}",
						template: "",
						reducer: "state.extensions = action.input.extensions || null;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-set-image",
						name: "SET_IMAGE",
						description: "",
						schema: "input SetImageInput {\n    image: URL\n}",
						template: "",
						reducer: "state.image = action.input.image || null;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-set-cover-image",
						name: "SET_COVER_IMAGE",
						description: "",
						schema: "input SetCoverImageInput {\n    coverImage: URL\n}",
						template: "",
						reducer: "state.coverImage = action.input.coverImage || null;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-set-email",
						name: "SET_EMAIL",
						description: "",
						schema: "input SetEmailInput {\n    email: EmailAddress\n}",
						template: "",
						reducer: "state.email = action.input.email || null;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-set-contact-name",
						name: "SET_CONTACT_NAME",
						description: "",
						schema: "input SetContactNameInput {\n    contactName: String\n}",
						template: "",
						reducer: "state.contactName = action.input.contactName || null;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-set-org-name",
						name: "SET_ORG_NAME",
						description: "",
						schema: "input SetOrgNameInput {\n    name: String!\n}",
						template: "",
						reducer: "state.name = action.input.name;",
						errors: [],
						examples: [],
						scope: "global"
					}
				]
			},
			{
				id: "links-module",
				name: "links",
				description: "Schema.org identity aliases and social media links",
				operations: [
					{
						id: "gs-add-same-as",
						name: "ADD_SAME_AS",
						description: "",
						schema: "input AddSameAsInput {\n    url: URL!\n}",
						template: "",
						reducer: "if (state.sameAs.includes(action.input.url)) {\n  throw new SameAsAlreadyExistsError(`URL ${action.input.url} already in sameAs list`);\n}\nstate.sameAs.push(action.input.url);",
						errors: [{
							id: "err-same-as-exists",
							name: "SameAsAlreadyExistsError",
							code: "SAME_AS_ALREADY_EXISTS",
							description: "Attempted to add a URL that is already present in the sameAs list.",
							template: ""
						}],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-remove-same-as",
						name: "REMOVE_SAME_AS",
						description: "",
						schema: "input RemoveSameAsInput {\n    url: URL!\n}",
						template: "",
						reducer: "const idx = state.sameAs.indexOf(action.input.url);\nif (idx === -1) {\n  throw new SameAsNotFoundError(`URL ${action.input.url} not in sameAs list`);\n}\nstate.sameAs.splice(idx, 1);",
						errors: [{
							id: "err-same-as-not-found",
							name: "SameAsNotFoundError",
							code: "SAME_AS_NOT_FOUND",
							description: "Attempted to remove a URL that is not present in the sameAs list.",
							template: ""
						}],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-add-social",
						name: "ADD_SOCIAL",
						description: "",
						schema: "input AddSocialInput {\n    id: OID!\n    platform: SocialPlatform!\n    url: URL!\n}",
						template: "",
						reducer: "state.socials.push({\n  id: action.input.id,\n  platform: action.input.platform,\n  url: action.input.url,\n});",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-remove-social",
						name: "REMOVE_SOCIAL",
						description: "",
						schema: "input RemoveSocialInput {\n    id: OID!\n}",
						template: "",
						reducer: "const idx = state.socials.findIndex((s) => s.id === action.input.id);\nif (idx === -1) {\n  throw new SocialNotFoundError(`Social with id ${action.input.id} not found`);\n}\nstate.socials.splice(idx, 1);",
						errors: [{
							id: "err-social-not-found-remove",
							name: "SocialNotFoundError",
							code: "SOCIAL_NOT_FOUND_REMOVE",
							description: "Attempted to remove a social link with an unknown id.",
							template: ""
						}],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-update-social-url",
						name: "UPDATE_SOCIAL_URL",
						description: "",
						schema: "input UpdateSocialUrlInput {\n    id: OID!\n    url: URL!\n}",
						template: "",
						reducer: "const social = state.socials.find((s) => s.id === action.input.id);\nif (!social) {\n  throw new SocialNotFoundError(`Social with id ${action.input.id} not found`);\n}\nsocial.url = action.input.url;",
						errors: [{
							id: "err-social-not-found-update",
							name: "SocialNotFoundUpdateError",
							code: "SOCIAL_NOT_FOUND_UPDATE",
							description: "Attempted to update a social link with an unknown id.",
							template: ""
						}],
						examples: [],
						scope: "global"
					}
				]
			},
			{
				id: "verification-module",
				name: "verification",
				description: "Publisher verification lifecycle operations",
				operations: [
					{
						id: "gs-set-publisher-wallet",
						name: "SET_PUBLISHER_WALLET",
						description: "",
						schema: "input SetPublisherWalletInput {\n    publisherWallet: EthereumAddress!\n}",
						template: "",
						reducer: "state.publisherWallet = action.input.publisherWallet;",
						errors: [],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-request-verification",
						name: "REQUEST_VERIFICATION",
						description: "",
						schema: "input RequestVerificationInput {\n    requestedAt: DateTime!\n}",
						template: "",
						reducer: "if (state.verificationState !== \"UNVERIFIED\") {\n  throw new InvalidStateTransitionError(\n    `Cannot request verification from state ${state.verificationState}; must be UNVERIFIED`\n  );\n}\nstate.verificationState = \"PENDING_REVIEW\";",
						errors: [{
							id: "err-invalid-transition-request",
							name: "InvalidStateTransitionError",
							code: "INVALID_STATE_TRANSITION_REQUEST",
							description: "Invalid state transition for verification lifecycle.",
							template: ""
						}],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-approve-verification",
						name: "APPROVE_VERIFICATION",
						description: "",
						schema: "input ApproveVerificationInput {\n    verifiedBy: String!\n    method: VerificationMethod!\n    verifiedAt: DateTime!\n}",
						template: "",
						reducer: "if (state.verificationState !== \"PENDING_REVIEW\") {\n  throw new InvalidStateTransitionError(\n    `Cannot approve verification from state ${state.verificationState}; must be PENDING_REVIEW`\n  );\n}\nstate.verificationState = \"VERIFIED\";\nstate.verifiedBy = action.input.verifiedBy;\nstate.verificationMethod = action.input.method;\nstate.verifiedAt = action.input.verifiedAt;\nstate.revokedAt = null;\nstate.revocationReason = null;",
						errors: [{
							id: "err-invalid-transition-approve",
							name: "InvalidApproveStateError",
							code: "INVALID_STATE_TRANSITION_APPROVE",
							description: "Cannot approve verification unless state is PENDING_REVIEW.",
							template: ""
						}],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-reject-verification",
						name: "REJECT_VERIFICATION",
						description: "",
						schema: "input RejectVerificationInput {\n    reason: String!\n    rejectedAt: DateTime!\n}",
						template: "",
						reducer: "if (state.verificationState !== \"PENDING_REVIEW\") {\n  throw new InvalidStateTransitionError(\n    `Cannot reject verification from state ${state.verificationState}; must be PENDING_REVIEW`\n  );\n}\nstate.verificationState = \"UNVERIFIED\";",
						errors: [{
							id: "err-invalid-transition-reject",
							name: "InvalidRejectStateError",
							code: "INVALID_STATE_TRANSITION_REJECT",
							description: "Cannot reject verification unless state is PENDING_REVIEW.",
							template: ""
						}],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-suspend-verification",
						name: "SUSPEND_VERIFICATION",
						description: "",
						schema: "input SuspendVerificationInput {\n    reason: String!\n    suspendedAt: DateTime!\n}",
						template: "",
						reducer: "if (state.verificationState !== \"VERIFIED\") {\n  throw new InvalidStateTransitionError(\n    `Cannot suspend from state ${state.verificationState}; must be VERIFIED`\n  );\n}\nstate.verificationState = \"SUSPENDED\";\nstate.revocationReason = action.input.reason;",
						errors: [{
							id: "err-invalid-transition-suspend",
							name: "InvalidSuspendStateError",
							code: "INVALID_STATE_TRANSITION_SUSPEND",
							description: "Cannot suspend unless state is VERIFIED.",
							template: ""
						}],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-revoke-verification",
						name: "REVOKE_VERIFICATION",
						description: "",
						schema: "input RevokeVerificationInput {\n    reason: String!\n    revokedAt: DateTime!\n}",
						template: "",
						reducer: "if (state.verificationState !== \"VERIFIED\") {\n  throw new InvalidStateTransitionError(\n    `Cannot revoke from state ${state.verificationState}; must be VERIFIED`\n  );\n}\nstate.verificationState = \"REVOKED\";\nstate.revokedAt = action.input.revokedAt;\nstate.revocationReason = action.input.reason;",
						errors: [{
							id: "err-invalid-transition-revoke",
							name: "InvalidRevokeStateError",
							code: "INVALID_STATE_TRANSITION_REVOKE",
							description: "Cannot revoke unless state is VERIFIED.",
							template: ""
						}],
						examples: [],
						scope: "global"
					},
					{
						id: "gs-reinstate-verification",
						name: "REINSTATE_VERIFICATION",
						description: "",
						schema: "input ReinstateVerificationInput {\n    reinstatedBy: String!\n    verifiedAt: DateTime!\n}",
						template: "",
						reducer: "if (state.verificationState !== \"SUSPENDED\" && state.verificationState !== \"REVOKED\") {\n  throw new InvalidStateTransitionError(\n    `Cannot reinstate from state ${state.verificationState}; must be SUSPENDED or REVOKED`\n  );\n}\nstate.verificationState = \"VERIFIED\";\nstate.verifiedBy = action.input.reinstatedBy;\nstate.verifiedAt = action.input.verifiedAt;\nstate.revokedAt = null;\nstate.revocationReason = null;",
						errors: [{
							id: "err-invalid-transition-reinstate",
							name: "InvalidReinstateStateError",
							code: "INVALID_STATE_TRANSITION_REINSTATE",
							description: "Cannot reinstate unless state is SUSPENDED or REVOKED.",
							template: ""
						}],
						examples: [],
						scope: "global"
					}
				]
			}
		],
		version: 1,
		changeLog: []
	}]
};
//#endregion
//#region document-models/grant-system/v1/src/reducers/identity.ts
const grantSystemIdentityOperations = {
	setTypeOperation(state, action) {
		state.type = action.input.type;
	},
	setCodeOperation(state, action) {
		state.code = action.input.code || null;
	},
	setDescriptionOperation(state, action) {
		state.description = action.input.description || null;
	},
	setGrantPoolsUriOperation(state, action) {
		state.grantPoolsURI = action.input.grantPoolsURI || null;
	},
	setExtensionsOperation(state, action) {
		state.extensions = action.input.extensions || null;
	},
	setImageOperation(state, action) {
		state.image = action.input.image || null;
	},
	setCoverImageOperation(state, action) {
		state.coverImage = action.input.coverImage || null;
	},
	setEmailOperation(state, action) {
		state.email = action.input.email || null;
	},
	setContactNameOperation(state, action) {
		state.contactName = action.input.contactName || null;
	},
	setOrgNameOperation(state, action) {
		state.name = action.input.name;
	}
};
//#endregion
//#region document-models/grant-system/v1/gen/links/error.ts
var SameAsAlreadyExistsError = class extends Error {
	errorCode = "SameAsAlreadyExistsError";
	constructor(message = "SameAsAlreadyExistsError") {
		super(message);
	}
};
var SameAsNotFoundError = class extends Error {
	errorCode = "SameAsNotFoundError";
	constructor(message = "SameAsNotFoundError") {
		super(message);
	}
};
var SocialNotFoundError = class extends Error {
	errorCode = "SocialNotFoundError";
	constructor(message = "SocialNotFoundError") {
		super(message);
	}
};
//#endregion
//#region document-models/grant-system/v1/src/reducers/links.ts
const grantSystemLinksOperations = {
	addSameAsOperation(state, action) {
		if (state.sameAs.includes(action.input.url)) throw new SameAsAlreadyExistsError(`URL ${action.input.url} already in sameAs list`);
		state.sameAs.push(action.input.url);
	},
	removeSameAsOperation(state, action) {
		const idx = state.sameAs.indexOf(action.input.url);
		if (idx === -1) throw new SameAsNotFoundError(`URL ${action.input.url} not in sameAs list`);
		state.sameAs.splice(idx, 1);
	},
	addSocialOperation(state, action) {
		state.socials.push({
			id: action.input.id,
			platform: action.input.platform,
			url: action.input.url
		});
	},
	removeSocialOperation(state, action) {
		const idx = state.socials.findIndex((s) => s.id === action.input.id);
		if (idx === -1) throw new SocialNotFoundError(`Social with id ${action.input.id} not found`);
		state.socials.splice(idx, 1);
	},
	updateSocialUrlOperation(state, action) {
		const social = state.socials.find((s) => s.id === action.input.id);
		if (!social) throw new SocialNotFoundError(`Social with id ${action.input.id} not found`);
		social.url = action.input.url;
	}
};
//#endregion
//#region document-models/grant-system/v1/gen/verification/error.ts
var InvalidStateTransitionError = class extends Error {
	errorCode = "InvalidStateTransitionError";
	constructor(message = "InvalidStateTransitionError") {
		super(message);
	}
};
//#endregion
//#region document-models/grant-system/v1/src/reducers/verification.ts
const grantSystemVerificationOperations = {
	setPublisherWalletOperation(state, action) {
		state.publisherWallet = action.input.publisherWallet;
	},
	requestVerificationOperation(state, action) {
		if (state.verificationState !== "UNVERIFIED") throw new InvalidStateTransitionError(`Cannot request verification from state ${state.verificationState}; must be UNVERIFIED`);
		state.verificationState = "PENDING_REVIEW";
	},
	approveVerificationOperation(state, action) {
		if (state.verificationState !== "PENDING_REVIEW") throw new InvalidStateTransitionError(`Cannot approve verification from state ${state.verificationState}; must be PENDING_REVIEW`);
		state.verificationState = "VERIFIED";
		state.verifiedBy = action.input.verifiedBy;
		state.verificationMethod = action.input.method;
		state.verifiedAt = action.input.verifiedAt;
		state.revokedAt = null;
		state.revocationReason = null;
	},
	rejectVerificationOperation(state, action) {
		if (state.verificationState !== "PENDING_REVIEW") throw new InvalidStateTransitionError(`Cannot reject verification from state ${state.verificationState}; must be PENDING_REVIEW`);
		state.verificationState = "UNVERIFIED";
	},
	suspendVerificationOperation(state, action) {
		if (state.verificationState !== "VERIFIED") throw new InvalidStateTransitionError(`Cannot suspend from state ${state.verificationState}; must be VERIFIED`);
		state.verificationState = "SUSPENDED";
		state.revocationReason = action.input.reason;
	},
	revokeVerificationOperation(state, action) {
		if (state.verificationState !== "VERIFIED") throw new InvalidStateTransitionError(`Cannot revoke from state ${state.verificationState}; must be VERIFIED`);
		state.verificationState = "REVOKED";
		state.revokedAt = action.input.revokedAt;
		state.revocationReason = action.input.reason;
	},
	reinstateVerificationOperation(state, action) {
		if (state.verificationState !== "SUSPENDED" && state.verificationState !== "REVOKED") throw new InvalidStateTransitionError(`Cannot reinstate from state ${state.verificationState}; must be SUSPENDED or REVOKED`);
		state.verificationState = "VERIFIED";
		state.verifiedBy = action.input.reinstatedBy;
		state.verifiedAt = action.input.verifiedAt;
		state.revokedAt = null;
		state.revocationReason = null;
	}
};
//#endregion
//#region document-models/grant-system/v1/gen/schema/zod.ts
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
const definedNonNullAnySchema = any().refine((v) => isDefinedNonNullAny(v));
const GrantSystemTypeSchema = _enum([
	"COMPANY",
	"DAO",
	"FOUNDATION",
	"OTHER",
	"PERSON",
	"PROGRAM",
	"PROTOCOL"
]);
const SocialPlatformSchema = _enum([
	"DISCORD",
	"FARCASTER",
	"GITHUB",
	"LENS",
	"LINKEDIN",
	"MIRROR",
	"TELEGRAM",
	"TWITTER",
	"WEBSITE"
]);
const VerificationMethodSchema = _enum([
	"DOMAIN_VERIFICATION",
	"MANUAL_REVIEW",
	"THIRD_PARTY_ATTESTATION",
	"WALLET_SIGNATURE"
]);
const VerificationStateSchema = _enum([
	"PENDING_REVIEW",
	"REVOKED",
	"SUSPENDED",
	"UNVERIFIED",
	"VERIFIED"
]);
function AddSameAsInputSchema() {
	return object({ url: url() });
}
function AddSocialInputSchema() {
	return object({
		id: string(),
		platform: SocialPlatformSchema,
		url: url()
	});
}
function ApproveVerificationInputSchema() {
	return object({
		method: VerificationMethodSchema,
		verifiedAt: datetime(),
		verifiedBy: string()
	});
}
function GrantSystemStateSchema() {
	return object({
		__typename: literal("GrantSystemState").optional(),
		code: string().nullish(),
		contactName: string().nullish(),
		coverImage: url().nullish(),
		description: string().nullish(),
		email: email().nullish(),
		extensions: string().nullish(),
		grantPoolsURI: url().nullish(),
		image: url().nullish(),
		name: string().nullish(),
		publisherWallet: string().regex(/^0x[a-fA-F0-9]{40}$/, { message: "Invalid Ethereum address format" }).nullish(),
		revocationReason: string().nullish(),
		revokedAt: datetime().nullish(),
		sameAs: array(url()),
		socials: array(lazy(() => SocialSchema())),
		type: GrantSystemTypeSchema.nullish(),
		verificationMethod: VerificationMethodSchema.nullish(),
		verificationState: VerificationStateSchema,
		verifiedAt: datetime().nullish(),
		verifiedBy: string().nullish()
	});
}
function ReinstateVerificationInputSchema() {
	return object({
		reinstatedBy: string(),
		verifiedAt: datetime()
	});
}
function RejectVerificationInputSchema() {
	return object({
		reason: string(),
		rejectedAt: datetime()
	});
}
function RemoveSameAsInputSchema() {
	return object({ url: url() });
}
function RemoveSocialInputSchema() {
	return object({ id: string() });
}
function RequestVerificationInputSchema() {
	return object({ requestedAt: datetime() });
}
function RevokeVerificationInputSchema() {
	return object({
		reason: string(),
		revokedAt: datetime()
	});
}
function SetCodeInputSchema() {
	return object({ code: string().nullish() });
}
function SetContactNameInputSchema() {
	return object({ contactName: string().nullish() });
}
function SetCoverImageInputSchema() {
	return object({ coverImage: url().nullish() });
}
function SetDescriptionInputSchema() {
	return object({ description: string().nullish() });
}
function SetEmailInputSchema() {
	return object({ email: email().nullish() });
}
function SetExtensionsInputSchema() {
	return object({ extensions: string().nullish() });
}
function SetGrantPoolsUriInputSchema() {
	return object({ grantPoolsURI: url().nullish() });
}
function SetImageInputSchema() {
	return object({ image: url().nullish() });
}
function SetOrgNameInputSchema() {
	return object({ name: string() });
}
function SetPublisherWalletInputSchema() {
	return object({ publisherWallet: string().regex(/^0x[a-fA-F0-9]{40}$/, { message: "Invalid Ethereum address format" }) });
}
function SetTypeInputSchema() {
	return object({ type: GrantSystemTypeSchema });
}
function SocialSchema() {
	return object({
		__typename: literal("Social").optional(),
		id: string(),
		platform: SocialPlatformSchema,
		url: url()
	});
}
function SuspendVerificationInputSchema() {
	return object({
		reason: string(),
		suspendedAt: datetime()
	});
}
function UpdateSocialUrlInputSchema() {
	return object({
		id: string(),
		url: url()
	});
}
//#endregion
//#region document-models/grant-system/v1/gen/reducer.ts
const stateReducer = (state, action, dispatch) => {
	if (isDocumentAction(action)) return state;
	switch (action.type) {
		case "SET_TYPE":
			SetTypeInputSchema().parse(action.input);
			grantSystemIdentityOperations.setTypeOperation(state[action.scope], action, dispatch);
			break;
		case "SET_CODE":
			SetCodeInputSchema().parse(action.input);
			grantSystemIdentityOperations.setCodeOperation(state[action.scope], action, dispatch);
			break;
		case "SET_DESCRIPTION":
			SetDescriptionInputSchema().parse(action.input);
			grantSystemIdentityOperations.setDescriptionOperation(state[action.scope], action, dispatch);
			break;
		case "SET_GRANT_POOLS_URI":
			SetGrantPoolsUriInputSchema().parse(action.input);
			grantSystemIdentityOperations.setGrantPoolsUriOperation(state[action.scope], action, dispatch);
			break;
		case "SET_EXTENSIONS":
			SetExtensionsInputSchema().parse(action.input);
			grantSystemIdentityOperations.setExtensionsOperation(state[action.scope], action, dispatch);
			break;
		case "SET_IMAGE":
			SetImageInputSchema().parse(action.input);
			grantSystemIdentityOperations.setImageOperation(state[action.scope], action, dispatch);
			break;
		case "SET_COVER_IMAGE":
			SetCoverImageInputSchema().parse(action.input);
			grantSystemIdentityOperations.setCoverImageOperation(state[action.scope], action, dispatch);
			break;
		case "SET_EMAIL":
			SetEmailInputSchema().parse(action.input);
			grantSystemIdentityOperations.setEmailOperation(state[action.scope], action, dispatch);
			break;
		case "SET_CONTACT_NAME":
			SetContactNameInputSchema().parse(action.input);
			grantSystemIdentityOperations.setContactNameOperation(state[action.scope], action, dispatch);
			break;
		case "SET_ORG_NAME":
			SetOrgNameInputSchema().parse(action.input);
			grantSystemIdentityOperations.setOrgNameOperation(state[action.scope], action, dispatch);
			break;
		case "ADD_SAME_AS":
			AddSameAsInputSchema().parse(action.input);
			grantSystemLinksOperations.addSameAsOperation(state[action.scope], action, dispatch);
			break;
		case "REMOVE_SAME_AS":
			RemoveSameAsInputSchema().parse(action.input);
			grantSystemLinksOperations.removeSameAsOperation(state[action.scope], action, dispatch);
			break;
		case "ADD_SOCIAL":
			AddSocialInputSchema().parse(action.input);
			grantSystemLinksOperations.addSocialOperation(state[action.scope], action, dispatch);
			break;
		case "REMOVE_SOCIAL":
			RemoveSocialInputSchema().parse(action.input);
			grantSystemLinksOperations.removeSocialOperation(state[action.scope], action, dispatch);
			break;
		case "UPDATE_SOCIAL_URL":
			UpdateSocialUrlInputSchema().parse(action.input);
			grantSystemLinksOperations.updateSocialUrlOperation(state[action.scope], action, dispatch);
			break;
		case "SET_PUBLISHER_WALLET":
			SetPublisherWalletInputSchema().parse(action.input);
			grantSystemVerificationOperations.setPublisherWalletOperation(state[action.scope], action, dispatch);
			break;
		case "REQUEST_VERIFICATION":
			RequestVerificationInputSchema().parse(action.input);
			grantSystemVerificationOperations.requestVerificationOperation(state[action.scope], action, dispatch);
			break;
		case "APPROVE_VERIFICATION":
			ApproveVerificationInputSchema().parse(action.input);
			grantSystemVerificationOperations.approveVerificationOperation(state[action.scope], action, dispatch);
			break;
		case "REJECT_VERIFICATION":
			RejectVerificationInputSchema().parse(action.input);
			grantSystemVerificationOperations.rejectVerificationOperation(state[action.scope], action, dispatch);
			break;
		case "SUSPEND_VERIFICATION":
			SuspendVerificationInputSchema().parse(action.input);
			grantSystemVerificationOperations.suspendVerificationOperation(state[action.scope], action, dispatch);
			break;
		case "REVOKE_VERIFICATION":
			RevokeVerificationInputSchema().parse(action.input);
			grantSystemVerificationOperations.revokeVerificationOperation(state[action.scope], action, dispatch);
			break;
		case "REINSTATE_VERIFICATION":
			ReinstateVerificationInputSchema().parse(action.input);
			grantSystemVerificationOperations.reinstateVerificationOperation(state[action.scope], action, dispatch);
			break;
		default: return state;
	}
};
const reducer = createReducer(stateReducer);
//#endregion
//#region document-models/grant-system/v1/gen/identity/creators.ts
var creators_exports$2 = /* @__PURE__ */ __exportAll({
	setCode: () => setCode,
	setContactName: () => setContactName,
	setCoverImage: () => setCoverImage,
	setDescription: () => setDescription,
	setEmail: () => setEmail,
	setExtensions: () => setExtensions,
	setGrantPoolsUri: () => setGrantPoolsUri,
	setImage: () => setImage,
	setOrgName: () => setOrgName,
	setType: () => setType
});
const setType = (input) => createAction("SET_TYPE", { ...input }, void 0, SetTypeInputSchema, "global");
const setCode = (input) => createAction("SET_CODE", { ...input }, void 0, SetCodeInputSchema, "global");
const setDescription = (input) => createAction("SET_DESCRIPTION", { ...input }, void 0, SetDescriptionInputSchema, "global");
const setGrantPoolsUri = (input) => createAction("SET_GRANT_POOLS_URI", { ...input }, void 0, SetGrantPoolsUriInputSchema, "global");
const setExtensions = (input) => createAction("SET_EXTENSIONS", { ...input }, void 0, SetExtensionsInputSchema, "global");
const setImage = (input) => createAction("SET_IMAGE", { ...input }, void 0, SetImageInputSchema, "global");
const setCoverImage = (input) => createAction("SET_COVER_IMAGE", { ...input }, void 0, SetCoverImageInputSchema, "global");
const setEmail = (input) => createAction("SET_EMAIL", { ...input }, void 0, SetEmailInputSchema, "global");
const setContactName = (input) => createAction("SET_CONTACT_NAME", { ...input }, void 0, SetContactNameInputSchema, "global");
const setOrgName = (input) => createAction("SET_ORG_NAME", { ...input }, void 0, SetOrgNameInputSchema, "global");
//#endregion
//#region document-models/grant-system/v1/gen/links/creators.ts
var creators_exports$1 = /* @__PURE__ */ __exportAll({
	addSameAs: () => addSameAs,
	addSocial: () => addSocial,
	removeSameAs: () => removeSameAs,
	removeSocial: () => removeSocial,
	updateSocialUrl: () => updateSocialUrl
});
const addSameAs = (input) => createAction("ADD_SAME_AS", { ...input }, void 0, AddSameAsInputSchema, "global");
const removeSameAs = (input) => createAction("REMOVE_SAME_AS", { ...input }, void 0, RemoveSameAsInputSchema, "global");
const addSocial = (input) => createAction("ADD_SOCIAL", { ...input }, void 0, AddSocialInputSchema, "global");
const removeSocial = (input) => createAction("REMOVE_SOCIAL", { ...input }, void 0, RemoveSocialInputSchema, "global");
const updateSocialUrl = (input) => createAction("UPDATE_SOCIAL_URL", { ...input }, void 0, UpdateSocialUrlInputSchema, "global");
//#endregion
//#region document-models/grant-system/v1/gen/verification/creators.ts
var creators_exports = /* @__PURE__ */ __exportAll({
	approveVerification: () => approveVerification,
	reinstateVerification: () => reinstateVerification,
	rejectVerification: () => rejectVerification,
	requestVerification: () => requestVerification,
	revokeVerification: () => revokeVerification,
	setPublisherWallet: () => setPublisherWallet,
	suspendVerification: () => suspendVerification
});
const setPublisherWallet = (input) => createAction("SET_PUBLISHER_WALLET", { ...input }, void 0, SetPublisherWalletInputSchema, "global");
const requestVerification = (input) => createAction("REQUEST_VERIFICATION", { ...input }, void 0, RequestVerificationInputSchema, "global");
const approveVerification = (input) => createAction("APPROVE_VERIFICATION", { ...input }, void 0, ApproveVerificationInputSchema, "global");
const rejectVerification = (input) => createAction("REJECT_VERIFICATION", { ...input }, void 0, RejectVerificationInputSchema, "global");
const suspendVerification = (input) => createAction("SUSPEND_VERIFICATION", { ...input }, void 0, SuspendVerificationInputSchema, "global");
const revokeVerification = (input) => createAction("REVOKE_VERIFICATION", { ...input }, void 0, RevokeVerificationInputSchema, "global");
const reinstateVerification = (input) => createAction("REINSTATE_VERIFICATION", { ...input }, void 0, ReinstateVerificationInputSchema, "global");
//#endregion
//#region document-models/grant-system/v1/actions.ts
/** Actions for the GrantSystem document model */
const actions = {
	...baseActions,
	...creators_exports$2,
	...creators_exports$1,
	...creators_exports
};
//#endregion
//#region document-models/grant-system/v1/gen/document-type.ts
const grantSystemDocumentType = "rfp-hub/grant-system";
//#endregion
//#region document-models/grant-system/v1/gen/document-schema.ts
/** Schema for validating the header object of a GrantSystem document */
const GrantSystemDocumentHeaderSchema = BaseDocumentHeaderSchema.extend({ documentType: literal(grantSystemDocumentType) });
/** Schema for validating the state object of a GrantSystem document */
const GrantSystemPHStateSchema = BaseDocumentStateSchema.extend({ global: GrantSystemStateSchema() });
const GrantSystemDocumentSchema = object({
	header: GrantSystemDocumentHeaderSchema,
	state: GrantSystemPHStateSchema,
	initialState: GrantSystemPHStateSchema
});
/** Simple helper function to check if a state object is a GrantSystem document state object */
function isGrantSystemState(state) {
	return GrantSystemPHStateSchema.safeParse(state).success;
}
/** Simple helper function to assert that a document state object is a GrantSystem document state object */
function assertIsGrantSystemState(state) {
	GrantSystemPHStateSchema.parse(state);
}
/** Simple helper function to check if a document is a GrantSystem document */
function isGrantSystemDocument(document) {
	return GrantSystemDocumentSchema.safeParse(document).success;
}
/** Simple helper function to assert that a document is a GrantSystem document */
function assertIsGrantSystemDocument(document) {
	GrantSystemDocumentSchema.parse(document);
}
//#endregion
//#region document-models/grant-system/v1/gen/utils.ts
const initialGlobalState = {
	name: null,
	type: null,
	grantPoolsURI: null,
	extensions: null,
	sameAs: [],
	code: null,
	description: null,
	image: null,
	coverImage: null,
	email: null,
	contactName: null,
	socials: [],
	verificationState: "UNVERIFIED",
	verificationMethod: null,
	verifiedAt: null,
	verifiedBy: null,
	revokedAt: null,
	revocationReason: null,
	publisherWallet: null
};
const initialLocalState = {};
const utils$1 = {
	fileExtension: "rfps",
	createState(state) {
		return {
			...defaultBaseState(),
			global: {
				...initialGlobalState,
				...state?.global
			},
			local: {
				...initialLocalState,
				...state?.local
			}
		};
	},
	createDocument(state) {
		const document = baseCreateDocument(utils$1.createState, state);
		document.header.documentType = grantSystemDocumentType;
		document.header.id = generateId();
		return document;
	},
	saveToFileHandle(document, input) {
		return baseSaveToFileHandle(document, input);
	},
	loadFromInput(input) {
		return baseLoadFromInput(input, reducer);
	},
	isStateOfType(state) {
		return isGrantSystemState(state);
	},
	assertIsStateOfType(state) {
		return assertIsGrantSystemState(state);
	},
	isDocumentOfType(document) {
		return isGrantSystemDocument(document);
	},
	assertIsDocumentOfType(document) {
		return assertIsGrantSystemDocument(document);
	}
};
//#endregion
//#region document-models/grant-system/v1/src/utils.ts
var utils_exports = /* @__PURE__ */ __exportAll({});
//#endregion
//#region document-models/grant-system/v1/utils.ts
/** Utils for the GrantSystem document model */
const utils = {
	...utils$1,
	...utils_exports
};
//#endregion
//#region document-models/grant-system/v1/module.ts
/** Document model module for the GrantSystem document type */
const GrantSystem = {
	version: 1,
	reducer,
	actions,
	utils,
	documentModel: createState(defaultBaseState(), documentModel)
};
//#endregion
export { SetContactNameInputSchema as $, setCode as A, reducer as B, addSameAs as C, removeSocial as D, removeSameAs as E, setExtensions as F, GrantSystemTypeSchema as G, AddSocialInputSchema as H, setGrantPoolsUri as I, RemoveSameAsInputSchema as J, ReinstateVerificationInputSchema as K, setImage as L, setCoverImage as M, setDescription as N, updateSocialUrl as O, setEmail as P, SetCodeInputSchema as Q, setOrgName as R, suspendVerification as S, creators_exports$1 as T, ApproveVerificationInputSchema as U, AddSameAsInputSchema as V, GrantSystemStateSchema as W, RequestVerificationInputSchema as X, RemoveSocialInputSchema as Y, RevokeVerificationInputSchema as Z, reinstateVerification as _, documentModel as _t, utils$1 as a, SetImageInputSchema as at, revokeVerification as b, GrantSystemPHStateSchema as c, SetTypeInputSchema as ct, isGrantSystemDocument as d, SuspendVerificationInputSchema as dt, SetCoverImageInputSchema as et, isGrantSystemState as f, UpdateSocialUrlInputSchema as ft, creators_exports as g, isDefinedNonNullAny as gt, approveVerification as h, definedNonNullAnySchema as ht, initialLocalState as i, SetGrantPoolsUriInputSchema as it, setContactName as j, creators_exports$2 as k, assertIsGrantSystemDocument as l, SocialPlatformSchema as lt, actions as m, VerificationStateSchema as mt, utils as n, SetEmailInputSchema as nt, GrantSystemDocumentHeaderSchema as o, SetOrgNameInputSchema as ot, grantSystemDocumentType as p, VerificationMethodSchema as pt, RejectVerificationInputSchema as q, initialGlobalState as r, SetExtensionsInputSchema as rt, GrantSystemDocumentSchema as s, SetPublisherWalletInputSchema as st, GrantSystem as t, SetDescriptionInputSchema as tt, assertIsGrantSystemState as u, SocialSchema as ut, rejectVerification as v, addSocial as w, setPublisherWallet as x, requestVerification as y, setType as z };

//# sourceMappingURL=module-GSyfQ2a7.js.map