import { HierarchicalKind } from '../../../../base/common/hierarchicalKind.js';
import { KeyMod as KeyMod$1, KeyCode } from '../../../../base/common/keyCodes.js';
import { registerEditorContribution, registerEditorCommand, EditorCommand, registerEditorAction, EditorAction, EditorContributionInstantiation } from '../../../browser/editorExtensions.js';
import { EditorContextKeys } from '../../../common/editorContextKeys.js';
import { registerEditorFeature } from '../../../common/editorFeatures.js';
import { changePasteTypeCommandId, pasteWidgetVisibleCtx, CopyPasteController } from './copyPasteController.js';
import { DefaultTextPasteOrDropEditProvider, DefaultPasteProvidersFeature } from './defaultProviders.js';
import { localizeWithPath } from '../../../../nls.js';
import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';
const _moduleId = "vs/editor/contrib/dropOrPasteInto/browser/copyPasteContribution";
registerEditorContribution(CopyPasteController.ID, CopyPasteController, EditorContributionInstantiation.Eager);
registerEditorFeature(DefaultPasteProvidersFeature);
registerEditorCommand(new (class extends EditorCommand {
    constructor() {
        super({
            id: changePasteTypeCommandId,
            precondition: pasteWidgetVisibleCtx,
            kbOpts: {
                weight: KeybindingWeight.EditorContrib,
                primary: KeyMod$1.CtrlCmd | KeyCode.Period,
            }
        });
    }
    runEditorCommand(_accessor, editor) {
        return CopyPasteController.get(editor)?.changePasteType();
    }
}));
registerEditorCommand(new (class extends EditorCommand {
    constructor() {
        super({
            id: 'editor.hidePasteWidget',
            precondition: pasteWidgetVisibleCtx,
            kbOpts: {
                weight: KeybindingWeight.EditorContrib,
                primary: KeyCode.Escape,
            }
        });
    }
    runEditorCommand(_accessor, editor) {
        CopyPasteController.get(editor)?.clearWidgets();
    }
}));
registerEditorAction(class PasteAsAction extends EditorAction {
    static { this.argsSchema = {
        type: 'object',
        properties: {
            kind: {
                type: 'string',
                description: ( localizeWithPath(
                    _moduleId,
                    0,
                    "The kind of the paste edit to try applying. If not provided or there are multiple edits for this kind, the editor will show a picker."
                )),
            }
        },
    }; }
    constructor() {
        super({
            id: 'editor.action.pasteAs',
            label: ( localizeWithPath(_moduleId, 1, "Paste As...")),
            alias: 'Paste As...',
            precondition: EditorContextKeys.writable,
            metadata: {
                description: 'Paste as',
                args: [{
                        name: 'args',
                        schema: PasteAsAction.argsSchema
                    }]
            }
        });
    }
    run(_accessor, editor, args) {
        let kind = typeof args?.kind === 'string' ? args.kind : undefined;
        if (!kind && args) {
            kind = typeof args.id === 'string' ? args.id : undefined;
        }
        return CopyPasteController.get(editor)?.pasteAs(kind ? ( (new HierarchicalKind(kind))) : undefined);
    }
});
registerEditorAction(class extends EditorAction {
    constructor() {
        super({
            id: 'editor.action.pasteAsText',
            label: ( localizeWithPath(_moduleId, 2, "Paste as Text")),
            alias: 'Paste as Text',
            precondition: EditorContextKeys.writable,
        });
    }
    run(_accessor, editor) {
        return CopyPasteController.get(editor)?.pasteAs({ providerId: DefaultTextPasteOrDropEditProvider.id });
    }
});
