import { Component, h, Host, Prop } from '@stencil/core';
const renderReference = (field, data, meta) => {
  const imageSrc = field.imageField ? data[field.imageField] : undefined;
  const initialLetters = field.titleField
    ? data[field.titleField].split(' ').map(word => word[0]).join('')
    : undefined;
  return (h("abbr", { title: data[field.titleField] },
    h("dvn-image", { bordered: true, leanedVertically: true, src: imageSrc, text: initialLetters, shape: meta === null || meta === void 0 ? void 0 : meta.imageShape })));
};
export class DvnFieldDisplayCellReference {
  render() {
    const { field, meta } = this;
    const value = this.value || [];
    return (h(Host, null, Array.isArray(value)
      ? value.map(data => renderReference(field, data, meta))
      : renderReference(field, value, meta)));
  }
  static get is() { return "dvn-field-display-cell-reference"; }
  static get encapsulation() { return "scoped"; }
  static get originalStyleUrls() { return {
    "$": ["dvn-field-display-cell-reference.css"]
  }; }
  static get styleUrls() { return {
    "$": ["dvn-field-display-cell-reference.css"]
  }; }
  static get properties() { return {
    "value": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "any[]",
        "resolved": "any[]",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "field": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "ReferenceField",
        "resolved": "ReferenceField",
        "references": {
          "ReferenceField": {
            "location": "import",
            "path": "../reference-field"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    },
    "meta": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "{ imageShape: ImageShape }",
        "resolved": "{ imageShape: ImageShape; }",
        "references": {
          "ImageShape": {
            "location": "import",
            "path": "@dvn/alaca/components/dvn-image/models"
          }
        }
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [],
        "text": ""
      }
    }
  }; }
}
