import { p as createBaseState, t as PHDocumentController, v as defaultBaseState } from "./dist-CdWSQzOH.js";
import { a as utils, d as isGrantSystemDocument, l as assertIsGrantSystemDocument, t as GrantSystem } from "./module-GSyfQ2a7.js";
import { c as useDocumentsInSelectedDrive, l as useDocumentsInSelectedFolder, p as useSelectedDocument, s as useDocumentById } from "./dist-B2aX2Fsh.js";
//#region document-models/grant-system/v1/gen/ph-factories.ts
function defaultGlobalState() {
	return {
		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
	};
}
function defaultLocalState() {
	return {};
}
function defaultPHState() {
	return {
		...defaultBaseState(),
		global: defaultGlobalState(),
		local: defaultLocalState()
	};
}
function createGlobalState(state) {
	return {
		...defaultGlobalState(),
		...state || {}
	};
}
function createLocalState(state) {
	return {
		...defaultLocalState(),
		...state || {}
	};
}
function createState(baseState, globalState, localState) {
	return {
		...createBaseState(baseState?.auth, baseState?.document),
		global: createGlobalState(globalState),
		local: createLocalState(localState)
	};
}
/**
* Creates a GrantSystemDocument with custom global and local state
* This properly handles the PHBaseState requirements while allowing
* document-specific state to be set.
*/
function createGrantSystemDocument(state) {
	return utils.createDocument(state ? createState(createBaseState(state.auth, state.document), state.global, state.local) : void 0);
}
//#endregion
//#region document-models/grant-system/v1/gen/controller.ts
const GrantSystemController = PHDocumentController.forDocumentModel(GrantSystem);
//#endregion
//#region document-models/grant-system/v1/hooks.ts
/** Hook to get a GrantSystem document by its id */
function useGrantSystemDocumentById(documentId) {
	const [document, dispatch] = useDocumentById(documentId);
	if (!isGrantSystemDocument(document)) return [void 0, void 0];
	return [document, dispatch];
}
/** Hook to get the selected GrantSystem document */
function useSelectedGrantSystemDocument() {
	const [document, dispatch] = useSelectedDocument();
	assertIsGrantSystemDocument(document);
	return [document, dispatch];
}
/** Hook to get all GrantSystem documents in the selected drive */
function useGrantSystemDocumentsInSelectedDrive() {
	return useDocumentsInSelectedDrive()?.filter(isGrantSystemDocument);
}
/** Hook to get all GrantSystem documents in the selected folder */
function useGrantSystemDocumentsInSelectedFolder() {
	return useDocumentsInSelectedFolder()?.filter(isGrantSystemDocument);
}
//#endregion
export { GrantSystemController as a, defaultGlobalState as c, useSelectedGrantSystemDocument as i, defaultLocalState as l, useGrantSystemDocumentsInSelectedDrive as n, createGrantSystemDocument as o, useGrantSystemDocumentsInSelectedFolder as r, createState as s, useGrantSystemDocumentById as t, defaultPHState as u };

//# sourceMappingURL=grant-system-BbYpxivd.js.map