{#if dragged && x && y}
{folders[folderId].name}
{/if}
{#if draggedOver}
{/if}
{ dispatch('open', state); }} >
{ if (clickTimer) { clearTimeout(clickTimer); // cancel the single-click action clickTimer = null; } renameHandler(); }} on:click={async (e) => { (e) => e.stopPropagation(); if (clickTimer) { clearTimeout(clickTimer); clickTimer = null; } clickTimer = setTimeout(async () => { const folder = await getFolderById(localStorage.token, folderId).catch((error) => { toast.error(`${error}`); return null; }); if (folder) { await selectedFolder.set(folder); } await goto('/'); if ($mobile) { showSidebar.set(!$showSidebar); } clickTimer = null; }, 100); // 100ms delay (typical double-click threshold) }} on:pointerup={(e) => { e.stopPropagation(); }} >
{ e.stopPropagation(); e.stopImmediatePropagation(); open = !open; isExpandedUpdateDebounceHandler(); }} > {#if folders[folderId]?.meta?.icon}
{#if open}
{:else}
{/if}
{:else}
{#if open}
{:else}
{/if}
{/if}
{#if edit}
{ console.log('Blur'); updateHandler({ name }); edit = false; }} on:click={(e) => { // Prevent accidental collapse toggling when clicking inside input e.stopPropagation(); }} on:mousedown={(e) => { // Prevent accidental collapse toggling when clicking inside input e.stopPropagation(); }} on:keydown={(e) => { if (e.key === 'Enter') { updateHandler({ name }); edit = false; } }} class="w-full h-full bg-transparent outline-hidden" /> {:else} {folders[folderId].name} {/if}
{ showFolderModal = true; }} onDelete={() => { showDeleteConfirm = true; }} onExport={() => { exportHandler(); }} >
{#if (folders[folderId]?.childrenIds ?? []).length > 0 || (chats ?? []).length > 0}
{#if folders[folderId]?.childrenIds} {@const children = folders[folderId]?.childrenIds .map((id) => folders[id]) .sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' }) )} {#each children as childFolder (`${folderId}-${childFolder.id}`)}
{ dispatch('import', e.detail); }} on:update={(e) => { dispatch('update', e.detail); }} on:change={(e) => { dispatch('change', e.detail); }} /> {/each} {/if} {#each chats ?? [] as chat (chat.id)}
{ dispatch('change', e.detail); }} /> {/each}
{/if} {#if chats === null}
{/if}