2025-06-22 00:21:09 +03:00

34 lines
2.5 KiB
JavaScript

import { s as subscribe } from "./utils.js";
import { c as create_ssr_component, e as escape, a as add_attribute } from "./ssr.js";
import { c as contactsStore } from "./contactsStore.js";
const css = {
code: "@keyframes svelte-lhyvo7-fade-out{0%{opacity:1}70%{opacity:1}100%{opacity:0}}.animate-fade-out.svelte-lhyvo7{animation:svelte-lhyvo7-fade-out 2s ease-out forwards}",
map: null
};
const TruncatedKey = create_ssr_component(($$result, $$props, $$bindings, slots) => {
let contactName;
let truncatedKey;
let displayText;
let $contactsStore, $$unsubscribe_contactsStore;
$$unsubscribe_contactsStore = subscribe(contactsStore, (value) => $contactsStore = value);
let { keyText = "" } = $$props;
let { frontChars = 4 } = $$props;
let { backChars = 4 } = $$props;
let { showCopy = true } = $$props;
let { className = "" } = $$props;
if ($$props.keyText === void 0 && $$bindings.keyText && keyText !== void 0) $$bindings.keyText(keyText);
if ($$props.frontChars === void 0 && $$bindings.frontChars && frontChars !== void 0) $$bindings.frontChars(frontChars);
if ($$props.backChars === void 0 && $$bindings.backChars && backChars !== void 0) $$bindings.backChars(backChars);
if ($$props.showCopy === void 0 && $$bindings.showCopy && showCopy !== void 0) $$bindings.showCopy(showCopy);
if ($$props.className === void 0 && $$bindings.className && className !== void 0) $$bindings.className(className);
$$result.css.add(css);
contactName = $contactsStore.contacts?.find((contact) => contact.address === keyText)?.name;
truncatedKey = keyText && keyText.length > frontChars + backChars + 3 ? `${keyText.slice(0, frontChars)}...${keyText.slice(-backChars)}` : keyText;
displayText = contactName || truncatedKey;
$$unsubscribe_contactsStore();
return ` <div class="${"flex items-center space-x-2 " + escape(className, true) + " svelte-lhyvo7"}"><span class="font-mono text-sm"${add_attribute("title", contactName ? `${contactName} (${keyText})` : keyText, 0)}>${escape(displayText)}</span> ${showCopy && keyText ? `<button class="p-1 text-gray-400 hover:text-gray-600 transition-colors" title="Copy full address" aria-label="Copy address to clipboard">${`<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path></svg>`}</button>` : ``} ${``} </div>`;
});
export {
TruncatedKey as T
};