import { _ as resolveNodeSystemdServiceName, c as NODE_WINDOWS_TASK_SCRIPT_NAME, g as resolveNodeLaunchAgentLabel, o as NODE_SERVICE_KIND, s as NODE_SERVICE_MARKER, v as resolveNodeWindowsTaskName } from "./constants-CeTJi0TJ.js";
import { i as resolveGatewayService } from "./service-BCFeOdHD.js";
//#region src/daemon/node-service.ts
function withNodeServiceEnv(env) {
	return {
		...env,
		NODMIX_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel(),
		NODMIX_SYSTEMD_UNIT: resolveNodeSystemdServiceName(),
		NODMIX_WINDOWS_TASK_NAME: resolveNodeWindowsTaskName(),
		NODMIX_WINDOWS_TASK_HIDDEN_LAUNCHER: "1",
		NODMIX_TASK_SCRIPT_NAME: NODE_WINDOWS_TASK_SCRIPT_NAME,
		NODMIX_LOG_PREFIX: "node",
		NODMIX_SERVICE_MARKER: NODE_SERVICE_MARKER,
		NODMIX_SERVICE_KIND: NODE_SERVICE_KIND
	};
}
function withNodeInstallEnv(args) {
	return {
		...args,
		env: withNodeServiceEnv(args.env),
		environment: {
			...args.environment,
			NODMIX_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel(),
			NODMIX_SYSTEMD_UNIT: resolveNodeSystemdServiceName(),
			NODMIX_WINDOWS_TASK_NAME: resolveNodeWindowsTaskName(),
			NODMIX_WINDOWS_TASK_HIDDEN_LAUNCHER: "1",
			NODMIX_TASK_SCRIPT_NAME: NODE_WINDOWS_TASK_SCRIPT_NAME,
			NODMIX_LOG_PREFIX: "node",
			NODMIX_SERVICE_MARKER: NODE_SERVICE_MARKER,
			NODMIX_SERVICE_KIND: NODE_SERVICE_KIND
		}
	};
}
function resolveNodeService() {
	const base = resolveGatewayService();
	return {
		...base,
		stage: async (args) => {
			return base.stage(withNodeInstallEnv(args));
		},
		install: async (args) => {
			return base.install(withNodeInstallEnv(args));
		},
		uninstall: async (args) => {
			return base.uninstall({
				...args,
				env: withNodeServiceEnv(args.env)
			});
		},
		stop: async (args) => {
			return base.stop({
				...args,
				env: withNodeServiceEnv(args.env ?? {})
			});
		},
		restart: async (args) => {
			return base.restart({
				...args,
				env: withNodeServiceEnv(args.env ?? {})
			});
		},
		isLoaded: async (args) => {
			return base.isLoaded({ env: withNodeServiceEnv(args.env ?? {}) });
		},
		readCommand: (env) => base.readCommand(withNodeServiceEnv(env)),
		readRuntime: (env) => base.readRuntime(withNodeServiceEnv(env))
	};
}
//#endregion
export { resolveNodeService as t };
