nostr-web-components
Version:
collection of web components that provide quick access to basic nostr things
3 lines (2 loc) • 1.3 kB
JavaScript
function l(n,t=100){let e,r,s;function i(){const a=Date.now()-r;a<t&&a>=0?e=setTimeout(i,t-a):(e=void 0,n(...s))}return function(...a){r=Date.now(),s=a,e||(e=setTimeout(i,t))}}function h(n){var e,r;let t=(r=(e=window.nwc)==null?void 0:e.nostrLink)==null?void 0:r.call(e,n);return t||"https://njump.me/"+n}function A(n){var e,r;let t=(r=(e=window.nwc)==null?void 0:e.relayLink)==null?void 0:r.call(e,n);return t||"https://njump.me/r/"+encodeURIComponent(n)}const o="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";function u(n){const t=n.target;console.warn("error loading image",n),t.src!==o&&(t.src=o)}function m(n){return n?n.split(" ").map(t=>t.trim()).filter(t=>t.length):[]}function f(n){let t=n.indexOf("1");return n.substring(0,t+3)+"…"+n.substring(n.length-5)}function g(n){if(n.length<=30)return n;try{let t=new URL(n);if(n.length<=40)return`${t.host}${t.pathname}${t.search.length?"?":""}${t.search}`;if(n.length<=50&&t.pathname.length<20)return`${t.host}${t.pathname}`;let e=t.pathname,r=t.pathname.split("/"),s=r[r.length-1];return s.length>10&&(s=`…${s.substring(s.length-6)}`),r.length>2?e=`/…/${s}`:e=`/${s}`,`${t.host}${e}`}catch{return n}}export{f as a,g as b,l as d,u as h,h as n,A as r,m as s,o as t};
//# sourceMappingURL=utils.js.map