import { r as registerInstance, h, d as getElement } from './chunk-eb0263ab.js';
import { _ as _t } from './chunk-a41b3114.js';
var AttributeValues = /** @class */ (function () {
    function AttributeValues(hostRef) {
        registerInstance(this, hostRef);
        this.options = [];
        this.header = _t('webmapgl.attribute-values.header');
        this.limit = 1;
        this.valueMaxWidth = '200px';
    }
    AttributeValues.prototype.componentWillLoad = function () {
        this.parseAttributeOptions();
    };
    AttributeValues.prototype.parseAttributeOptions = function () {
        this.options = (typeof this.attributeOptions === 'string') ?
            JSON.parse(this.attributeOptions) : this.attributeOptions;
    };
    AttributeValues.prototype.getItemsForFeature = function (feature, options) {
        var _this = this;
        return options
            .filter(function (attr) { return attr.name != _this.headerAttribute
            && feature.properties[attr.name] !== undefined; })
            .map(function (attr) { return (h("ion-item", null, h("ion-label", { position: _this.labelPosition }, attr.alias || attr.name), h("ion-note", { slot: (_this.labelPosition != 'stacked') ? 'end' : null, "text-wrap": true, style: { 'max-width': _this.valueMaxWidth } }, feature.properties[attr.name]))); });
    };
    AttributeValues.prototype.generateOptions = function (feature) {
        var opts = [];
        for (var prop in feature.properties) {
            opts.push({
                name: prop
            });
        }
        return opts;
    };
    AttributeValues.prototype.render = function () {
        if (!this.features || !this.features.length)
            return null;
        var items = [];
        for (var _i = 0, _a = this.features.slice(0, this.limit); _i < _a.length; _i++) {
            var feature = _a[_i];
            var header = (this.headerAttribute) ?
                feature.properties[this.headerAttribute] : this.header;
            items.push(h("ion-item-divider", null, h("ion-label", null, header)));
            var featureOpts = this.options || this.generateOptions(feature);
            Array.prototype.push.apply(items, this.getItemsForFeature(feature, featureOpts));
        }
        return (h("ion-list", null, items));
    };
    Object.defineProperty(AttributeValues.prototype, "el", {
        get: function () { return getElement(this); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(AttributeValues, "watchers", {
        get: function () {
            return {
                "attributeOptions": ["parseAttributeOptions"]
            };
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(AttributeValues, "style", {
        get: function () { return "gl-attribute-values ion-note{font-size:14px;line-height:14px;padding-top:16px;text-align:right}"; },
        enumerable: true,
        configurable: true
    });
    return AttributeValues;
}());
export { AttributeValues as gl_attribute_values };
