{#snippet plainText(text: string)} {#each text.split(/(\s)/) as line, idx (idx)} {#if line === '\n'}
{:else} {line} {/if} {/each} {/snippet} {#snippet segments(segments: RichtextSegment[])} {#each segments as segment, idx (idx)} {@const { text, features: _features } = segment} {@const features = _features ?? []} {#if features.length > 0} {#each features as feature, idx (idx)} {#if feature.$type === 'app.bsky.richtext.facet#mention'} handleProfileClick(e, feature.did)}>{@render plainText(text)} {:else if feature.$type === 'app.bsky.richtext.facet#link'} {@const uri = new URL(feature.uri)} {@const text = `${!uri.protocol.startsWith('http') ? `${uri.protocol}//` : ''}${uri.host}${uri.hash.length === 0 && uri.search.length === 0 && uri.pathname === '/' ? '' : uri.pathname}${uri.search}${uri.hash}`} {@render plainText(`${text.substring(0, 40)}${text.length > 40 ? '...' : ''}`)} {:else if feature.$type === 'app.bsky.richtext.facet#tag'} {@render plainText(text)} {:else} {@render plainText(text)} {/if} {/each} {:else} {@render plainText(text)} {/if} {/each} {/snippet} {#await richtext} {@render plainText(text)} {:then richtext} {@render segments(segmentize(richtext.text, richtext.facets))} {/await}