import "reflect-metadata";
import { injectable } from "inversify";
import {
  NoopTracer,
  NoopLogger,
  type ITracer,
  type ILogger,
} from "@repo/core-shared/instrumentation";

import type { IHeaderRepository } from "../../application/repositories/header.repository.interface";
import type { Header, HeaderItem } from "../../entities/models/header";

const DEFAULT_ITEMS: HeaderItem[] = [
  { label: "Home", href: "/", external: false },
  { label: "Blog", href: "/blog", external: false },
  { label: "Docs", href: "/docs", external: true },
];

@injectable()
export class MockHeaderRepository implements IHeaderRepository {
  private readonly data: Header;
  private tracer: ITracer;
  private logger: ILogger;

  constructor(
    initialData?: Header,
    tracer: ITracer = new NoopTracer(),
    logger: ILogger = new NoopLogger(),
  ) {
    this.data = initialData ?? { items: DEFAULT_ITEMS };
    this.tracer = tracer;
    this.logger = logger;
    void this.logger; // currently unused; reserved for future mock-thrown captures
  }

  async getHeader(): Promise<Header> {
    return this.tracer.startSpan(
      { name: "header.getHeader", op: "repository", attributes: {} },
      async (span) => {
        span.setAttribute("itemCount", this.data.items.length);
        return this.data;
      },
    );
  }
}
