
import { Extensions } from '../../../../platform/configuration/common/configurationRegistry.js';
import { workbenchConfigurationNodeBase } from '../../../common/configuration.js';
import { localize } from '../../../../nls.js';
import { Registry } from '../../../../platform/registry/common/platform.js';

const defaultExternalUriOpenerId = "default";
const externalUriOpenersSettingId = "workbench.externalUriOpeners";
const externalUriOpenerIdSchemaAddition = {
    type: "string",
    enum: []
};
const exampleUriPatterns = `
- \`https://microsoft.com\`: Matches this specific domain using https
- \`https://microsoft.com:8080\`: Matches this specific domain on this port using https
- \`https://microsoft.com:*\`: Matches this specific domain on any port using https
- \`https://microsoft.com/foo\`: Matches \`https://microsoft.com/foo\` and \`https://microsoft.com/foo/bar\`, but not \`https://microsoft.com/foobar\` or \`https://microsoft.com/bar\`
- \`https://*.microsoft.com\`: Match all domains ending in \`microsoft.com\` using https
- \`microsoft.com\`: Match this specific domain using either http or https
- \`*.microsoft.com\`: Match all domains ending in \`microsoft.com\` using either http or https
- \`http://192.168.0.1\`: Matches this specific IP using http
- \`http://192.168.0.*\`: Matches all IP's with this prefix using http
- \`*\`: Match all domains using either http or https`;
const externalUriOpenersConfigurationNode = {
    ...workbenchConfigurationNodeBase,
    properties: {
        [externalUriOpenersSettingId]: {
            type: "object",
            markdownDescription: ( localize(10255, "Configure the opener to use for external URIs (http, https).")),
            defaultSnippets: [{
                body: {
                    "example.com": "$1"
                }
            }],
            additionalProperties: {
                anyOf: [{
                    type: "string",
                    markdownDescription: ( localize(
                        10256,
                        "Map URI pattern to an opener id.\nExample patterns: \n{0}",
                        exampleUriPatterns
                    ))
                }, {
                    type: "string",
                    markdownDescription: ( localize(
                        10256,
                        "Map URI pattern to an opener id.\nExample patterns: \n{0}",
                        exampleUriPatterns
                    )),
                    enum: [defaultExternalUriOpenerId],
                    enumDescriptions: [( localize(10257, "Open using VS Code's standard opener."))]
                }, externalUriOpenerIdSchemaAddition]
            }
        }
    }
};
function updateContributedOpeners(enumValues, enumDescriptions) {
    externalUriOpenerIdSchemaAddition.enum = enumValues;
    externalUriOpenerIdSchemaAddition.enumDescriptions = enumDescriptions;
    ( Registry.as(Extensions.Configuration)).notifyConfigurationSchemaUpdated(externalUriOpenersConfigurationNode);
}

export { defaultExternalUriOpenerId, externalUriOpenersConfigurationNode, externalUriOpenersSettingId, updateContributedOpeners };
