2022-09-06 23:26:43 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import {LitElement, html} from './lit-all.min.js';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import * as tfrpc from '/static/tfrpc.js';
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-22 19:39:20 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import {styles, generate_theme} from './tf-styles.js';
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-06 23:26:43 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class TfUserElement extends LitElement {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									static get properties() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										return {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											id: {type: String},
							 | 
						
					
						
							
								
									
										
										
										
											2025-04-12 07:05:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											fallback_name: {type: String},
							 | 
						
					
						
							
								
									
										
										
										
											2025-06-27 12:46:15 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											icon_only: {type: Boolean},
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-06 23:26:43 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
											users: {type: Object},
							 | 
						
					
						
							
								
									
										
										
										
											2025-08-13 19:16:34 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											nolink: {type: Boolean},
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-29 22:02:12 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										};
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-06 23:26:43 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									static styles = styles;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									constructor() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										super();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
										this.id = null;
							 | 
						
					
						
							
								
									
										
										
										
											2025-04-12 07:05:37 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										this.fallback_name = null;
							 | 
						
					
						
							
								
									
										
										
										
											2025-06-27 12:46:15 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										this.icon_only = false;
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-06 23:26:43 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										this.users = {};
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
									render() {
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-11 13:48:06 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										let user = this.users[this.id];
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-27 21:02:15 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										let shape =
							 | 
						
					
						
							
								
									
										
										
										
											2025-02-16 15:52:27 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											user?.follow_depth === undefined || user.follow_depth >= 2
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												? 'w3-circle'
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												: 'w3-round';
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-12 10:40:06 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										let image = html`<span
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-11 13:48:06 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											class=${'w3-theme-l4 ' + shape}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-12 10:40:06 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											style="display: inline-block; width: 2em; height: 2em; text-align: center; line-height: 2em"
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-18 21:17:07 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											>😎</span
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-15 19:25:48 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										>`;
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-19 23:31:08 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										let name = this.users?.[this.id]?.name;
							 | 
						
					
						
							
								
									
										
										
										
											2025-07-02 12:49:14 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										let name_string = name ?? this.fallback_name ?? this.id;
							 | 
						
					
						
							
								
									
										
										
										
											2025-06-27 12:46:15 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										name = this.icon_only
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											? undefined
							 | 
						
					
						
							
								
									
										
										
										
											2025-08-13 19:16:34 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											: !this.nolink
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												? html`<a target="_top" href=${'#' + this.id}>${name_string}</a>`
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												: html`<span>${name_string}</span>`;
							 | 
						
					
						
							
								
									
										
										
										
											2023-03-19 23:31:08 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-11 13:48:06 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										if (user) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											let image_link = user.image;
							 | 
						
					
						
							
								
									
										
										
										
											2025-05-11 21:42:48 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											if (typeof image_link == 'string' && !image_link.startsWith('&')) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												try {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
													image_link = JSON.parse(image_link)?.link;
							 | 
						
					
						
							
								
									
										
										
										
											2025-05-11 21:54:53 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												} catch {}
							 | 
						
					
						
							
								
									
										
										
										
											2025-05-11 21:42:48 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-12 10:40:06 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
											if (image_link !== undefined) {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												image = html`<img
							 | 
						
					
						
							
								
									
										
										
										
											2025-01-11 13:48:06 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													class=${'w3-theme-l4 ' + shape}
							 | 
						
					
						
							
								
									
										
										
										
											2024-10-10 21:41:34 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													style="width: 2em; height: 2em; vertical-align: middle; object-fit: cover"
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-12 10:40:06 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													src="/${image_link}/view"
							 | 
						
					
						
							
								
									
										
										
										
											2025-07-02 12:49:14 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
													title=${name_string + ' (' + this.id + ')'}
							 | 
						
					
						
							
								
									
										
										
										
											2024-05-12 10:40:06 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
												/>`;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											}
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-06 23:26:43 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
										}
							 | 
						
					
						
							
								
									
										
										
										
											2025-10-22 19:39:20 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
										return html` <style>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												${generate_theme()}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											</style>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											<div
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												style=${'display: inline-block; vertical-align: middle; text-wrap: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis' +
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												(this.nolink ? '' : '; font-weight: bold')}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											>
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
												${image} ${name}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
											</div>`;
							 | 
						
					
						
							
								
									
										
										
										
											2022-09-06 23:26:43 +00:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
									}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2024-02-24 11:09:34 -05:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								customElements.define('tf-user', TfUserElement);
							 |