"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const lifecycle = require("../../../../base/common/lifecycle.js");
const editorExtensions = require("../../../browser/editorExtensions.js");
const editorContextKeys = require("../../../common/editorContextKeys.js");
const languages = require("../../../common/languages.js");
const provideSignatureHelp = require("./provideSignatureHelp.js");
const nls = require("../../../../nls.js");
const contextkey = require("../../../../platform/contextkey/common/contextkey.js");
const instantiation = require("../../../../platform/instantiation/common/instantiation.js");
const parameterHintsWidget = require("./parameterHintsWidget.js");
var __decorate = globalThis && globalThis.__decorate || function(decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
    r = Reflect.decorate(decorators, target, key, desc);
  else
    for (var i = decorators.length - 1; i >= 0; i--)
      if (d = decorators[i])
        r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = globalThis && globalThis.__param || function(paramIndex, decorator) {
  return function(target, key) {
    decorator(target, key, paramIndex);
  };
};
let ParameterHintsController = class ParameterHintsController2 extends lifecycle.Disposable {
  constructor(editor, instantiationService) {
    super();
    this.editor = editor;
    this.widget = this._register(instantiationService.createInstance(parameterHintsWidget.ParameterHintsWidget, this.editor));
  }
  static get(editor) {
    return editor.getContribution(ParameterHintsController2.ID);
  }
  cancel() {
    this.widget.cancel();
  }
  previous() {
    this.widget.previous();
  }
  next() {
    this.widget.next();
  }
  trigger(context) {
    this.widget.trigger(context);
  }
};
ParameterHintsController.ID = "editor.controller.parameterHints";
ParameterHintsController = __decorate([
  __param(1, instantiation.IInstantiationService)
], ParameterHintsController);
class TriggerParameterHintsAction extends editorExtensions.EditorAction {
  constructor() {
    super({
      id: "editor.action.triggerParameterHints",
      label: nls.localize("parameterHints.trigger.label", "Trigger Parameter Hints"),
      alias: "Trigger Parameter Hints",
      precondition: editorContextKeys.EditorContextKeys.hasSignatureHelpProvider,
      kbOpts: {
        kbExpr: editorContextKeys.EditorContextKeys.editorTextFocus,
        primary: 2048 | 1024 | 10,
        weight: 100
        /* EditorContrib */
      }
    });
  }
  run(accessor, editor) {
    const controller = ParameterHintsController.get(editor);
    if (controller) {
      controller.trigger({
        triggerKind: languages.SignatureHelpTriggerKind.Invoke
      });
    }
  }
}
editorExtensions.registerEditorContribution(ParameterHintsController.ID, ParameterHintsController);
editorExtensions.registerEditorAction(TriggerParameterHintsAction);
const weight = 100 + 75;
const ParameterHintsCommand = editorExtensions.EditorCommand.bindToContribution(ParameterHintsController.get);
editorExtensions.registerEditorCommand(new ParameterHintsCommand({
  id: "closeParameterHints",
  precondition: provideSignatureHelp.Context.Visible,
  handler: (x) => x.cancel(),
  kbOpts: {
    weight,
    kbExpr: editorContextKeys.EditorContextKeys.focus,
    primary: 9,
    secondary: [
      1024 | 9
      /* Escape */
    ]
  }
}));
editorExtensions.registerEditorCommand(new ParameterHintsCommand({
  id: "showPrevParameterHint",
  precondition: contextkey.ContextKeyExpr.and(provideSignatureHelp.Context.Visible, provideSignatureHelp.Context.MultipleSignatures),
  handler: (x) => x.previous(),
  kbOpts: {
    weight,
    kbExpr: editorContextKeys.EditorContextKeys.focus,
    primary: 16,
    secondary: [
      512 | 16
      /* UpArrow */
    ],
    mac: { primary: 16, secondary: [
      512 | 16,
      256 | 46
      /* KeyP */
    ] }
  }
}));
editorExtensions.registerEditorCommand(new ParameterHintsCommand({
  id: "showNextParameterHint",
  precondition: contextkey.ContextKeyExpr.and(provideSignatureHelp.Context.Visible, provideSignatureHelp.Context.MultipleSignatures),
  handler: (x) => x.next(),
  kbOpts: {
    weight,
    kbExpr: editorContextKeys.EditorContextKeys.focus,
    primary: 18,
    secondary: [
      512 | 18
      /* DownArrow */
    ],
    mac: { primary: 18, secondary: [
      512 | 18,
      256 | 44
      /* KeyN */
    ] }
  }
}));
exports.TriggerParameterHintsAction = TriggerParameterHintsAction;
