<script lang="ts">
    import type FileViewState from "../models/FileViewState.svelte";
    import StreamEditor from "./StreamEditor.svelte";
    import type { StreamData } from "../models/StreamData.svelte";
    import RenderedPageView from "./RenderedPageView.svelte";

    let {
        fState,
        height,
    }: {
        fState: FileViewState;
        height: number;
    } = $props();
    let streamData: StreamData | undefined = $derived(
        fState.container_prim?.stream_data,
    );
</script>

{#if streamData}
    {#if streamData.type === "Image"}
        <RenderedPageView img={streamData.imageData} {height}
        ></RenderedPageView>
    {:else if streamData.textData}
        <StreamEditor
            stream_data={streamData.textData}
            {height}
            save={(updated_data) => fState.saveStreamData(updated_data)}
        ></StreamEditor>
    {/if}
{/if}

<style lang="postcss">
</style>
