import { refkey } from "@alloy-js/core";
import * as ts from "@alloy-js/typescript";
import type * as cl from "@typespec/http-client";
import { httpRuntimeTemplateLib } from "../external-packages/ts-http-runtime.js";

export interface ClientContextDeclarationProps {
  client: cl.Client;
}

export function getClientcontextDeclarationRef(client: cl.Client) {
  return refkey(client, "declaration");
}

export function ClientContextDeclaration(props: ClientContextDeclarationProps) {
  const ref = getClientcontextDeclarationRef(props.client);
  const namePolicy = ts.useTSNamePolicy();
  const name = namePolicy.getName(`${props.client.name}Context`, "class");
  return (
    <ts.InterfaceDeclaration
      export
      name={name}
      refkey={ref}
      extends={httpRuntimeTemplateLib.Client}
    />
  );
}
