// CodeMirror核心库文件 - 完整版
// 请从 https://codemirror.net/5/ 下载完整版本并替换此文件
// 或使用以下命令下载：
// Invoke-WebRequest -Uri "https://codemirror.net/5/codemirror.zip" -OutFile "codemirror.zip"
// Expand-Archive -Path "codemirror.zip" -DestinationPath "assets/codemirror"

// 临时基础实现保证基本功能
(function(root, factory) {
    if (typeof exports === 'object' && typeof module === 'object')
        module.exports = factory();
    else if (typeof define === 'function' && define.amd)
        define([], factory);
    else
        root.CodeMirror = factory();
})(this, function() {
    const CodeMirror = function(place, options) {
        if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);
        this.options = options || {};
        this.doc = {text: options.value || "", mode: options.mode};
        this.display = {
            wrapper: place,
            setValue: (text) => { this.doc.text = text; }
        };
    };

    CodeMirror.prototype = {
        setValue: function(text) {
            this.doc.text = text;
            if (this.display.wrapper) {
                this.display.wrapper.innerHTML = text;
            }
        },
        getValue: function() {
            return this.doc.text;
        },
        setOption: function(option, value) {
            this.options[option] = value;
        },
        getOption: function(option) {
            return this.options[option];
        }
    };

    // 静态方法
    CodeMirror.defineMode = function(name, mode) {
        CodeMirror.modes[name] = mode;
    };

    CodeMirror.modes = {};
    return CodeMirror;
});