/**
 * Get array of ActivityStreams Objects id
 */ export function getApIds(value) {
    if (value == null) return [];
    const array = Array.isArray(value) ? value : [
        value
    ];
    return array.map((x)=>getApId(x));
}
/**
 * Get first ActivityStreams Object id
 */ export function getOneApId(value) {
    const firstOne = Array.isArray(value) ? value[0] : value;
    return getApId(firstOne);
}
/**
 * Get ActivityStreams Object id
 */ export function getApId(value) {
    if (typeof value === "string") return value;
    if (typeof value.id === "string") return value.id;
    throw new Error("cannot detemine id");
}
/**
 * Get ActivityStreams Object type
 */ export function getApType(value) {
    if (typeof value.type === "string") return value.type;
    if (Array.isArray(value.type) && typeof value.type[0] === "string") return value.type[0];
    throw new Error("cannot detect type");
}
export function getOneApHrefNullable(value) {
    const firstOne = Array.isArray(value) ? value[0] : value;
    return getApHrefNullable(firstOne);
}
export function getApHrefNullable(value) {
    if (typeof value === "string") return value;
    if (typeof value?.href === "string") return value.href;
    return undefined;
}
export const validPost = [
    "Note",
    "Question",
    "Article",
    "Audio",
    "Document",
    "Image",
    "Page",
    "Video",
    "Event"
];
export const isPost = (object)=>validPost.includes(getApType(object));
export const isQuestion = (object)=>getApType(object) === "Note" || getApType(object) === "Question";
export const isTombstone = (object)=>getApType(object) === "Tombstone";
export const validActor = [
    "Person",
    "Service",
    "Group",
    "Organization",
    "Application"
];
export const isActor = (object)=>validActor.includes(getApType(object));
export const isCollection = (object)=>getApType(object) === "Collection";
export const isOrderedCollection = (object)=>getApType(object) === "OrderedCollection";
export const isCollectionOrOrderedCollection = (object)=>isCollection(object) || isOrderedCollection(object);
export const isPropertyValue = (object)=>object && getApType(object) === "PropertyValue" && typeof object.name === "string" && typeof object.value === "string";
export const isMention = (object)=>getApType(object) === "Mention" && typeof object.href === "string";
export const isHashtag = (object)=>getApType(object) === "Hashtag" && typeof object.name === "string";
export const isEmoji = (object)=>getApType(object) === "Emoji" && !Array.isArray(object.icon) && object.icon.url != null;
export const isCreate = (object)=>getApType(object) === "Create";
export const isDelete = (object)=>getApType(object) === "Delete";
export const isUpdate = (object)=>getApType(object) === "Update";
export const isRead = (object)=>getApType(object) === "Read";
export const isUndo = (object)=>getApType(object) === "Undo";
export const isFollow = (object)=>getApType(object) === "Follow";
export const isAccept = (object)=>getApType(object) === "Accept";
export const isReject = (object)=>getApType(object) === "Reject";
export const isAdd = (object)=>getApType(object) === "Add";
export const isRemove = (object)=>getApType(object) === "Remove";
export const isLike = (object)=>getApType(object) === "Like" || getApType(object) === "EmojiReaction" || getApType(object) === "EmojiReact";
export const isAnnounce = (object)=>getApType(object) === "Announce";
export const isBlock = (object)=>getApType(object) === "Block";
export const isFlag = (object)=>getApType(object) === "Flag";
export const isMove = (object)=>getApType(object) === "Move";
export const isBite = (object)=>getApType(object) === "Bite";
export const isQuoteRequest = (object)=>getApType(object) === "QuoteRequest";
