// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
import { setTypeSpecNamespace, } from "@typespec/compiler";
/**
 * The fully qualified decorator name pattern for the dynamicModel decorator.
 * This is used in SDK context options to ensure the decorator is properly recognized.
 * @beta
 */
export const DYNAMIC_MODEL_DECORATOR_PATTERN = "TypeSpec\\.HttpClient\\.CSharp\\.@dynamicModel";
const externalDocsKey = Symbol("externalDocs");
export function getExternalDocs(context, entity) {
    return context.program.stateMap(externalDocsKey).get(entity);
}
const operationIdsKey = Symbol("operationIds");
/**
 * @returns operationId set via the @operationId decorator or `undefined`
 */
export function getOperationId(context, entity) {
    return context.program.stateMap(operationIdsKey).get(entity);
}
export function hasDecorator(type, name) {
    return type.decorators.find((it) => it.decorator.name === name) !== undefined;
}
const dynamicModelKey = Symbol("dynamicModel");
/**
 * Marks a model or namespace as dynamic, indicating it should generate dynamic model code.
 * Can be applied to Model or Namespace types.
 * @param context - The decorator context
 * @param target - The model or namespace to mark as dynamic
 * @beta
 */
export const $dynamicModel = (context, target) => {
    context.program.stateSet(dynamicModelKey).add(target);
};
// Set the namespace for the decorator
setTypeSpecNamespace("TypeSpec.HttpClient.CSharp", $dynamicModel);
/**
 * Check if the given model or namespace is marked as dynamic.
 * @param program - The TypeSpec program
 * @param target - The model or namespace to check
 * @returns true if the target is marked as dynamic, false otherwise
 * @beta
 */
export function isDynamicModel(program, target) {
    return program.stateSet(dynamicModelKey).has(target);
}
//# sourceMappingURL=decorators.js.map