Files

{#each Object.entries(fileTree) as [name, value]} {@const isFile = value && typeof value === 'object' && 'path' in value} {@const isDir = value && typeof value === 'object' && !('path' in value)} {#if isDir} {@const dirPath = name} {@const isExpandedDir = isExpanded(dirPath)}
{#if isExpandedDir}
{#each Object.entries(value).sort(([a, valA], [b, valB]) => { const aIsFile = valA && typeof valA === 'object' && 'path' in valA; const bIsFile = valB && typeof valB === 'object' && 'path' in valB; const aIsDir = valA && typeof valA === 'object' && !('path' in valA); const bIsDir = valB && typeof valB === 'object' && !('path' in valB); if (aIsDir && !bIsDir) return -1; if (!aIsDir && bIsDir) return 1; return a.localeCompare(b); }) as [subName, subValue]} {#if subValue && typeof subValue === 'object' && 'path' in subValue} {@const file = subValue as GitFile}
{:else if subValue && typeof subValue === 'object'} {@const subDirPath = `${dirPath}/${subName}`} {@const isExpandedSubDir = isExpanded(subDirPath)}
{#if isExpandedSubDir}
{#each Object.entries(subValue).sort(([a, valA], [b, valB]) => { const aIsFile = valA && typeof valA === 'object' && 'path' in valA; const bIsFile = valB && typeof valB === 'object' && 'path' in valB; const aIsDir = valA && typeof valA === 'object' && !('path' in valA); const bIsDir = valB && typeof valB === 'object' && !('path' in valB); if (aIsDir && !bIsDir) return -1; if (!aIsDir && bIsDir) return 1; return a.localeCompare(b); }) as [nestedName, nestedValue]} {#if nestedValue && typeof nestedValue === 'object' && 'path' in nestedValue} {@const nestedFile = nestedValue as GitFile}
{:else if nestedValue && typeof nestedValue === 'object'} {@const deeperDirPath = `${subDirPath}/${nestedName}`} {@const isExpandedDeeper = isExpanded(deeperDirPath)}
{#if isExpandedDeeper}
{#each Object.entries(nestedValue).sort(([a, valA], [b, valB]) => { const aIsFile = valA && typeof valA === 'object' && 'path' in valA; const bIsFile = valB && typeof valB === 'object' && 'path' in valB; const aIsDir = valA && typeof valA === 'object' && !('path' in valA); const bIsDir = valB && typeof valB === 'object' && !('path' in valB); if (aIsDir && !bIsDir) return -1; if (!aIsDir && bIsDir) return 1; return a.localeCompare(b); }) as [deepName, deepValue]} {#if deepValue && typeof deepValue === 'object' && 'path' in deepValue} {@const deepFile = deepValue as GitFile}
{:else}
📁 {deepName}/ (deeper nesting not fully expanded)
{/if} {/each}
{/if}
{/if} {/each}
{/if}
{/if} {/each}
{/if}
{:else if isFile} {@const file = value as GitFile}
{/if} {/each}
{#if loadingContent}

Loading file content...

{:else if contentError}

Error: {contentError}

{:else if selectedFile && (fileContent !== null || fileUrl)}

{selectedFile.path}

{formatFileSize(selectedFile.size)}
{#if isImageFile(selectedFile) && fileUrl}
{selectedFile.name}
{:else if isVideoFile(selectedFile) && fileUrl}
{:else if isAudioFile(selectedFile) && fileUrl}
{:else if fileContent !== null} {#if isCodeFile(selectedFile)}
{fileContent}
{:else}
{fileContent}
{/if} {/if}
{:else}

Select a file to view its contents

{/if}