"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRelativeWorkspaceUrl = void 0;
const getTypeFromEntity_1 = require("./getTypeFromEntity");
const isValidEntityType_1 = require("./isValidEntityType");
/**
 * From within the context of a hub site, the following util
 * returns an entity's relative workspace URL
 *
 * @param type item type
 * @param identifier entity id or slug
 */
const getRelativeWorkspaceUrl = (type, identifier, pane) => {
    let url = "/";
    const entityType = (0, getTypeFromEntity_1.getTypeFromEntity)({ type });
    /**
     * Note: this logic will likely need to be enhanced to:
     * 1. accommodate enterprise
     * 2. handle entity variation
     */
    if ((0, isValidEntityType_1.isValidEntityType)(entityType)) {
        let typeSegment = entityType;
        if (typeSegment !== "content") {
            typeSegment = `${typeSegment}s`;
        }
        url = `/workspace/${typeSegment}/${identifier}`;
        if (pane) {
            url += `/${pane}`;
        }
    }
    return url;
};
exports.getRelativeWorkspaceUrl = getRelativeWorkspaceUrl;
//# sourceMappingURL=getRelativeWorkspaceUrl.js.map