import { r as registerInstance, h, H as Host } from './index-ecdfb761.js';
import { h as hasLink, l as linkify } from './utils-c4a3ab3b.js';

const dvnFieldDisplayTextCss = "dvn-field-display-text{display:block;--line-count:0;overflow:hidden;display:-webkit-box;-webkit-line-clamp:var(--line-count);-webkit-box-orient:vertical;line-height:var(--line-height);min-height:calc(var(--line-count) * var(--line-height))}";

const DvnFieldDisplayText = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.meta = {};
  }
  render() {
    const { field, meta } = this;
    let value = this.value;
    // 0 means no limit
    const { lines = 0 } = meta;
    if (!value) {
      return (h(Host, { style: { '--line-count': lines } }, "-"));
    }
    if (field.inputType === 'url') {
      value = h("a", { href: value.startsWith('http') ? value : `http://${value}`, target: "_blank" }, value);
    }
    if (hasLink(value)) {
      return (h(Host, { style: { '--line-count': lines }, innerHTML: linkify(this.value) }));
    }
    if (field.format === 'markdown') {
      return (h(Host, { style: { '--line-count': lines } }, h("dvn-markdown", { content: value })));
    }
    return (h(Host, { style: { '--line-count': lines } }, value));
  }
};
DvnFieldDisplayText.style = dvnFieldDisplayTextCss;

export { DvnFieldDisplayText as dvn_field_display_text };
