
import { EditorAction2, EditorAction } from '../../../../browser/editorExtensions.js';
import { KeyCode } from '../../../../../base/common/keyCodes.js';
import { localize2, localize } from '../../../../../nls.js';
import { KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js';
import { EditorContextKeys } from '../../../../common/editorContextKeys.js';
import { MenuId } from '../../../../../platform/actions/common/actions.js';
import { StandaloneColorPickerController } from './standaloneColorPickerController.js';

class ShowOrFocusStandaloneColorPicker extends EditorAction2 {
    constructor() {
        super({
            id: 'editor.action.showOrFocusStandaloneColorPicker',
            title: {
                ...( localize2(903, "Show or Focus Standalone Color Picker")),
                mnemonicTitle: ( localize(904, "&&Show or Focus Standalone Color Picker")),
            },
            precondition: undefined,
            menu: [
                { id: MenuId.CommandPalette },
            ],
            metadata: {
                description: ( localize2(
                    905,
                    "Show or focus a standalone color picker which uses the default color provider. It displays hex/rgb/hsl colors."
                )),
            }
        });
    }
    runEditorCommand(_accessor, editor) {
        StandaloneColorPickerController.get(editor)?.showOrFocus();
    }
}
class HideStandaloneColorPicker extends EditorAction {
    constructor() {
        super({
            id: 'editor.action.hideColorPicker',
            label: ( localize2(906, "Hide the Color Picker")),
            precondition: ( EditorContextKeys.standaloneColorPickerVisible.isEqualTo(true)),
            kbOpts: {
                primary: KeyCode.Escape,
                weight: KeybindingWeight.EditorContrib
            },
            metadata: {
                description: ( localize2(907, "Hide the standalone color picker.")),
            }
        });
    }
    run(_accessor, editor) {
        StandaloneColorPickerController.get(editor)?.hide();
    }
}
class InsertColorWithStandaloneColorPicker extends EditorAction {
    constructor() {
        super({
            id: 'editor.action.insertColorWithStandaloneColorPicker',
            label: ( localize2(908, "Insert Color with Standalone Color Picker")),
            precondition: ( EditorContextKeys.standaloneColorPickerFocused.isEqualTo(true)),
            kbOpts: {
                primary: KeyCode.Enter,
                weight: KeybindingWeight.EditorContrib
            },
            metadata: {
                description: ( localize2(909, "Insert hex/rgb/hsl colors with the focused standalone color picker.")),
            }
        });
    }
    run(_accessor, editor) {
        StandaloneColorPickerController.get(editor)?.insertColor();
    }
}

export { HideStandaloneColorPicker, InsertColorWithStandaloneColorPicker, ShowOrFocusStandaloneColorPicker };
