const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
const require_errors = require('./types/errors.cjs');
const require_promises = require('./promises.cjs');
const require_context = require('./context.cjs');
const require_rpc = require('./types/rpc.cjs');
const require_internal = require('./internal.cjs');
const require_common_api = require('./common_api.cjs');
const require_withOptions = require('./endpoint/withOptions.cjs');
const require_node_endpoint = require('./endpoint/node_endpoint.cjs');
let __restatedev_restate_sdk_core = require("@restatedev/restate-sdk-core");
__restatedev_restate_sdk_core = require_rolldown_runtime.__toESM(__restatedev_restate_sdk_core);

//#region src/node.ts
/**
* Create a new {@link RestateEndpoint}.
* @deprecated Please use {@link createEndpointHandler}
*/
function endpoint() {
	return new require_node_endpoint.NodeEndpoint();
}
/**
* Creates a request handler for the provided services.
*
* The returned handler auto-detects the HTTP protocol version per request:
* - HTTP/2+ requests use bidirectional streaming (`BIDI_STREAM`)
* - HTTP/1.1 requests use request-response mode (`REQUEST_RESPONSE`) by default
*
* Set `bidirectional: true` to force `BIDI_STREAM` for all requests, or
* `bidirectional: false` to force `REQUEST_RESPONSE` for all requests.
*
* @example HTTP/2 server
* ```
* const httpServer = http2.createServer(createEndpointHandler({ services: [myService] }));
* httpServer.listen(port);
* ```
*
* @example HTTP/1.1 server
* ```
* const httpServer = http.createServer(createEndpointHandler({ services: [myService] }));
* httpServer.listen(port);
* ```
*
* @param {NodeEndpointOptions} options - Configuration options for the endpoint handler.
* @returns A request handler function compatible with both HTTP/1.1 and HTTP/2 servers.
*/
function createEndpointHandler(options) {
	const { bidirectional,...endpointOptions } = options;
	return require_withOptions.withOptions(new require_node_endpoint.NodeEndpoint(), endpointOptions).handler({ bidirectional });
}
/**
* Serves this Restate services as HTTP2 server, listening to the given port.
*
* If the port is undefined, this method will use the port set in the `PORT`
* environment variable. If that variable is undefined as well, the method will
* default to port 9080.
*
* The returned promise resolves with the bound port when the server starts listening, or rejects with a failure otherwise.
*
* If you need to manually control the server lifecycle, we suggest to manually instantiate the http2 server and use {@link createEndpointHandler}.
*
* @param {ServeOptions} options - Configuration options for the endpoint handler.
* @returns a Promise that resolves with the bound port, or rejects with a failure otherwise.
*/
function serve({ port,...options }) {
	return require_withOptions.withOptions(new require_node_endpoint.NodeEndpoint(), options).listen(port);
}

//#endregion
exports.CancelledError = require_errors.CancelledError;
exports.CombineablePromise = require_common_api.CombineablePromise;
exports.InvocationIdParser = require_context.InvocationIdParser;
exports.Opts = require_rpc.Opts;
exports.RestateError = require_errors.RestateError;
exports.RestatePromise = require_context.RestatePromise;
exports.RetryableError = require_errors.RetryableError;
exports.SendOpts = require_rpc.SendOpts;
exports.TerminalError = require_errors.TerminalError;
exports.TimeoutError = require_errors.TimeoutError;
exports.createEndpointHandler = createEndpointHandler;
exports.createObjectHandler = require_common_api.createObjectHandler;
exports.createObjectSharedHandler = require_common_api.createObjectSharedHandler;
exports.createServiceHandler = require_common_api.createServiceHandler;
exports.createWorkflowHandler = require_common_api.createWorkflowHandler;
exports.createWorkflowSharedHandler = require_common_api.createWorkflowSharedHandler;
exports.endpoint = endpoint;
Object.defineProperty(exports, 'handlers', {
  enumerable: true,
  get: function () {
    return require_rpc.handlers;
  }
});
Object.defineProperty(exports, 'internal', {
  enumerable: true,
  get: function () {
    return require_internal.internal_exports;
  }
});
exports.isRestatePromise = require_promises.isRestatePromise;
exports.object = require_rpc.object;
Object.defineProperty(exports, 'rpc', {
  enumerable: true,
  get: function () {
    return require_rpc.rpc;
  }
});
Object.defineProperty(exports, 'serde', {
  enumerable: true,
  get: function () {
    return __restatedev_restate_sdk_core.serde;
  }
});
exports.serve = serve;
exports.service = require_rpc.service;
exports.workflow = require_rpc.workflow;