import type { Dependency } from '@univerjs/core';

import { DependentOn, Inject, Injector, LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
import { UniverSheetsUIPlugin } from '@univerjs/sheets-ui';

import { JnpfSheetsDialogController } from '../controllers/sheet-dialog.controller';
import zhCN from '../locales/zh-CN';

@DependentOn(UniverSheetsUIPlugin)
export class JnpfSheetsDialogPlugin extends Plugin {
  static override pluginName = 'JNPF_SHEET_DIALOG_PLUGIN';
  static override type = UniverInstanceType.UNIVER_SHEET;

  constructor(
    @Inject(Injector) protected readonly _injector: Injector,
    @Inject(LocaleService) private readonly _localeService: LocaleService,
  ) {
    super();

    this._localeService.load({
      zhCN,
    });
  }

  override onStarting(): void {
    ([[JnpfSheetsDialogController]] as Dependency[]).forEach(d => this._injector.add(d));

    this._injector.get(JnpfSheetsDialogController);
  }
}
