{#snippet commentHeader(filePath?: string, selectionRange?: SelectionRange)} {#if filePath && selectionRange}
{filePath.split("/").length > 1 ? "…/" : ""}{filePath .split("/") .slice(-1)}:{selectionRange.start.side === "left" ? "L" : "R"}{selectionRange.start.lineNumber} {#if selectionRange.end} -> {selectionRange.end.side === "left" ? "L" : "R"}{selectionRange.end .lineNumber} {/if}
{/if} {/snippet}
{#if file.diff.type === "plain"} {#each file.diff.hunks as hunk, hunkIdx}
{hunk.header}
{#each hunk.lines as line, lineIdx} {@const thread = findLineThread(line)}
{ if (codeComments?.createComment && !thread) { selectLine(e, file, "left", line, hunkIdx, lineIdx); } }}> {lineNumber(line, "left")}
{ if (codeComments?.createComment && !thread) { selectLine(e, file, "right", line, hunkIdx, lineIdx); } }}> {lineNumber(line, "right")}
{#if line.type === "addition"} + {:else if line.type === "deletion"} - {/if}
{#if line.highlight && line.highlight.items.length > 0}
{@html line.highlight.items .map( paint => `${escape(paint.item)}`, ) .join("")}
{:else if line.line !== ""}
{line.line}
{:else}

{/if}
{#if thread} {#if thread.root.resolved} toggleCommentExpand(thread.root.id)} /> {:else} toggleCommentExpand(thread.root.id)} /> {/if} {/if}
{#if codeComments && thread && !threadExpandedStates[thread.root.id]}
{@render commentHeader( thread.root.location?.path, rangeAnchorsFromCodeLocation(thread.root.location), )} {#if codeComments.changeCommentStatus && roles.isDelegateOrAuthor( codeComments.config.publicKey, codeComments.repoDelegates.map(delegate => delegate.did), thread.root.author.did, )}
{#if thread.root.resolved}
{:else}
{/if}
{/if}
{ await codeComments.createComment( body, embeds, thread.root.id, ); } : undefined} editComment={codeComments.editComment} canEditComment={partial( roles.isDelegateOrAuthor, codeComments.config.publicKey, codeComments.repoDelegates.map(delegate => delegate.did), )} />
{/if} {#if codeComments && selection && selection.hunkIdx === hunkIdx && selection.lineIdx === lineIdx && selection.codeLocation}
{ e.stopPropagation(); }}>
{@render commentHeader(selection.file, { start: selection.start, })}
{ selection = undefined; }} focus placeholder="Leave a comment" disableAttachments={codeComments.disableAttachments} submit={async (body, embeds) => { if (selection?.codeLocation) { try { await codeComments.createComment( body, embeds, undefined, selection.codeLocation, ); } catch (e) { console.error("Comment creation failed", e); } finally { selection = undefined; } } }} />
{/if} {/each}
{/each} {/if}