import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_components__ from "@tachybase/components";
import * as __WEBPACK_EXTERNAL_MODULE__emotion_css__ from "@emotion/css";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE_classnames__ from "classnames";
import * as __WEBPACK_EXTERNAL_MODULE__index_mjs__ from "../../index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__EllipsisWithTooltip_mjs__ from "./EllipsisWithTooltip.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__shared_mjs__ from "./shared.mjs";
function _tagged_template_literal(strings, raw) {
    if (!raw) raw = strings.slice(0);
    return Object.freeze(Object.defineProperties(strings, {
        raw: {
            value: Object.freeze(raw)
        }
    }));
}
function _templateObject() {
    const data = _tagged_template_literal([
        "\n          margin-bottom: 0;\n          line-height: 1.5;\n          font-size: 90%;\n        "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const ReadPretty = ()=>null;
const _Input = (props)=>{
    const prefixCls = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_components__.usePrefixCls)('description-input', props);
    const compile = (0, __WEBPACK_EXTERNAL_MODULE__index_mjs__.useCompile)();
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        className: (0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])(prefixCls, props.className),
        style: {
            display: 'flex',
            alignItems: 'center',
            overflowWrap: 'break-word',
            whiteSpace: 'normal',
            ...props.style
        },
        children: [
            compile(props.addonBefore),
            compile(props.prefix),
            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__EllipsisWithTooltip_mjs__.EllipsisWithTooltip, {
                ellipsis: props.ellipsis,
                children: compile(props.value)
            }),
            compile(props.suffix),
            compile(props.addonAfter)
        ]
    });
};
const _TextArea = (props)=>{
    const prefixCls = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_components__.usePrefixCls)('description-textarea', props);
    const compile = (0, __WEBPACK_EXTERNAL_MODULE__index_mjs__.useCompile)();
    var _props_value;
    const value = compile(null !== (_props_value = props.value) && void 0 !== _props_value ? _props_value : '');
    const { autop = true, ellipsis, text } = props;
    const html = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
        style: {
            lineHeight: 1.612
        },
        dangerouslySetInnerHTML: {
            __html: (0, __WEBPACK_EXTERNAL_MODULE__shared_mjs__.HTMLEncode)(value).split('\n').join('<br/>')
        }
    });
    const content = ellipsis ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__EllipsisWithTooltip_mjs__.EllipsisWithTooltip, {
        ellipsis: ellipsis,
        popoverContent: autop ? html : value,
        children: text || value
    }) : autop ? html : value;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        className: (0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])(prefixCls, props.className),
        style: {
            overflowWrap: 'break-word',
            ...props.style
        },
        children: [
            props.addonBefore,
            props.prefix,
            content,
            props.suffix,
            props.addonAfter
        ]
    });
};
function convertToText(html) {
    const temp = document.createElement('div');
    temp.innerHTML = html;
    const text = temp.innerText;
    return (null == text ? void 0 : text.replace(/[\n\r]/g, '')) || '';
}
const _Html = (props)=>{
    const prefixCls = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_components__.usePrefixCls)('description-textarea', props);
    const compile = (0, __WEBPACK_EXTERNAL_MODULE__index_mjs__.useCompile)();
    var _props_value;
    const value = compile(null !== (_props_value = props.value) && void 0 !== _props_value ? _props_value : '');
    const { autop = true, ellipsis } = props;
    const html = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
        dangerouslySetInnerHTML: {
            __html: value
        }
    });
    const text = convertToText(value);
    const content = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__EllipsisWithTooltip_mjs__.EllipsisWithTooltip, {
        ellipsis: ellipsis,
        popoverContent: autop ? html : value,
        children: ellipsis ? text : html
    });
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        className: (0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])(prefixCls, props.className),
        style: {
            overflowWrap: 'break-word',
            ...props.style
        },
        children: [
            props.addonBefore,
            props.prefix,
            content,
            props.suffix,
            props.addonAfter
        ]
    });
};
const _URL = (props)=>{
    var _props_value;
    const prefixCls = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_components__.usePrefixCls)('description-url', props);
    const content = props.value && /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Typography.Link, {
        ellipsis: true,
        target: '_blank',
        href: props.value,
        children: null === (_props_value = props.value) || void 0 === _props_value ? void 0 : _props_value.toString()
    });
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
        className: (0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])(prefixCls, props.className),
        style: props.style,
        children: [
            props.addonBefore,
            props.prefix,
            content,
            props.suffix,
            props.addonAfter
        ]
    });
};
const _JSON = (props)=>{
    const prefixCls = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_components__.usePrefixCls)('json', props);
    var _props_space;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("pre", {
        className: (0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])(prefixCls, props.className, (0, __WEBPACK_EXTERNAL_MODULE__emotion_css__.css)(_templateObject())),
        style: props.style,
        children: null != props.value ? JSON.stringify(props.value, null, null !== (_props_space = props.space) && void 0 !== _props_space ? _props_space : 2) : ''
    });
};
ReadPretty.Input = _Input;
ReadPretty.TextArea = _TextArea;
ReadPretty.URL = _URL;
ReadPretty.Html = _Html;
ReadPretty.JSON = _JSON;
export { ReadPretty };
