import { p as proxyCustomElement, H, h, c as Host } from './p-ae373651.js';
import { s as shorten, f as formatName } from './p-efabd2ce.js';
import { e as defaultIconPack, i as useLanguage } from './p-5b3a7f00.js';
import { S as SyncWithStore } from './p-070aa695.js';

const rtkNameTagCss = ":host{line-height:initial;font-family:var(--rtk-font-family, sans-serif);font-feature-settings:normal;font-variation-settings:normal}p{margin:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}:host{display:inline-flex;-webkit-user-select:none;-moz-user-select:none;user-select:none;align-items:center;padding-top:var(--rtk-space-1, 4px);padding-bottom:var(--rtk-space-1, 4px);padding-left:var(--rtk-space-1\\.5, 6px);padding-right:var(--rtk-space-1\\.5, 6px);font-size:14px;border-radius:var(--rtk-border-radius-sm, 4px);--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-700, 44 44 44) / var(--tw-bg-opacity));color:rgb(var(--rtk-colors-text-900, 255 255 255 / 0.88))}span.name{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}::slotted(rtk-audio-visualizer[slot='start']){margin-right:var(--rtk-space-1\\.5, 6px)}::slotted(rtk-audio-visualizer[slot='end']){margin-left:var(--rtk-space-1\\.5, 6px)}:host([size='sm']){font-size:12px;--tw-bg-opacity:0.6}:host([variant='text']){background-color:transparent;padding:var(--rtk-space-0, 0px)}";
const RtkNameTagStyle0 = rtkNameTagCss;

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
        r = Reflect.decorate(decorators, target, key, desc);
    else
        for (var i = decorators.length - 1; i >= 0; i--)
            if (d = decorators[i])
                r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const RtkNameTag = /*@__PURE__*/ proxyCustomElement(class RtkNameTag extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        /** Whether it is used in a screen share view */
        this.isScreenShare = false;
        /** Name tag variant */
        this.variant = 'default';
        /** Icon pack */
        this.iconPack = defaultIconPack;
        /** Language */
        this.t = useLanguage();
        this.length = 13;
    }
    sizeChanged(size) {
        this.length = size === 'sm' ? 8 : 13;
    }
    formatNameTag(name, isSelf) {
        return !this.isScreenShare
            ? isSelf
                ? `${shorten(name, this.length - 3)} (${this.t('you')})`
                : shorten(name, this.length)
            : isSelf
                ? `${this.t('screen')} - ${shorten(name, this.length - 3)} (${this.t('you')})`
                : `${this.t('screen')} - ${shorten(name, this.length)}`;
    }
    render() {
        var _a, _b, _c;
        const name = formatName(((_a = this.participant) === null || _a === void 0 ? void 0 : _a.name) || '');
        const isSelf = ((_b = this.participant) === null || _b === void 0 ? void 0 : _b.id) === ((_c = this.meeting) === null || _c === void 0 ? void 0 : _c.self.id);
        return (h(Host, { key: '9040aabe429bea4cfcdc7a6635eeb336f2154961', title: name }, h("slot", { key: 'f66091f5af1914e91e14415a4758f9bdc15c0c85', name: "start" }), h("span", { key: '241ca42f60b258c5b3c20f423e9ade272f8f5a8b', class: "name" }, this.formatNameTag(name, isSelf)), h("slot", { key: '7f6f9b8e5c2ea76042a0ff812458af6ed702b43d', name: "end" })));
    }
    static get watchers() { return {
        "size": ["sizeChanged"]
    }; }
    static get style() { return RtkNameTagStyle0; }
}, [1, "rtk-name-tag", {
        "participant": [16],
        "meeting": [16],
        "size": [513],
        "isScreenShare": [4, "is-screen-share"],
        "variant": [513],
        "iconPack": [16],
        "t": [16],
        "length": [32]
    }, undefined, {
        "size": ["sizeChanged"]
    }]);
__decorate([
    SyncWithStore()
], RtkNameTag.prototype, "meeting", void 0);
__decorate([
    SyncWithStore()
], RtkNameTag.prototype, "iconPack", void 0);
__decorate([
    SyncWithStore()
], RtkNameTag.prototype, "t", void 0);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["rtk-name-tag"];
    components.forEach(tagName => { switch (tagName) {
        case "rtk-name-tag":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, RtkNameTag);
            }
            break;
    } });
}
defineCustomElement();

export { RtkNameTag as R, defineCustomElement as d };
