import { __commonJS } from "../../../_virtual/rolldown_runtime.mjs";

//#region ../../node_modules/xml-crypto/lib/types.js
var require_types = /* @__PURE__ */ __commonJS({ "../../node_modules/xml-crypto/lib/types.js": ((exports) => {
	Object.defineProperty(exports, "__esModule", { value: true });
	exports.createOptionalCallbackFunction = void 0;
	/**
	* ### Sign
	* #### Properties
	* - {@link SignedXml#privateKey} [required]
	* - {@link SignedXml#publicCert} [optional]
	* - {@link SignedXml#signatureAlgorithm} [optional]
	* - {@link SignedXml#canonicalizationAlgorithm} [optional]
	* #### Api
	*  - {@link SignedXml#addReference}
	*  - {@link SignedXml#computeSignature}
	*  - {@link SignedXml#getSignedXml}
	*  - {@link SignedXml#getSignatureXml}
	*  - {@link SignedXml#getOriginalXmlWithIds}
	*
	* ### Verify
	* #### Properties
	* -  {@link SignedXml#publicCert} [optional]
	* #### Api
	*  - {@link SignedXml#loadSignature}
	*  - {@link SignedXml#checkSignature}
	*/
	function isErrorFirstCallback(possibleCallback) {
		return typeof possibleCallback === "function";
	}
	/**
	* This function will add a callback version of a sync function.
	*
	* This follows the factory pattern.
	* Just call this function, passing the function that you'd like to add a callback version of.
	*/
	function createOptionalCallbackFunction(syncVersion) {
		return ((...args) => {
			const possibleCallback = args[args.length - 1];
			if (isErrorFirstCallback(possibleCallback)) try {
				possibleCallback(null, syncVersion(...args.slice(0, -1)));
			} catch (err) {
				possibleCallback(err instanceof Error ? err : /* @__PURE__ */ new Error("Unknown error"));
			}
			else return syncVersion(...args);
		});
	}
	exports.createOptionalCallbackFunction = createOptionalCallbackFunction;
}) });

//#endregion
export default require_types();

export { require_types };
//# sourceMappingURL=types.mjs.map