import { g as defaultBaseState, p as createBaseState, t as PHDocumentController } from "./dist-Dacf6lFH.js";
import { a as utils, d as isChatDocument, l as assertIsChatDocument, t as Chat } from "./module-CADVf4FS.js";
import { a as useDocumentsInSelectedDrive, c as useSelectedDocument, i as useDocumentById, o as useDocumentsInSelectedFolder } from "./dist-rER8Mj9l.js";
//#region document-models/chat/v1/gen/ph-factories.ts
function defaultGlobalState() {
	return {
		channelId: null,
		messages: [],
		pinnedMessageIds: []
	};
}
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 ChatDocument with custom global and local state
* This properly handles the PHBaseState requirements while allowing
* document-specific state to be set.
*/
function createChatDocument(state) {
	return utils.createDocument(state ? createState(createBaseState(state.auth, state.document), state.global, state.local) : void 0);
}
//#endregion
//#region document-models/chat/v1/gen/controller.ts
const ChatController = PHDocumentController.forDocumentModel(Chat);
//#endregion
//#region document-models/chat/v1/hooks.ts
/** Hook to get a Chat document by its id */
function useChatDocumentById(documentId) {
	const [document, dispatch] = useDocumentById(documentId);
	if (!isChatDocument(document)) return [void 0, void 0];
	return [document, dispatch];
}
/** Hook to get the selected Chat document */
function useSelectedChatDocument() {
	const [document, dispatch] = useSelectedDocument();
	assertIsChatDocument(document);
	return [document, dispatch];
}
/** Hook to get all Chat documents in the selected drive */
function useChatDocumentsInSelectedDrive() {
	return useDocumentsInSelectedDrive()?.filter(isChatDocument);
}
/** Hook to get all Chat documents in the selected folder */
function useChatDocumentsInSelectedFolder() {
	return useDocumentsInSelectedFolder()?.filter(isChatDocument);
}
//#endregion
export { ChatController as a, defaultGlobalState as c, useSelectedChatDocument as i, defaultLocalState as l, useChatDocumentsInSelectedDrive as n, createChatDocument as o, useChatDocumentsInSelectedFolder as r, createState as s, useChatDocumentById as t, defaultPHState as u };

//# sourceMappingURL=chat-DlL9ydQT.js.map