import { p as proxyCustomElement, H, h } from './p-BsG0yTW8.js';

const textRendererCss = ":host{display:block;width:100%;--primary-color:#007AFF;--success-color:#34C759;--warning-color:#FF9500;--error-color:#FF3B30;--text-color:#000000;--text-color-secondary:#8E8E93;--background-color:#F2F2F7;--border-color:#C6C6C8;--spacing-xs:4px;--spacing-sm:8px;--spacing-md:16px;--spacing-lg:24px;--spacing-xl:32px;--font-size-xs:11px;--font-size-sm:12px;--font-size-md:14px;--font-size-lg:16px;--font-size-xl:18px;--border-radius-sm:4px;--border-radius-md:8px;--border-radius-lg:12px;--border-radius-xl:16px;--shadow-sm:0 1px 2px rgba(0, 0, 0, 0.1);--shadow-md:0 2px 4px rgba(0, 0, 0, 0.1);--shadow-lg:0 4px 8px rgba(0, 0, 0, 0.1);--transition-fast:0.15s ease;--transition-normal:0.3s ease;--transition-slow:0.5s ease}.text-renderer{line-height:1.5;word-wrap:break-word;word-break:break-word;border:1px solid yellow;padding:16px}.text-renderer a{color:var(--primary-color);text-decoration:none;border-bottom:1px solid transparent;transition:border-color var(--transition-fast)}.text-renderer a:hover{border-bottom-color:var(--primary-color)}.text-renderer a:active{opacity:0.7}.text-renderer code{background-color:var(--background-color);color:var(--error-color);padding:2px 4px;border-radius:var(--border-radius-sm);font-family:'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;font-size:0.9em}.text-renderer pre{background-color:var(--background-color);border:1px solid var(--border-color);border-radius:var(--border-radius-md);padding:var(--spacing-md);margin:var(--spacing-sm) 0;overflow-x:auto;-webkit-overflow-scrolling:touch}.text-renderer pre code{background:none;padding:0;color:var(--text-color);font-size:13px;line-height:1.4}@media (max-width: 768px){.text-renderer{font-size:16px}.text-renderer pre{font-size:14px}}";

const TextRenderer = /*@__PURE__*/ proxyCustomElement(class TextRenderer extends H {
    constructor(registerHost) {
        super();
        if (registerHost !== false) {
            this.__registerHost();
        }
        this.__attachShadow();
    }
    /**
     * 要渲染的文本内容
     */
    content = '';
    /**
     * 是否保留换行符
     */
    preserveWhitespace = true;
    /**
     * 是否支持链接自动识别
     */
    autoLink = true;
    /**
     * 是否支持代码高亮
     */
    highlightCode = false;
    formatText(text) {
        if (!text)
            return '';
        let formattedText = text;
        // 处理换行符
        if (this.preserveWhitespace) {
            formattedText = formattedText.replace(/\n/g, '<br>');
        }
        // 自动识别链接
        if (this.autoLink) {
            const urlRegex = /(https?:\/\/[^\s]+)/g;
            formattedText = formattedText.replace(urlRegex, '<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>');
        }
        // 处理代码块
        if (this.highlightCode) {
            const codeBlockRegex = /```([\s\S]*?)```/g;
            formattedText = formattedText.replace(codeBlockRegex, '<pre><code>$1</code></pre>');
            const inlineCodeRegex = /`([^`]+)`/g;
            formattedText = formattedText.replace(inlineCodeRegex, '<code>$1</code>');
        }
        return formattedText;
    }
    render() {
        const formattedContent = this.formatText(this.content);
        return (h("div", { key: 'd0c58038fa8cc5da57d72420ac4e3ea87ed1a080', class: "text-renderer", innerHTML: formattedContent }));
    }
    static get style() { return textRendererCss; }
}, [257, "text-renderer", {
        "content": [1],
        "preserveWhitespace": [4, "preserve-whitespace"],
        "autoLink": [4, "auto-link"],
        "highlightCode": [4, "highlight-code"]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["text-renderer"];
    components.forEach(tagName => { switch (tagName) {
        case "text-renderer":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, TextRenderer);
            }
            break;
    } });
}
defineCustomElement();

export { TextRenderer as T, defineCustomElement as d };
//# sourceMappingURL=p-DO7ZS-Db.js.map

//# sourceMappingURL=p-DO7ZS-Db.js.map