{#if mode === "categories"} {#if show_legend}
{#if _color_map} {#each Object.entries(_color_map) as [class_or_confidence, color], i}
handle_mouseover(class_or_confidence)} on:focus={() => handle_mouseover(class_or_confidence)} on:mouseout={() => handle_mouseout()} on:blur={() => handle_mouseout()} class="class_or_confidence-label" style={"background-color:" + color.secondary} > {class_or_confidence}
{/each} {/if}
{/if}
{#each value as { token, class_or_confidence }, i} {#each splitTextByNewline(token) as line, j} {#if line.trim() !== ""} { if (class_or_confidence !== null) { handleSelect(i, token, class_or_confidence); } }} on:keydown={(e) => { if (class_or_confidence !== null) { labelToEdit = i; handleSelect(i, token, class_or_confidence); } else { handleKeydownSelection(e); } }} on:focus={() => (activeElementIndex = i)} on:mouseover={() => (activeElementIndex = i)} > handleKeydownSelection(e)} on:focus={() => (activeElementIndex = i)} on:mouseover={() => (activeElementIndex = i)} on:click={() => (labelToEdit = i)} tabindex="0">{line} {#if !show_legend && class_or_confidence !== null && labelToEdit !== i} (labelToEdit = i)} on:keydown={() => (labelToEdit = i)} > {class_or_confidence} {/if} {#if labelToEdit === i && class_or_confidence !== null}   {/if} {#if class_or_confidence !== null} removeHighlightedText(i)} on:keydown={(event) => { if (event.key === "Enter") { removeHighlightedText(i); } }} >× {/if} {/if} {#if j < splitTextByNewline(token).length - 1}
{/if} {/each} {/each}
{:else} {#if show_legend}
-1 0 +1
{/if}
{#each value as { token, class_or_confidence }, i} {@const score = typeof class_or_confidence === "string" ? parseInt(class_or_confidence) : class_or_confidence} (activeElementIndex = i)} on:focus={() => (activeElementIndex = i)} on:click={() => (labelToEdit = i)} on:keydown={(e) => { if (e.key === "Enter") { labelToEdit = i; } }} style={"background-color: rgba(" + (score && score < 0 ? "128, 90, 213," + -score : "239, 68, 60," + score) + ")"} > {token} {#if class_or_confidence && labelToEdit === i} {/if} {#if class_or_confidence && activeElementIndex === i} removeHighlightedText(i)} on:keydown={(event) => { if (event.key === "Enter") { removeHighlightedText(i); } }} >× {/if} {/each}
{/if}