"use client"

import { useLayoutEffect } from "react"
import { getDemoDriveLayoutPreview } from "@/lib/demo/demo-drive-layout-preview"
import { useDriveUIStore } from "@/lib/stores/drive-ui-store"

/** Sidebar drive pour iframes marketing (?preview=). */
export function DemoDriveLayoutPreviewBootstrap() {
  useLayoutEffect(() => {
    const preview = getDemoDriveLayoutPreview()
    if (!preview) return

    if (preview === "phone") {
      useDriveUIStore.getState().setSidebarCollapsed(true)
    }

    if (preview === "tablet" || preview === "desktop") {
      useDriveUIStore.getState().setSidebarCollapsed(false)
    }
  }, [])

  return null
}
