{#snippet totals( label: string, list: Sum[], key: "owe" | "owed" )}
{label} {#if list.length > 0} ({ ...sum, amount: sum[key] }))} tone={key === "owed" ? "income" : "expense"} /> {:else} 0 {/if}
{/snippet} {#snippet actions()} Create a new liability {/snippet} {#if liabilities.isPending}
{:else if liabilities.isError}

{liabilities.error.message}

{:else}
{#if debts.length > 0}
{@render totals("Owed to you", owedToYou, "owed")} {@render totals("You owe", youOwe, "owe")}
{#each cards as item (item.id)} {@const i = index.get(item.id) ?? -1} (nav.cursor = i)} /> {/each}
{:else}

No debts yet

Create a new liability
{/if} {#if others.length > 0}
{#each others as item (item.id)} {@const a = item.attributes} {@const i = index.get(item.id) ?? -1} nav.click(i, event)} > {/each}
Name Type of liability Interest Last activity Amount due
{a.name} {LIABILITY_LABEL[a.liability_type ?? ""] ?? ""} {toNumber(a.interest)}% {PERIOD_LABEL[a.interest_period ?? ""] ?? a.interest_period} {a.last_activity ? formatDate(a.last_activity.slice(0, 10)) : "never"}
{/if} {#if (inactive.data?.meta.pagination?.total ?? 0) > 0} {@const count = inactive.data?.meta.pagination?.total ?? 0} {count} inactive {count === 1 ? "liability" : "liabilities"} {/if}
{/if}