/**
 * Canvas environment → host mapping.
 *
 * All host/URL knowledge for the adapter lives here: consumers declare
 * WHERE their docs are (environment + org + resource + doc ids) and never
 * assemble URLs by hand. The `vX` path segment is literal — the Canvas CRUD
 * API versions itself via a capability marker in its descriptors, not the
 * URL.
 */
// The Canvas CRUD API is currently served on staging only; the production
// entry is forward-wiring (see the CanvasEnvironment note in types.ts).
const CANVAS_HOSTS = {
    production: {
        api: "https://api.sanity.io",
        dashboard: "https://www.sanity.io",
    },
    staging: {
        api: "https://api.sanity.work",
        dashboard: "https://www.sanity.work",
    },
};
/** Hosts for the source's environment. */
export function canvasHosts(source) {
    if (!(source.environment in CANVAS_HOSTS)) {
        throw new Error(`Canvas source has an invalid environment ${JSON.stringify(source.environment)}; expected "production" or "staging"`);
    }
    return CANVAS_HOSTS[source.environment];
}
/** Canvas CRUD path prefix (`<api host>/vX/canvases/<resourceId>/assist`). */
export function canvasApiBase(source) {
    return `${canvasHosts(source).api}/vX/canvases/${source.resourceId}/assist`;
}
/**
 * Dashboard URL for a Canvas document — the human-facing link used as the
 * stable `resource` in fetch-failure reports.
 */
export function canvasViewUrl(source, documentId) {
    return `${canvasHosts(source).dashboard}/@${source.organizationId}/canvas/doc/${documentId}`;
}
/** Path shape of a dashboard doc URL — the parse-side twin of {@link canvasViewUrl}. */
export const DASHBOARD_DOC_PATH = /^\/@([^/]+)\/canvas\/doc\/([A-Za-z0-9_-]+)$/;
