"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.create = create;
const vscode_uri_1 = require("vscode-uri");
function create() {
    return {
        name: 'vue-format-per-block',
        capabilities: {
            documentFormattingProvider: true,
            documentOnTypeFormattingProvider: {
                triggerCharacters: [],
            },
        },
        create(context) {
            return {
                async provideDocumentFormattingEdits(document) {
                    if (await shouldSkip(document)) {
                        return [];
                    }
                    return undefined;
                },
                async provideOnTypeFormattingEdits(document) {
                    if (await shouldSkip(document)) {
                        return [];
                    }
                    return undefined;
                },
            };
            async function shouldSkip(document) {
                const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(document.uri));
                if (!decoded) {
                    return false;
                }
                const [, embeddedCodeId] = decoded;
                if (embeddedCodeId === 'script_raw' || embeddedCodeId === 'scriptsetup_raw') {
                    return await context.env.getConfiguration?.('vue.format.script.enabled') === false;
                }
                if (embeddedCodeId.startsWith('style_')) {
                    return await context.env.getConfiguration?.('vue.format.style.enabled') === false;
                }
                if (embeddedCodeId === 'template'
                    || embeddedCodeId.startsWith('template_inline_ts_')
                    || embeddedCodeId === 'root_tags') {
                    return await context.env.getConfiguration?.('vue.format.template.enabled') === false;
                }
                return false;
            }
        },
    };
}
//# sourceMappingURL=vue-format-per-block.js.map