
import { localize } from '../../../../nls.js';
import { RawContextKey, ContextKeyExpr } from '../../../../platform/contextkey/common/contextkey.js';
import { IsWebContext } from '../../../../platform/contextkey/common/contextkeys.js';
import { RemoteNameContext } from '../../../common/contextkeys.js';
import { ChatMode, ChatConfiguration, ChatAgentLocation } from './constants.js';

var ChatContextKeys;
(function (ChatContextKeys) {
    ChatContextKeys.responseVote = ( new RawContextKey(
        'chatSessionResponseVote',
        '',
        { type: 'string', description: ( localize(
            4934,
            "When the response has been voted up, is set to 'up'. When voted down, is set to 'down'. Otherwise an empty string."
        )) }
    ));
    ChatContextKeys.responseDetectedAgentCommand = ( new RawContextKey(
        'chatSessionResponseDetectedAgentOrCommand',
        false,
        { type: 'boolean', description: ( localize(4935, "When the agent or command was automatically detected")) }
    ));
    ChatContextKeys.responseSupportsIssueReporting = ( new RawContextKey(
        'chatResponseSupportsIssueReporting',
        false,
        { type: 'boolean', description: ( localize(4936, "True when the current chat response supports issue reporting.")) }
    ));
    ChatContextKeys.responseIsFiltered = ( new RawContextKey(
        'chatSessionResponseFiltered',
        false,
        { type: 'boolean', description: ( localize(4937, "True when the chat response was filtered out by the server.")) }
    ));
    ChatContextKeys.responseHasError = ( new RawContextKey(
        'chatSessionResponseError',
        false,
        { type: 'boolean', description: ( localize(4938, "True when the chat response resulted in an error.")) }
    ));
    ChatContextKeys.requestInProgress = ( new RawContextKey(
        'chatSessionRequestInProgress',
        false,
        { type: 'boolean', description: ( localize(4939, "True when the current request is still in progress.")) }
    ));
    ChatContextKeys.isRequestPaused = ( new RawContextKey(
        'chatRequestIsPaused',
        false,
        { type: 'boolean', description: ( localize(4940, "True when the current request is paused.")) }
    ));
    ChatContextKeys.canRequestBePaused = ( new RawContextKey(
        'chatCanRequestBePaused',
        false,
        { type: 'boolean', description: ( localize(4941, "True when the current request can be paused.")) }
    ));
    ChatContextKeys.isResponse = ( new RawContextKey('chatResponse', false, { type: 'boolean', description: ( localize(4942, "The chat item is a response.")) }));
    ChatContextKeys.isRequest = ( new RawContextKey('chatRequest', false, { type: 'boolean', description: ( localize(4943, "The chat item is a request")) }));
    ChatContextKeys.itemId = ( new RawContextKey('chatItemId', '', { type: 'string', description: ( localize(4944, "The id of the chat item.")) }));
    ChatContextKeys.lastItemId = ( new RawContextKey('chatLastItemId', [], { type: 'string', description: ( localize(4945, "The id of the last chat item.")) }));
    ChatContextKeys.editApplied = ( new RawContextKey('chatEditApplied', false, { type: 'boolean', description: ( localize(4946, "True when the chat text edits have been applied.")) }));
    ChatContextKeys.inputHasText = ( new RawContextKey('chatInputHasText', false, { type: 'boolean', description: ( localize(4947, "True when the chat input has text.")) }));
    ChatContextKeys.inputHasFocus = ( new RawContextKey('chatInputHasFocus', false, { type: 'boolean', description: ( localize(4948, "True when the chat input has focus.")) }));
    ChatContextKeys.inChatInput = ( new RawContextKey('inChatInput', false, { type: 'boolean', description: ( localize(4949, "True when focus is in the chat input, false otherwise.")) }));
    ChatContextKeys.inChatSession = ( new RawContextKey('inChat', false, { type: 'boolean', description: ( localize(4950, "True when focus is in the chat widget, false otherwise.")) }));
    ChatContextKeys.inUnifiedChat = ( new RawContextKey('inUnifiedChat', false, { type: 'boolean', description: ( localize(4951, "True when focus is in the unified chat widget, false otherwise.")) }));
    ChatContextKeys.instructionsAttached = ( new RawContextKey(
        'chatInstructionsAttached',
        false,
        { type: 'boolean', description: ( localize(4952, "True when the chat has a prompt instructions attached.")) }
    ));
    ChatContextKeys.chatMode = ( new RawContextKey('chatMode', ChatMode.Ask, { type: 'string', description: ( localize(4953, "The current chat mode.")) }));
    ChatContextKeys.supported = ( ContextKeyExpr.or(( IsWebContext.toNegated()), ( RemoteNameContext.notEqualsTo(''))));
    ChatContextKeys.enabled = ( new RawContextKey('chatIsEnabled', false, { type: 'boolean', description: ( localize(
        4954,
        "True when chat is enabled because a default chat participant is activated with an implementation."
    )) }));
    ChatContextKeys.panelParticipantRegistered = ( new RawContextKey(
        'chatPanelParticipantRegistered',
        false,
        { type: 'boolean', description: ( localize(4955, "True when a default chat participant is registered for the panel.")) }
    ));
    ChatContextKeys.editingParticipantRegistered = ( new RawContextKey(
        'chatEditingParticipantRegistered',
        false,
        { type: 'boolean', description: ( localize(4956, "True when a default chat participant is registered for editing.")) }
    ));
    ChatContextKeys.chatEditingCanUndo = ( new RawContextKey(
        'chatEditingCanUndo',
        false,
        { type: 'boolean', description: ( localize(
            4957,
            "True when it is possible to undo an interaction in the editing panel."
        )) }
    ));
    ChatContextKeys.chatEditingCanRedo = ( new RawContextKey(
        'chatEditingCanRedo',
        false,
        { type: 'boolean', description: ( localize(
            4958,
            "True when it is possible to redo an interaction in the editing panel."
        )) }
    ));
    ChatContextKeys.extensionInvalid = ( new RawContextKey(
        'chatExtensionInvalid',
        false,
        { type: 'boolean', description: ( localize(
            4959,
            "True when the installed chat extension is invalid and needs to be updated."
        )) }
    ));
    ChatContextKeys.inputCursorAtTop = ( new RawContextKey('chatCursorAtTop', false));
    ChatContextKeys.inputHasAgent = ( new RawContextKey('chatInputHasAgent', false));
    ChatContextKeys.location = ( new RawContextKey('chatLocation', undefined));
    ChatContextKeys.inQuickChat = ( new RawContextKey('quickChatHasFocus', false, { type: 'boolean', description: ( localize(4960, "True when the quick chat UI has focus, false otherwise.")) }));
    ChatContextKeys.hasFileAttachments = ( new RawContextKey(
        'chatHasFileAttachments',
        false,
        { type: 'boolean', description: ( localize(4961, "True when the chat has file attachments.")) }
    ));
    ChatContextKeys.languageModelsAreUserSelectable = ( new RawContextKey(
        'chatModelsAreUserSelectable',
        false,
        { type: 'boolean', description: ( localize(4962, "True when the chat model can be selected manually by the user.")) }
    ));
    ChatContextKeys.Setup = {
        hidden: ( new RawContextKey('chatSetupHidden', false, true)),
        installed: ( new RawContextKey('chatSetupInstalled', false, true)),
        fromDialog: ( ContextKeyExpr.has('config.chat.setupFromDialog')),
    };
    ChatContextKeys.Entitlement = {
        signedOut: ( new RawContextKey('chatSetupSignedOut', false, true)),
        canSignUp: ( new RawContextKey('chatPlanCanSignUp', false, true)),
        limited: ( new RawContextKey('chatPlanLimited', false, true)),
        pro: ( new RawContextKey('chatPlanPro', false, true))
    };
    ChatContextKeys.SetupViewKeys = ( new Set(
        [ChatContextKeys.Setup.hidden.key, ChatContextKeys.Setup.installed.key, ChatContextKeys.Entitlement.signedOut.key, ChatContextKeys.Entitlement.canSignUp.key, ...( ChatContextKeys.Setup.fromDialog.keys())]
    ));
    ChatContextKeys.SetupViewCondition = ( ContextKeyExpr.and(( ChatContextKeys.Setup.fromDialog.negate()), ( ContextKeyExpr.or(( ContextKeyExpr.and(( ChatContextKeys.Setup.hidden.negate()), ( ChatContextKeys.Setup.installed.negate()))), ( ContextKeyExpr.and(ChatContextKeys.Entitlement.canSignUp, ChatContextKeys.Setup.installed)), ( ContextKeyExpr.and(ChatContextKeys.Entitlement.signedOut, ChatContextKeys.Setup.installed))))));
    ChatContextKeys.chatQuotaExceeded = ( new RawContextKey('chatQuotaExceeded', false, true));
    ChatContextKeys.completionsQuotaExceeded = ( new RawContextKey('completionsQuotaExceeded', false, true));
    ChatContextKeys.Editing = {
        hasToolsAgent: ( new RawContextKey('chatHasToolsAgent', false, { type: 'boolean', description: ( localize(4963, "True when a tools agent is registered.")) })),
        agentModeDisallowed: ( new RawContextKey(
            'chatAgentModeDisallowed',
            undefined,
            { type: 'boolean', description: ( localize(4964, "True when agent mode is not allowed.")) }
        )),
        hasToolConfirmation: ( new RawContextKey(
            'chatHasToolConfirmation',
            false,
            { type: 'boolean', description: ( localize(4965, "True when a tool confirmation is present.")) }
        )),
    };
    ChatContextKeys.Tools = {
        toolsCount: ( new RawContextKey('toolsCount', 0, { type: 'number', description: ( localize(4966, "The count of tools available in the chat.")) }))
    };
})(ChatContextKeys || (ChatContextKeys = {}));
var ChatContextKeyExprs;
(function (ChatContextKeyExprs) {
    ChatContextKeyExprs.unifiedChatEnabled = ( ContextKeyExpr.has(`config.${ChatConfiguration.UnifiedChatView}`));
    ChatContextKeyExprs.inEditsOrUnified = ( ContextKeyExpr.or(( ChatContextKeys.location.isEqualTo(ChatAgentLocation.EditingSession)), ChatContextKeys.inUnifiedChat));
    ChatContextKeyExprs.inNonUnifiedPanel = ( ContextKeyExpr.and(( ChatContextKeys.location.isEqualTo(ChatAgentLocation.Panel)), ( ChatContextKeys.inUnifiedChat.negate())));
    ChatContextKeyExprs.inEditingMode = ( ContextKeyExpr.or(( ChatContextKeys.chatMode.isEqualTo(ChatMode.Edit)), ( ChatContextKeys.chatMode.isEqualTo(ChatMode.Agent))));
})(ChatContextKeyExprs || (ChatContextKeyExprs = {}));

export { ChatContextKeyExprs, ChatContextKeys };
