/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { assert, IModelStatus } from "@itwin/core-bentley";
import { IModelError } from "@itwin/core-common";
import { _nativeDb } from "./internal/Symbols";
/** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.
 * @internal
 */
export async function generateElementGraphics(request, iModel) {
    const result = await iModel[_nativeDb].generateElementGraphics(request); // ###TODO update package versions in addon
    let error;
    switch (result.status) {
        case 2 /* ElementGraphicsStatus.NoGeometry */:
        case 1 /* ElementGraphicsStatus.Canceled */:
            return undefined;
        case 0 /* ElementGraphicsStatus.Success */:
            return result.content;
        case 3 /* ElementGraphicsStatus.InvalidJson */:
            error = "Invalid JSON";
            break;
        case 4 /* ElementGraphicsStatus.UnknownMajorFormatVersion */:
            error = "Unknown major format version";
            break;
        case 5 /* ElementGraphicsStatus.ElementNotFound */:
            error = `Element Id ${request.elementId} not found`;
            break;
        case 6 /* ElementGraphicsStatus.DuplicateRequestId */:
            error = `Duplicate request Id "${request.id}"`;
            break;
    }
    assert(undefined !== error);
    throw new IModelError(IModelStatus.BadRequest, error);
}
//# sourceMappingURL=ElementGraphics.js.map