import { a as NODE_SERVICE_KIND, b as resolveNodeSystemdServiceName, o as NODE_SERVICE_MARKER, s as NODE_WINDOWS_TASK_SCRIPT_NAME, x as resolveNodeWindowsTaskName, y as resolveNodeLaunchAgentLabel } from "./constants-C2y93ya8.js";
import { t as resolveGatewayService } from "./service-DbZp-Ejz.js";

//#region src/daemon/node-service.ts
function withNodeServiceEnv(env) {
	return {
		...env,
		FASED_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel(),
		FASED_SYSTEMD_UNIT: resolveNodeSystemdServiceName(),
		FASED_WINDOWS_TASK_NAME: resolveNodeWindowsTaskName(),
		FASED_TASK_SCRIPT_NAME: NODE_WINDOWS_TASK_SCRIPT_NAME,
		FASED_LOG_PREFIX: "node",
		FASED_SERVICE_MARKER: NODE_SERVICE_MARKER,
		FASED_SERVICE_KIND: NODE_SERVICE_KIND
	};
}
function withNodeInstallEnv(args) {
	return {
		...args,
		env: withNodeServiceEnv(args.env),
		environment: {
			...args.environment,
			FASED_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel(),
			FASED_SYSTEMD_UNIT: resolveNodeSystemdServiceName(),
			FASED_WINDOWS_TASK_NAME: resolveNodeWindowsTaskName(),
			FASED_TASK_SCRIPT_NAME: NODE_WINDOWS_TASK_SCRIPT_NAME,
			FASED_LOG_PREFIX: "node",
			FASED_SERVICE_MARKER: NODE_SERVICE_MARKER,
			FASED_SERVICE_KIND: NODE_SERVICE_KIND
		}
	};
}
function resolveNodeService() {
	const base = resolveGatewayService();
	return {
		...base,
		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 };