/**
 * amis v3.1.0
 * Copyright 2018-2023 baidu
 */

import { __extends, __assign, __decorate, __metadata } from 'tslib';
import { SparkLine } from 'amis-ui';
import { createObject, getPropValue, autobind, Renderer } from 'amis-core';
import React from 'react';

/** @class */ ((function (_super) {
    __extends(SparkLineRenderer, _super);
    function SparkLineRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    SparkLineRenderer.prototype.handleClick = function (e, ctx) {
        var _a = this.props, disabled = _a.disabled, onAction = _a.onAction, clickAction = _a.clickAction, data = _a.data;
        if (e.defaultPrevented || !clickAction || disabled) {
            return;
        }
        onAction === null || onAction === void 0 ? void 0 : onAction(null, clickAction, ctx ? createObject(data, ctx) : data);
    };
    SparkLineRenderer.prototype.render = function () {
        var _a = this.props; _a.value; _a.name; _a.data; var clickAction = _a.clickAction;
        var finalValue = getPropValue(this.props) || [1, 1];
        return (React.createElement(SparkLine, __assign({ onClick: clickAction ? this.handleClick : undefined }, this.props, { value: finalValue })));
    };
    __decorate([
        autobind,
        __metadata("design:type", Function),
        __metadata("design:paramtypes", [Object, Object]),
        __metadata("design:returntype", void 0)
    ], SparkLineRenderer.prototype, "handleClick", null);
    SparkLineRenderer = __decorate([
        Renderer({
            type: 'sparkline'
        })
    ], SparkLineRenderer);
    return SparkLineRenderer;
})(React.Component));
