

import { ClaimFormat } from "../../vc/models/ClaimFormat.mjs";
import "../../vc/index.mjs";
import "../../mdoc/index.mjs";
import "../../sd-jwt-vc/index.mjs";

//#region src/modules/dcql/utils/DcqlPresentationsToCreate.ts
function dcqlGetPresentationsToCreate(credentialsForInputDescriptor) {
	const presentationsToCreate = {};
	for (const [credentialQueryId, matches] of Object.entries(credentialsForInputDescriptor)) for (const match of matches) {
		let presentationToCreate;
		switch (match.claimFormat) {
			case ClaimFormat.SdJwtDc:
				presentationToCreate = {
					claimFormat: ClaimFormat.SdJwtDc,
					subjectIds: [],
					credentialRecord: match.credentialRecord,
					disclosedPayload: match.disclosedPayload,
					additionalPayload: match.additionalPayload
				};
				break;
			case ClaimFormat.MsoMdoc:
				presentationToCreate = {
					claimFormat: ClaimFormat.MsoMdoc,
					subjectIds: [],
					credentialRecord: match.credentialRecord,
					disclosedPayload: match.disclosedPayload
				};
				break;
			case ClaimFormat.JwtW3cVc:
			case ClaimFormat.SdJwtW3cVc:
				presentationToCreate = {
					claimFormat: match.claimFormat === ClaimFormat.JwtW3cVc ? ClaimFormat.JwtW3cVp : ClaimFormat.SdJwtW3cVp,
					subjectIds: [],
					credentialRecord: match.credentialRecord,
					disclosedPayload: match.disclosedPayload
				};
				break;
			default:
				presentationToCreate = {
					claimFormat: match.claimFormat === ClaimFormat.LdpVc ? ClaimFormat.LdpVp : ClaimFormat.JwtVp,
					subjectIds: [match.credentialRecord.credential.credentialSubjectIds[0]],
					credentialRecord: match.credentialRecord,
					disclosedPayload: match.disclosedPayload
				};
				break;
		}
		if (!presentationsToCreate[credentialQueryId]) presentationsToCreate[credentialQueryId] = [presentationToCreate];
		else presentationsToCreate[credentialQueryId].push(presentationToCreate);
	}
	return presentationsToCreate;
}

//#endregion
export { dcqlGetPresentationsToCreate };
//# sourceMappingURL=DcqlPresentationsToCreate.mjs.map