import { g as defaultBaseState, p as createBaseState, t as PHDocumentController } from "./dist-JCXjvFc8.mjs";
import { a as utils, d as isChannelDocument, l as assertIsChannelDocument, t as Channel } from "./module-DajjN_0a.mjs";
import { a as useDocumentsInSelectedDrive, c as useSelectedDocument, i as useDocumentById, o as useDocumentsInSelectedFolder } from "./dist-Bg4aWBAL.mjs";
//#region document-models/channel/v1/gen/ph-factories.ts
function defaultGlobalState() {
	return {
		name: null,
		description: null,
		topic: null,
		channelType: "TEXT",
		visibility: "PUBLIC",
		participants: []
	};
}
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 ChannelDocument with custom global and local state
* This properly handles the PHBaseState requirements while allowing
* document-specific state to be set.
*/
function createChannelDocument(state) {
	return utils.createDocument(state ? createState(createBaseState(state.auth, state.document), state.global, state.local) : void 0);
}
//#endregion
//#region document-models/channel/v1/gen/controller.ts
const ChannelController = PHDocumentController.forDocumentModel(Channel);
//#endregion
//#region document-models/channel/v1/hooks.ts
/** Hook to get a Channel document by its id */
function useChannelDocumentById(documentId) {
	const [document, dispatch] = useDocumentById(documentId);
	if (!isChannelDocument(document)) return [void 0, void 0];
	return [document, dispatch];
}
/** Hook to get the selected Channel document */
function useSelectedChannelDocument() {
	const [document, dispatch] = useSelectedDocument();
	assertIsChannelDocument(document);
	return [document, dispatch];
}
/** Hook to get all Channel documents in the selected drive */
function useChannelDocumentsInSelectedDrive() {
	return useDocumentsInSelectedDrive()?.filter(isChannelDocument);
}
/** Hook to get all Channel documents in the selected folder */
function useChannelDocumentsInSelectedFolder() {
	return useDocumentsInSelectedFolder()?.filter(isChannelDocument);
}
//#endregion
export { ChannelController as a, defaultGlobalState as c, useSelectedChannelDocument as i, defaultLocalState as l, useChannelDocumentsInSelectedDrive as n, createChannelDocument as o, useChannelDocumentsInSelectedFolder as r, createState as s, useChannelDocumentById as t, defaultPHState as u };

//# sourceMappingURL=channel-CgMvjz3u.mjs.map