

const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.js');
const require_CredoError = require('../../../error/CredoError.js');
require('../../../error/index.js');
const require_Hasher = require('../../../crypto/hashes/Hasher.js');
const require_types = require('../../../types.js');
require('../../../crypto/index.js');
require('../models/index.js');
let __sd_jwt_decode = require("@sd-jwt/decode");
__sd_jwt_decode = require_rolldown_runtime.__toESM(__sd_jwt_decode);

//#region src/modules/vc/sd-jwt-vc/W3cV2SdJwt.ts
function sdJwtVcHasher(data, alg) {
	return require_Hasher.Hasher.hash(typeof data === "string" ? data : new Uint8Array(data), alg);
}
function decodeSdJwt(compact, claimFormat) {
	const { jwt, disclosures, kbJwt } = (0, __sd_jwt_decode.decodeSdJwtSync)(compact, sdJwtVcHasher);
	const header = jwt.header;
	const payload = jwt.payload;
	const prettyClaims = (0, __sd_jwt_decode.getClaimsSync)(payload, disclosures, sdJwtVcHasher);
	if (!require_types.isJsonObject(prettyClaims)) throw new require_CredoError.CredoError("SD-JWT claims are not a valid JSON object");
	return {
		claimFormat,
		compact,
		header,
		payload,
		prettyClaims,
		kbJwt
	};
}

//#endregion
exports.decodeSdJwt = decodeSdJwt;
exports.sdJwtVcHasher = sdJwtVcHasher;