"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.behavior = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const Iconista_1 = require("nice-ui/lib/icons/Iconista");
const Sidetip_1 = require("nice-ui/lib/1-inline/Sidetip");
const renderIcon_1 = require("./renderIcon");
const View_1 = require("./View");
const Edit_1 = require("./Edit");
const util_1 = require("../../../../../web/util");
exports.behavior = {
    menu: {
        name: 'Link',
        icon: () => React.createElement(Iconista_1.Iconista, { width: 15, height: 15, set: "lucide", icon: "link" }),
        // icon: () => <Iconista width={15} height={15} set="radix" icon="link-2" />,
        right: () => React.createElement(Sidetip_1.Sidetip, { small: true }, "\u2318 K"),
        keys: ['⌘', 'k'],
    },
    validate: (formatting) => {
        const obj = formatting.conf()?.view();
        if (!obj || typeof obj !== 'object')
            return [{ code: 'INVALID_CONFIG' }];
        const href = obj.href || '';
        if (typeof href !== 'string')
            return [{ code: 'INVALID_URL' }];
        if (href.length < 4)
            return 'empty';
        const domain = (0, util_1.getDomain)(href);
        return domain ? 'good' : 'fine';
    },
    previewText: (formatting) => {
        const data = formatting.conf()?.view();
        if (!data || typeof data !== 'object')
            return '';
        return (data.href || '').replace(/^(https?:\/\/)?(www\.)?/, '');
    },
    renderIcon: renderIcon_1.renderIcon,
    Edit: Edit_1.Edit,
    View: View_1.View,
};
//# sourceMappingURL=behavior.js.map