"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchEntityResolver = fetchEntityResolver;
const fetchHubEntity_1 = require("../fetchHubEntity");
/**
 * Resolves an entity:// reference by fetching the referenced Hub entity.
 * Example `$ref: "entity://:type/:id"` returns the Hub entity for the specified item.
 * @param ref The entity reference to resolve.
 * @param context The ArcGIS context for making the request.
 * @returns The resolved Hub entity.
 * @throws Error if the ref is invalid or the entity cannot be fetched.
 */
async function fetchEntityResolver(ref, context) {
    const parts = ref.split("/");
    const type = parts[2];
    const id = parts[3];
    try {
        return await (0, fetchHubEntity_1.fetchHubEntity)(type, id, context);
    }
    catch (_error) {
        throw new Error(`fetchEntityResolver: could not fetch entity ${ref}`);
    }
}
//# sourceMappingURL=fetchEntityResolver.js.map