

import { CredoError } from "../../../../error/CredoError.mjs";
import "../../../../error/index.mjs";
import { getAlternativeDidsForNumAlgo4Did } from "./peerDidNumAlgo4.mjs";

//#region src/modules/dids/methods/peer/didPeer.ts
const PEER_DID_REGEX = /^did:peer:(([01](z)([1-9a-km-zA-HJ-NP-Z]{5,200}))|(2((.[AEVID](z)([1-9a-km-zA-HJ-NP-Z]{5,200}))+(.(S)[0-9a-zA-Z=]*)*))|([4](z[1-9a-km-zA-HJ-NP-Z]{46})(:z[1-9a-km-zA-HJ-NP-Z]{6,}){0,1}))$/;
function isValidPeerDid(did) {
	return PEER_DID_REGEX.test(did);
}
let PeerDidNumAlgo = /* @__PURE__ */ function(PeerDidNumAlgo$1) {
	PeerDidNumAlgo$1[PeerDidNumAlgo$1["InceptionKeyWithoutDoc"] = 0] = "InceptionKeyWithoutDoc";
	PeerDidNumAlgo$1[PeerDidNumAlgo$1["GenesisDoc"] = 1] = "GenesisDoc";
	PeerDidNumAlgo$1[PeerDidNumAlgo$1["MultipleInceptionKeyWithoutDoc"] = 2] = "MultipleInceptionKeyWithoutDoc";
	PeerDidNumAlgo$1[PeerDidNumAlgo$1["ShortFormAndLongForm"] = 4] = "ShortFormAndLongForm";
	return PeerDidNumAlgo$1;
}({});
function getNumAlgoFromPeerDid(did) {
	const numAlgo = Number(did[9]);
	if (numAlgo !== PeerDidNumAlgo.InceptionKeyWithoutDoc && numAlgo !== PeerDidNumAlgo.GenesisDoc && numAlgo !== PeerDidNumAlgo.MultipleInceptionKeyWithoutDoc && numAlgo !== PeerDidNumAlgo.ShortFormAndLongForm) throw new CredoError(`Invalid peer did numAlgo: ${numAlgo}`);
	return numAlgo;
}
/**
* Given a peer did, returns any alternative forms equivalent to it.
*
* @param did
* @returns array of alternative dids or undefined if not applicable
*/
function getAlternativeDidsForPeerDid(did) {
	if (getNumAlgoFromPeerDid(did) === PeerDidNumAlgo.ShortFormAndLongForm) return getAlternativeDidsForNumAlgo4Did(did);
}

//#endregion
export { PeerDidNumAlgo, getAlternativeDidsForPeerDid, getNumAlgoFromPeerDid, isValidPeerDid };
//# sourceMappingURL=didPeer.mjs.map