var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import css from './Chip.module.scss';
import { _cx } from 'src/utility/class';
var cx = _cx(css);
var Chip = function (props) {
    var children = props.children, onClick = props.onClick, disabled = props.disabled, url = props.url, _a = props.active, active = _a === void 0 ? true : _a, _b = props.beforeIcon, beforeIcon = _b === void 0 ? false : _b, _c = props.afterIcon, afterIcon = _c === void 0 ? true : _c, beforeIconUrl = props.beforeIconUrl, afterIconUrl = props.afterIconUrl;
    var getHref = function () {
        if (disabled)
            return 'javascript:void(0)';
        if (!url)
            return '/';
        return url;
    };
    var handleClick = function (e) {
        if (onClick) {
            e.preventDefault();
            onClick(e);
        }
    };
    var getBeforeIcon = function (active) {
        return (_jsx("div", { className: cx('beforeIcon'), children: beforeIconUrl || (_jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M6.25 13.75V9.25H7.75V10.75H13.75V12.25H7.75V13.75H6.25ZM0.25 12.25V10.75H4.75V12.25H0.25ZM3.25 9.25V7.75H0.25V6.25H3.25V4.75H4.75V9.25H3.25ZM6.25 7.75V6.25H13.75V7.75H6.25ZM9.25 4.75V0.25H10.75V1.75H13.75V3.25H10.75V4.75H9.25ZM0.25 3.25V1.75H7.75V3.25H0.25Z", fill: active ? '#ffffff' : '#3D3935' }) })) }));
    };
    var getAfterIcon = function (active) {
        return (_jsx("div", { className: cx('afterIcon'), children: afterIconUrl || (_jsx("svg", { width: "8", height: "5", viewBox: "0 0 8 5", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("path", { d: "M0.25 0.5L4 4.25L7.75 0.5H0.25Z", fill: active ? '#ffffff' : '#3D3935' }) })) }));
    };
    return (_jsx("div", { className: cx('chip-wrapper', { active: active }), children: _jsxs("a", __assign({ href: getHref() }, (onClick && { onClick: handleClick }), { children: [beforeIcon && getBeforeIcon(active), active && (_jsx("img", { className: cx('tick'), src: "https://images.ctfassets.net/vh25xg5i1h5l/289BlubQMLpSeIR98o7yp7/6990f7e8e2872402a771524cf512c6a0/tickIcon.svg", alt: "tick" })), children, afterIcon && getAfterIcon(active)] })) }));
};
export default Chip;
