//#region src/plugins/plugin-manager.ts
/**
* Create the plugin manager store
*
* This store manages all plugins registered with the API client
*/
var createPluginManager = ({ plugins = [] }) => {
	const registeredPlugins = /* @__PURE__ */ new Map();
	plugins.forEach((plugin) => {
		const pluginInstance = plugin();
		registeredPlugins.set(pluginInstance.name, pluginInstance);
	});
	const executeHook = (event, ...args) => {
		const [payload] = args;
		if (event === "onBeforeRequest" && payload && "request" in payload) {
			const hooks = Array.from(registeredPlugins.values()).map((plugin) => plugin.hooks?.onBeforeRequest).filter((hook) => typeof hook === "function");
			return Promise.all(hooks.map((hook) => hook({ request: payload.request })));
		}
		if (event === "onResponseReceived" && payload && "response" in payload && "operation" in payload) {
			const hooks = Array.from(registeredPlugins.values()).map((plugin) => plugin.hooks?.onResponseReceived).filter((hook) => typeof hook === "function");
			return Promise.all(hooks.map((hook) => hook({
				response: payload.response,
				operation: payload.operation
			})));
		}
		return Promise.resolve([]);
	};
	return {
		getViewComponents: (view) => {
			return Array.from(registeredPlugins.values()).flatMap((plugin) => plugin.views?.[view] || []);
		},
		executeHook
	};
};
//#endregion
export { createPluginManager };

//# sourceMappingURL=plugin-manager.js.map